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 A, Conditional, ExprRange, Function, IndexedVar, K, V, Variable, W, n, v
from proveit.core_expr_types import A_1_to_n, V_1_to_n, W_1_to_n, v_1_to_n
from proveit.linear_algebra import LinMap, TensorProd, VecSpaces
from proveit.logic import 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}")
expr = Conditional(Forall(instance_param_or_params = [V_1_to_n, W_1_to_n], instance_expr = Forall(instance_param_or_params = [A_1_to_n], instance_expr = Forall(instance_param_or_params = [v_1_to_n], instance_expr = Equals(Function(TensorProd(A_1_to_n), [TensorProd(v_1_to_n)]), TensorProd(ExprRange(sub_expr1, Function(IndexedVar(A, sub_expr1), [IndexedVar(v, sub_expr1)]), one, n))), domains = [V_1_to_n]).with_wrapping(), domains = [ExprRange(sub_expr1, LinMap(IndexedVar(V, sub_expr1), IndexedVar(W, sub_expr1)), one, n)]).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), InSet(n, 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_{n}, W_{1}, W_{2}, \ldots, W_{n} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{\left(A_{1} \in \mathcal{L}\left(V_{1}, W_{1}\right)\right), \left(A_{2} \in \mathcal{L}\left(V_{2}, W_{2}\right)\right), \ldots, \left(A_{n} \in \mathcal{L}\left(V_{n}, W_{n}\right)\right)}~\\
\left[\begin{array}{l}\forall_{\left(v_{1} \in V_{1}\right), \left(v_{2} \in V_{2}\right), \ldots, \left(v_{n} \in V_{n}\right)}~\\
\left(\left(A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{n}\right)\left(v_{1} {\otimes}  v_{2} {\otimes}  \ldots {\otimes}  v_{n}\right) = \left(A_{1}\left(v_{1}\right) {\otimes}  A_{2}\left(v_{2}\right) {\otimes}  \ldots {\otimes}  A_{n}\left(v_{n}\right)\right)\right)\end{array}\right]\end{array}\right]\end{array} \textrm{ if } n \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: 27
operand: 5
2Operationoperator: 68
operands: 4
3ExprTuple5
4ExprTuple77, 6
5Lambdaparameters: 7
body: 8
6Literal
7ExprTuple9, 10
8Conditionalvalue: 11
condition: 12
9ExprRangelambda_map: 13
start_index: 76
end_index: 77
10ExprRangelambda_map: 14
start_index: 76
end_index: 77
11Operationoperator: 27
operand: 17
12Operationoperator: 46
operands: 16
13Lambdaparameter: 85
body: 74
14Lambdaparameter: 85
body: 63
15ExprTuple17
16ExprTuple18, 19
17Lambdaparameters: 59
body: 20
18ExprRangelambda_map: 21
start_index: 76
end_index: 77
19ExprRangelambda_map: 22
start_index: 76
end_index: 77
20Conditionalvalue: 23
condition: 24
21Lambdaparameter: 85
body: 25
22Lambdaparameter: 85
body: 26
23Operationoperator: 27
operand: 33
24Operationoperator: 46
operands: 29
25Operationoperator: 31
operands: 30
26Operationoperator: 31
operands: 32
27Literal
28ExprTuple33
29ExprTuple34
30ExprTuple74, 35
31Literal
32ExprTuple63, 35
33Lambdaparameters: 66
body: 36
34ExprRangelambda_map: 37
start_index: 76
end_index: 77
35Operationoperator: 38
operand: 43
36Conditionalvalue: 40
condition: 41
37Lambdaparameter: 85
body: 42
38Literal
39ExprTuple43
40Operationoperator: 44
operands: 45
41Operationoperator: 46
operands: 47
42Operationoperator: 68
operands: 48
43Variable
44Literal
45ExprTuple49, 50
46Literal
47ExprTuple51
48ExprTuple78, 52
49Operationoperator: 53
operand: 60
50Operationoperator: 65
operands: 55
51ExprRangelambda_map: 56
start_index: 76
end_index: 77
52Operationoperator: 57
operands: 58
53Operationoperator: 65
operands: 59
54ExprTuple60
55ExprTuple61
56Lambdaparameter: 85
body: 62
57Literal
58ExprTuple74, 63
59ExprTuple64
60Operationoperator: 65
operands: 66
61ExprRangelambda_map: 67
start_index: 76
end_index: 77
62Operationoperator: 68
operands: 69
63IndexedVarvariable: 70
index: 85
64ExprRangelambda_map: 71
start_index: 76
end_index: 77
65Literal
66ExprTuple72
67Lambdaparameter: 85
body: 73
68Literal
69ExprTuple82, 74
70Variable
71Lambdaparameter: 85
body: 78
72ExprRangelambda_map: 75
start_index: 76
end_index: 77
73Operationoperator: 78
operand: 82
74IndexedVarvariable: 80
index: 85
75Lambdaparameter: 85
body: 82
76Literal
77Variable
78IndexedVarvariable: 81
index: 85
79ExprTuple82
80Variable
81Variable
82IndexedVarvariable: 83
index: 85
83Variable
84ExprTuple85
85Variable