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 A, B, C, Conditional, D, ExprRange, IndexedVar, Lambda, Variable, l, m, n
from proveit.core_expr_types import A_1_to_l, C_1_to_m, D_1_to_n
from proveit.logic import And, Boolean, Equals, InSet, Or
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([A_1_to_l, B, C_1_to_m, D_1_to_n], Conditional(Equals(Or(A_1_to_l, B, C_1_to_m, D_1_to_n), Or(A_1_to_l, C_1_to_m, B, D_1_to_n)).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(A, sub_expr1), Boolean), one, l), InSet(B, Boolean), ExprRange(sub_expr1, InSet(IndexedVar(C, sub_expr1), Boolean), one, m), ExprRange(sub_expr1, InSet(IndexedVar(D, sub_expr1), Boolean), one, n))))
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(A_{1}, A_{2}, \ldots, A_{l}, B, C_{1}, C_{2}, \ldots, C_{m}, D_{1}, D_{2}, \ldots, D_{n}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{l} \lor B\lor C_{1} \lor  C_{2} \lor  \ldots \lor  C_{m}\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_{1} \lor  C_{2} \lor  \ldots \lor  C_{m} \lor B\lor D_{1} \lor  D_{2} \lor  \ldots \lor  D_{n}\right) \end{array} \end{array} \textrm{ if } \left(A_{1} \in \mathbb{B}\right) ,  \left(A_{2} \in \mathbb{B}\right) ,  \ldots ,  \left(A_{l} \in \mathbb{B}\right) ,  B \in \mathbb{B}, \left(C_{1} \in \mathbb{B}\right) ,  \left(C_{2} \in \mathbb{B}\right) ,  \ldots ,  \left(C_{m} \in \mathbb{B}\right), \left(D_{1} \in \mathbb{B}\right) ,  \left(D_{2} \in \mathbb{B}\right) ,  \ldots ,  \left(D_{n} \in \mathbb{B}\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: 14
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12, 13
8Operationoperator: 15
operands: 14
9Operationoperator: 15
operands: 16
10ExprRangelambda_map: 17
start_index: 33
end_index: 29
11Operationoperator: 37
operands: 18
12ExprRangelambda_map: 19
start_index: 33
end_index: 31
13ExprRangelambda_map: 20
start_index: 33
end_index: 34
14ExprTuple21, 25, 22, 23
15Literal
16ExprTuple21, 22, 25, 23
17Lambdaparameter: 47
body: 24
18ExprTuple25, 42
19Lambdaparameter: 47
body: 26
20Lambdaparameter: 47
body: 27
21ExprRangelambda_map: 28
start_index: 33
end_index: 29
22ExprRangelambda_map: 30
start_index: 33
end_index: 31
23ExprRangelambda_map: 32
start_index: 33
end_index: 34
24Operationoperator: 37
operands: 35
25Variable
26Operationoperator: 37
operands: 36
27Operationoperator: 37
operands: 38
28Lambdaparameter: 47
body: 39
29Variable
30Lambdaparameter: 47
body: 40
31Variable
32Lambdaparameter: 47
body: 41
33Literal
34Variable
35ExprTuple39, 42
36ExprTuple40, 42
37Literal
38ExprTuple41, 42
39IndexedVarvariable: 43
index: 47
40IndexedVarvariable: 44
index: 47
41IndexedVarvariable: 45
index: 47
42Literal
43Variable
44Variable
45Variable
46ExprTuple47
47Variable