Exemple #1
0
 def Ite(self, then_, else_):
     if _env().enable_infix_notation:
         if isinstance(then_, FNode) and isinstance(else_, FNode):
             return _mgr().Ite(self, then_, else_)
         else:
             raise PysmtModeError(
                 "Cannot infix ITE with implicit argument types.")
     else:
         raise PysmtModeError("Cannot use infix notation")
Exemple #2
0
 def __call__(self, *args):
     env = pysmt.environment.get_env()
     # Note: This uses the global type manager
     if not env.enable_infix_notation:
         raise PysmtModeError("Infix notation disabled. "
                              "Use type_manager.get_type_instance instead.")
     return env.type_manager.get_type_instance(self, *args)
Exemple #3
0
 def __getitem__(self, idx):
     if not _env().enable_infix_notation:
         raise PysmtModeError("Cannot use infix notation")
     if isinstance(idx, slice):
         end = idx.stop
         start = idx.start
         if start is None: start = 0
     else:
         # Single point [idx]
         end = idx
         start = idx
     if _is_bv(self):
         return _mgr().BVExtract(self, start=start, end=end)
     raise NotImplementedError
Exemple #4
0
 def _apply_infix(self, right, function, bv_function=None):
     if _env().enable_infix_notation:
         mgr = _mgr()
         # BVs
         # Default bv_function to function
         if bv_function is None: bv_function = function
         if _is_bv(self):
             if is_python_integer(right):
                 right = mgr.BV(right, width=self.bv_width())
             return bv_function(self, right)
         # Boolean, Integer and Arithmetic
         if is_python_boolean(right):
             right = mgr.Bool(right)
         elif is_python_integer(right):
             ty = self.get_type()
             if ty.is_real_type():
                 right = mgr.Real(right)
             else:
                 right = mgr.Int(right)
         elif is_python_rational(right):
             right = mgr.Real(right)
         return function(self, right)
     else:
         raise PysmtModeError("Cannot use infix notation")
Exemple #5
0
 def Ite(self, then_, else_):
     if isinstance(then_, FNode) and isinstance(else_, FNode):
         return _mgr().Ite(self, then_, else_)
     else:
         raise PysmtModeError(
             "Cannot infix ITE with implicit argument types.")
Exemple #6
0
 def assert_infix_enabled_wrap(*args, **kwargs):
     from pysmt.environment import get_env
     if not get_env().enable_infix_notation:
         raise PysmtModeError(INFIX_ERROR_MSG)
     return f(*args, **kwargs)
Exemple #7
0
 def __invert__(self):
     if not _env().enable_infix_notation:
         raise PysmtModeError("Cannot use infix notation")
     if _is_bv(self):
         return _mgr().BVNot(self)
     return _mgr().Not(self)