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 neg_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(neg_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
2ExprTuple58, 56, 47, 48
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: 46
end_index: 22
15ExprRangelambda_map: 23
start_index: 24
end_index: 25
16Literal
17ExprTuple26, 27
18ExprTuple28, 29
19Literal
20ExprTuple30, 31
21Lambdaparameter: 64
body: 32
22Operationoperator: 62
operand: 56
23Lambdaparameter: 64
body: 34
24Operationoperator: 62
operand: 47
25Operationoperator: 62
operand: 48
26Operationoperator: 54
operands: 37
27Literal
28Operationoperator: 54
operands: 38
29Operationoperator: 54
operands: 39
30Operationoperator: 54
operands: 40
31Operationoperator: 54
operands: 41
32Operationoperator: 43
operand: 49
33ExprTuple56
34Operationoperator: 43
operand: 50
35ExprTuple47
36ExprTuple48
37ExprTuple45, 46
38ExprTuple58, 59
39ExprTuple47, 61
40ExprTuple56, 59
41ExprTuple48, 61
42ExprTuple49
43Variable
44ExprTuple50
45Operationoperator: 54
operands: 51
46Operationoperator: 62
operand: 58
47Variable
48Variable
49Operationoperator: 54
operands: 53
50Operationoperator: 54
operands: 55
51ExprTuple56, 57
52ExprTuple58
53ExprTuple60, 59
54Literal
55ExprTuple60, 61
56Variable
57Literal
58Variable
59Variable
60Operationoperator: 62
operand: 64
61Variable
62Literal
63ExprTuple64
64Variable