|
| | sort (self) |
| | is_int (self) |
| | is_real (self) |
| | __add__ (self, other) |
| | __radd__ (self, other) |
| | __mul__ (self, other) |
| | __rmul__ (self, other) |
| | __sub__ (self, other) |
| | __rsub__ (self, other) |
| | __pow__ (self, other) |
| | __rpow__ (self, other) |
| | __div__ (self, other) |
| | __truediv__ (self, other) |
| | __rdiv__ (self, other) |
| | __rtruediv__ (self, other) |
| | __mod__ (self, other) |
| | __rmod__ (self, other) |
| | __neg__ (self) |
| | __pos__ (self) |
| | __le__ (self, other) |
| | __lt__ (self, other) |
| | __gt__ (self, other) |
| | __ge__ (self, other) |
| | __abs__ (self) |
| | as_ast (self) |
| | get_id (self) |
| | sort_kind (self) |
| | __eq__ (self, other) |
| | __hash__ (self) |
| | __ne__ (self, other) |
| | params (self) |
| | decl (self) |
| | kind (self) |
| | num_args (self) |
| | arg (self, idx) |
| | children (self) |
| | update (self, *args) |
| | from_string (self, s) |
| | serialize (self) |
| | __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) |
| | use_pp (self) |
Integer and Real expressions.
Definition at line 2523 of file z3py.py.
◆ __abs__()
Return an expression representing `abs(self)`.
>>> x = Int('x')
>>> abs(x)
If(x > 0, x, -x)
>>> eq(abs(x), Abs(x))
True
Definition at line 2807 of file z3py.py.
2807 def __abs__(self):
2808 """Return an expression representing `abs(self)`.
2809
2810 >>> x = Int('x')
2811 >>> abs(x)
2812 If(x > 0, x, -x)
2813 >>> eq(abs(x), Abs(x))
2814 True
2815 """
2816 return Abs(self)
2817
2818
◆ __add__()
Create the Z3 expression `self + other`.
>>> x = Int('x')
>>> y = Int('y')
>>> x + y
x + y
>>> (x + y).sort()
Int
Definition at line 2561 of file z3py.py.
2561 def __add__(self, other):
2562 """Create the Z3 expression `self + other`.
2563
2564 >>> x = Int('x')
2565 >>> y = Int('y')
2566 >>> x + y
2567 x + y
2568 >>> (x + y).sort()
2569 Int
2570 """
2571 a, b = _coerce_exprs(self, other)
2572 return ArithRef(_mk_bin(Z3_mk_add, a, b), self.ctx)
2573
◆ __div__()
Create the Z3 expression `other/self`.
>>> x = Int('x')
>>> y = Int('y')
>>> x/y
x/y
>>> (x/y).sort()
Int
>>> (x/y).sexpr()
'(div x y)'
>>> x = Real('x')
>>> y = Real('y')
>>> x/y
x/y
>>> (x/y).sort()
Real
>>> (x/y).sexpr()
'(/ x y)'
Definition at line 2660 of file z3py.py.
2660 def __div__(self, other):
2661 """Create the Z3 expression `other/self`.
2662
2663 >>> x = Int('x')
2664 >>> y = Int('y')
2665 >>> x/y
2666 x/y
2667 >>> (x/y).sort()
2668 Int
2669 >>> (x/y).sexpr()
2670 '(div x y)'
2671 >>> x = Real('x')
2672 >>> y = Real('y')
2673 >>> x/y
2674 x/y
2675 >>> (x/y).sort()
2676 Real
2677 >>> (x/y).sexpr()
2678 '(/ x y)'
2679 """
2680 a, b = _coerce_exprs(self, other)
2681 return ArithRef(
Z3_mk_div(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2682
Z3_ast Z3_API Z3_mk_div(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 div arg2.
Referenced by __truediv__(), and BitVecRef.__truediv__().
◆ __ge__()
Create the Z3 expression `other >= self`.
>>> x, y = Ints('x y')
>>> x >= y
x >= y
>>> y = Real('y')
>>> x >= y
ToReal(x) >= y
Definition at line 2794 of file z3py.py.
2794 def __ge__(self, other):
2795 """Create the Z3 expression `other >= self`.
2796
2797 >>> x, y = Ints('x y')
2798 >>> x >= y
2799 x >= y
2800 >>> y = Real('y')
2801 >>> x >= y
2802 ToReal(x) >= y
2803 """
2804 a, b = _coerce_exprs(self, other)
2805 return BoolRef(
Z3_mk_ge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2806
Z3_ast Z3_API Z3_mk_ge(Z3_context c, Z3_ast t1, Z3_ast t2)
Create greater than or equal to.
◆ __gt__()
Create the Z3 expression `other > self`.
>>> x, y = Ints('x y')
>>> x > y
x > y
>>> y = Real('y')
>>> x > y
ToReal(x) > y
Definition at line 2781 of file z3py.py.
2781 def __gt__(self, other):
2782 """Create the Z3 expression `other > self`.
2783
2784 >>> x, y = Ints('x y')
2785 >>> x > y
2786 x > y
2787 >>> y = Real('y')
2788 >>> x > y
2789 ToReal(x) > y
2790 """
2791 a, b = _coerce_exprs(self, other)
2792 return BoolRef(
Z3_mk_gt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2793
Z3_ast Z3_API Z3_mk_gt(Z3_context c, Z3_ast t1, Z3_ast t2)
Create greater than.
◆ __le__()
Create the Z3 expression `other <= self`.
>>> x, y = Ints('x y')
>>> x <= y
x <= y
>>> y = Real('y')
>>> x <= y
ToReal(x) <= y
Definition at line 2755 of file z3py.py.
2755 def __le__(self, other):
2756 """Create the Z3 expression `other <= self`.
2757
2758 >>> x, y = Ints('x y')
2759 >>> x <= y
2760 x <= y
2761 >>> y = Real('y')
2762 >>> x <= y
2763 ToReal(x) <= y
2764 """
2765 a, b = _coerce_exprs(self, other)
2766 return BoolRef(
Z3_mk_le(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2767
Z3_ast Z3_API Z3_mk_le(Z3_context c, Z3_ast t1, Z3_ast t2)
Create less than or equal to.
◆ __lt__()
Create the Z3 expression `other < self`.
>>> x, y = Ints('x y')
>>> x < y
x < y
>>> y = Real('y')
>>> x < y
ToReal(x) < y
Definition at line 2768 of file z3py.py.
2768 def __lt__(self, other):
2769 """Create the Z3 expression `other < self`.
2770
2771 >>> x, y = Ints('x y')
2772 >>> x < y
2773 x < y
2774 >>> y = Real('y')
2775 >>> x < y
2776 ToReal(x) < y
2777 """
2778 a, b = _coerce_exprs(self, other)
2779 return BoolRef(
Z3_mk_lt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2780
Z3_ast Z3_API Z3_mk_lt(Z3_context c, Z3_ast t1, Z3_ast t2)
Create less than.
◆ __mod__()
Create the Z3 expression `other%self`.
>>> x = Int('x')
>>> y = Int('y')
>>> x % y
x%y
>>> simplify(IntVal(10) % IntVal(3))
1
Definition at line 2708 of file z3py.py.
2708 def __mod__(self, other):
2709 """Create the Z3 expression `other%self`.
2710
2711 >>> x = Int('x')
2712 >>> y = Int('y')
2713 >>> x % y
2714 x%y
2715 >>> simplify(IntVal(10) % IntVal(3))
2716 1
2717 """
2718 a, b = _coerce_exprs(self, other)
2719 if z3_debug():
2720 _z3_assert(a.is_int(), "Z3 integer expression expected")
2721 return ArithRef(
Z3_mk_mod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2722
Z3_ast Z3_API Z3_mk_mod(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 mod arg2.
◆ __mul__()
Create the Z3 expression `self * other`.
>>> x = Real('x')
>>> y = Real('y')
>>> x * y
x*y
>>> (x * y).sort()
Real
Definition at line 2584 of file z3py.py.
2584 def __mul__(self, other):
2585 """Create the Z3 expression `self * other`.
2586
2587 >>> x = Real('x')
2588 >>> y = Real('y')
2589 >>> x * y
2590 x*y
2591 >>> (x * y).sort()
2592 Real
2593 """
2594 if isinstance(other, BoolRef):
2595 return If(other, self, 0)
2596 a, b = _coerce_exprs(self, other)
2597 return ArithRef(_mk_bin(Z3_mk_mul, a, b), self.ctx)
2598
◆ __neg__()
Return an expression representing `-self`.
>>> x = Int('x')
>>> -x
-x
>>> simplify(-(-x))
x
Definition at line 2735 of file z3py.py.
2735 def __neg__(self):
2736 """Return an expression representing `-self`.
2737
2738 >>> x = Int('x')
2739 >>> -x
2740 -x
2741 >>> simplify(-(-x))
2742 x
2743 """
2745
Z3_ast Z3_API Z3_mk_unary_minus(Z3_context c, Z3_ast arg)
Create an AST node representing - arg.
◆ __pos__()
Return `self`.
>>> x = Int('x')
>>> +x
x
Definition at line 2746 of file z3py.py.
2746 def __pos__(self):
2747 """Return `self`.
2748
2749 >>> x = Int('x')
2750 >>> +x
2751 x
2752 """
2753 return self
2754
◆ __pow__()
Create the Z3 expression `self**other` (** is the power operator).
>>> x = Real('x')
>>> x**3
x**3
>>> (x**3).sort()
Real
>>> simplify(IntVal(2)**8)
256
Definition at line 2632 of file z3py.py.
2632 def __pow__(self, other):
2633 """Create the Z3 expression `self**other` (** is the power operator).
2634
2635 >>> x = Real('x')
2636 >>> x**3
2637 x**3
2638 >>> (x**3).sort()
2639 Real
2640 >>> simplify(IntVal(2)**8)
2641 256
2642 """
2643 a, b = _coerce_exprs(self, other)
2644 return ArithRef(
Z3_mk_power(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2645
Z3_ast Z3_API Z3_mk_power(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 ^ arg2.
◆ __radd__()
Create the Z3 expression `other + self`.
>>> x = Int('x')
>>> 10 + x
10 + x
Definition at line 2574 of file z3py.py.
2574 def __radd__(self, other):
2575 """Create the Z3 expression `other + self`.
2576
2577 >>> x = Int('x')
2578 >>> 10 + x
2579 10 + x
2580 """
2581 a, b = _coerce_exprs(self, other)
2582 return ArithRef(_mk_bin(Z3_mk_add, b, a), self.ctx)
2583
◆ __rdiv__()
Create the Z3 expression `other/self`.
>>> x = Int('x')
>>> 10/x
10/x
>>> (10/x).sexpr()
'(div 10 x)'
>>> x = Real('x')
>>> 10/x
10/x
>>> (10/x).sexpr()
'(/ 10.0 x)'
Definition at line 2687 of file z3py.py.
2687 def __rdiv__(self, other):
2688 """Create the Z3 expression `other/self`.
2689
2690 >>> x = Int('x')
2691 >>> 10/x
2692 10/x
2693 >>> (10/x).sexpr()
2694 '(div 10 x)'
2695 >>> x = Real('x')
2696 >>> 10/x
2697 10/x
2698 >>> (10/x).sexpr()
2699 '(/ 10.0 x)'
2700 """
2701 a, b = _coerce_exprs(self, other)
2702 return ArithRef(
Z3_mk_div(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2703
Referenced by __rtruediv__(), and BitVecRef.__rtruediv__().
◆ __rmod__()
Create the Z3 expression `other%self`.
>>> x = Int('x')
>>> 10 % x
10%x
Definition at line 2723 of file z3py.py.
2723 def __rmod__(self, other):
2724 """Create the Z3 expression `other%self`.
2725
2726 >>> x = Int('x')
2727 >>> 10 % x
2728 10%x
2729 """
2730 a, b = _coerce_exprs(self, other)
2731 if z3_debug():
2732 _z3_assert(a.is_int(), "Z3 integer expression expected")
2733 return ArithRef(
Z3_mk_mod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2734
◆ __rmul__()
Create the Z3 expression `other * self`.
>>> x = Real('x')
>>> 10 * x
10*x
Definition at line 2599 of file z3py.py.
2599 def __rmul__(self, other):
2600 """Create the Z3 expression `other * self`.
2601
2602 >>> x = Real('x')
2603 >>> 10 * x
2604 10*x
2605 """
2606 a, b = _coerce_exprs(self, other)
2607 return ArithRef(_mk_bin(Z3_mk_mul, b, a), self.ctx)
2608
◆ __rpow__()
Create the Z3 expression `other**self` (** is the power operator).
>>> x = Real('x')
>>> 2**x
2**x
>>> (2**x).sort()
Real
>>> simplify(2**IntVal(8))
256
Definition at line 2646 of file z3py.py.
2646 def __rpow__(self, other):
2647 """Create the Z3 expression `other**self` (** is the power operator).
2648
2649 >>> x = Real('x')
2650 >>> 2**x
2651 2**x
2652 >>> (2**x).sort()
2653 Real
2654 >>> simplify(2**IntVal(8))
2655 256
2656 """
2657 a, b = _coerce_exprs(self, other)
2658 return ArithRef(
Z3_mk_power(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2659
◆ __rsub__()
Create the Z3 expression `other - self`.
>>> x = Int('x')
>>> 10 - x
10 - x
Definition at line 2622 of file z3py.py.
2622 def __rsub__(self, other):
2623 """Create the Z3 expression `other - self`.
2624
2625 >>> x = Int('x')
2626 >>> 10 - x
2627 10 - x
2628 """
2629 a, b = _coerce_exprs(self, other)
2630 return ArithRef(_mk_bin(Z3_mk_sub, b, a), self.ctx)
2631
◆ __rtruediv__()
| __rtruediv__ |
( |
| self, |
|
|
| other ) |
Create the Z3 expression `other/self`.
Definition at line 2704 of file z3py.py.
2704 def __rtruediv__(self, other):
2705 """Create the Z3 expression `other/self`."""
2706 return self.__rdiv__(other)
2707
◆ __sub__()
Create the Z3 expression `self - other`.
>>> x = Int('x')
>>> y = Int('y')
>>> x - y
x - y
>>> (x - y).sort()
Int
Definition at line 2609 of file z3py.py.
2609 def __sub__(self, other):
2610 """Create the Z3 expression `self - other`.
2611
2612 >>> x = Int('x')
2613 >>> y = Int('y')
2614 >>> x - y
2615 x - y
2616 >>> (x - y).sort()
2617 Int
2618 """
2619 a, b = _coerce_exprs(self, other)
2620 return ArithRef(_mk_bin(Z3_mk_sub, a, b), self.ctx)
2621
◆ __truediv__()
| __truediv__ |
( |
| self, |
|
|
| other ) |
Create the Z3 expression `other/self`.
Definition at line 2683 of file z3py.py.
2683 def __truediv__(self, other):
2684 """Create the Z3 expression `other/self`."""
2685 return self.__div__(other)
2686
◆ is_int()
Return `True` if `self` is an integer expression.
>>> x = Int('x')
>>> x.is_int()
True
>>> (x + 1).is_int()
True
>>> y = Real('y')
>>> (x + y).is_int()
False
Reimplemented in RatNumRef.
Definition at line 2536 of file z3py.py.
2536 def is_int(self):
2537 """Return `True` if `self` is an integer expression.
2538
2539 >>> x = Int('x')
2540 >>> x.is_int()
2541 True
2542 >>> (x + 1).is_int()
2543 True
2544 >>> y = Real('y')
2545 >>> (x + y).is_int()
2546 False
2547 """
2548 return self.sort().is_int()
2549
Referenced by IntNumRef.as_long(), and is_int().
◆ is_real()
Return `True` if `self` is an real expression.
>>> x = Real('x')
>>> x.is_real()
True
>>> (x + 1).is_real()
True
Reimplemented in RatNumRef.
Definition at line 2550 of file z3py.py.
2550 def is_real(self):
2551 """Return `True` if `self` is an real expression.
2552
2553 >>> x = Real('x')
2554 >>> x.is_real()
2555 True
2556 >>> (x + 1).is_real()
2557 True
2558 """
2559 return self.sort().is_real()
2560
Referenced by is_real().
◆ sort()
Return the sort (type) of the arithmetical expression `self`.
>>> Int('x').sort()
Int
>>> (Real('x') + 1).sort()
Real
Reimplemented from ExprRef.
Definition at line 2526 of file z3py.py.
2526 def sort(self):
2527 """Return the sort (type) of the arithmetical expression `self`.
2528
2529 >>> Int('x').sort()
2530 Int
2531 >>> (Real('x') + 1).sort()
2532 Real
2533 """
2534 return ArithSortRef(
Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
2535
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.