logo

Expression of type Lambda

from the theory of proveit.logic.booleans.conjunction

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, l, m, n
from proveit.core_expr_types import A_1_to_l, B_1_to_m, C_1_to_n
from proveit.logic import And, Boolean, Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda([l, m, n], Conditional(Forall(instance_param_or_params = [A_1_to_l, B_1_to_m, C_1_to_n], instance_expr = Equals(And(A_1_to_l, B_1_to_m, C_1_to_n), And(A_1_to_l, And(B_1_to_m), C_1_to_n)).with_wrapping_at(2), domain = Boolean), And(InSet(l, Natural), InSet(m, Natural), InSet(n, Natural))))
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(l, m, n\right) \mapsto \left\{\forall_{A_{1}, A_{2}, \ldots, A_{l}, B_{1}, B_{2}, \ldots, B_{m}, C_{1}, C_{2}, \ldots, C_{n} \in \mathbb{B}}~\left(\begin{array}{c} \begin{array}{l} \left(A_{1} \land  A_{2} \land  \ldots \land  A_{l}\land B_{1} \land  B_{2} \land  \ldots \land  B_{m}\land C_{1} \land  C_{2} \land  \ldots \land  C_{n}\right) =  \\ \left(A_{1} \land  A_{2} \land  \ldots \land  A_{l} \land \left(B_{1} \land  B_{2} \land  \ldots \land  B_{m}\right)\land C_{1} \land  C_{2} \land  \ldots \land  C_{n}\right) \end{array} \end{array}\right) \textrm{ if } l \in \mathbb{N} ,  m \in \mathbb{N} ,  n \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
0Lambdaparameters: 1
body: 2
1ExprTuple39, 54, 43
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 40
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameters: 27
body: 12
9Operationoperator: 46
operands: 13
10Operationoperator: 46
operands: 14
11Operationoperator: 46
operands: 15
12Conditionalvalue: 16
condition: 17
13ExprTuple39, 18
14ExprTuple54, 18
15ExprTuple43, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 40
operands: 21
18Literal
19Literal
20ExprTuple22, 23
21ExprTuple24, 25, 26
22Operationoperator: 40
operands: 27
23Operationoperator: 40
operands: 28
24ExprRangelambda_map: 29
start_index: 53
end_index: 39
25ExprRangelambda_map: 30
start_index: 53
end_index: 54
26ExprRangelambda_map: 31
start_index: 53
end_index: 43
27ExprTuple32, 48, 34
28ExprTuple32, 33, 34
29Lambdaparameter: 60
body: 35
30Lambdaparameter: 60
body: 36
31Lambdaparameter: 60
body: 37
32ExprRangelambda_map: 38
start_index: 53
end_index: 39
33Operationoperator: 40
operands: 41
34ExprRangelambda_map: 42
start_index: 53
end_index: 43
35Operationoperator: 46
operands: 44
36Operationoperator: 46
operands: 45
37Operationoperator: 46
operands: 47
38Lambdaparameter: 60
body: 49
39Variable
40Literal
41ExprTuple48
42Lambdaparameter: 60
body: 50
43Variable
44ExprTuple49, 51
45ExprTuple57, 51
46Literal
47ExprTuple50, 51
48ExprRangelambda_map: 52
start_index: 53
end_index: 54
49IndexedVarvariable: 55
index: 60
50IndexedVarvariable: 56
index: 60
51Literal
52Lambdaparameter: 60
body: 57
53Literal
54Variable
55Variable
56Variable
57IndexedVarvariable: 58
index: 60
58Variable
59ExprTuple60
60Variable