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, Conditional, ExprRange, IndexedVar, Lambda, Variable, m
from proveit.core_expr_types import A_1_to_m, B_1_to_m
from proveit.logic import And, Boolean, Implies, InSet, Not, Or
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(B, sub_expr1)
sub_expr3 = IndexedVar(A, sub_expr1)
expr = Lambda([A_1_to_m, B_1_to_m], Conditional(Or(ExprRange(sub_expr1, Not(sub_expr2), one, m)), And(ExprRange(sub_expr1, InSet(sub_expr3, Boolean), one, m), ExprRange(sub_expr1, InSet(sub_expr2, Boolean), one, m), Or(ExprRange(sub_expr1, Not(sub_expr3), one, m)), ExprRange(sub_expr1, Implies(sub_expr3, sub_expr2), one, m))))
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_{m}, B_{1}, B_{2}, \ldots, B_{m}\right) \mapsto \left\{(\lnot B_{1}) \lor  (\lnot B_{2}) \lor  \ldots \lor  (\lnot B_{m}) \textrm{ if } \left(A_{1} \in \mathbb{B}\right) ,  \left(A_{2} \in \mathbb{B}\right) ,  \ldots ,  \left(A_{m} \in \mathbb{B}\right), \left(B_{1} \in \mathbb{B}\right) ,  \left(B_{2} \in \mathbb{B}\right) ,  \ldots ,  \left(B_{m} \in \mathbb{B}\right) ,  (\lnot A_{1}) \lor  (\lnot A_{2}) \lor  \ldots \lor  (\lnot A_{m}), \left(A_{1} \Rightarrow B_{1}\right) ,  \left(A_{2} \Rightarrow B_{2}\right) ,  \ldots ,  \left(A_{m} \Rightarrow B_{m}\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: 1
body: 2
1ExprTuple3, 4
2Conditionalvalue: 5
condition: 6
3ExprRangelambda_map: 7
start_index: 33
end_index: 34
4ExprRangelambda_map: 8
start_index: 33
end_index: 34
5Operationoperator: 20
operands: 9
6Operationoperator: 10
operands: 11
7Lambdaparameter: 46
body: 43
8Lambdaparameter: 46
body: 39
9ExprTuple12
10Literal
11ExprTuple13, 14, 15, 16
12ExprRangelambda_map: 17
start_index: 33
end_index: 34
13ExprRangelambda_map: 18
start_index: 33
end_index: 34
14ExprRangelambda_map: 19
start_index: 33
end_index: 34
15Operationoperator: 20
operands: 21
16ExprRangelambda_map: 22
start_index: 33
end_index: 34
17Lambdaparameter: 46
body: 23
18Lambdaparameter: 46
body: 24
19Lambdaparameter: 46
body: 25
20Literal
21ExprTuple26
22Lambdaparameter: 46
body: 27
23Operationoperator: 40
operand: 39
24Operationoperator: 30
operands: 29
25Operationoperator: 30
operands: 31
26ExprRangelambda_map: 32
start_index: 33
end_index: 34
27Operationoperator: 35
operands: 36
28ExprTuple39
29ExprTuple43, 37
30Literal
31ExprTuple39, 37
32Lambdaparameter: 46
body: 38
33Literal
34Variable
35Literal
36ExprTuple43, 39
37Literal
38Operationoperator: 40
operand: 43
39IndexedVarvariable: 42
index: 46
40Literal
41ExprTuple43
42Variable
43IndexedVarvariable: 44
index: 46
44Variable
45ExprTuple46
46Variable