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 Equals, Forall, InSet
from proveit.numbers import Add, Integer, Natural, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Lambda(a, Conditional(Forall(instance_param_or_params = [i, j, k, l], instance_expr = shift_equiv, conditions = [InSet(subtract(Add(j, one), i), Natural), Equals(k, subtract(i, a)), Equals(l, subtract(j, a))]), InSet(a, 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())
a \mapsto \left\{\forall_{i, j, k, l~|~\left(\left(j + 1\right) - i\right) \in \mathbb{N}, k = \left(i - a\right), l = \left(j - a\right)}~\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)\right) \textrm{ if } a \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
0Lambdaparameter: 58
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 23
operands: 6
4Literal
5ExprTuple7
6ExprTuple58, 8
7Lambdaparameters: 9
body: 10
8Literal
9ExprTuple56, 54, 32, 34
10Conditionalvalue: 11
condition: 12
11Operationoperator: 26
operands: 13
12Operationoperator: 14
operands: 15
13ExprTuple16, 17
14Literal
15ExprTuple18, 19, 20
16ExprTuple21
17ExprTuple22
18Operationoperator: 23
operands: 24
19Operationoperator: 26
operands: 25
20Operationoperator: 26
operands: 27
21ExprRangelambda_map: 28
start_index: 56
end_index: 54
22ExprRangelambda_map: 29
start_index: 32
end_index: 34
23Literal
24ExprTuple30, 31
25ExprTuple32, 33
26Literal
27ExprTuple34, 35
28Lambdaparameter: 57
body: 36
29Lambdaparameter: 57
body: 37
30Operationoperator: 52
operands: 38
31Literal
32Variable
33Operationoperator: 52
operands: 39
34Variable
35Operationoperator: 52
operands: 40
36Operationoperator: 42
operand: 57
37Operationoperator: 42
operand: 47
38ExprTuple44, 45
39ExprTuple56, 46
40ExprTuple54, 46
41ExprTuple57
42Variable
43ExprTuple47
44Operationoperator: 52
operands: 48
45Operationoperator: 50
operand: 56
46Operationoperator: 50
operand: 58
47Operationoperator: 52
operands: 53
48ExprTuple54, 55
49ExprTuple56
50Literal
51ExprTuple58
52Literal
53ExprTuple57, 58
54Variable
55Literal
56Variable
57Variable
58Variable