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, VecSpaces, VecSum
from proveit.logic import Equals, Forall, Implies, InClass, 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(Forall(instance_param_or_params = [k], instance_expr = 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), domain = K), InClass(V, VecSpaces(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\{\forall_{k \in K}~\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}\right) \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\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
operand: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple25, 8
7Lambdaparameter: 48
body: 10
8Operationoperator: 11
operand: 20
9ExprTuple48
10Conditionalvalue: 13
condition: 14
11Literal
12ExprTuple20
13Operationoperator: 15
operands: 16
14Operationoperator: 21
operands: 17
15Literal
16ExprTuple18, 19
17ExprTuple48, 20
18Operationoperator: 21
operands: 22
19Operationoperator: 23
operands: 24
20Variable
21Literal
22ExprTuple30, 25
23Literal
24ExprTuple26, 27
25Variable
26Operationoperator: 42
operands: 28
27Operationoperator: 32
operand: 31
28ExprTuple48, 30
29ExprTuple31
30Operationoperator: 32
operand: 35
31Lambdaparameters: 52
body: 34
32Literal
33ExprTuple35
34Conditionalvalue: 36
condition: 40
35Lambdaparameters: 52
body: 37
36Operationoperator: 42
operands: 38
37Conditionalvalue: 39
condition: 40
38ExprTuple41, 47
39Operationoperator: 42
operands: 43
40Operationoperator: 44
operands: 52
41Operationoperator: 45
operands: 46
42Literal
43ExprTuple49, 47
44Variable
45Literal
46ExprTuple48, 49
47Operationoperator: 50
operands: 52
48Variable
49Operationoperator: 51
operands: 52
50Variable
51Variable
52ExprTuple53
53ExprRangelambda_map: 54
start_index: 55
end_index: 56
54Lambdaparameter: 60
body: 57
55Literal
56Variable
57IndexedVarvariable: 58
index: 60
58Variable
59ExprTuple60
60Variable