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, C, Conditional, ExprRange, IndexedVar, Lambda, Variable, m
from proveit.core_expr_types import A_1_to_m
from proveit.logic import And, Boolean, Forall, Implies, InSet, 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(A, sub_expr1)
expr = Lambda([A_1_to_m], Conditional(Forall(instance_param_or_params = [C], instance_expr = C, condition = ExprRange(sub_expr1, Implies(sub_expr2, C), one, m)), And(ExprRange(sub_expr1, InSet(sub_expr2, Boolean), one, m), Or(A_1_to_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}\right) \mapsto \left\{\forall_{C~|~\left(A_{1} \Rightarrow C\right), \left(A_{2} \Rightarrow C\right), \ldots, \left(A_{m} \Rightarrow C\right)}~C \textrm{ if } \left(A_{1} \in \mathbb{B}\right) ,  \left(A_{2} \in \mathbb{B}\right) ,  \ldots ,  \left(A_{m} \in \mathbb{B}\right) ,  A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m}\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
operand: 7
3Operationoperator: 18
operands: 6
4Literal
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameter: 32
body: 11
8ExprRangelambda_map: 12
start_index: 26
end_index: 27
9Operationoperator: 13
operands: 14
10ExprTuple32
11Conditionalvalue: 32
condition: 15
12Lambdaparameter: 35
body: 16
13Literal
14ExprTuple17
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17ExprRangelambda_map: 22
start_index: 26
end_index: 27
18Literal
19ExprTuple23
20Literal
21ExprTuple31, 24
22Lambdaparameter: 35
body: 31
23ExprRangelambda_map: 25
start_index: 26
end_index: 27
24Literal
25Lambdaparameter: 35
body: 28
26Literal
27Variable
28Operationoperator: 29
operands: 30
29Literal
30ExprTuple31, 32
31IndexedVarvariable: 33
index: 35
32Variable
33Variable
34ExprTuple35
35Variable