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, K, V, v
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.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import Equals, Forall, Implies, InClass, InSet
from proveit.numbers import Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
expr = Conditional(Forall(instance_param_or_params = [v], instance_expr = Implies(InSet(vec_summation_b1toj_fQ, K), Equals(ScalarMult(Sum(index_or_indices = sub_expr1, summand = f__b_1_to_j, condition = Q__b_1_to_j), v), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(f__b_1_to_j, v), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(2), domain = V), 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_{v \in V}~\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)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right] \in K\right) \Rightarrow  \\ \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)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right] \cdot v\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(f\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot v\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
6ExprTuple20, 8
7Lambdaparameter: 44
body: 10
8Operationoperator: 11
operand: 26
9ExprTuple44
10Conditionalvalue: 13
condition: 14
11Literal
12ExprTuple26
13Operationoperator: 15
operands: 16
14Operationoperator: 21
operands: 17
15Literal
16ExprTuple18, 19
17ExprTuple44, 20
18Operationoperator: 21
operands: 22
19Operationoperator: 23
operands: 24
20Variable
21Literal
22ExprTuple25, 26
23Literal
24ExprTuple27, 28
25Operationoperator: 30
operand: 37
26Variable
27Operationoperator: 40
operands: 29
28Operationoperator: 30
operand: 33
29ExprTuple32, 44
30Literal
31ExprTuple33
32Operationoperator: 34
operand: 37
33Lambdaparameters: 47
body: 36
34Literal
35ExprTuple37
36Conditionalvalue: 38
condition: 42
37Lambdaparameters: 47
body: 39
38Operationoperator: 40
operands: 41
39Conditionalvalue: 43
condition: 42
40Literal
41ExprTuple43, 44
42Operationoperator: 45
operands: 47
43Operationoperator: 46
operands: 47
44Variable
45Variable
46Variable
47ExprTuple48
48ExprRangelambda_map: 49
start_index: 50
end_index: 51
49Lambdaparameter: 55
body: 52
50Literal
51Variable
52IndexedVarvariable: 53
index: 55
53Variable
54ExprTuple55
55Variable