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, Lambda, a, n
from proveit.core_expr_types import b_1_to_n
from proveit.logic import Forall, InSet
from proveit.numbers import DecimalSequence, Digits, Natural, NaturalPos, greater, zero
In [2]:
# build up the expression from sub-expressions
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [a, b_1_to_n], instance_expr = InSet(DecimalSequence(a, b_1_to_n), NaturalPos), domain = Digits, condition = greater(a, zero)), 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())
n \mapsto \left\{\forall_{a, b_{1}, b_{2}, \ldots, b_{n} \in \mathbb{N}^{\leq 9}~|~a > 0}~\left(\texttt{\#}(a ~ b_{1}, b_{2}, \ldots, b_{n}) \in \mathbb{N}^+\right) \textrm{ if } 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
0Lambdaparameter: 33
body: 2
1ExprTuple33
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 34
operands: 7
5Literal
6ExprTuple8
7ExprTuple33, 9
8Lambdaparameters: 22
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 34
operands: 13
12Operationoperator: 14
operands: 15
13ExprTuple16, 17
14Literal
15ExprTuple18, 19, 20
16Operationoperator: 21
operands: 22
17Literal
18Operationoperator: 34
operands: 23
19ExprRangelambda_map: 24
start_index: 32
end_index: 33
20Operationoperator: 25
operands: 26
21Literal
22ExprTuple30, 27
23ExprTuple30, 37
24Lambdaparameter: 40
body: 28
25Literal
26ExprTuple29, 30
27ExprRangelambda_map: 31
start_index: 32
end_index: 33
28Operationoperator: 34
operands: 35
29Literal
30Variable
31Lambdaparameter: 40
body: 36
32Literal
33Variable
34Literal
35ExprTuple36, 37
36IndexedVarvariable: 38
index: 40
37Literal
38Variable
39ExprTuple40
40Variable