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, Conditional, ExprRange, IndexedVar, Lambda, Variable, m
from proveit.logic import And, Boolean, InSet, Or
from proveit.numbers import Add, one, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(A, sub_expr1)
sub_expr3 = Add(m, one)
expr = Lambda([ExprRange(sub_expr1, sub_expr2, one, Add(m, two))], Conditional(InSet(Or(ExprRange(sub_expr1, sub_expr2, one, sub_expr3)), Boolean), And(ExprRange(sub_expr1, InSet(sub_expr2, Boolean), one, sub_expr3))))
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 + 2}\right) \mapsto \left\{\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m + 1}\right) \in \mathbb{B} \textrm{ if } \left(A_{1} \in \mathbb{B}\right) \land  \left(A_{2} \in \mathbb{B}\right) \land  \ldots \land  \left(A_{m + 1} \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: 1
body: 2
1ExprTuple3
2Conditionalvalue: 4
condition: 5
3ExprRangelambda_map: 19
start_index: 28
end_index: 6
4Operationoperator: 21
operands: 7
5Operationoperator: 8
operands: 9
6Operationoperator: 23
operands: 10
7ExprTuple11, 26
8Literal
9ExprTuple12
10ExprTuple27, 13
11Operationoperator: 14
operands: 15
12ExprRangelambda_map: 16
start_index: 28
end_index: 20
13Literal
14Literal
15ExprTuple17
16Lambdaparameter: 31
body: 18
17ExprRangelambda_map: 19
start_index: 28
end_index: 20
18Operationoperator: 21
operands: 22
19Lambdaparameter: 31
body: 25
20Operationoperator: 23
operands: 24
21Literal
22ExprTuple25, 26
23Literal
24ExprTuple27, 28
25IndexedVarvariable: 29
index: 31
26Literal
27Variable
28Literal
29Variable
30ExprTuple31
31Variable