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 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 = 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(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
1ExprTuple57, 55, 46, 47
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: 45
end_index: 21
14ExprRangelambda_map: 22
start_index: 23
end_index: 24
15Literal
16ExprTuple25, 26
17ExprTuple27, 28
18Literal
19ExprTuple29, 30
20Lambdaparameter: 63
body: 31
21Operationoperator: 61
operand: 55
22Lambdaparameter: 63
body: 33
23Operationoperator: 61
operand: 46
24Operationoperator: 61
operand: 47
25Operationoperator: 53
operands: 36
26Literal
27Operationoperator: 53
operands: 37
28Operationoperator: 53
operands: 38
29Operationoperator: 53
operands: 39
30Operationoperator: 53
operands: 40
31Operationoperator: 42
operand: 48
32ExprTuple55
33Operationoperator: 42
operand: 49
34ExprTuple46
35ExprTuple47
36ExprTuple44, 45
37ExprTuple57, 58
38ExprTuple46, 60
39ExprTuple55, 58
40ExprTuple47, 60
41ExprTuple48
42Variable
43ExprTuple49
44Operationoperator: 53
operands: 50
45Operationoperator: 61
operand: 57
46Variable
47Variable
48Operationoperator: 53
operands: 52
49Operationoperator: 53
operands: 54
50ExprTuple55, 56
51ExprTuple57
52ExprTuple59, 58
53Literal
54ExprTuple59, 60
55Variable
56Literal
57Variable
58Variable
59Operationoperator: 61
operand: 63
60Variable
61Literal
62ExprTuple63
63Variable