logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(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())
\left(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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 44
body: 3
2ExprTuple44
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 37
operands: 8
6Literal
7ExprTuple9
8ExprTuple44, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple39, 48
12Conditionalvalue: 13
condition: 14
13Operationoperator: 15
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple21, 22, 23
19Operationoperator: 45
operands: 24
20Operationoperator: 34
operands: 25
21ExprRangelambda_map: 26
start_index: 43
end_index: 44
22Operationoperator: 37
operands: 27
23Operationoperator: 28
operands: 29
24ExprTuple30, 48
25ExprTuple31
26Lambdaparameter: 51
body: 32
27ExprTuple48, 41
28Literal
29ExprTuple48, 33
30Operationoperator: 34
operands: 35
31ExprRangelambda_map: 36
start_index: 43
end_index: 44
32Operationoperator: 37
operands: 38
33Literal
34Literal
35ExprTuple39
36Lambdaparameter: 51
body: 40
37Literal
38ExprTuple47, 41
39ExprRangelambda_map: 42
start_index: 43
end_index: 44
40Operationoperator: 45
operands: 46
41Literal
42Lambdaparameter: 51
body: 47
43Literal
44Variable
45Literal
46ExprTuple47, 48
47IndexedVarvariable: 49
index: 51
48Variable
49Variable
50ExprTuple51
51Variable