コード例 #1
0
ファイル: synthesis.py プロジェクト: uwplse/cozy
def check_discovery(spec, expected, state_vars=[], args=[], examples=[], assumptions=ETRUE):
    ctx = RootCtx(state_vars=state_vars, args=args)
    for r in improve(spec,
            assumptions=assumptions,
            context=ctx,
            examples=examples):
        print("GOT RESULT ==> {}".format(pprint(r)))
        if isinstance(expected, Exp):
            if alpha_equivalent(r, expected):
                return True
        elif expected(r):
            return True
    return False
コード例 #2
0
def check_discovery(spec,
                    expected,
                    state_vars=[],
                    args=[],
                    examples=[],
                    assumptions=ETRUE):
    ctx = RootCtx(state_vars=state_vars, args=args)
    for r in improve(spec,
                     assumptions=assumptions,
                     context=ctx,
                     examples=examples):
        print("GOT RESULT ==> {}".format(pprint(r)))
        if isinstance(expected, Exp):
            if alpha_equivalent(r, expected):
                return True
        elif expected(r):
            return True
    return False
コード例 #3
0
ファイル: synthesis.py プロジェクト: sanidhya/cozy
    def test_incomplete_binders_list_2(self):
        res = None
        x = EVar("x").with_type(BOOL)
        xs = EVar("xs").with_type(TBag(BOOL))
        target = EFilter(EStateVar(xs), ELambda(x, T))
        assumptions = EUnaryOp(UOp.All, xs)
        assert retypecheck(target)
        assert retypecheck(assumptions)

        def should_stop():
            return res == EStateVar(EVar("xs"))

        for r in improve(target,
                         assumptions, [], [xs], [],
                         CompositeCostModel(),
                         BinderBuilder([], [xs], []),
                         stop_callback=should_stop):
            print(pprint(r))
            res = r
        assert should_stop()