Exemplo n.º 1
0
############# Section 5
# Program, VC, and Instantiation

def pgm(x, ret):
    return IteBool(x == nil, ret == nil, ret == next(x))

def vc(x, ret):
    return Implies(dlist(x),
                    Implies(pgm(x, ret), list(ret)))

deref = [x]
const = [nil]
verification_condition = vc(x,ret)

# End of input

###########################################################################################################################
# Lemma synthesis stub 
##########################################################################################################################

config_params = {'mode': 'random', 'num_true_models':0}
config_params['pfp_dict'] = pfp_dict
config_params['use_cex_models'] = True

name = 'dlist-list'
grammar_string = importlib_resources.read_text('experiments', 'grammar_{}.sy'.format(name))

synth_dict = {}

solveProblem(fcts_z3, axioms_python, axioms_z3, unfold_recdefs_z3, unfold_recdefs_python, deref, const, verification_condition, name, grammar_string, config_params, synth_dict)
Exemplo n.º 2
0
AddRecDefinition(bst, x, If(x == nil, True,
                            And(0 < key(x),
                                And(key(x) < 100,
                                    And(bst(lft(x)),
                                        And(bst(rght(x)),
                                            And(maxr(lft(x)) <= key(x),
                                                key(x) <= minr(rght(x)))))))))
AddRecDefinition(hbst, x, If(x == nil, fgsetsort.lattice_bottom,
                             SetAdd(SetUnion(hbst(lft(x)), hbst(rght(x))), x)))
AddAxiom((), lft(nil) == nil)
AddAxiom((), rght(nil) == nil)

# Problem parameters
goal = Implies(bst(x), Implies(And(x != nil,
                                   And(IsMember(y, hbst(x)),
                                       And(k == minr(x),
                                           And(k == minr(y), y != nil)))),
                               k == minr(lft(y))))

# parameters representing the grammar for synth-fun and
# terms on which finite model is extracted
# TODO: extract this automatically from grammar_string
v = Var('v', fgsort)
lemma_grammar_args = [v, y, k, nil]
lemma_grammar_terms = {v, lft(v), rght(v), nil, y}

name = 'bst-minimal'
grammar_string = importlib_resources.read_text('experiments', 'grammar_{}.sy'.format(name))

solveProblem(lemma_grammar_args, lemma_grammar_terms, goal, name, grammar_string)
Exemplo n.º 3
0
# Uncomment this line for fixed_depth=1 mode
# config_params['goal_instantiation_mode'] = proveroptions.fixed_depth  # Default depth is 1
# Uncomment these two lines for manual instantiation mode
# config_params['goal_instantiation_mode'] = proveroptions.manual_instantiation
# config_params['goal_instantiation_terms'] = {x, nxt(x)}

goal_heaplet_1a = Implies(hlseg(x, y, v), Implies(lseg(y, z), hlseg(x, z, v)))
goal_heaplet_1b = Implies(
    lseg(x, y), Implies(y != nil, Implies(lseg(y, z), hlseg(x, z, y))))
goal_heaplet_2 = Implies(hlseg(x, z, v),
                         Implies(lseg(y, z), Or(v == y, hlseg(x, y, v))))

# lemma synthesis
v1, v2, v3, v4 = Vars('v1 v2 v3 v4', fgsort)
lemma_grammar_args = [v1, v2, nil]
lemma_grammar_terms = {
    v1, nil,
    nxt(nil), v2,
    nxt(v2),
    nxt(v1),
    nxt(nxt(v1)),
    nxt(nxt(nxt(v1)))
}

name = 'lseg-nil-list'
grammar_string = importlib_resources.read_text('experiments',
                                               'grammar_{}.sy'.format(name))

solveProblem(lemma_grammar_args, lemma_grammar_terms, goal_heaplet_1a, name,
             grammar_string)