logo

Expression of type Conditional

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, ExprRange, IndexedVar, Variable, a, c, l
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Complex, Integer, Mult, Sum, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [l]
sub_expr3 = IndexedVar(a, sub_expr1)
sub_expr4 = Add(l, one)
sub_expr5 = IndexedVar(c, one)
sub_expr6 = ExprRange(sub_expr1, sub_expr3, one, zero)
expr = Conditional(Equals(Mult(sub_expr6, Sum(index_or_indices = sub_expr2, summand = sub_expr4, domain = Integer), sub_expr5), Sum(index_or_indices = sub_expr2, summand = Mult(sub_expr6, sub_expr4, sub_expr5), domain = Integer)).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(sub_expr3, Complex), one, zero), InSet(sub_expr5, 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\{\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{0} \cdot \left[\sum_{l \in \mathbb{Z}}~\left(l + 1\right)\right] \cdot c_{1}\right) =  \\ \left[\sum_{l \in \mathbb{Z}}~\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{0} \cdot \left(l + 1\right) \cdot c_{1}\right)\right] \end{array} \end{array} \textrm{ if } \left(a_{1} \in \mathbb{C}\right) ,  \left(a_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(a_{0} \in \mathbb{C}\right) ,  c_{1} \in \mathbb{C}\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9, 10
7Operationoperator: 27
operands: 11
8Operationoperator: 18
operand: 16
9ExprRangelambda_map: 13
start_index: 44
end_index: 36
10Operationoperator: 33
operands: 14
11ExprTuple30, 15, 32
12ExprTuple16
13Lambdaparameter: 47
body: 17
14ExprTuple32, 24
15Operationoperator: 18
operand: 22
16Lambdaparameter: 43
body: 20
17Operationoperator: 33
operands: 21
18Literal
19ExprTuple22
20Conditionalvalue: 23
condition: 29
21ExprTuple42, 24
22Lambdaparameter: 43
body: 26
23Operationoperator: 27
operands: 28
24Literal
25ExprTuple43
26Conditionalvalue: 31
condition: 29
27Literal
28ExprTuple30, 31, 32
29Operationoperator: 33
operands: 34
30ExprRangelambda_map: 35
start_index: 44
end_index: 36
31Operationoperator: 37
operands: 38
32IndexedVarvariable: 39
index: 44
33Literal
34ExprTuple43, 41
35Lambdaparameter: 47
body: 42
36Literal
37Literal
38ExprTuple43, 44
39Variable
40ExprTuple44
41Literal
42IndexedVarvariable: 45
index: 47
43Variable
44Literal
45Variable
46ExprTuple47
47Variable