logo

Expression of type Lambda

from the theory of proveit.logic.booleans.disjunction

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 C, Conditional, Lambda, l, m, n
from proveit.core_expr_types import A_1_to_l, B_1_to_m, D_1_to_n
from proveit.logic import And, Boolean, Equals, Forall, InSet, Or
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, D_1_to_n], instance_expr = Equals(Or(A_1_to_l, B_1_to_m, C, D_1_to_n), Or(A_1_to_l, C, B_1_to_m, D_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, D_{1}, D_{2}, \ldots, D_{n} \in \mathbb{B}}~\left(\begin{array}{c} \begin{array}{l} \left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{l}\lor B_{1} \lor  B_{2} \lor  \ldots \lor  B_{m} \lor C\lor D_{1} \lor  D_{2} \lor  \ldots \lor  D_{n}\right) =  \\ \left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{l} \lor C\lor B_{1} \lor  B_{2} \lor  \ldots \lor  B_{m}\lor D_{1} \lor  D_{2} \lor  \ldots \lor  D_{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
1ExprTuple44, 46, 49
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 21
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameters: 29
body: 12
9Operationoperator: 52
operands: 13
10Operationoperator: 52
operands: 14
11Operationoperator: 52
operands: 15
12Conditionalvalue: 16
condition: 17
13ExprTuple44, 18
14ExprTuple46, 18
15ExprTuple49, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18Literal
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26, 27, 28
23Operationoperator: 30
operands: 29
24Operationoperator: 30
operands: 31
25ExprRangelambda_map: 32
start_index: 48
end_index: 44
26ExprRangelambda_map: 33
start_index: 48
end_index: 46
27Operationoperator: 52
operands: 34
28ExprRangelambda_map: 35
start_index: 48
end_index: 49
29ExprTuple36, 37, 41, 38
30Literal
31ExprTuple36, 41, 37, 38
32Lambdaparameter: 62
body: 39
33Lambdaparameter: 62
body: 40
34ExprTuple41, 57
35Lambdaparameter: 62
body: 42
36ExprRangelambda_map: 43
start_index: 48
end_index: 44
37ExprRangelambda_map: 45
start_index: 48
end_index: 46
38ExprRangelambda_map: 47
start_index: 48
end_index: 49
39Operationoperator: 52
operands: 50
40Operationoperator: 52
operands: 51
41Variable
42Operationoperator: 52
operands: 53
43Lambdaparameter: 62
body: 54
44Variable
45Lambdaparameter: 62
body: 55
46Variable
47Lambdaparameter: 62
body: 56
48Literal
49Variable
50ExprTuple54, 57
51ExprTuple55, 57
52Literal
53ExprTuple56, 57
54IndexedVarvariable: 58
index: 62
55IndexedVarvariable: 59
index: 62
56IndexedVarvariable: 60
index: 62
57Literal
58Variable
59Variable
60Variable
61ExprTuple62
62Variable