logo

Expression of type Lambda

from the theory of proveit.numbers.division

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, n, x, y
from proveit.core_expr_types import x_1_to_n
from proveit.logic import Equals, Forall, InSet, NotEquals
from proveit.numbers import Add, Complex, NaturalPos, frac, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [x_1_to_n, y], instance_expr = Equals(frac(Add(x_1_to_n), y), Add(ExprRange(sub_expr1, frac(IndexedVar(x, sub_expr1), y), one, n))), domain = Complex, condition = NotEquals(y, zero)), InSet(n, NaturalPos)))
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_{x_{1}, x_{2}, \ldots, x_{n}, y \in \mathbb{C}~|~y \neq 0}~\left(\frac{x_{1} +  x_{2} +  \ldots +  x_{n}}{y} = \left(\frac{x_{1}}{y} +  \frac{x_{2}}{y} +  \ldots +  \frac{x_{n}}{y}\right)\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: 43
body: 2
1ExprTuple43
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 36
operands: 7
5Literal
6ExprTuple8
7ExprTuple43, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple38, 47
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple20, 21, 22
18Operationoperator: 44
operands: 23
19Operationoperator: 33
operands: 24
20ExprRangelambda_map: 25
start_index: 42
end_index: 43
21Operationoperator: 36
operands: 26
22Operationoperator: 27
operands: 28
23ExprTuple29, 47
24ExprTuple30
25Lambdaparameter: 50
body: 31
26ExprTuple47, 40
27Literal
28ExprTuple47, 32
29Operationoperator: 33
operands: 34
30ExprRangelambda_map: 35
start_index: 42
end_index: 43
31Operationoperator: 36
operands: 37
32Literal
33Literal
34ExprTuple38
35Lambdaparameter: 50
body: 39
36Literal
37ExprTuple46, 40
38ExprRangelambda_map: 41
start_index: 42
end_index: 43
39Operationoperator: 44
operands: 45
40Literal
41Lambdaparameter: 50
body: 46
42Literal
43Variable
44Literal
45ExprTuple46, 47
46IndexedVarvariable: 48
index: 50
47Variable
48Variable
49ExprTuple50
50Variable