logo

Expression of type ExprTuple

from the theory of proveit.numbers.summation

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, c, d, fj, gj, j, x
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Complex, Integer, Interval, Mult, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [j]
sub_expr2 = Interval(c, d)
expr = ExprTuple(Lambda(x, Conditional(Forall(instance_param_or_params = [c, d], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = Mult(Mult(x, gj), fj), domain = sub_expr2), Mult(x, Sum(index_or_indices = sub_expr1, summand = Mult(gj, fj), domain = sub_expr2))), domain = Integer), 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(x \mapsto \left\{\forall_{c, d \in \mathbb{Z}}~\left(\left(\sum_{j = c}^{d} \left(\left(x \cdot g\left(j\right)\right) \cdot f\left(j\right)\right)\right) = \left(x \cdot \left(\sum_{j = c}^{d} \left(g\left(j\right) \cdot f\left(j\right)\right)\right)\right)\right) \textrm{ if } x \in \mathbb{C}\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: 42
operands: 8
6Literal
7ExprTuple9
8ExprTuple44, 10
9Lambdaparameters: 52
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple20, 21
18Operationoperator: 30
operand: 26
19Operationoperator: 40
operands: 23
20Operationoperator: 42
operands: 24
21Operationoperator: 42
operands: 25
22ExprTuple26
23ExprTuple44, 27
24ExprTuple54, 28
25ExprTuple55, 28
26Lambdaparameter: 53
body: 29
27Operationoperator: 30
operand: 33
28Literal
29Conditionalvalue: 32
condition: 38
30Literal
31ExprTuple33
32Operationoperator: 40
operands: 34
33Lambdaparameter: 53
body: 35
34ExprTuple36, 46
35Conditionalvalue: 37
condition: 38
36Operationoperator: 40
operands: 39
37Operationoperator: 40
operands: 41
38Operationoperator: 42
operands: 43
39ExprTuple44, 45
40Literal
41ExprTuple45, 46
42Literal
43ExprTuple53, 47
44Variable
45Operationoperator: 48
operand: 53
46Operationoperator: 49
operand: 53
47Operationoperator: 51
operands: 52
48Variable
49Variable
50ExprTuple53
51Literal
52ExprTuple54, 55
53Variable
54Variable
55Variable