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, a, b, i, x
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Complex, Integer, Interval, Mult, Neg, Sum, one
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([a, b], Conditional(Forall(instance_param_or_params = [x], instance_expr = Equals(Sum(index_or_indices = [i], summand = x, domain = Interval(a, b)), Mult(Add(b, Neg(a), one), x)), domain = Complex), And(InSet(a, Integer), InSet(b, Integer)))))
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(a, b\right) \mapsto \left\{\forall_{x \in \mathbb{C}}~\left(\left(\sum_{i = a}^{b} x\right) = \left(\left(b - a + 1\right) \cdot x\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z}\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: 46
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 35
body: 13
10Operationoperator: 39
operands: 14
11Operationoperator: 39
operands: 15
12ExprTuple35
13Conditionalvalue: 16
condition: 17
14ExprTuple47, 18
15ExprTuple48, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 39
operands: 21
18Literal
19Literal
20ExprTuple22, 23
21ExprTuple35, 24
22Operationoperator: 25
operand: 29
23Operationoperator: 27
operands: 28
24Literal
25Literal
26ExprTuple29
27Literal
28ExprTuple30, 35
29Lambdaparameter: 43
body: 32
30Operationoperator: 33
operands: 34
31ExprTuple43
32Conditionalvalue: 35
condition: 36
33Literal
34ExprTuple48, 37, 38
35Variable
36Operationoperator: 39
operands: 40
37Operationoperator: 41
operand: 47
38Literal
39Literal
40ExprTuple43, 44
41Literal
42ExprTuple47
43Variable
44Operationoperator: 45
operands: 46
45Literal
46ExprTuple47, 48
47Variable
48Variable