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 neg_shift_equiv
from proveit.logic import And, Equals, InSet
from proveit.numbers import Natural, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, j, k, l], Conditional(neg_shift_equiv, And(InSet(subtract(subtract(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
1ExprTuple53, 51, 40, 41
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: 43
end_index: 21
14ExprRangelambda_map: 22
start_index: 23
end_index: 24
15Literal
16ExprTuple25, 26
17ExprTuple40, 27
18Literal
19ExprTuple41, 28
20Lambdaparameter: 60
body: 29
21Operationoperator: 57
operand: 51
22Lambdaparameter: 60
body: 31
23Operationoperator: 57
operand: 40
24Operationoperator: 57
operand: 41
25Operationoperator: 49
operands: 34
26Literal
27Operationoperator: 49
operands: 35
28Operationoperator: 49
operands: 36
29Operationoperator: 38
operand: 54
30ExprTuple51
31Operationoperator: 38
operand: 45
32ExprTuple40
33ExprTuple41
34ExprTuple42, 43
35ExprTuple53, 44
36ExprTuple51, 44
37ExprTuple54
38Variable
39ExprTuple45
40Variable
41Variable
42Operationoperator: 49
operands: 46
43Operationoperator: 57
operand: 53
44Operationoperator: 57
operand: 55
45Operationoperator: 49
operands: 50
46ExprTuple51, 52
47ExprTuple53
48ExprTuple55
49Literal
50ExprTuple54, 55
51Variable
52Operationoperator: 57
operand: 59
53Variable
54Operationoperator: 57
operand: 60
55Variable
56ExprTuple59
57Literal
58ExprTuple60
59Literal
60Variable