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, j, 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, InSet
from proveit.numbers import NaturalPos, 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 = 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), domain = VecSpaces(K)), InSet(j, NaturalPos))
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 \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\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)\right] \textrm{ if } j \in \mathbb{N}^+\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: 11
operand: 5
2Operationoperator: 29
operands: 4
3ExprTuple5
4ExprTuple59, 6
5Lambdaparameter: 28
body: 8
6Literal
7ExprTuple28
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operand: 15
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15
13Literal
14ExprTuple28, 16
15Lambdaparameter: 52
body: 18
16Operationoperator: 19
operand: 34
17ExprTuple52
18Conditionalvalue: 21
condition: 22
19Literal
20ExprTuple34
21Operationoperator: 23
operands: 24
22Operationoperator: 29
operands: 25
23Literal
24ExprTuple26, 27
25ExprTuple52, 28
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operands: 32
28Variable
29Literal
30ExprTuple33, 34
31Literal
32ExprTuple35, 36
33Operationoperator: 38
operand: 45
34Variable
35Operationoperator: 48
operands: 37
36Operationoperator: 38
operand: 41
37ExprTuple40, 52
38Literal
39ExprTuple41
40Operationoperator: 42
operand: 45
41Lambdaparameters: 55
body: 44
42Literal
43ExprTuple45
44Conditionalvalue: 46
condition: 50
45Lambdaparameters: 55
body: 47
46Operationoperator: 48
operands: 49
47Conditionalvalue: 51
condition: 50
48Literal
49ExprTuple51, 52
50Operationoperator: 53
operands: 55
51Operationoperator: 54
operands: 55
52Variable
53Variable
54Variable
55ExprTuple56
56ExprRangelambda_map: 57
start_index: 58
end_index: 59
57Lambdaparameter: 63
body: 60
58Literal
59Variable
60IndexedVarvariable: 61
index: 63
61Variable
62ExprTuple63
63Variable