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 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)), 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()
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}\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}
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: 51
end_index: 46
6Operationoperator: 9
operand: 12
7Operationoperator: 29
operands: 11
8Lambdaparameter: 57
body: 43
9Literal
10ExprTuple12
11ExprTuple13
12Lambdaparameters: 38
body: 14
13ExprRangelambda_map: 15
start_index: 51
end_index: 46
14Conditionalvalue: 16
condition: 17
15Lambdaparameter: 57
body: 18
16Operationoperator: 48
operands: 19
17Operationoperator: 29
operands: 20
18Operationoperator: 21
operands: 22
19ExprTuple23, 51
20ExprTuple24, 25
21Literal
22ExprTuple43, 26
23Operationoperator: 52
operand: 33
24ExprRangelambda_map: 28
start_index: 51
end_index: 46
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operand: 36
27ExprTuple33
28Lambdaparameter: 57
body: 34
29Literal
30ExprTuple35
31Literal
32ExprTuple36
33Operationoperator: 37
operands: 38
34Operationoperator: 39
operands: 40
35ExprRangelambda_map: 41
start_index: 51
end_index: 46
36Variable
37Literal
38ExprTuple42
39Literal
40ExprTuple54, 43
41Lambdaparameter: 57
body: 44
42ExprRangelambda_map: 45
start_index: 51
end_index: 46
43IndexedVarvariable: 47
index: 57
44Operationoperator: 48
operands: 49
45Lambdaparameter: 57
body: 54
46Variable
47Variable
48Literal
49ExprTuple50, 51
50Operationoperator: 52
operand: 54
51Literal
52Literal
53ExprTuple54
54IndexedVarvariable: 55
index: 57
55Variable
56ExprTuple57
57Variable