Z3
Public Member Functions
BoolSortRef Class Reference

Booleans. More...

+ Inheritance diagram for BoolSortRef:

Public Member Functions

def cast (self, val)
 
def subsort (self, other)
 
def is_int (self)
 
def is_bool (self)
 
- Public Member Functions inherited from SortRef
def as_ast (self)
 
def get_id (self)
 
def kind (self)
 
def subsort (self, other)
 
def cast (self, val)
 
def name (self)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def __hash__ (self)
 
- Public Member Functions inherited from AstRef
def __init__ (self, ast, ctx=None)
 
def __del__ (self)
 
def __deepcopy__ (self, memo={})
 
def __str__ (self)
 
def __repr__ (self)
 
def __eq__ (self, other)
 
def __hash__ (self)
 
def __nonzero__ (self)
 
def __bool__ (self)
 
def sexpr (self)
 
def as_ast (self)
 
def get_id (self)
 
def ctx_ref (self)
 
def eq (self, other)
 
def translate (self, target)
 
def __copy__ (self)
 
def hash (self)
 
- Public Member Functions inherited from Z3PPObject
def use_pp (self)
 

Additional Inherited Members

- Data Fields inherited from AstRef
 ast
 
 ctx
 

Detailed Description

Booleans.

Boolean sort.

Definition at line 1349 of file z3py.py.

Member Function Documentation

◆ cast()

def cast (   self,
  val 
)
Try to cast `val` as a Boolean.

>>> x = BoolSort().cast(True)
>>> x
True
>>> is_expr(x)
True
>>> is_expr(True)
False
>>> x.sort()
Bool

Definition at line 1351 of file z3py.py.

1351  def cast(self, val):
1352  """Try to cast `val` as a Boolean.
1353 
1354  >>> x = BoolSort().cast(True)
1355  >>> x
1356  True
1357  >>> is_expr(x)
1358  True
1359  >>> is_expr(True)
1360  False
1361  >>> x.sort()
1362  Bool
1363  """
1364  if isinstance(val, bool):
1365  return BoolVal(val, self.ctx)
1366  if __debug__:
1367  if not is_expr(val):
1368  _z3_assert(is_expr(val), "True, False or Z3 Boolean expression expected. Received %s" % val)
1369  if not self.eq(val.sort()):
1370  _z3_assert(self.eq(val.sort()), "Value cannot be converted into a Z3 Boolean value")
1371  return val
1372 
def BoolVal(val, ctx=None)
Definition: z3py.py:1529
def is_expr(a)
Definition: z3py.py:1094

◆ is_bool()

def is_bool (   self)

Definition at line 1379 of file z3py.py.

1379  def is_bool(self):
1380  return True
1381 
1382 
def is_bool(a)
Definition: z3py.py:1401

◆ is_int()

def is_int (   self)

Definition at line 1376 of file z3py.py.

1376  def is_int(self):
1377  return True
1378 
def is_int(a)
Definition: z3py.py:2469

◆ subsort()

def subsort (   self,
  other 
)

Definition at line 1373 of file z3py.py.

1373  def subsort(self, other):
1374  return isinstance(other, ArithSortRef)
1375