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, i, j, k
from proveit.core_expr_types import Q__b_1_to_j, a_1_to_i, b_1_to_j, c_1_to_k, f__b_1_to_j
from proveit.linear_algebra import TensorProd, VecSpaces, VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import And, Equals, Forall, Implies, InSet
from proveit.numbers import Natural, NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
sub_expr2 = TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)
expr = Conditional(Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [a_1_to_i, c_1_to_k], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(sub_expr2, V), condition = Q__b_1_to_j), Equals(TensorProd(a_1_to_i, vec_summation_b1toj_fQ, c_1_to_k), VecSum(index_or_indices = sub_expr1, summand = sub_expr2, condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(2)).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), And(InSet(i, Natural), InSet(j, NaturalPos), 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_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{k}}~\\
\left(\begin{array}{c} \begin{array}{l} \left[\forall_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} f\left(b_{1}, b_{2}, \ldots, b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \in V\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} f\left(b_{1}, b_{2}, \ldots, b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right)\right] \end{array} \end{array}\right) \end{array} \end{array}\right)\end{array}\right]\end{array} \textrm{ if } i \in \mathbb{N} ,  j \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: 33
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8, 9
6Lambdaparameter: 51
body: 11
7Operationoperator: 46
operands: 12
8Operationoperator: 46
operands: 13
9Operationoperator: 46
operands: 14
10ExprTuple51
11Conditionalvalue: 15
condition: 16
12ExprTuple63, 18
13ExprTuple74, 17
14ExprTuple67, 18
15Operationoperator: 33
operand: 22
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22
20Literal
21ExprTuple51, 23
22Lambdaparameters: 24
body: 25
23Operationoperator: 26
operand: 30
24ExprTuple58, 60
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple30
28Literal
29ExprTuple31, 32
30Variable
31Operationoperator: 33
operand: 37
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple37
35Literal
36ExprTuple38, 39
37Lambdaparameters: 65
body: 40
38Operationoperator: 55
operands: 41
39Operationoperator: 48
operand: 45
40Conditionalvalue: 43
condition: 57
41ExprTuple58, 44, 60
42ExprTuple45
43Operationoperator: 46
operands: 47
44Operationoperator: 48
operand: 52
45Lambdaparameters: 65
body: 50
46Literal
47ExprTuple53, 51
48Literal
49ExprTuple52
50Conditionalvalue: 53
condition: 57
51Variable
52Lambdaparameters: 65
body: 54
53Operationoperator: 55
operands: 56
54Conditionalvalue: 59
condition: 57
55Literal
56ExprTuple58, 59, 60
57Operationoperator: 61
operands: 65
58ExprRangelambda_map: 62
start_index: 73
end_index: 63
59Operationoperator: 64
operands: 65
60ExprRangelambda_map: 66
start_index: 73
end_index: 67
61Variable
62Lambdaparameter: 79
body: 68
63Variable
64Variable
65ExprTuple69
66Lambdaparameter: 79
body: 70
67Variable
68IndexedVarvariable: 71
index: 79
69ExprRangelambda_map: 72
start_index: 73
end_index: 74
70IndexedVarvariable: 75
index: 79
71Variable
72Lambdaparameter: 79
body: 76
73Literal
74Variable
75Variable
76IndexedVarvariable: 77
index: 79
77Variable
78ExprTuple79
79Variable