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 And, Equals, FALSE, Forall, InSet
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([m, n], Conditional(Forall(instance_param_or_params = [a_1_to_m, b, c_1_to_n], instance_expr = 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)), And(InSet(m, Natural), InSet(n, Natural))))
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(m, n\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{m}, b, c_{1}, c_{2}, \ldots, c_{n}}~\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) \textrm{ if } m \in \mathbb{N} ,  n \in \mathbb{N}\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
1ExprTuple31, 34
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 15
operands: 14
11Operationoperator: 15
operands: 16
12ExprTuple17, 28, 18
13Operationoperator: 19
operands: 20
14ExprTuple31, 21
15Literal
16ExprTuple34, 21
17ExprRangelambda_map: 22
start_index: 33
end_index: 31
18ExprRangelambda_map: 23
start_index: 33
end_index: 34
19Literal
20ExprTuple24, 28
21Literal
22Lambdaparameter: 43
body: 37
23Lambdaparameter: 43
body: 38
24Operationoperator: 25
operands: 26
25Literal
26ExprTuple27, 28, 29
27ExprRangelambda_map: 30
start_index: 33
end_index: 31
28Variable
29ExprRangelambda_map: 32
start_index: 33
end_index: 34
30Lambdaparameter: 43
body: 35
31Variable
32Lambdaparameter: 43
body: 36
33Literal
34Variable
35Conditionalvalue: 37
condition: 39
36Conditionalvalue: 38
condition: 39
37IndexedVarvariable: 40
index: 43
38IndexedVarvariable: 41
index: 43
39Literal
40Variable
41Variable
42ExprTuple43
43Variable