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 And, Equals, InSet, NotEquals
from proveit.numbers import Add, Complex, frac, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(x, sub_expr1)
expr = ExprTuple(Lambda([x_1_to_n, y], Conditional(Equals(frac(Add(x_1_to_n), y), Add(ExprRange(sub_expr1, frac(sub_expr2, y), one, n))), And(ExprRange(sub_expr1, InSet(sub_expr2, Complex), one, n), InSet(y, Complex), NotEquals(y, zero)))))
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(\left(x_{1}, x_{2}, \ldots, x_{n}, y\right) \mapsto \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) \textrm{ if } \left(x_{1} \in \mathbb{C}\right) ,  \left(x_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(x_{n} \in \mathbb{C}\right) ,  y \in \mathbb{C} ,  y \neq 0\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
1Lambdaparameters: 2
body: 3
2ExprTuple30, 39
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14
10Operationoperator: 36
operands: 15
11Operationoperator: 25
operands: 16
12ExprRangelambda_map: 17
start_index: 34
end_index: 35
13Operationoperator: 28
operands: 18
14Operationoperator: 19
operands: 20
15ExprTuple21, 39
16ExprTuple22
17Lambdaparameter: 42
body: 23
18ExprTuple39, 32
19Literal
20ExprTuple39, 24
21Operationoperator: 25
operands: 26
22ExprRangelambda_map: 27
start_index: 34
end_index: 35
23Operationoperator: 28
operands: 29
24Literal
25Literal
26ExprTuple30
27Lambdaparameter: 42
body: 31
28Literal
29ExprTuple38, 32
30ExprRangelambda_map: 33
start_index: 34
end_index: 35
31Operationoperator: 36
operands: 37
32Literal
33Lambdaparameter: 42
body: 38
34Literal
35Variable
36Literal
37ExprTuple38, 39
38IndexedVarvariable: 40
index: 42
39Variable
40Variable
41ExprTuple42
42Variable