logo

Expression of type Lambda

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, 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 = 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(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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple53, 51, 41, 42
2Conditionalvalue: 3
condition: 4
3Operationoperator: 18
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12
8ExprTuple13
9ExprTuple14
10Operationoperator: 15
operands: 16
11Operationoperator: 18
operands: 17
12Operationoperator: 18
operands: 19
13ExprRangelambda_map: 20
start_index: 53
end_index: 51
14ExprRangelambda_map: 21
start_index: 41
end_index: 42
15Literal
16ExprTuple22, 23
17ExprTuple24, 25
18Literal
19ExprTuple26, 27
20Lambdaparameter: 55
body: 28
21Lambdaparameter: 55
body: 30
22Operationoperator: 49
operands: 31
23Literal
24Operationoperator: 49
operands: 32
25Operationoperator: 49
operands: 33
26Operationoperator: 49
operands: 34
27Operationoperator: 49
operands: 35
28Operationoperator: 37
operand: 43
29ExprTuple55
30Operationoperator: 37
operand: 44
31ExprTuple39, 40
32ExprTuple53, 54
33ExprTuple41, 56
34ExprTuple51, 54
35ExprTuple42, 56
36ExprTuple43
37Variable
38ExprTuple44
39Operationoperator: 49
operands: 45
40Operationoperator: 46
operand: 53
41Variable
42Variable
43Operationoperator: 49
operands: 48
44Operationoperator: 49
operands: 50
45ExprTuple51, 52
46Literal
47ExprTuple53
48ExprTuple55, 54
49Literal
50ExprTuple55, 56
51Variable
52Literal
53Variable
54Variable
55Variable
56Variable