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, 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 = [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)), Mult(ExprRange(sub_expr1, Norm(IndexedVar(a, sub_expr1)), one, i))), domains = sub_expr2).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_{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} {\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}\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: 17
operand: 2
1ExprTuple2
2Lambdaparameter: 57
body: 4
3ExprTuple57
4Conditionalvalue: 5
condition: 6
5Operationoperator: 17
operand: 9
6Operationoperator: 50
operands: 8
7ExprTuple9
8ExprTuple57, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple13
12Conditionalvalue: 14
condition: 15
13ExprRangelambda_map: 16
start_index: 56
end_index: 57
14Operationoperator: 17
operand: 20
15Operationoperator: 29
operands: 19
16Lambdaparameter: 64
body: 54
17Literal
18ExprTuple20
19ExprTuple21
20Lambdaparameters: 48
body: 22
21ExprRangelambda_map: 23
start_index: 56
end_index: 57
22Conditionalvalue: 24
condition: 25
23Lambdaparameter: 64
body: 26
24Operationoperator: 27
operands: 28
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operands: 32
27Literal
28ExprTuple33, 34
29Literal
30ExprTuple35
31Literal
32ExprTuple54, 36
33Operationoperator: 58
operand: 43
34Operationoperator: 38
operands: 39
35ExprRangelambda_map: 40
start_index: 56
end_index: 57
36Operationoperator: 41
operand: 46
37ExprTuple43
38Literal
39ExprTuple44
40Lambdaparameter: 64
body: 45
41Literal
42ExprTuple46
43Operationoperator: 47
operands: 48
44ExprRangelambda_map: 49
start_index: 56
end_index: 57
45Operationoperator: 50
operands: 51
46Variable
47Literal
48ExprTuple52
49Lambdaparameter: 64
body: 53
50Literal
51ExprTuple61, 54
52ExprRangelambda_map: 55
start_index: 56
end_index: 57
53Operationoperator: 58
operand: 61
54IndexedVarvariable: 60
index: 64
55Lambdaparameter: 64
body: 61
56Literal
57Variable
58Literal
59ExprTuple61
60Variable
61IndexedVarvariable: 62
index: 64
62Variable
63ExprTuple64
64Variable