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 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 = [i, k], instance_expr = 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(), domain = Natural), InSet(alpha, K))
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\{\forall_{i, k \in \mathbb{N}}~\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}\right] \textrm{ if } \alpha \in K\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: 26
operand: 5
2Operationoperator: 72
operands: 4
3ExprTuple5
4ExprTuple74, 66
5Lambdaparameters: 6
body: 7
6ExprTuple81, 84
7Conditionalvalue: 8
condition: 9
8Operationoperator: 26
operand: 12
9Operationoperator: 43
operands: 11
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameters: 15
body: 16
13Operationoperator: 72
operands: 17
14Operationoperator: 72
operands: 18
15ExprTuple19, 64, 20
16Conditionalvalue: 21
condition: 22
17ExprTuple81, 23
18ExprTuple84, 23
19ExprRangelambda_map: 24
start_index: 83
end_index: 81
20ExprRangelambda_map: 25
start_index: 83
end_index: 84
21Operationoperator: 26
operand: 29
22Operationoperator: 43
operands: 28
23Literal
24Lambdaparameter: 92
body: 78
25Lambdaparameter: 92
body: 79
26Literal
27ExprTuple29
28ExprTuple30, 31, 32
29Lambdaparameters: 70
body: 33
30ExprRangelambda_map: 34
start_index: 83
end_index: 81
31Operationoperator: 46
operands: 35
32ExprRangelambda_map: 36
start_index: 83
end_index: 84
33Conditionalvalue: 37
condition: 38
34Lambdaparameter: 92
body: 39
35ExprTuple64, 53
36Lambdaparameter: 92
body: 40
37Operationoperator: 41
operands: 42
38Operationoperator: 43
operands: 44
39Operationoperator: 46
operands: 45
40Operationoperator: 46
operands: 47
41Literal
42ExprTuple48, 49
43Literal
44ExprTuple50, 51, 52
45ExprTuple78, 53
46Literal
47ExprTuple79, 53
48Operationoperator: 69
operands: 54
49Operationoperator: 67
operands: 55
50ExprRangelambda_map: 56
start_index: 83
end_index: 81
51Operationoperator: 72
operands: 57
52ExprRangelambda_map: 58
start_index: 83
end_index: 84
53Operationoperator: 59
operand: 66
54ExprTuple75, 61, 77
55ExprTuple74, 62
56Lambdaparameter: 92
body: 63
57ExprTuple76, 64
58Lambdaparameter: 92
body: 65
59Literal
60ExprTuple66
61Operationoperator: 67
operands: 68
62Operationoperator: 69
operands: 70
63Operationoperator: 72
operands: 71
64Variable
65Operationoperator: 72
operands: 73
66Variable
67Literal
68ExprTuple74, 76
69Literal
70ExprTuple75, 76, 77
71ExprTuple87, 78
72Literal
73ExprTuple88, 79
74Variable
75ExprRangelambda_map: 80
start_index: 83
end_index: 81
76Variable
77ExprRangelambda_map: 82
start_index: 83
end_index: 84
78IndexedVarvariable: 85
index: 92
79IndexedVarvariable: 86
index: 92
80Lambdaparameter: 92
body: 87
81Variable
82Lambdaparameter: 92
body: 88
83Literal
84Variable
85Variable
86Variable
87IndexedVarvariable: 89
index: 92
88IndexedVarvariable: 90
index: 92
89Variable
90Variable
91ExprTuple92
92Variable