Z3
 
Loading...
Searching...
No Matches
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
 
- Protected Member Functions inherited from Z3PPObject
def _repr_html_ (self)
 

Detailed Description

Booleans.

Boolean sort.

Definition at line 1514 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 1517 of file z3py.py.

1517 def cast(self, val):
1518 """Try to cast `val` as a Boolean.
1519
1520 >>> x = BoolSort().cast(True)
1521 >>> x
1522 True
1523 >>> is_expr(x)
1524 True
1525 >>> is_expr(True)
1526 False
1527 >>> x.sort()
1528 Bool
1529 """
1530 if isinstance(val, bool):
1531 return BoolVal(val, self.ctx)
1532 if z3_debug():
1533 if not is_expr(val):
1534 msg = "True, False or Z3 Boolean expression expected. Received %s of type %s"
1535 _z3_assert(is_expr(val), msg % (val, type(val)))
1536 if not self.eq(val.sort()):
1537 _z3_assert(self.eq(val.sort()), "Value cannot be converted into a Z3 Boolean value")
1538 return val
1539

Referenced by BoolSortRef.cast().

◆ is_bool()

def is_bool (   self)

Definition at line 1546 of file z3py.py.

1546 def is_bool(self):
1547 return True
1548
1549

◆ is_int()

def is_int (   self)

Definition at line 1543 of file z3py.py.

1543 def is_int(self):
1544 return True
1545

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 1540 of file z3py.py.

1540 def subsort(self, other):
1541 return isinstance(other, ArithSortRef)
1542