logo

Expression of type Conditional

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 Conditional, 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, InSet
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 = Conditional(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(), InSet(i, 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())
\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} \textrm{ if } i \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 13
operand: 5
2Operationoperator: 43
operands: 4
3ExprTuple5
4ExprTuple50, 6
5Lambdaparameters: 7
body: 8
6Literal
7ExprTuple9
8Conditionalvalue: 10
condition: 11
9ExprRangelambda_map: 12
start_index: 55
end_index: 50
10Operationoperator: 13
operand: 16
11Operationoperator: 33
operands: 15
12Lambdaparameter: 61
body: 47
13Literal
14ExprTuple16
15ExprTuple17
16Lambdaparameters: 42
body: 18
17ExprRangelambda_map: 19
start_index: 55
end_index: 50
18Conditionalvalue: 20
condition: 21
19Lambdaparameter: 61
body: 22
20Operationoperator: 52
operands: 23
21Operationoperator: 33
operands: 24
22Operationoperator: 25
operands: 26
23ExprTuple27, 55
24ExprTuple28, 29
25Literal
26ExprTuple47, 30
27Operationoperator: 56
operand: 37
28ExprRangelambda_map: 32
start_index: 55
end_index: 50
29Operationoperator: 33
operands: 34
30Operationoperator: 35
operand: 40
31ExprTuple37
32Lambdaparameter: 61
body: 38
33Literal
34ExprTuple39
35Literal
36ExprTuple40
37Operationoperator: 41
operands: 42
38Operationoperator: 43
operands: 44
39ExprRangelambda_map: 45
start_index: 55
end_index: 50
40Variable
41Literal
42ExprTuple46
43Literal
44ExprTuple58, 47
45Lambdaparameter: 61
body: 48
46ExprRangelambda_map: 49
start_index: 55
end_index: 50
47IndexedVarvariable: 51
index: 61
48Operationoperator: 52
operands: 53
49Lambdaparameter: 61
body: 58
50Variable
51Variable
52Literal
53ExprTuple54, 55
54Operationoperator: 56
operand: 58
55Literal
56Literal
57ExprTuple58
58IndexedVarvariable: 59
index: 61
59Variable
60ExprTuple61
61Variable