logo

Expression of type Lambda

from the theory of proveit.core_expr_types.lambda_maps

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, Q, f, g, i
from proveit.core_expr_types import Q__a_1_to_i, Q__b_1_to_i, Q__c_1_to_i, a_1_to_i, b_1_to_i, c_1_to_i, f__a_1_to_i, f__b_1_to_i, g__a_1_to_i, g__c_1_to_i
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Lambda(i, Conditional(Forall(instance_param_or_params = [f, g, Q], instance_expr = Implies(Forall(instance_param_or_params = [a_1_to_i], instance_expr = Equals(f__a_1_to_i, g__a_1_to_i), condition = Q__a_1_to_i), Equals(Lambda([b_1_to_i], Conditional(f__b_1_to_i, Q__b_1_to_i)), Lambda([c_1_to_i], Conditional(g__c_1_to_i, Q__c_1_to_i))).with_wrapping_at(2)).with_wrapping_at(2)), InSet(i, NaturalPos)))
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())
i \mapsto \left\{\forall_{f, g, Q}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{a_{1}, a_{2}, \ldots, a_{i}~|~Q\left(a_{1}, a_{2}, \ldots, a_{i}\right)}~\left(f\left(a_{1}, a_{2}, \ldots, a_{i}\right) = g\left(a_{1}, a_{2}, \ldots, a_{i}\right)\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[\left(b_{1}, b_{2}, \ldots, b_{i}\right) \mapsto \left\{f\left(b_{1}, b_{2}, \ldots, b_{i}\right) \textrm{ if } Q\left(b_{1}, b_{2}, \ldots, b_{i}\right)\right..\right] =  \\ \left[\left(c_{1}, c_{2}, \ldots, c_{i}\right) \mapsto \left\{g\left(c_{1}, c_{2}, \ldots, c_{i}\right) \textrm{ if } Q\left(c_{1}, c_{2}, \ldots, c_{i}\right)\right..\right] \end{array} \end{array}\right) \end{array} \end{array}\right) \textrm{ if } i \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 50
body: 2
1ExprTuple50
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple50, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple40, 41, 34
11Operationoperator: 12
operands: 13
12Literal
13ExprTuple14, 15
14Operationoperator: 16
operand: 19
15Operationoperator: 31
operands: 18
16Literal
17ExprTuple19
18ExprTuple20, 21
19Lambdaparameters: 42
body: 22
20Lambdaparameters: 33
body: 23
21Lambdaparameters: 35
body: 24
22Conditionalvalue: 25
condition: 26
23Conditionalvalue: 27
condition: 28
24Conditionalvalue: 29
condition: 30
25Operationoperator: 31
operands: 32
26Operationoperator: 34
operands: 42
27Operationoperator: 40
operands: 33
28Operationoperator: 34
operands: 33
29Operationoperator: 41
operands: 35
30Operationoperator: 34
operands: 35
31Literal
32ExprTuple36, 37
33ExprTuple38
34Variable
35ExprTuple39
36Operationoperator: 40
operands: 42
37Operationoperator: 41
operands: 42
38ExprRangelambda_map: 43
start_index: 49
end_index: 50
39ExprRangelambda_map: 44
start_index: 49
end_index: 50
40Variable
41Variable
42ExprTuple45
43Lambdaparameter: 56
body: 46
44Lambdaparameter: 56
body: 47
45ExprRangelambda_map: 48
start_index: 49
end_index: 50
46IndexedVarvariable: 51
index: 56
47IndexedVarvariable: 52
index: 56
48Lambdaparameter: 56
body: 53
49Literal
50Variable
51Variable
52Variable
53IndexedVarvariable: 54
index: 56
54Variable
55ExprTuple56
56Variable