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, i, j, k, l
from proveit.core_expr_types.tuples import shift_equiv
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, And(InSet(subtract(Add(j, one), i), Natural), Equals(k, subtract(i, a)), Equals(l, subtract(j, a))))))
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\right), f\left(i + 1\right), \ldots, f\left(j\right)\right) = \left(f\left(k + a\right), f\left(\left(k + 1\right) + a\right), \ldots, f\left(l + a\right)\right) \textrm{ if } \left(\left(j + 1\right) - i\right) \in \mathbb{N} ,  k = \left(i - a\right) ,  l = \left(j - a\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
2ExprTuple49, 47, 25, 27
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: 49
end_index: 47
15ExprRangelambda_map: 22
start_index: 25
end_index: 27
16Literal
17ExprTuple23, 24
18ExprTuple25, 26
19Literal
20ExprTuple27, 28
21Lambdaparameter: 50
body: 29
22Lambdaparameter: 50
body: 30
23Operationoperator: 45
operands: 31
24Literal
25Variable
26Operationoperator: 45
operands: 32
27Variable
28Operationoperator: 45
operands: 33
29Operationoperator: 35
operand: 50
30Operationoperator: 35
operand: 40
31ExprTuple37, 38
32ExprTuple49, 39
33ExprTuple47, 39
34ExprTuple50
35Variable
36ExprTuple40
37Operationoperator: 45
operands: 41
38Operationoperator: 43
operand: 49
39Operationoperator: 43
operand: 51
40Operationoperator: 45
operands: 46
41ExprTuple47, 48
42ExprTuple49
43Literal
44ExprTuple51
45Literal
46ExprTuple50, 51
47Variable
48Literal
49Variable
50Variable
51Variable