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 Equals, Forall, InSet
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 = 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)), Mult(ExprRange(sub_expr1, Norm(IndexedVar(a, sub_expr1)), one, i))), domains = sub_expr2).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} {\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} \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: 46
operands: 4
3ExprTuple5
4ExprTuple53, 6
5Lambdaparameters: 7
body: 8
6Literal
7ExprTuple9
8Conditionalvalue: 10
condition: 11
9ExprRangelambda_map: 12
start_index: 52
end_index: 53
10Operationoperator: 13
operand: 16
11Operationoperator: 25
operands: 15
12Lambdaparameter: 60
body: 50
13Literal
14ExprTuple16
15ExprTuple17
16Lambdaparameters: 44
body: 18
17ExprRangelambda_map: 19
start_index: 52
end_index: 53
18Conditionalvalue: 20
condition: 21
19Lambdaparameter: 60
body: 22
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operands: 26
22Operationoperator: 27
operands: 28
23Literal
24ExprTuple29, 30
25Literal
26ExprTuple31
27Literal
28ExprTuple50, 32
29Operationoperator: 54
operand: 39
30Operationoperator: 34
operands: 35
31ExprRangelambda_map: 36
start_index: 52
end_index: 53
32Operationoperator: 37
operand: 42
33ExprTuple39
34Literal
35ExprTuple40
36Lambdaparameter: 60
body: 41
37Literal
38ExprTuple42
39Operationoperator: 43
operands: 44
40ExprRangelambda_map: 45
start_index: 52
end_index: 53
41Operationoperator: 46
operands: 47
42Variable
43Literal
44ExprTuple48
45Lambdaparameter: 60
body: 49
46Literal
47ExprTuple57, 50
48ExprRangelambda_map: 51
start_index: 52
end_index: 53
49Operationoperator: 54
operand: 57
50IndexedVarvariable: 56
index: 60
51Lambdaparameter: 60
body: 57
52Literal
53Variable
54Literal
55ExprTuple57
56Variable
57IndexedVarvariable: 58
index: 60
58Variable
59ExprTuple60
60Variable