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, VecSpaces, 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 = Forall(instance_param_or_params = [v], instance_expr = Implies(InSet(vec_summation_b1toj_fQ, K), Equals(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(f__b_1_to_j, v), condition = Q__b_1_to_j), ScalarMult(Sum(index_or_indices = sub_expr1, summand = f__b_1_to_j, condition = Q__b_1_to_j), v)).with_wrapping_at(1)).with_wrapping_at(2), domain = V), domain = 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())
\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[\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] \\  = \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) \end{array} \end{array}\right) \end{array} \end{array}\right)\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: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 24
body: 4
3ExprTuple24
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple24, 12
11Lambdaparameter: 46
body: 14
12Operationoperator: 15
operand: 30
13ExprTuple46
14Conditionalvalue: 17
condition: 18
15Literal
16ExprTuple30
17Operationoperator: 19
operands: 20
18Operationoperator: 25
operands: 21
19Literal
20ExprTuple22, 23
21ExprTuple46, 24
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operands: 28
24Variable
25Literal
26ExprTuple29, 30
27Literal
28ExprTuple31, 32
29Operationoperator: 33
operand: 42
30Variable
31Operationoperator: 33
operand: 36
32Operationoperator: 43
operands: 35
33Literal
34ExprTuple36
35ExprTuple37, 46
36Lambdaparameters: 51
body: 38
37Operationoperator: 39
operand: 42
38Conditionalvalue: 41
condition: 48
39Literal
40ExprTuple42
41Operationoperator: 43
operands: 44
42Lambdaparameters: 51
body: 45
43Literal
44ExprTuple47, 46
45Conditionalvalue: 47
condition: 48
46Variable
47Operationoperator: 49
operands: 51
48Operationoperator: 50
operands: 51
49Variable
50Variable
51ExprTuple52
52ExprRangelambda_map: 53
start_index: 54
end_index: 55
53Lambdaparameter: 59
body: 56
54Literal
55Variable
56IndexedVarvariable: 57
index: 59
57Variable
58ExprTuple59
59Variable