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, Variable, a, i
from proveit.core_expr_types import V_1_to_i, a_1_to_i
from proveit.linear_algebra import 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}")
expr = Forall(instance_param_or_params = [a_1_to_i], instance_expr = Equals(Norm(TensorProd(a_1_to_i)), one), domains = [V_1_to_i], condition = And(ExprRange(sub_expr1, Equals(Norm(IndexedVar(a, sub_expr1)), one), one, i))).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_{\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}
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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 20
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 30
operands: 7
6Operationoperator: 14
operands: 8
7ExprTuple9, 33
8ExprTuple10, 11
9Operationoperator: 34
operand: 16
10ExprRangelambda_map: 13
start_index: 33
end_index: 28
11Operationoperator: 14
operands: 15
12ExprTuple16
13Lambdaparameter: 39
body: 17
14Literal
15ExprTuple18
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18ExprRangelambda_map: 23
start_index: 33
end_index: 28
19Literal
20ExprTuple24
21Literal
22ExprTuple36, 25
23Lambdaparameter: 39
body: 26
24ExprRangelambda_map: 27
start_index: 33
end_index: 28
25IndexedVarvariable: 29
index: 39
26Operationoperator: 30
operands: 31
27Lambdaparameter: 39
body: 36
28Variable
29Variable
30Literal
31ExprTuple32, 33
32Operationoperator: 34
operand: 36
33Literal
34Literal
35ExprTuple36
36IndexedVarvariable: 37
index: 39
37Variable
38ExprTuple39
39Variable