logo

Expression of type And

from the theory of proveit.numbers.exponentiation

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import a, a_star, b, b_star
from proveit.logic import And, Equals, Exists, FALSE, Forall, Implies
from proveit.numbers import Abs, GCD, NaturalPos, frac, one, sqrt, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Abs(sqrt(two))
expr = And(Exists(instance_param_or_params = [a, b], instance_expr = And(Equals(sub_expr1, frac(a, b)), Equals(GCD(a, b), one)), domain = NaturalPos), Forall(instance_param_or_params = [a_star, b_star], instance_expr = Implies(And(Equals(sub_expr1, frac(a_star, b_star)), Equals(GCD(a_star, b_star), one)), FALSE), domain = NaturalPos))
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left[\exists_{a, b \in \mathbb{N}^+}~\left(\left(\left|\sqrt{2}\right| = \frac{a}{b}\right) \land \left(gcd\left(a, b\right) = 1\right)\right)\right] \land \left[\forall_{a^*, b^* \in \mathbb{N}^+}~\left(\left(\left(\left|\sqrt{2}\right| = \frac{a^*}{b^*}\right) \land \left(gcd\left(a^*, b^*\right) = 1\right)\right) \Rightarrow \bot\right)\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 33
operands: 1
1ExprTuple2, 3
2Operationoperator: 4
operand: 8
3Operationoperator: 6
operand: 9
4Literal
5ExprTuple8
6Literal
7ExprTuple9
8Lambdaparameters: 43
body: 10
9Lambdaparameters: 55
body: 11
10Conditionalvalue: 12
condition: 13
11Conditionalvalue: 14
condition: 15
12Operationoperator: 33
operands: 16
13Operationoperator: 33
operands: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 33
operands: 20
16ExprTuple21, 22
17ExprTuple23, 24
18Literal
19ExprTuple25, 26
20ExprTuple27, 28
21Operationoperator: 45
operands: 29
22Operationoperator: 45
operands: 30
23Operationoperator: 36
operands: 31
24Operationoperator: 36
operands: 32
25Operationoperator: 33
operands: 34
26Literal
27Operationoperator: 36
operands: 35
28Operationoperator: 36
operands: 37
29ExprTuple49, 38
30ExprTuple39, 64
31ExprTuple47, 42
32ExprTuple48, 42
33Literal
34ExprTuple40, 41
35ExprTuple57, 42
36Literal
37ExprTuple58, 42
38Operationoperator: 62
operands: 43
39Operationoperator: 54
operands: 43
40Operationoperator: 45
operands: 44
41Operationoperator: 45
operands: 46
42Literal
43ExprTuple47, 48
44ExprTuple49, 50
45Literal
46ExprTuple51, 64
47Variable
48Variable
49Operationoperator: 52
operand: 56
50Operationoperator: 62
operands: 55
51Operationoperator: 54
operands: 55
52Literal
53ExprTuple56
54Literal
55ExprTuple57, 58
56Operationoperator: 59
operands: 60
57Variable
58Variable
59Literal
60ExprTuple65, 61
61Operationoperator: 62
operands: 63
62Literal
63ExprTuple64, 65
64Literal
65Literal