Z3
 
Loading...
Searching...
No Matches
BoolSortRef Class Reference

Booleans. More...

+ Inheritance diagram for BoolSortRef:

Public Member Functions

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

Additional Inherited Members

- Data Fields inherited from AstRef
 ast = ast
 
 ctx = _get_ctx(ctx)
 
- Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)
 

Detailed Description

Booleans.

Boolean sort.

Definition at line 1547 of file z3py.py.

Member Function Documentation

◆ cast()

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

1550 def cast(self, val):
1551 """Try to cast `val` as a Boolean.
1552
1553 >>> x = BoolSort().cast(True)
1554 >>> x
1555 True
1556 >>> is_expr(x)
1557 True
1558 >>> is_expr(True)
1559 False
1560 >>> x.sort()
1561 Bool
1562 """
1563 if isinstance(val, bool):
1564 return BoolVal(val, self.ctx)
1565 if z3_debug():
1566 if not is_expr(val):
1567 msg = "True, False or Z3 Boolean expression expected. Received %s of type %s"
1568 _z3_assert(is_expr(val), msg % (val, type(val)))
1569 if not self.eq(val.sort()):
1570 _z3_assert(self.eq(val.sort()), "Value cannot be converted into a Z3 Boolean value")
1571 return val
1572

◆ is_bool()

is_bool ( self)

Definition at line 1579 of file z3py.py.

1579 def is_bool(self):
1580 return True
1581
1582

◆ is_int()

is_int ( self)

Definition at line 1576 of file z3py.py.

1576 def is_int(self):
1577 return True
1578

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

◆ subsort()

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

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

Reimplemented from SortRef.

Definition at line 1573 of file z3py.py.

1573 def subsort(self, other):
1574 return isinstance(other, ArithSortRef)
1575