logo

Expression of type And

from the theory of proveit.core_expr_types.tuples

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 ExprRange, IndexedVar, Variable, a, b, m
from proveit.logic import And, Equals, Forall
from proveit.numbers import Add, NaturalPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(a, one)
sub_expr3 = IndexedVar(b, one)
sub_expr4 = IndexedVar(a, sub_expr1)
sub_expr5 = Add(m, one)
sub_expr6 = IndexedVar(b, sub_expr1)
sub_expr7 = ExprRange(sub_expr1, sub_expr4, one, sub_expr5)
sub_expr8 = ExprRange(sub_expr1, sub_expr6, one, sub_expr5)
sub_expr9 = Equals(sub_expr4, sub_expr6)
sub_expr10 = ExprRange(sub_expr1, sub_expr4, one, m)
sub_expr11 = ExprRange(sub_expr1, sub_expr6, one, m)
expr = And(Forall(instance_param_or_params = [sub_expr2, sub_expr3], instance_expr = Equals([sub_expr2], [sub_expr3]), condition = Equals(sub_expr2, sub_expr3)), Forall(instance_param_or_params = [m], instance_expr = Forall(instance_param_or_params = [sub_expr7, sub_expr8], instance_expr = Equals([sub_expr7], [sub_expr8]), condition = ExprRange(sub_expr1, sub_expr9, one, sub_expr5)), domain = NaturalPos, condition = Forall(instance_param_or_params = [sub_expr10, sub_expr11], instance_expr = Equals([sub_expr10], [sub_expr11]), condition = ExprRange(sub_expr1, sub_expr9, one, m))).with_wrapping())
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[\forall_{a_{1}, b_{1}~|~a_{1} = b_{1}}~\left(\left(a_{1}\right) = \left(b_{1}\right)\right)\right] \land \left[\begin{array}{l}\forall_{m \in \mathbb{N}^+~|~\forall_{a_{1}, a_{2}, \ldots, a_{m}, b_{1}, b_{2}, \ldots, b_{m}~|~\left(a_{1} = b_{1}\right), \left(a_{2} = b_{2}\right), \ldots, \left(a_{m} = b_{m}\right)}~\left(\left(a_{1}, a_{2}, \ldots, a_{m}\right) = \left(b_{1}, b_{2}, \ldots, b_{m}\right)\right)}~\\
\left[\forall_{a_{1}, a_{2}, \ldots, a_{m + 1}, b_{1}, b_{2}, \ldots, b_{m + 1}~|~\left(a_{1} = b_{1}\right), \left(a_{2} = b_{2}\right), \ldots, \left(a_{m + 1} = b_{m + 1}\right)}~\left(\left(a_{1}, a_{2}, \ldots, a_{m + 1}\right) = \left(b_{1}, b_{2}, \ldots, b_{m + 1}\right)\right)\right]\end{array}\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: 49
operands: 1
1ExprTuple2, 3
2Operationoperator: 30
operand: 6
3Operationoperator: 30
operand: 7
4ExprTuple6
5ExprTuple7
6Lambdaparameters: 16
body: 8
7Lambdaparameter: 63
body: 10
8Conditionalvalue: 11
condition: 12
9ExprTuple63
10Conditionalvalue: 13
condition: 14
11Operationoperator: 65
operands: 15
12Operationoperator: 65
operands: 16
13Operationoperator: 30
operand: 21
14Operationoperator: 49
operands: 18
15ExprTuple19, 20
16ExprTuple24, 25
17ExprTuple21
18ExprTuple22, 23
19ExprTuple24
20ExprTuple25
21Lambdaparameters: 26
body: 27
22Operationoperator: 28
operands: 29
23Operationoperator: 30
operand: 36
24IndexedVarvariable: 69
index: 62
25IndexedVarvariable: 70
index: 62
26ExprTuple46, 47
27Conditionalvalue: 33
condition: 34
28Literal
29ExprTuple63, 35
30Literal
31ExprTuple36
32ExprTuple62
33Operationoperator: 65
operands: 37
34Operationoperator: 49
operands: 38
35Literal
36Lambdaparameters: 39
body: 40
37ExprTuple41, 42
38ExprTuple43
39ExprTuple57, 58
40Conditionalvalue: 44
condition: 45
41ExprTuple46
42ExprTuple47
43ExprRangelambda_map: 59
start_index: 62
end_index: 51
44Operationoperator: 65
operands: 48
45Operationoperator: 49
operands: 50
46ExprRangelambda_map: 60
start_index: 62
end_index: 51
47ExprRangelambda_map: 61
start_index: 62
end_index: 51
48ExprTuple52, 53
49Literal
50ExprTuple54
51Operationoperator: 55
operands: 56
52ExprTuple57
53ExprTuple58
54ExprRangelambda_map: 59
start_index: 62
end_index: 63
55Literal
56ExprTuple63, 62
57ExprRangelambda_map: 60
start_index: 62
end_index: 63
58ExprRangelambda_map: 61
start_index: 62
end_index: 63
59Lambdaparameter: 72
body: 64
60Lambdaparameter: 72
body: 67
61Lambdaparameter: 72
body: 68
62Literal
63Variable
64Operationoperator: 65
operands: 66
65Literal
66ExprTuple67, 68
67IndexedVarvariable: 69
index: 72
68IndexedVarvariable: 70
index: 72
69Variable
70Variable
71ExprTuple72
72Variable