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, j, 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, InSet
from proveit.numbers import Mult, NaturalPos
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 = [V], instance_expr = Forall(instance_param_or_params = [k], instance_expr = Implies(InSet(sub_expr3, V), Equals(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Mult(k, sub_expr2), f__b_1_to_j), condition = Q__b_1_to_j), ScalarMult(k, sub_expr3)).with_wrapping_at(1)).with_wrapping_at(1), domain = K), 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_{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[\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] \\  = \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) \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
4ExprTuple64, 6
5Lambdaparameter: 33
body: 8
6Literal
7ExprTuple33
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operand: 15
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15
13Literal
14ExprTuple33, 16
15Lambdaparameter: 55
body: 18
16Operationoperator: 19
operand: 28
17ExprTuple55
18Conditionalvalue: 21
condition: 22
19Literal
20ExprTuple28
21Operationoperator: 23
operands: 24
22Operationoperator: 29
operands: 25
23Literal
24ExprTuple26, 27
25ExprTuple55, 28
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operands: 32
28Variable
29Literal
30ExprTuple39, 33
31Literal
32ExprTuple34, 35
33Variable
34Operationoperator: 41
operand: 38
35Operationoperator: 52
operands: 37
36ExprTuple38
37ExprTuple55, 39
38Lambdaparameters: 60
body: 40
39Operationoperator: 41
operand: 44
40Conditionalvalue: 43
condition: 49
41Literal
42ExprTuple44
43Operationoperator: 52
operands: 45
44Lambdaparameters: 60
body: 46
45ExprTuple47, 57
46Conditionalvalue: 48
condition: 49
47Operationoperator: 50
operands: 51
48Operationoperator: 52
operands: 53
49Operationoperator: 54
operands: 60
50Literal
51ExprTuple55, 56
52Literal
53ExprTuple56, 57
54Variable
55Variable
56Operationoperator: 58
operands: 60
57Operationoperator: 59
operands: 60
58Variable
59Variable
60ExprTuple61
61ExprRangelambda_map: 62
start_index: 63
end_index: 64
62Lambdaparameter: 68
body: 65
63Literal
64Variable
65IndexedVarvariable: 66
index: 68
66Variable
67ExprTuple68
68Variable