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 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 __nonzero__ (self)
 
def __bool__ (self)
 
def sexpr (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 1372 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

Reimplemented from SortRef.

Definition at line 1374 of file z3py.py.

1374  def cast(self, val):
1375  """Try to cast `val` as a Boolean.
1376 
1377  >>> x = BoolSort().cast(True)
1378  >>> x
1379  True
1380  >>> is_expr(x)
1381  True
1382  >>> is_expr(True)
1383  False
1384  >>> x.sort()
1385  Bool
1386  """
1387  if isinstance(val, bool):
1388  return BoolVal(val, self.ctx)
1389  if z3_debug():
1390  if not is_expr(val):
1391  _z3_assert(is_expr(val), "True, False or Z3 Boolean expression expected. Received %s" % val)
1392  if not self.eq(val.sort()):
1393  _z3_assert(self.eq(val.sort()), "Value cannot be converted into a Z3 Boolean value")
1394  return val
1395 
def z3_debug()
Definition: z3py.py:58
def BoolVal(val, ctx=None)
Definition: z3py.py:1552
def is_expr(a)
Definition: z3py.py:1117

◆ is_bool()

def is_bool (   self)

Definition at line 1402 of file z3py.py.

1402  def is_bool(self):
1403  return True
1404 
1405 
def is_bool(a)
Definition: z3py.py:1424

◆ is_int()

def is_int (   self)

Definition at line 1399 of file z3py.py.

1399  def is_int(self):
1400  return True
1401 
def is_int(a)
Definition: z3py.py:2501

Referenced by IntNumRef.as_long(), and ArithSortRef.subsort().

◆ subsort()

def subsort (   self,
  other 
)
Return `True` if `self` is a subsort of `other`.

>>> IntSort().subsort(RealSort())
True

Reimplemented from SortRef.

Definition at line 1396 of file z3py.py.

1396  def subsort(self, other):
1397  return isinstance(other, ArithSortRef)
1398