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 Function, K, V, c, 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, VecSum
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Mult
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 = 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)
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_{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)
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: 40
body: 5
4ExprTuple40
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 14
operands: 10
8Literal
9ExprTuple11, 12
10ExprTuple40, 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13Variable
14Literal
15ExprTuple24, 18
16Literal
17ExprTuple19, 20
18Variable
19Operationoperator: 26
operand: 23
20Operationoperator: 37
operands: 22
21ExprTuple23
22ExprTuple40, 24
23Lambdaparameters: 45
body: 25
24Operationoperator: 26
operand: 29
25Conditionalvalue: 28
condition: 34
26Literal
27ExprTuple29
28Operationoperator: 37
operands: 30
29Lambdaparameters: 45
body: 31
30ExprTuple32, 42
31Conditionalvalue: 33
condition: 34
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operands: 38
34Operationoperator: 39
operands: 45
35Literal
36ExprTuple40, 41
37Literal
38ExprTuple41, 42
39Variable
40Variable
41Operationoperator: 43
operands: 45
42Operationoperator: 44
operands: 45
43Variable
44Variable
45ExprTuple46
46ExprRangelambda_map: 47
start_index: 48
end_index: 49
47Lambdaparameter: 53
body: 50
48Literal
49Variable
50IndexedVarvariable: 51
index: 53
51Variable
52ExprTuple53
53Variable