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 ExprRange, IndexedVar, K, V, Variable, a, i, v
from proveit.core_expr_types import a_1_to_i
from proveit.linear_algebra import ScalarMult, VecAdd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import Complex, Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [i], instance_expr = Forall(instance_param_or_params = [a_1_to_i, v], instance_expr = Equals(VecAdd(ExprRange(sub_expr1, ScalarMult(IndexedVar(a, sub_expr1), v), one, i)), ScalarMult(VecAdd(a_1_to_i), v)).with_wrapping_at(2), domains = [Complex, V]), domain = Natural), 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_{i \in \mathbb{N}}~\left[\forall_{\left(a_{1} \in \mathbb{C}\right), \left(a_{2} \in \mathbb{C}\right), \ldots, \left(a_{i} \in \mathbb{C}\right), v \in V}~\left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} \cdot v\right) +  \left(a_{2} \cdot v\right) +  \ldots +  \left(a_{i} \cdot v\right)\right) =  \\ \left(\left(a_{1} +  a_{2} +  \ldots +  a_{i}\right) \cdot v\right) \end{array} \end{array}\right)\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: 19
operand: 2
1ExprTuple2
2Lambdaparameter: 43
body: 4
3ExprTuple43
4Conditionalvalue: 5
condition: 6
5Operationoperator: 19
operand: 10
6Operationoperator: 8
operands: 9
7ExprTuple10
8Literal
9ExprTuple43, 11
10Lambdaparameter: 56
body: 13
11Operationoperator: 14
operand: 18
12ExprTuple56
13Conditionalvalue: 16
condition: 17
14Literal
15ExprTuple18
16Operationoperator: 19
operand: 22
17Operationoperator: 47
operands: 21
18Variable
19Literal
20ExprTuple22
21ExprTuple56, 23
22Lambdaparameters: 24
body: 25
23Literal
24ExprTuple50, 57
25Conditionalvalue: 26
condition: 27
26Operationoperator: 28
operands: 29
27Operationoperator: 30
operands: 31
28Literal
29ExprTuple32, 33
30Literal
31ExprTuple34, 35
32Operationoperator: 45
operands: 36
33Operationoperator: 52
operands: 37
34ExprRangelambda_map: 38
start_index: 55
end_index: 56
35Operationoperator: 47
operands: 39
36ExprTuple40
37ExprTuple41, 57
38Lambdaparameter: 61
body: 42
39ExprTuple57, 43
40ExprRangelambda_map: 44
start_index: 55
end_index: 56
41Operationoperator: 45
operands: 46
42Operationoperator: 47
operands: 48
43Variable
44Lambdaparameter: 61
body: 49
45Literal
46ExprTuple50
47Literal
48ExprTuple58, 51
49Operationoperator: 52
operands: 53
50ExprRangelambda_map: 54
start_index: 55
end_index: 56
51Literal
52Literal
53ExprTuple58, 57
54Lambdaparameter: 61
body: 58
55Literal
56Variable
57Variable
58IndexedVarvariable: 59
index: 61
59Variable
60ExprTuple61
61Variable