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, 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 = 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(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..
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
1ExprTuple48, 46, 24, 26
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: 48
end_index: 46
14ExprRangelambda_map: 21
start_index: 24
end_index: 26
15Literal
16ExprTuple22, 23
17ExprTuple24, 25
18Literal
19ExprTuple26, 27
20Lambdaparameter: 49
body: 28
21Lambdaparameter: 49
body: 29
22Operationoperator: 44
operands: 30
23Literal
24Variable
25Operationoperator: 44
operands: 31
26Variable
27Operationoperator: 44
operands: 32
28Operationoperator: 34
operand: 49
29Operationoperator: 34
operand: 39
30ExprTuple36, 37
31ExprTuple48, 38
32ExprTuple46, 38
33ExprTuple49
34Variable
35ExprTuple39
36Operationoperator: 44
operands: 40
37Operationoperator: 42
operand: 48
38Operationoperator: 42
operand: 50
39Operationoperator: 44
operands: 45
40ExprTuple46, 47
41ExprTuple48
42Literal
43ExprTuple50
44Literal
45ExprTuple49, 50
46Variable
47Literal
48Variable
49Variable
50Variable