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, Forall, InSet
from proveit.numbers import Add, Integer, Natural, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Lambda([a, b], Conditional(Forall(instance_param_or_params = [i, j, k, l], instance_expr = shift_equiv_both, conditions = [InSet(subtract(Add(j, one), i), Natural), Equals(Add(i, a), Add(k, b)), Equals(Add(j, a), Add(l, b))]), And(InSet(a, Integer), InSet(b, Integer))))
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(a, b\right) \mapsto \left\{\forall_{i, j, k, l~|~\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)}~\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)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z}\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
1ExprTuple67, 69
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 19
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 28
operands: 13
10Operationoperator: 28
operands: 14
11ExprTuple66, 64, 54, 55
12Conditionalvalue: 15
condition: 16
13ExprTuple67, 17
14ExprTuple69, 17
15Operationoperator: 31
operands: 18
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 24, 25
21ExprTuple26
22ExprTuple27
23Operationoperator: 28
operands: 29
24Operationoperator: 31
operands: 30
25Operationoperator: 31
operands: 32
26ExprRangelambda_map: 33
start_index: 66
end_index: 64
27ExprRangelambda_map: 34
start_index: 54
end_index: 55
28Literal
29ExprTuple35, 36
30ExprTuple37, 38
31Literal
32ExprTuple39, 40
33Lambdaparameter: 68
body: 41
34Lambdaparameter: 68
body: 43
35Operationoperator: 62
operands: 44
36Literal
37Operationoperator: 62
operands: 45
38Operationoperator: 62
operands: 46
39Operationoperator: 62
operands: 47
40Operationoperator: 62
operands: 48
41Operationoperator: 50
operand: 56
42ExprTuple68
43Operationoperator: 50
operand: 57
44ExprTuple52, 53
45ExprTuple66, 67
46ExprTuple54, 69
47ExprTuple64, 67
48ExprTuple55, 69
49ExprTuple56
50Variable
51ExprTuple57
52Operationoperator: 62
operands: 58
53Operationoperator: 59
operand: 66
54Variable
55Variable
56Operationoperator: 62
operands: 61
57Operationoperator: 62
operands: 63
58ExprTuple64, 65
59Literal
60ExprTuple66
61ExprTuple68, 67
62Literal
63ExprTuple68, 69
64Variable
65Literal
66Variable
67Variable
68Variable
69Variable