logo

Expression of type Lambda

from the theory of proveit.numbers.numerals.decimals

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, ExprRange, IndexedVar, Lambda, Variable, a, b, c, d, k, m, n
from proveit.logic import And, Equals, InSet
from proveit.numbers import DecimalSequence, Digits, one
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 = IndexedVar(c, sub_expr1)
sub_expr4 = IndexedVar(d, sub_expr1)
sub_expr5 = ExprRange(sub_expr1, b, one, n)
sub_expr6 = ExprRange(sub_expr1, sub_expr2, one, m)
sub_expr7 = ExprRange(sub_expr1, sub_expr3, one, n)
sub_expr8 = ExprRange(sub_expr1, sub_expr4, one, k)
expr = Lambda([sub_expr6, b, sub_expr7, sub_expr8], Conditional(Equals(DecimalSequence(sub_expr6, sub_expr5, sub_expr8), DecimalSequence(sub_expr6, sub_expr7, sub_expr8)), And(ExprRange(sub_expr1, InSet(sub_expr2, Digits), one, m), InSet(b, Digits), ExprRange(sub_expr1, InSet(sub_expr3, Digits), one, n), ExprRange(sub_expr1, InSet(sub_expr4, Digits), one, k), Equals([sub_expr5], [sub_expr7]))))
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}, d_{1}, d_{2}, \ldots, d_{k}\right) \mapsto \left\{\texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ b, b, ..\left(n - 3\right) \times.., b ~ d_{1}, d_{2}, \ldots, d_{k}) = \texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ c_{1}, c_{2}, \ldots, c_{n} ~ d_{1}, d_{2}, \ldots, d_{k}) \textrm{ if } \left(a_{1} \in \mathbb{N}^{\leq 9}\right) ,  \left(a_{2} \in \mathbb{N}^{\leq 9}\right) ,  \ldots ,  \left(a_{m} \in \mathbb{N}^{\leq 9}\right) ,  b \in \mathbb{N}^{\leq 9}, \left(c_{1} \in \mathbb{N}^{\leq 9}\right) ,  \left(c_{2} \in \mathbb{N}^{\leq 9}\right) ,  \ldots ,  \left(c_{n} \in \mathbb{N}^{\leq 9}\right), \left(d_{1} \in \mathbb{N}^{\leq 9}\right) ,  \left(d_{2} \in \mathbb{N}^{\leq 9}\right) ,  \ldots ,  \left(d_{k} \in \mathbb{N}^{\leq 9}\right) ,  \left(b, b, ..\left(n - 3\right) \times.., b\right) = \left(c_{1}, c_{2}, \ldots, c_{n}\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
1ExprTuple24, 50, 40, 25
2Conditionalvalue: 3
condition: 4
3Operationoperator: 22
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12, 13, 14
8Operationoperator: 16
operands: 15
9Operationoperator: 16
operands: 17
10ExprRangelambda_map: 18
start_index: 46
end_index: 32
11Operationoperator: 37
operands: 19
12ExprRangelambda_map: 20
start_index: 46
end_index: 47
13ExprRangelambda_map: 21
start_index: 46
end_index: 34
14Operationoperator: 22
operands: 23
15ExprTuple24, 39, 25
16Literal
17ExprTuple24, 40, 25
18Lambdaparameter: 54
body: 26
19ExprTuple50, 43
20Lambdaparameter: 54
body: 27
21Lambdaparameter: 54
body: 28
22Literal
23ExprTuple29, 30
24ExprRangelambda_map: 31
start_index: 46
end_index: 32
25ExprRangelambda_map: 33
start_index: 46
end_index: 34
26Operationoperator: 37
operands: 35
27Operationoperator: 37
operands: 36
28Operationoperator: 37
operands: 38
29ExprTuple39
30ExprTuple40
31Lambdaparameter: 54
body: 41
32Variable
33Lambdaparameter: 54
body: 42
34Variable
35ExprTuple41, 43
36ExprTuple51, 43
37Literal
38ExprTuple42, 43
39ExprRangelambda_map: 44
start_index: 46
end_index: 47
40ExprRangelambda_map: 45
start_index: 46
end_index: 47
41IndexedVarvariable: 48
index: 54
42IndexedVarvariable: 49
index: 54
43Literal
44Lambdaparameter: 54
body: 50
45Lambdaparameter: 54
body: 51
46Literal
47Variable
48Variable
49Variable
50Variable
51IndexedVarvariable: 52
index: 54
52Variable
53ExprTuple54
54Variable