Exemple #1
0
def decl_const_or_fun(definition):
    if isinstance(definition, Sort):
        fargs_sorts = definition.arg_sorts
        if len(fargs_sorts) == 0:
            return sast.Command("declare-const", [definition.name, sp.sort_of(definition)])
        else:
            return sast.Command("declare-fun", [definition.name, [sp.sort_of(x) for x in fargs_sorts], sp.sort_of(definition)])
    else:
        logger.error("decl_constant_or_fun called on %s" % str(definition))
        raise TypeError("%s is not supported." % str(definition))
Exemple #2
0
def p_define_functions_rec(p):
    '''command : LPAR DEFFUNSREC LPAR function_def_list RPAR LPAR term_list RPAR RPAR'''
    if len(p[4]) != len(p[7]):
        raise Exception(
            "Function definition: provide as many terms as functions definition."
        )

    p[0] = ast.Command(p[2], [p[4], p[7]])
Exemple #3
0
def smtlib_string(ast : list, funcs, extra_consts="" ,extra_asserts = ""):
    funcs = [decl_const_or_fun(definition) for definition in funcs]
    new_ast = []
    before_asserts = True
    for i in range(len(ast)):
        c = ast[i]
        if isinstance(c, BoolFuncApp) or (isinstance(c, Let) and isinstance(c.term, BoolFuncApp)):
            if before_asserts:
                before_asserts = False
                new_ast += funcs
            new_ast.append(sast.Command("assert", [c]))
        elif isinstance(c, sast.Command) and c.cname == "assert":
            if before_asserts:
                before_asserts = False
                new_ast += funcs
            new_ast.append(c)
        else:
            new_ast.append(c)
			
    smtlib = "\n".join([str(command) for command in new_ast])
    logger.info("\n"+smtlib)
    return extra_consts + smtlib + extra_asserts
Exemple #4
0
def p_checksat_assuming(p):
    '''command : LPAR CHKSATASSUMING prop_literal_list RPAR'''
    p[0] = ast.Command(p[2], p[3])
Exemple #5
0
def p_set_logic(p):
    '''command : LPAR SETLOGIC symbol RPAR'''
    p[0] = ast.Command(p[2], [p[3]])
Exemple #6
0
def p_reset_assertions(p):
    '''command : LPAR RESETASSERTIONS'''
    p[0] = ast.Command(p[2], [])
Exemple #7
0
def p_push(p):
    '''command : LPAR PUSH NUMBER RPAR'''
    p[0] = ast.Command(p[2], [p[3]])
Exemple #8
0
def p_get_value(p):
    '''command : LPAR GETVAL LPAR term_list RPAR RPAR'''
    p[0] = ast.Command(p[2], [p[4]])
Exemple #9
0
def p_get_unsat_assumptions(p):
    '''command : LPAR GETUNSATASSUMPTS RPAR'''
    p[0] = ast.Command(p[2])
Exemple #10
0
def p_define_function_rec(p):
    '''command : LPAR DEFFUNREC function_def RPAR'''
    p[0] = ast.Command(p[2], [p[3]])
Exemple #11
0
def p_declare_sort(p):
    '''command : LPAR DECLSORT symbol NUMBER RPAR'''
    p[0] = ast.Command(p[2], [p[3], p[4]])
Exemple #12
0
def p_declare_function(p):
    '''command : LPAR DECLFUN symbol LPAR sortlist RPAR sort RPAR'''
    p[0] = ast.Command(p[2], [p[3], p[5], p[7]])
Exemple #13
0
def p_declare_datatypes(p):
    '''command : LPAR DECLDATATYPES LPAR symbollist RPAR LPAR datatype_dec_list RPAR RPAR'''
    p[0] = ast.Command(p[2], [p[4], p[7]])
Exemple #14
0
def p_declare_datatype(p):
    '''command : LPAR DECLDATATYPE symbol datatype_dec RPAR'''
    p[0] = ast.Command(p[2], [p[3], p[4]])
Exemple #15
0
def p_declare_const(p):
    '''command : LPAR DECLCONST symbol sort RPAR'''
    p[0] = ast.Command(p[2], [p[3], p[4]])
Exemple #16
0
def p_getoptions(p):
    '''command : LPAR GETOPT RPAR'''
    p[0] = ast.Command(p[2], [])
Exemple #17
0
def p_getproof(p):
    '''command : LPAR GETPRF RPAR'''
    p[0] = ast.Command(p[2], [])
Exemple #18
0
def p_define_sort(p):
    '''command : LPAR DEFSORT symbol LPAR symbollist RPAR sort RPAR'''
    p[0] = ast.Command(p[2], [p[3], p[5], p[7]])
Exemple #19
0
def p_get_unsat_core(p):
    '''command : LPAR GETUNSATCORE RPAR'''
    p[0] = ast.Command(p[2], [])
Exemple #20
0
def p_echo(p):
    '''command : LPAR ECHO STRING RPAR'''
    p[0] = ast.Command(p[2], p[3])
Exemple #21
0
def p_pop(p):
    '''command : LPAR POP NUMBER RPAR'''
    p[0] = ast.Command(p[2], [p[3]])
Exemple #22
0
def p_exit(p):
    '''command : LPAR EXIT RPAR'''
    p[0] = ast.Command(p[2], [])
Exemple #23
0
def p_reset(p):
    '''command : LPAR RESET RPAR'''
    p[0] = ast.Command(p[2])
Exemple #24
0
def p_geassertions(p):
    '''command : LPAR GETASSERTIONS RPAR'''
    p[0] = ast.Command(p[2], [])
Exemple #25
0
def p_set_info(p):
    '''command : LPAR SETINFO attribute RPAR'''
    p[0] = ast.Command(p[2], [p[3]])
Exemple #26
0
def p_getassignment(p):
    '''command : LPAR GETASSIGNMENT RPAR'''
    p[0] = ast.Command(p[2], [])
Exemple #27
0
def p_set_option(p):
    '''command : LPAR SETOPT option RPAR'''
    p[0] = ast.Command(p[2], [p[3]])
Exemple #28
0
def p_getinfo(p):
    '''command : LPAR GETINF info_flag RPAR'''
    p[0] = ast.Command(p[2], [p[3]])
Exemple #29
0
def p_getmodel(p):
    '''command : LPAR GETMOD RPAR'''
    p[0] = ast.Command(p[2], [])
Exemple #30
0
def p_checksat(p):
    '''command : LPAR CHKSAT RPAR'''
    p[0] = ast.Command(p[2], [])