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 Conditional, ExprTuple, Lambda, a, b, i, j, k, l
from proveit.core_expr_types.tuples import shift_equiv_both
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Natural, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([i, j, k, l], Conditional(shift_equiv_both, And(InSet(subtract(Add(j, one), i), Natural), Equals(Add(i, a), Add(k, b)), Equals(Add(j, a), Add(l, b))))))
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(i, j, k, l\right) \mapsto \left\{\left(f\left(i + a\right), f\left(\left(i + 1\right) + a\right), \ldots, f\left(j + a\right)\right) = \left(f\left(k + b\right), f\left(\left(k + 1\right) + b\right), \ldots, f\left(l + b\right)\right) \textrm{ if } \left(\left(j + 1\right) - i\right) \in \mathbb{N} ,  \left(i + a\right) = \left(k + b\right) ,  \left(j + a\right) = \left(l + b\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
2ExprTuple54, 52, 42, 43
3Conditionalvalue: 4
condition: 5
4Operationoperator: 19
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13
9ExprTuple14
10ExprTuple15
11Operationoperator: 16
operands: 17
12Operationoperator: 19
operands: 18
13Operationoperator: 19
operands: 20
14ExprRangelambda_map: 21
start_index: 54
end_index: 52
15ExprRangelambda_map: 22
start_index: 42
end_index: 43
16Literal
17ExprTuple23, 24
18ExprTuple25, 26
19Literal
20ExprTuple27, 28
21Lambdaparameter: 56
body: 29
22Lambdaparameter: 56
body: 31
23Operationoperator: 50
operands: 32
24Literal
25Operationoperator: 50
operands: 33
26Operationoperator: 50
operands: 34
27Operationoperator: 50
operands: 35
28Operationoperator: 50
operands: 36
29Operationoperator: 38
operand: 44
30ExprTuple56
31Operationoperator: 38
operand: 45
32ExprTuple40, 41
33ExprTuple54, 55
34ExprTuple42, 57
35ExprTuple52, 55
36ExprTuple43, 57
37ExprTuple44
38Variable
39ExprTuple45
40Operationoperator: 50
operands: 46
41Operationoperator: 47
operand: 54
42Variable
43Variable
44Operationoperator: 50
operands: 49
45Operationoperator: 50
operands: 51
46ExprTuple52, 53
47Literal
48ExprTuple54
49ExprTuple56, 55
50Literal
51ExprTuple56, 57
52Variable
53Literal
54Variable
55Variable
56Variable
57Variable