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 = [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_{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]
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: 54
body: 4
3ExprTuple54
4Conditionalvalue: 5
condition: 6
5Operationoperator: 17
operand: 9
6Operationoperator: 47
operands: 8
7ExprTuple9
8ExprTuple54, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple13
12Conditionalvalue: 14
condition: 15
13ExprRangelambda_map: 16
start_index: 59
end_index: 54
14Operationoperator: 17
operand: 20
15Operationoperator: 37
operands: 19
16Lambdaparameter: 65
body: 51
17Literal
18ExprTuple20
19ExprTuple21
20Lambdaparameters: 46
body: 22
21ExprRangelambda_map: 23
start_index: 59
end_index: 54
22Conditionalvalue: 24
condition: 25
23Lambdaparameter: 65
body: 26
24Operationoperator: 56
operands: 27
25Operationoperator: 37
operands: 28
26Operationoperator: 29
operands: 30
27ExprTuple31, 59
28ExprTuple32, 33
29Literal
30ExprTuple51, 34
31Operationoperator: 60
operand: 41
32ExprRangelambda_map: 36
start_index: 59
end_index: 54
33Operationoperator: 37
operands: 38
34Operationoperator: 39
operand: 44
35ExprTuple41
36Lambdaparameter: 65
body: 42
37Literal
38ExprTuple43
39Literal
40ExprTuple44
41Operationoperator: 45
operands: 46
42Operationoperator: 47
operands: 48
43ExprRangelambda_map: 49
start_index: 59
end_index: 54
44Variable
45Literal
46ExprTuple50
47Literal
48ExprTuple62, 51
49Lambdaparameter: 65
body: 52
50ExprRangelambda_map: 53
start_index: 59
end_index: 54
51IndexedVarvariable: 55
index: 65
52Operationoperator: 56
operands: 57
53Lambdaparameter: 65
body: 62
54Variable
55Variable
56Literal
57ExprTuple58, 59
58Operationoperator: 60
operand: 62
59Literal
60Literal
61ExprTuple62
62IndexedVarvariable: 63
index: 65
63Variable
64ExprTuple65
65Variable