logo

Expression of type Lambda

from the theory of proveit.core_expr_types.conditionals

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 Conditional, ConditionalSet, ExprRange, IndexedVar, Lambda, Variable, a, b, c, m, n
from proveit.core_expr_types import a_1_to_m, c_1_to_n
from proveit.logic import Equals, FALSE
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_m, b, c_1_to_n], Equals(ConditionalSet(ExprRange(sub_expr1, Conditional(IndexedVar(a, sub_expr1), FALSE), one, m), b, ExprRange(sub_expr1, Conditional(IndexedVar(c, sub_expr1), FALSE), one, n)), b))
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, c_{1}, c_{2}, \ldots, c_{n}\right) \mapsto \left(\left\{\begin{array}{ccc}a_{1} \textrm{ if } \bot \\ a_{2} \textrm{ if } \bot \\  \vdots \\ a_{m} \textrm{ if } \bot \\ b \\ c_{1} \textrm{ if } \bot \\ c_{2} \textrm{ if } \bot \\  \vdots \\ c_{n} \textrm{ if } \bot\end{array}\right.. = b\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, 13, 4
2Operationoperator: 5
operands: 6
3ExprRangelambda_map: 7
start_index: 18
end_index: 16
4ExprRangelambda_map: 8
start_index: 18
end_index: 19
5Literal
6ExprTuple9, 13
7Lambdaparameter: 28
body: 22
8Lambdaparameter: 28
body: 23
9Operationoperator: 10
operands: 11
10Literal
11ExprTuple12, 13, 14
12ExprRangelambda_map: 15
start_index: 18
end_index: 16
13Variable
14ExprRangelambda_map: 17
start_index: 18
end_index: 19
15Lambdaparameter: 28
body: 20
16Variable
17Lambdaparameter: 28
body: 21
18Literal
19Variable
20Conditionalvalue: 22
condition: 24
21Conditionalvalue: 23
condition: 24
22IndexedVarvariable: 25
index: 28
23IndexedVarvariable: 26
index: 28
24Literal
25Variable
26Variable
27ExprTuple28
28Variable