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, i, j, k
from proveit.core_expr_types import f_i_to_j, fk, g_i_to_j, gk
from proveit.logic import And, Equals, Forall, Implies, InSet
from proveit.numbers import Integer, Interval
In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, j], Conditional(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])), And(InSet(i, Integer), InSet(j, 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(i, j\right) \mapsto \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) \textrm{ if } i \in \mathbb{Z} ,  j \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: 42
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Operationoperator: 12
operand: 17
9Operationoperator: 28
operands: 14
10Operationoperator: 30
operands: 15
11Operationoperator: 30
operands: 16
12Literal
13ExprTuple17
14ExprTuple18, 19
15ExprTuple45, 20
16ExprTuple46, 20
17Lambdaparameter: 44
body: 21
18ExprTuple22
19ExprTuple23
20Literal
21Conditionalvalue: 24
condition: 25
22ExprRangelambda_map: 26
start_index: 45
end_index: 46
23ExprRangelambda_map: 27
start_index: 45
end_index: 46
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operands: 31
26Lambdaparameter: 43
body: 32
27Lambdaparameter: 43
body: 33
28Literal
29ExprTuple34, 35
30Literal
31ExprTuple44, 36
32Operationoperator: 38
operand: 43
33Operationoperator: 39
operand: 43
34Operationoperator: 38
operand: 44
35Operationoperator: 39
operand: 44
36Operationoperator: 41
operands: 42
37ExprTuple43
38Variable
39Variable
40ExprTuple44
41Literal
42ExprTuple45, 46
43Variable
44Variable
45Variable
46Variable