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(VecSum(index_or_indices = sub_expr1, summand = sub_expr2, condition = Q__b_1_to_j), TensorProd(a_1_to_i, vec_summation_b1toj_fQ, c_1_to_k)).with_wrapping_at(1)).with_wrapping_at(2)), domain = VecSpaces(K)), 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\{\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\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[\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] \\  = \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) \end{array} \end{array}\right) \end{array} \end{array}\right)\right] \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
12ExprTuple62, 18
13ExprTuple75, 17
14ExprTuple64, 18
15Operationoperator: 33
operand: 22
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22
20Literal
21ExprTuple51, 23
22Lambdaparameters: 24
body: 25
23Operationoperator: 26
operand: 30
24ExprTuple57, 58
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple30
28Literal
29ExprTuple31, 32
30Variable
31Operationoperator: 33
operand: 37
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple37
35Literal
36ExprTuple38, 39
37Lambdaparameters: 67
body: 40
38Operationoperator: 49
operand: 44
39Operationoperator: 54
operands: 42
40Conditionalvalue: 43
condition: 60
41ExprTuple44
42ExprTuple57, 45, 58
43Operationoperator: 46
operands: 47
44Lambdaparameters: 67
body: 48
45Operationoperator: 49
operand: 53
46Literal
47ExprTuple52, 51
48Conditionalvalue: 52
condition: 60
49Literal
50ExprTuple53
51Variable
52Operationoperator: 54
operands: 55
53Lambdaparameters: 67
body: 56
54Literal
55ExprTuple57, 59, 58
56Conditionalvalue: 59
condition: 60
57ExprRangelambda_map: 61
start_index: 74
end_index: 62
58ExprRangelambda_map: 63
start_index: 74
end_index: 64
59Operationoperator: 65
operands: 67
60Operationoperator: 66
operands: 67
61Lambdaparameter: 79
body: 68
62Variable
63Lambdaparameter: 79
body: 69
64Variable
65Variable
66Variable
67ExprTuple70
68IndexedVarvariable: 71
index: 79
69IndexedVarvariable: 72
index: 79
70ExprRangelambda_map: 73
start_index: 74
end_index: 75
71Variable
72Variable
73Lambdaparameter: 79
body: 76
74Literal
75Variable
76IndexedVarvariable: 77
index: 79
77Variable
78ExprTuple79
79Variable