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 And, Equals, Forall
from proveit.numbers import NaturalPos, 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 = [K], instance_expr = Forall(instance_param_or_params = [i], instance_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)), one), domains = sub_expr2, condition = And(ExprRange(sub_expr1, Equals(Norm(IndexedVar(a, sub_expr1)), one), one, i))).with_wrapping(), domain = InnerProdSpaces(K)).with_wrapping(), domain = NaturalPos))
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}~\left[\forall_{i \in \mathbb{N}^+}~\left[\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}\right \| = 1\right) \land  \left(\left \|a_{2}\right \| = 1\right) \land  \ldots \land  \left(\left \|a_{i}\right \| = 1\right)}~\\
\left(\left \|a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}\right \| = 1\right)\end{array}\right]\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: 20
operand: 2
1ExprTuple2
2Lambdaparameter: 47
body: 3
3Operationoperator: 20
operand: 5
4ExprTuple5
5Lambdaparameter: 57
body: 7
6ExprTuple57
7Conditionalvalue: 8
condition: 9
8Operationoperator: 20
operand: 12
9Operationoperator: 50
operands: 11
10ExprTuple12
11ExprTuple57, 13
12Lambdaparameters: 14
body: 15
13Literal
14ExprTuple16
15Conditionalvalue: 17
condition: 18
16ExprRangelambda_map: 19
start_index: 62
end_index: 57
17Operationoperator: 20
operand: 23
18Operationoperator: 40
operands: 22
19Lambdaparameter: 68
body: 54
20Literal
21ExprTuple23
22ExprTuple24
23Lambdaparameters: 49
body: 25
24ExprRangelambda_map: 26
start_index: 62
end_index: 57
25Conditionalvalue: 27
condition: 28
26Lambdaparameter: 68
body: 29
27Operationoperator: 59
operands: 30
28Operationoperator: 40
operands: 31
29Operationoperator: 32
operands: 33
30ExprTuple34, 62
31ExprTuple35, 36
32Literal
33ExprTuple54, 37
34Operationoperator: 63
operand: 44
35ExprRangelambda_map: 39
start_index: 62
end_index: 57
36Operationoperator: 40
operands: 41
37Operationoperator: 42
operand: 47
38ExprTuple44
39Lambdaparameter: 68
body: 45
40Literal
41ExprTuple46
42Literal
43ExprTuple47
44Operationoperator: 48
operands: 49
45Operationoperator: 50
operands: 51
46ExprRangelambda_map: 52
start_index: 62
end_index: 57
47Variable
48Literal
49ExprTuple53
50Literal
51ExprTuple65, 54
52Lambdaparameter: 68
body: 55
53ExprRangelambda_map: 56
start_index: 62
end_index: 57
54IndexedVarvariable: 58
index: 68
55Operationoperator: 59
operands: 60
56Lambdaparameter: 68
body: 65
57Variable
58Variable
59Literal
60ExprTuple61, 62
61Operationoperator: 63
operand: 65
62Literal
63Literal
64ExprTuple65
65IndexedVarvariable: 66
index: 68
66Variable
67ExprTuple68
68Variable