logo

Expression of type Conditional

from the theory of proveit.numbers.multiplication

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, Function, IndexedVar, Q, Variable, a, c, f, i, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.logic import And, Equals, InSet
from proveit.numbers import Complex, Mult, Sum, one
from proveit.numbers.summation import summation_b1toj_fQ
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [b_1_to_j]
expr = Conditional(Equals(Mult(a_1_to_i, summation_b1toj_fQ, c_1_to_k), Sum(index_or_indices = sub_expr2, summand = Mult(a_1_to_i, Function(f, sub_expr2), c_1_to_k), condition = Function(Q, sub_expr2))).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), Complex), one, k)))
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_{i} \cdot \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) =  \\ \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\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_{i} \in \mathbb{C}\right), \left(c_{1} \in \mathbb{C}\right) ,  \left(c_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(c_{k} \in \mathbb{C}\right)\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: 29
operands: 11
8Operationoperator: 19
operand: 16
9ExprRangelambda_map: 13
start_index: 47
end_index: 37
10ExprRangelambda_map: 14
start_index: 47
end_index: 41
11ExprTuple32, 15, 34
12ExprTuple16
13Lambdaparameter: 53
body: 17
14Lambdaparameter: 53
body: 18
15Operationoperator: 19
operand: 25
16Lambdaparameters: 39
body: 21
17Operationoperator: 23
operands: 22
18Operationoperator: 23
operands: 24
19Literal
20ExprTuple25
21Conditionalvalue: 26
condition: 31
22ExprTuple42, 27
23Literal
24ExprTuple44, 27
25Lambdaparameters: 39
body: 28
26Operationoperator: 29
operands: 30
27Literal
28Conditionalvalue: 33
condition: 31
29Literal
30ExprTuple32, 33, 34
31Operationoperator: 35
operands: 39
32ExprRangelambda_map: 36
start_index: 47
end_index: 37
33Operationoperator: 38
operands: 39
34ExprRangelambda_map: 40
start_index: 47
end_index: 41
35Variable
36Lambdaparameter: 53
body: 42
37Variable
38Variable
39ExprTuple43
40Lambdaparameter: 53
body: 44
41Variable
42IndexedVarvariable: 45
index: 53
43ExprRangelambda_map: 46
start_index: 47
end_index: 48
44IndexedVarvariable: 49
index: 53
45Variable
46Lambdaparameter: 53
body: 50
47Literal
48Variable
49Variable
50IndexedVarvariable: 51
index: 53
51Variable
52ExprTuple53
53Variable