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, Forall, InSet
from proveit.numbers import DecimalSequence, Digits, Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = ExprRange(sub_expr1, b, one, n)
sub_expr3 = ExprRange(sub_expr1, IndexedVar(a, sub_expr1), one, m)
sub_expr4 = ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, n)
sub_expr5 = ExprRange(sub_expr1, IndexedVar(d, sub_expr1), one, k)
expr = Lambda([m, n, k], Conditional(Forall(instance_param_or_params = [sub_expr3, b, sub_expr4, sub_expr5], instance_expr = Equals(DecimalSequence(sub_expr3, sub_expr2, sub_expr5), DecimalSequence(sub_expr3, sub_expr4, sub_expr5)), domain = Digits, condition = Equals([sub_expr2], [sub_expr4])), And(InSet(m, Natural), InSet(n, Natural), InSet(k, 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, k\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{m}, b, c_{1}, c_{2}, \ldots, c_{n}, d_{1}, d_{2}, \ldots, d_{k} \in \mathbb{N}^{\leq 9}~|~\left(b, b, ..\left(n - 3\right) \times.., b\right) = \left(c_{1}, c_{2}, \ldots, c_{n}\right)}~\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})\right) \textrm{ if } m \in \mathbb{N} ,  n \in \mathbb{N} ,  k \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
1ExprTuple47, 62, 49
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 21
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameters: 12
body: 13
9Operationoperator: 52
operands: 14
10Operationoperator: 52
operands: 15
11Operationoperator: 52
operands: 16
12ExprTuple39, 65, 55, 40
13Conditionalvalue: 17
condition: 18
14ExprTuple47, 19
15ExprTuple62, 19
16ExprTuple49, 19
17Operationoperator: 37
operands: 20
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26, 27, 28, 29
23Operationoperator: 31
operands: 30
24Operationoperator: 31
operands: 32
25ExprRangelambda_map: 33
start_index: 61
end_index: 47
26Operationoperator: 52
operands: 34
27ExprRangelambda_map: 35
start_index: 61
end_index: 62
28ExprRangelambda_map: 36
start_index: 61
end_index: 49
29Operationoperator: 37
operands: 38
30ExprTuple39, 54, 40
31Literal
32ExprTuple39, 55, 40
33Lambdaparameter: 69
body: 41
34ExprTuple65, 58
35Lambdaparameter: 69
body: 42
36Lambdaparameter: 69
body: 43
37Literal
38ExprTuple44, 45
39ExprRangelambda_map: 46
start_index: 61
end_index: 47
40ExprRangelambda_map: 48
start_index: 61
end_index: 49
41Operationoperator: 52
operands: 50
42Operationoperator: 52
operands: 51
43Operationoperator: 52
operands: 53
44ExprTuple54
45ExprTuple55
46Lambdaparameter: 69
body: 56
47Variable
48Lambdaparameter: 69
body: 57
49Variable
50ExprTuple56, 58
51ExprTuple66, 58
52Literal
53ExprTuple57, 58
54ExprRangelambda_map: 59
start_index: 61
end_index: 62
55ExprRangelambda_map: 60
start_index: 61
end_index: 62
56IndexedVarvariable: 63
index: 69
57IndexedVarvariable: 64
index: 69
58Literal
59Lambdaparameter: 69
body: 65
60Lambdaparameter: 69
body: 66
61Literal
62Variable
63Variable
64Variable
65Variable
66IndexedVarvariable: 67
index: 69
67Variable
68ExprTuple69
69Variable