logo

Expression of type ExprTuple

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, ExprTuple, IndexedVar, Variable, a, b, m
from proveit.logic import Equals, Forall, InSet
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, sub_expr1)
sub_expr3 = IndexedVar(b, sub_expr1)
sub_expr4 = ExprRange(sub_expr1, sub_expr2, one, m)
sub_expr5 = ExprRange(sub_expr1, sub_expr3, one, m)
sub_expr6 = Equals(sub_expr2, sub_expr3)
expr = ExprTuple(InSet(m, NaturalPos), Forall(instance_param_or_params = [sub_expr4, sub_expr5], instance_expr = Equals([sub_expr4], [sub_expr5]), condition = ExprRange(sub_expr1, sub_expr6, one, m)), ExprRange(sub_expr1, sub_expr6, one, Add(m, one)))
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(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(a_{1} = b_{1}\right), \left(a_{2} = b_{2}\right), \ldots, \left(a_{m + 1} = b_{m + 1}\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2, 3
1Operationoperator: 4
operands: 5
2Operationoperator: 6
operand: 10
3ExprRangelambda_map: 25
start_index: 28
end_index: 8
4Literal
5ExprTuple29, 9
6Literal
7ExprTuple10
8Operationoperator: 11
operands: 12
9Literal
10Lambdaparameters: 13
body: 14
11Literal
12ExprTuple29, 28
13ExprTuple23, 24
14Conditionalvalue: 15
condition: 16
15Operationoperator: 31
operands: 17
16Operationoperator: 18
operands: 19
17ExprTuple20, 21
18Literal
19ExprTuple22
20ExprTuple23
21ExprTuple24
22ExprRangelambda_map: 25
start_index: 28
end_index: 29
23ExprRangelambda_map: 26
start_index: 28
end_index: 29
24ExprRangelambda_map: 27
start_index: 28
end_index: 29
25Lambdaparameter: 38
body: 30
26Lambdaparameter: 38
body: 33
27Lambdaparameter: 38
body: 34
28Literal
29Variable
30Operationoperator: 31
operands: 32
31Literal
32ExprTuple33, 34
33IndexedVarvariable: 35
index: 38
34IndexedVarvariable: 36
index: 38
35Variable
36Variable
37ExprTuple38
38Variable