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, 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 = neg_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
1ExprTuple71, 73
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
11ExprTuple70, 68, 59, 60
12Conditionalvalue: 15
condition: 16
13ExprTuple71, 17
14ExprTuple73, 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: 58
end_index: 34
27ExprRangelambda_map: 35
start_index: 36
end_index: 37
28Literal
29ExprTuple38, 39
30ExprTuple40, 41
31Literal
32ExprTuple42, 43
33Lambdaparameter: 76
body: 44
34Operationoperator: 74
operand: 68
35Lambdaparameter: 76
body: 46
36Operationoperator: 74
operand: 59
37Operationoperator: 74
operand: 60
38Operationoperator: 66
operands: 49
39Literal
40Operationoperator: 66
operands: 50
41Operationoperator: 66
operands: 51
42Operationoperator: 66
operands: 52
43Operationoperator: 66
operands: 53
44Operationoperator: 55
operand: 61
45ExprTuple68
46Operationoperator: 55
operand: 62
47ExprTuple59
48ExprTuple60
49ExprTuple57, 58
50ExprTuple70, 71
51ExprTuple59, 73
52ExprTuple68, 71
53ExprTuple60, 73
54ExprTuple61
55Variable
56ExprTuple62
57Operationoperator: 66
operands: 63
58Operationoperator: 74
operand: 70
59Variable
60Variable
61Operationoperator: 66
operands: 65
62Operationoperator: 66
operands: 67
63ExprTuple68, 69
64ExprTuple70
65ExprTuple72, 71
66Literal
67ExprTuple72, 73
68Variable
69Literal
70Variable
71Variable
72Operationoperator: 74
operand: 76
73Variable
74Literal
75ExprTuple76
76Variable