Exemple #1
0
 def test_qf_bool_smt2(self):
     # QF_BOOL does not exist in SMT-LIB
     # This test is to enforce the consistent choice of QF_UF
     close_l = get_closer_smtlib_logic(logics.QF_BOOL)
     self.assertEqual(close_l, logics.QF_UF)
     # For BOOL we use LRA
     close_l = get_closer_smtlib_logic(logics.BOOL)
     self.assertEqual(close_l, logics.LRA)
Exemple #2
0
 def test_qf_bool_smt2(self):
     # QF_BOOL does not exist in SMT-LIB
     # This test is to enforce the consistent choice of QF_UF
     close_l = get_closer_smtlib_logic(logics.QF_BOOL)
     self.assertEqual(close_l, logics.QF_UF)
     # For BOOL we use LRA
     close_l = get_closer_smtlib_logic(logics.BOOL)
     self.assertEqual(close_l, logics.LRA)
Exemple #3
0
def smtlibscript_from_formula(formula):
    script = SmtLibScript()

    # Get the simplest SmtLib logic that contains the formula
    f_logic = get_logic(formula)

    smt_logic = None
    try:
        smt_logic = get_closer_smtlib_logic(f_logic)
    except NoLogicAvailableError:
        warnings.warn("The logic %s is not reducible to any SMTLib2 " \
                      "standard logic. Proceeding with non-standard " \
                      "logic '%s'" % (f_logic, f_logic))
        smt_logic = f_logic

    script.add(name=smtcmd.SET_LOGIC, args=[smt_logic])

    deps = formula.get_free_variables()
    # Declare all variables
    for symbol in deps:
        assert symbol.is_symbol()
        script.add(name=smtcmd.DECLARE_FUN, args=[symbol])

    # Assert formula
    script.add_command(SmtLibCommand(name=smtcmd.ASSERT, args=[formula]))
    # check-sat
    script.add_command(SmtLibCommand(name=smtcmd.CHECK_SAT, args=[]))

    return script
Exemple #4
0
def smtlibscript_from_formula(formula):
    script = SmtLibScript()

    # Get the simplest SmtLib logic that contains the formula
    f_logic = get_logic(formula)

    smt_logic = None
    try:
        smt_logic = get_closer_smtlib_logic(f_logic)
    except NoLogicAvailableError:
        warnings.warn("The logic %s is not reducible to any SMTLib2 " \
                      "standard logic. Proceeding with non-standard " \
                      "logic '%s'" % (f_logic, f_logic))
        smt_logic = f_logic

    script.add(name=smtcmd.SET_LOGIC,
               args=[smt_logic])

    deps = formula.get_free_variables()
    # Declare all variables
    for symbol in deps:
        assert symbol.is_symbol()
        script.add(name=smtcmd.DECLARE_FUN, args=[symbol])

    # Assert formula
    script.add_command(SmtLibCommand(name=smtcmd.ASSERT,
                                     args=[formula]))
    # check-sat
    script.add_command(SmtLibCommand(name=smtcmd.CHECK_SAT,
                                     args=[]))

    return script
Exemple #5
0
def smtlibscript_from_formula(formula, logic=None):
    script = SmtLibScript()

    if logic is None:
        # Get the simplest SmtLib logic that contains the formula
        f_logic = get_logic(formula)

        smt_logic = None
        try:
            smt_logic = get_closer_smtlib_logic(f_logic)
        except NoLogicAvailableError:
            warnings.warn("The logic %s is not reducible to any SMTLib2 " \
                          "standard logic. Proceeding with non-standard " \
                          "logic '%s'" % (f_logic, f_logic),
                          stacklevel=3)
            smt_logic = f_logic
    elif not (isinstance(logic, Logic) or isinstance(logic, str)):
        raise UndefinedLogicError(str(logic))
    else:
        if logic not in SMTLIB2_LOGICS:
            warnings.warn("The logic %s is not reducible to any SMTLib2 " \
                          "standard logic. Proceeding with non-standard " \
                          "logic '%s'" % (logic, logic),
                          stacklevel=3)
        smt_logic = logic

    script.add(name=smtcmd.SET_LOGIC,
               args=[smt_logic])

    # Declare all types
    types = get_env().typeso.get_types(formula, custom_only=True)
    for type_ in types:
        script.add(name=smtcmd.DECLARE_SORT, args=[type_.decl])

    deps = formula.get_free_variables()
    # Declare all variables
    for symbol in deps:
        assert symbol.is_symbol()
        script.add(name=smtcmd.DECLARE_FUN, args=[symbol])

    # Assert formula
    script.add_command(SmtLibCommand(name=smtcmd.ASSERT,
                                     args=[formula]))
    # check-sat
    script.add_command(SmtLibCommand(name=smtcmd.CHECK_SAT,
                                     args=[]))
    return script
Exemple #6
0
def smtlibscript_from_formula(formula, logic=None):
    script = SmtLibScript()

    if logic is None:
        # Get the simplest SmtLib logic that contains the formula
        f_logic = get_logic(formula)

        smt_logic = None
        try:
            smt_logic = get_closer_smtlib_logic(f_logic)
        except NoLogicAvailableError:
            warnings.warn("The logic %s is not reducible to any SMTLib2 " \
                          "standard logic. Proceeding with non-standard " \
                          "logic '%s'" % (f_logic, f_logic),
                          stacklevel=3)
            smt_logic = f_logic
    elif not (isinstance(logic, Logic) or isinstance(logic, str)):
        raise UndefinedLogicError(str(logic))
    else:
        if logic not in SMTLIB2_LOGICS:
            warnings.warn("The logic %s is not reducible to any SMTLib2 " \
                          "standard logic. Proceeding with non-standard " \
                          "logic '%s'" % (logic, logic),
                          stacklevel=3)
        smt_logic = logic

    script.add(name=smtcmd.SET_LOGIC, args=[smt_logic])

    # Declare all types
    types = get_env().typeso.get_types(formula, custom_only=True)
    for type_ in types:
        script.add(name=smtcmd.DECLARE_SORT, args=[type_.decl])

    deps = formula.get_free_variables()
    # Declare all variables
    for symbol in deps:
        assert symbol.is_symbol()
        script.add(name=smtcmd.DECLARE_FUN, args=[symbol])

    # Assert formula
    script.add_command(SmtLibCommand(name=smtcmd.ASSERT, args=[formula]))
    # check-sat
    script.add_command(SmtLibCommand(name=smtcmd.CHECK_SAT, args=[]))
    return script
Exemple #7
0
def smtlibscript_from_formula(formula):
    script = SmtLibScript()

    # Get the simplest SmtLib logic that contains the formula
    f_logic = get_logic(formula)
    smt_logic = get_closer_smtlib_logic(f_logic)
    script.add(name=smtcmd.SET_LOGIC,
               args=[smt_logic])

    deps = formula.get_free_variables()
    # Declare all variables
    for symbol in deps:
        assert symbol.is_symbol()
        script.add(name=smtcmd.DECLARE_FUN, args=[symbol])

    # Assert formula
    script.add_command(SmtLibCommand(name=smtcmd.ASSERT,
                                     args=[formula]))
    # check-sat
    script.add_command(SmtLibCommand(name=smtcmd.CHECK_SAT,
                                     args=[]))

    return script