def walk_constant(self, formula, args): """Returns a new theory object with the type of the constant.""" if formula.is_real_constant(): theory_out = Theory(real_arithmetic=True, real_difference=True) elif formula.is_int_constant(): theory_out = Theory(integer_arithmetic=True, integer_difference=True) else: assert formula.is_bool_constant() theory_out = Theory() return theory_out
def walk_function(self, formula, args, **kwargs): """Extends the Theory with UF.""" if len(args) == 1: theory_out = args[0].copy() elif len(args) > 1: theory_out = args[0] for t in args[1:]: theory_out = theory_out.combine(t) else: theory_out = Theory() theory_out.uninterpreted = True return theory_out
def walk_function(self, formula, args, **kwargs): """Extends the Theory with UF.""" #pylint: disable=unused-argument if len(args) == 1: theory_out = args[0].copy() elif len(args) > 1: theory_out = args[0] for t in args[1:]: theory_out = theory_out.combine(t) else: theory_out = Theory() theory_out.uninterpreted = True return theory_out
def walk_function(self, formula, args): """Extends the Theory with UF.""" if len(args) == 1: theory_out = args[0].copy() elif len(args) > 1: theory_out = args[0] for t in args[1:]: theory_out = theory_out.combine(t) else: theory_out = Theory() theory_out.uninterpreted = True return theory_out
def walk_constant(self, formula, args, **kwargs): """Returns a new theory object with the type of the constant.""" #pylint: disable=unused-argument if formula.is_real_constant(): theory_out = Theory(real_arithmetic=True, real_difference=True) elif formula.is_int_constant(): theory_out = Theory(integer_arithmetic=True, integer_difference=True) elif formula.is_bv_constant(): theory_out = Theory(bit_vectors=True) else: assert formula.is_bool_constant() theory_out = Theory() return theory_out
def walk_symbol(self, formula, args): """Returns a new theory object with the type of the symbol.""" f_type = formula.symbol_type() if f_type.is_real_type(): theory_out = Theory(real_arithmetic=True, real_difference=True) elif f_type.is_int_type(): theory_out = Theory(integer_arithmetic=True, integer_difference=True) elif f_type.is_bool_type(): theory_out = Theory() else: assert f_type.is_function_type() theory_out = Theory(uninterpreted=True) return theory_out
def walk_function(self, formula, args, **kwargs): """Extends the Theory with UF.""" #pylint: disable=unused-argument if len(args) == 1: theory_out = args[0].copy() elif len(args) > 1: theory_out = args[0] for t in args[1:]: theory_out = theory_out.combine(t) else: theory_out = Theory() # Extend Theory with function return type rtype = formula.function_name().symbol_type().return_type theory_out = theory_out.combine(self._theory_from_type(rtype)) theory_out.uninterpreted = True return theory_out
def walk_strings(self, formula, args, **kwargs): """Extends the Theory with Strings.""" #pylint: disable=unused-argument if formula.is_string_constant(): theory_out = Theory(strings=True) else: theory_out = args[0].set_strings() # This makes a copy of args[0] return theory_out
def walk_symbol(self, formula, args, **kwargs): #pylint: disable=unused-argument """Returns a new theory object with the type of the symbol.""" f_type = formula.symbol_type() if f_type.is_real_type(): theory_out = Theory(real_arithmetic=True, real_difference=True) elif f_type.is_int_type(): theory_out = Theory(integer_arithmetic=True, integer_difference=True) elif f_type.is_bool_type(): theory_out = Theory() elif f_type.is_bv_type(): theory_out = Theory(bit_vectors=True) else: assert f_type.is_function_type() theory_out = Theory(uninterpreted=True) return theory_out
def walk_constant(self, formula, args, **kwargs): """Returns a new theory object with the type of the constant.""" #pylint: disable=unused-argument theory_out = Theory() if formula.is_real_constant() or formula.is_algebraic_constant(): theory_out.real_arithmetic = True theory_out.real_difference = True elif formula.is_int_constant(): theory_out.integer_arithmetic = True theory_out.integer_difference = True elif formula.is_bv_constant(): theory_out.bit_vectors = True elif formula.is_string_constant(): theory_out.strings = True else: assert formula.is_bool_constant() return theory_out
def _theory_from_type(self, ty): theory = None if ty.is_real_type(): theory = Theory(real_arithmetic=True, real_difference=True) elif ty.is_int_type(): theory = Theory(integer_arithmetic=True, integer_difference=True) elif ty.is_bool_type(): theory = Theory() elif ty.is_bv_type(): theory = Theory(bit_vectors=True) elif ty.is_array_type(): theory = Theory(arrays=True) theory = theory.combine(self._theory_from_type(ty.index_type)) theory = theory.combine(self._theory_from_type(ty.elem_type)) else: assert ty.is_function_type() theory = Theory(uninterpreted=True) return theory
def test_most_generic(self): self.assertTrue(QF_LIA < LIA) self.assertTrue(LIA < UFLIRA) self.assertTrue(UFLIRA > QF_LIA) self.assertTrue(UFLIRA >= UFLIRA) self.assertFalse(LRA >= LIA) self.assertFalse(LRA <= LIA) mgl = most_generic_logic([QF_LIA, LIA, LRA, UFLIRA]) self.assertEqual(mgl, UFLIRA) self.assertFalse(QF_BV >= QF_UFLIRA) self.assertFalse(QF_BV <= QF_UFLIRA) self.assertTrue(NRA > LRA) self.assertTrue(QF_BOOL < QF_IDL) with self.assertRaises(NoLogicAvailableError): most_generic_logic(PYSMT_LOGICS) t = Theory(arrays=True, arrays_const=True, integer_arithmetic=True) self.assertIsNotNone(t)
def walk_constant(self, formula, args, **kwargs): """Returns a new theory object with the type of the constant.""" #pylint: disable=unused-argument theory_out = Theory() if formula.is_real_constant(): theory_out.real_arithmetic = True theory_out.real_difference = True elif formula.is_int_constant(): theory_out.integer_arithmetic = True theory_out.integer_difference = True elif formula.is_bv_constant(): theory_out.bit_vectors = True elif formula.is_string_constant(): theory_out.strings = True else: assert formula.is_bool_constant() return theory_out
def _theory_from_type(self, ty): theory = Theory() if ty.is_real_type(): theory.real_arithmetic = True theory.real_difference = True elif ty.is_int_type(): theory.integer_arithmetic = True theory.integer_difference = True elif ty.is_bool_type(): pass elif ty.is_bv_type(): theory.bit_vectors = True elif ty.is_array_type(): theory.arrays = True theory = theory.combine(self._theory_from_type(ty.index_type)) theory = theory.combine(self._theory_from_type(ty.elem_type)) elif ty.is_string_type(): theory.strings = True elif ty.is_custom_type(): theory.custom_type = True else: # ty is either a function type theory.uninterpreted = True return theory