logo

Expression of type Lambda

from the theory of proveit.numbers.summation

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, k
from proveit.logic import Equals, InSet
from proveit.numbers import Add, Interval, eight, nine, one, subtract, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = subtract(k, two)
expr = Lambda(k, Equals(Conditional(sub_expr1, InSet(k, Interval(Add(eight, one), nine))), Conditional(sub_expr1, InSet(k, Interval(nine, nine)))))
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())
k \mapsto \left(\left\{k - 2 \textrm{ if } k \in \{8 + 1~\ldotp \ldotp~9\}\right.. = \left\{k - 2 \textrm{ if } k \in \{9~\ldotp \ldotp~9\}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 16
body: 2
1ExprTuple16
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Conditionalvalue: 8
condition: 7
6Conditionalvalue: 8
condition: 9
7Operationoperator: 12
operands: 10
8Operationoperator: 26
operands: 11
9Operationoperator: 12
operands: 13
10ExprTuple16, 14
11ExprTuple16, 15
12Literal
13ExprTuple16, 17
14Operationoperator: 21
operands: 18
15Operationoperator: 19
operand: 24
16Variable
17Operationoperator: 21
operands: 22
18ExprTuple23, 25
19Literal
20ExprTuple24
21Literal
22ExprTuple25, 25
23Operationoperator: 26
operands: 27
24Literal
25Literal
26Literal
27ExprTuple28, 29
28Literal
29Literal