logo

Expression of type Lambda

from the theory of proveit.numbers.multiplication

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, n, x
from proveit.core_expr_types import a_1_to_n
from proveit.logic import And, Equals, Forall, InSet, Set
from proveit.numbers import Add, Complex, Mult, Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda([n, x], Conditional(Forall(instance_param_or_params = [a_1_to_n], instance_expr = Equals(Add(a_1_to_n), Mult(x, n)), domain = Set(x)), And(InSet(n, Natural), InSet(x, Complex))))
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(n, x\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{n} \in \left\{x\right\}}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{n}\right) = \left(x \cdot n\right)\right) \textrm{ if } n \in \mathbb{N} ,  x \in \mathbb{C}\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
1ExprTuple34, 44
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 20
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 26
body: 11
9Operationoperator: 35
operands: 12
10Operationoperator: 35
operands: 13
11Conditionalvalue: 14
condition: 15
12ExprTuple34, 16
13ExprTuple44, 17
14Operationoperator: 18
operands: 19
15Operationoperator: 20
operands: 21
16Literal
17Literal
18Literal
19ExprTuple22, 23
20Literal
21ExprTuple24
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operands: 28
24ExprRangelambda_map: 29
start_index: 33
end_index: 34
25Literal
26ExprTuple30
27Literal
28ExprTuple44, 34
29Lambdaparameter: 43
body: 31
30ExprRangelambda_map: 32
start_index: 33
end_index: 34
31Operationoperator: 35
operands: 36
32Lambdaparameter: 43
body: 37
33Literal
34Variable
35Literal
36ExprTuple37, 38
37IndexedVarvariable: 39
index: 43
38Operationoperator: 41
operand: 44
39Variable
40ExprTuple43
41Literal
42ExprTuple44
43Variable
44Variable