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 Lambda, f, g, i, j, k
from proveit.core_expr_types import f_i_to_j, fk, g_i_to_j, gk
from proveit.logic import Equals, Forall, Implies
from proveit.numbers import Integer, Interval
In [2]:
# build up the expression from sub-expressions
expr = Lambda([f, g], Forall(instance_param_or_params = [i, j], instance_expr = Implies(Forall(instance_param_or_params = [k], instance_expr = Equals(fk, gk), domain = Interval(i, j)), Equals([f_i_to_j], [g_i_to_j])), domain = 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(f, g\right) \mapsto \left[\forall_{i, j \in \mathbb{Z}}~\left(\left[\forall_{k \in \{i~\ldotp \ldotp~j\}}~\left(f\left(k\right) = g\left(k\right)\right)\right] \Rightarrow \left(\left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right)\right) = \left(g\left(i\right), g\left(i + 1\right), \ldots, g\left(j\right)\right)\right)\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
1ExprTuple42, 43
2Operationoperator: 16
operand: 4
3ExprTuple4
4Lambdaparameters: 46
body: 5
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15
12Operationoperator: 16
operand: 21
13Operationoperator: 32
operands: 18
14Operationoperator: 34
operands: 19
15Operationoperator: 34
operands: 20
16Literal
17ExprTuple21
18ExprTuple22, 23
19ExprTuple49, 24
20ExprTuple50, 24
21Lambdaparameter: 48
body: 25
22ExprTuple26
23ExprTuple27
24Literal
25Conditionalvalue: 28
condition: 29
26ExprRangelambda_map: 30
start_index: 49
end_index: 50
27ExprRangelambda_map: 31
start_index: 49
end_index: 50
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operands: 35
30Lambdaparameter: 47
body: 36
31Lambdaparameter: 47
body: 37
32Literal
33ExprTuple38, 39
34Literal
35ExprTuple48, 40
36Operationoperator: 42
operand: 47
37Operationoperator: 43
operand: 47
38Operationoperator: 42
operand: 48
39Operationoperator: 43
operand: 48
40Operationoperator: 45
operands: 46
41ExprTuple47
42Variable
43Variable
44ExprTuple48
45Literal
46ExprTuple49, 50
47Variable
48Variable
49Variable
50Variable