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, Function, K, V, i, j, k, s
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 ScalarMult, TensorProd, VecSpaces, VecSum
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 = Function(s, sub_expr1)
sub_expr3 = ScalarMult(sub_expr2, f__b_1_to_j)
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(TensorProd(a_1_to_i, sub_expr3, c_1_to_k), V), condition = Q__b_1_to_j), Equals(TensorProd(a_1_to_i, VecSum(index_or_indices = sub_expr1, summand = sub_expr3, condition = Q__b_1_to_j), c_1_to_k), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)), 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} \left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\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)}~\left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\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(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot \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)\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: 52
body: 11
7Operationoperator: 46
operands: 12
8Operationoperator: 46
operands: 13
9Operationoperator: 46
operands: 14
10ExprTuple52
11Conditionalvalue: 15
condition: 16
12ExprTuple72, 18
13ExprTuple83, 17
14ExprTuple76, 18
15Operationoperator: 33
operand: 22
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22
20Literal
21ExprTuple52, 23
22Lambdaparameters: 24
body: 25
23Operationoperator: 26
operand: 30
24ExprTuple67, 69
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple30
28Literal
29ExprTuple31, 32
30Variable
31Operationoperator: 33
operand: 37
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple37
35Literal
36ExprTuple38, 39
37Lambdaparameters: 74
body: 40
38Operationoperator: 64
operands: 41
39Operationoperator: 48
operand: 45
40Conditionalvalue: 43
condition: 59
41ExprTuple67, 44, 69
42ExprTuple45
43Operationoperator: 46
operands: 47
44Operationoperator: 48
operand: 53
45Lambdaparameters: 74
body: 50
46Literal
47ExprTuple51, 52
48Literal
49ExprTuple53
50Conditionalvalue: 54
condition: 59
51Operationoperator: 64
operands: 55
52Variable
53Lambdaparameters: 74
body: 56
54Operationoperator: 61
operands: 57
55ExprTuple67, 58, 69
56Conditionalvalue: 58
condition: 59
57ExprTuple66, 60
58Operationoperator: 61
operands: 62
59Operationoperator: 63
operands: 74
60Operationoperator: 64
operands: 65
61Literal
62ExprTuple66, 68
63Variable
64Literal
65ExprTuple67, 68, 69
66Operationoperator: 70
operands: 74
67ExprRangelambda_map: 71
start_index: 82
end_index: 72
68Operationoperator: 73
operands: 74
69ExprRangelambda_map: 75
start_index: 82
end_index: 76
70Variable
71Lambdaparameter: 88
body: 77
72Variable
73Variable
74ExprTuple78
75Lambdaparameter: 88
body: 79
76Variable
77IndexedVarvariable: 80
index: 88
78ExprRangelambda_map: 81
start_index: 82
end_index: 83
79IndexedVarvariable: 84
index: 88
80Variable
81Lambdaparameter: 88
body: 85
82Literal
83Variable
84Variable
85IndexedVarvariable: 86
index: 88
86Variable
87ExprTuple88
88Variable