logo

Expression of type Conditional

from the theory of proveit.linear_algebra.scalar_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, Function, K, V, c, k
from proveit.core_expr_types import Q__b_1_to_j, b_1_to_j, f__b_1_to_j
from proveit.linear_algebra import ScalarMult, VecSum
from proveit.logic import Equals, Implies, InSet
from proveit.numbers import Mult
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
sub_expr2 = Function(c, sub_expr1)
sub_expr3 = VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, f__b_1_to_j), condition = Q__b_1_to_j)
expr = Conditional(Implies(InSet(sub_expr3, V), Equals(ScalarMult(k, sub_expr3), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Mult(k, sub_expr2), f__b_1_to_j), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(1), InSet(k, 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(\left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(c\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right] \in V\right) \\  \Rightarrow \left(\begin{array}{c} \begin{array}{l} \left(k \cdot \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(c\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right]\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(\left(k \cdot c\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right] \end{array} \end{array}\right) \end{array} \end{array} \textrm{ if } k \in K\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: 9
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple36, 8
6Operationoperator: 9
operands: 10
7Operationoperator: 11
operands: 12
8Variable
9Literal
10ExprTuple18, 13
11Literal
12ExprTuple14, 15
13Variable
14Operationoperator: 30
operands: 16
15Operationoperator: 20
operand: 19
16ExprTuple36, 18
17ExprTuple19
18Operationoperator: 20
operand: 23
19Lambdaparameters: 40
body: 22
20Literal
21ExprTuple23
22Conditionalvalue: 24
condition: 28
23Lambdaparameters: 40
body: 25
24Operationoperator: 30
operands: 26
25Conditionalvalue: 27
condition: 28
26ExprTuple29, 35
27Operationoperator: 30
operands: 31
28Operationoperator: 32
operands: 40
29Operationoperator: 33
operands: 34
30Literal
31ExprTuple37, 35
32Variable
33Literal
34ExprTuple36, 37
35Operationoperator: 38
operands: 40
36Variable
37Operationoperator: 39
operands: 40
38Variable
39Variable
40ExprTuple41
41ExprRangelambda_map: 42
start_index: 43
end_index: 44
42Lambdaparameter: 48
body: 45
43Literal
44Variable
45IndexedVarvariable: 46
index: 48
46Variable
47ExprTuple48
48Variable