logo

Expression of type Forall

from the theory of proveit.linear_algebra.tensors

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, Variable, a, i
from proveit.core_expr_types import V_1_to_i, a_1_to_i
from proveit.linear_algebra import InnerProdSpaces, Norm, TensorProd
from proveit.logic import Equals, Forall
from proveit.numbers import Mult, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [V_1_to_i]
expr = Forall(instance_param_or_params = sub_expr2, instance_expr = Forall(instance_param_or_params = [a_1_to_i], instance_expr = Equals(Norm(TensorProd(a_1_to_i)), Mult(ExprRange(sub_expr1, Norm(IndexedVar(a, sub_expr1)), one, i))), domains = sub_expr2).with_wrapping(), domain = InnerProdSpaces(K)).with_wrapping()
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())
\begin{array}{l}\forall_{V_{1}, V_{2}, \ldots, V_{i} \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{\left(a_{1} \in V_{1}\right), \left(a_{2} \in V_{2}\right), \ldots, \left(a_{i} \in V_{i}\right)}~\\
\left(\left \|a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}\right \| = \left(\left \|a_{1}\right \| \cdot  \left \|a_{2}\right \| \cdot  \ldots \cdot  \left \|a_{i}\right \|\right)\right)\end{array}\right]\end{array}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('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: 9
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple5
4Conditionalvalue: 6
condition: 7
5ExprRangelambda_map: 8
start_index: 48
end_index: 49
6Operationoperator: 9
operand: 12
7Operationoperator: 21
operands: 11
8Lambdaparameter: 56
body: 46
9Literal
10ExprTuple12
11ExprTuple13
12Lambdaparameters: 40
body: 14
13ExprRangelambda_map: 15
start_index: 48
end_index: 49
14Conditionalvalue: 16
condition: 17
15Lambdaparameter: 56
body: 18
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operands: 24
19Literal
20ExprTuple25, 26
21Literal
22ExprTuple27
23Literal
24ExprTuple46, 28
25Operationoperator: 50
operand: 35
26Operationoperator: 30
operands: 31
27ExprRangelambda_map: 32
start_index: 48
end_index: 49
28Operationoperator: 33
operand: 38
29ExprTuple35
30Literal
31ExprTuple36
32Lambdaparameter: 56
body: 37
33Literal
34ExprTuple38
35Operationoperator: 39
operands: 40
36ExprRangelambda_map: 41
start_index: 48
end_index: 49
37Operationoperator: 42
operands: 43
38Variable
39Literal
40ExprTuple44
41Lambdaparameter: 56
body: 45
42Literal
43ExprTuple53, 46
44ExprRangelambda_map: 47
start_index: 48
end_index: 49
45Operationoperator: 50
operand: 53
46IndexedVarvariable: 52
index: 56
47Lambdaparameter: 56
body: 53
48Literal
49Variable
50Literal
51ExprTuple53
52Variable
53IndexedVarvariable: 54
index: 56
54Variable
55ExprTuple56
56Variable