logo

Expression of type ExprTuple

from the theory of proveit.logic.equality

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 Conditional, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, n, x
from proveit.core_expr_types import x_1_to_np1
from proveit.logic import And, Equals
from proveit.numbers import Add, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda([x_1_to_np1], Conditional(Equals(IndexedVar(x, one), IndexedVar(x, Add(n, one))), And(ExprRange(sub_expr1, Equals(IndexedVar(x, sub_expr1), IndexedVar(x, Add(sub_expr1, one))), one, n)))))
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(\left(x_{1}, x_{2}, \ldots, x_{n + 1}\right) \mapsto \left\{x_{1} = x_{n + 1} \textrm{ if } \left(x_{1} = x_{1 + 1}\right) \land  \left(x_{2} = x_{2 + 1}\right) \land  \ldots \land  \left(x_{n} = x_{n + 1}\right)\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple4
3Conditionalvalue: 5
condition: 6
4ExprRangelambda_map: 7
start_index: 32
end_index: 17
5Operationoperator: 20
operands: 8
6Operationoperator: 9
operands: 10
7Lambdaparameter: 31
body: 23
8ExprTuple11, 12
9Literal
10ExprTuple13
11IndexedVarvariable: 26
index: 32
12IndexedVarvariable: 26
index: 17
13ExprRangelambda_map: 16
start_index: 32
end_index: 22
14ExprTuple32
15ExprTuple17
16Lambdaparameter: 31
body: 18
17Operationoperator: 29
operands: 19
18Operationoperator: 20
operands: 21
19ExprTuple22, 32
20Literal
21ExprTuple23, 24
22Variable
23IndexedVarvariable: 26
index: 31
24IndexedVarvariable: 26
index: 28
25ExprTuple31
26Variable
27ExprTuple28
28Operationoperator: 29
operands: 30
29Literal
30ExprTuple31, 32
31Variable
32Literal