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, ExprTuple, Lambda, Py, S, y, z
from proveit.logic import And, Equals, InSet, NotEquals
from proveit.numbers import Complex, Sum, frac, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [y]
expr = ExprTuple(Lambda(z, Conditional(Equals(frac(Sum(index_or_indices = sub_expr1, summand = Py, domain = S), z), Sum(index_or_indices = sub_expr1, summand = frac(Py, z), domain = S)), And(InSet(z, Complex), NotEquals(z, 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(z \mapsto \left\{\frac{\sum_{y \in S}~P\left(y\right)}{z} = \left[\sum_{y \in S}~\frac{P\left(y\right)}{z}\right] \textrm{ if } z \in \mathbb{C} ,  z \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
1Lambdaparameter: 33
body: 3
2ExprTuple33
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13
10Operationoperator: 29
operands: 14
11Operationoperator: 23
operand: 20
12Operationoperator: 34
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple19, 33
15ExprTuple20
16ExprTuple33, 21
17Literal
18ExprTuple33, 22
19Operationoperator: 23
operand: 26
20Lambdaparameter: 39
body: 25
21Literal
22Literal
23Literal
24ExprTuple26
25Conditionalvalue: 27
condition: 31
26Lambdaparameter: 39
body: 28
27Operationoperator: 29
operands: 30
28Conditionalvalue: 32
condition: 31
29Literal
30ExprTuple32, 33
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operand: 39
33Variable
34Literal
35ExprTuple39, 38
36Variable
37ExprTuple39
38Variable
39Variable