logo

Expression of type Forall

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 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, VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
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)
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())
\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)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 37
body: 5
4ExprTuple37
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 14
operands: 10
8Literal
9ExprTuple11, 12
10ExprTuple37, 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13Variable
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple20, 21
18Operationoperator: 23
operand: 30
19Variable
20Operationoperator: 33
operands: 22
21Operationoperator: 23
operand: 26
22ExprTuple25, 37
23Literal
24ExprTuple26
25Operationoperator: 27
operand: 30
26Lambdaparameters: 40
body: 29
27Literal
28ExprTuple30
29Conditionalvalue: 31
condition: 35
30Lambdaparameters: 40
body: 32
31Operationoperator: 33
operands: 34
32Conditionalvalue: 36
condition: 35
33Literal
34ExprTuple36, 37
35Operationoperator: 38
operands: 40
36Operationoperator: 39
operands: 40
37Variable
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