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, K, V, alpha, b, i, k
from proveit.core_expr_types import U_1_to_i, W_1_to_k, a_1_to_i, c_1_to_k
from proveit.linear_algebra import ScalarMult, TensorProd, VecSpaces
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [U_1_to_i, V, W_1_to_k]
expr = Conditional(Forall(instance_param_or_params = sub_expr1, instance_expr = Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, ScalarMult(alpha, b), c_1_to_k), ScalarMult(alpha, TensorProd(a_1_to_i, b, c_1_to_k))).with_wrapping_at(1), domains = sub_expr1).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), And(InSet(i, Natural), InSet(k, Natural)))
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_{U_{1}, U_{2}, \ldots, U_{i}, V, W_{1}, W_{2}, \ldots, W_{k} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{\left(a_{1} \in U_{1}\right), \left(a_{2} \in U_{2}\right), \ldots, \left(a_{i} \in U_{i}\right), b \in V,\left(c_{1} \in W_{1}\right), \left(c_{2} \in W_{2}\right), \ldots, \left(c_{k} \in W_{k}\right)}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(\alpha \cdot b\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(\alpha \cdot \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right)\right) \end{array} \end{array}\right)\end{array}\right]\end{array} \textrm{ if } i \in \mathbb{N} ,  k \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: 19
operand: 5
2Operationoperator: 36
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 8
body: 9
6Operationoperator: 65
operands: 10
7Operationoperator: 65
operands: 11
8ExprTuple12, 57, 13
9Conditionalvalue: 14
condition: 15
10ExprTuple74, 16
11ExprTuple77, 16
12ExprRangelambda_map: 17
start_index: 76
end_index: 74
13ExprRangelambda_map: 18
start_index: 76
end_index: 77
14Operationoperator: 19
operand: 22
15Operationoperator: 36
operands: 21
16Literal
17Lambdaparameter: 85
body: 71
18Lambdaparameter: 85
body: 72
19Literal
20ExprTuple22
21ExprTuple23, 24, 25
22Lambdaparameters: 63
body: 26
23ExprRangelambda_map: 27
start_index: 76
end_index: 74
24Operationoperator: 39
operands: 28
25ExprRangelambda_map: 29
start_index: 76
end_index: 77
26Conditionalvalue: 30
condition: 31
27Lambdaparameter: 85
body: 32
28ExprTuple57, 46
29Lambdaparameter: 85
body: 33
30Operationoperator: 34
operands: 35
31Operationoperator: 36
operands: 37
32Operationoperator: 39
operands: 38
33Operationoperator: 39
operands: 40
34Literal
35ExprTuple41, 42
36Literal
37ExprTuple43, 44, 45
38ExprTuple71, 46
39Literal
40ExprTuple72, 46
41Operationoperator: 62
operands: 47
42Operationoperator: 60
operands: 48
43ExprRangelambda_map: 49
start_index: 76
end_index: 74
44Operationoperator: 65
operands: 50
45ExprRangelambda_map: 51
start_index: 76
end_index: 77
46Operationoperator: 52
operand: 59
47ExprTuple68, 54, 70
48ExprTuple67, 55
49Lambdaparameter: 85
body: 56
50ExprTuple69, 57
51Lambdaparameter: 85
body: 58
52Literal
53ExprTuple59
54Operationoperator: 60
operands: 61
55Operationoperator: 62
operands: 63
56Operationoperator: 65
operands: 64
57Variable
58Operationoperator: 65
operands: 66
59Variable
60Literal
61ExprTuple67, 69
62Literal
63ExprTuple68, 69, 70
64ExprTuple80, 71
65Literal
66ExprTuple81, 72
67Variable
68ExprRangelambda_map: 73
start_index: 76
end_index: 74
69Variable
70ExprRangelambda_map: 75
start_index: 76
end_index: 77
71IndexedVarvariable: 78
index: 85
72IndexedVarvariable: 79
index: 85
73Lambdaparameter: 85
body: 80
74Variable
75Lambdaparameter: 85
body: 81
76Literal
77Variable
78Variable
79Variable
80IndexedVarvariable: 82
index: 85
81IndexedVarvariable: 83
index: 85
82Variable
83Variable
84ExprTuple85
85Variable