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, 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 Equals, Forall, Implies, InClass, InSet
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 = [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(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), TensorProd(a_1_to_i, VecSum(index_or_indices = sub_expr1, summand = sub_expr3, condition = Q__b_1_to_j), c_1_to_k)).with_wrapping_at(1)).with_wrapping_at(2)).with_wrapping(), InClass(V, VecSpaces(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\{\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[\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] \\  = \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) \end{array} \end{array}\right) \end{array} \end{array}\right)\end{array} \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\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: 17
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple36, 7
6Lambdaparameters: 8
body: 9
7Operationoperator: 10
operand: 14
8ExprTuple50, 51
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14
12Literal
13ExprTuple15, 16
14Variable
15Operationoperator: 17
operand: 21
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21
19Literal
20ExprTuple22, 23
21Lambdaparameters: 60
body: 24
22Operationoperator: 33
operand: 28
23Operationoperator: 45
operands: 26
24Conditionalvalue: 27
condition: 44
25ExprTuple28
26ExprTuple50, 29, 51
27Operationoperator: 30
operands: 31
28Lambdaparameters: 60
body: 32
29Operationoperator: 33
operand: 38
30Literal
31ExprTuple35, 36
32Conditionalvalue: 37
condition: 44
33Literal
34ExprTuple38
35Operationoperator: 45
operands: 39
36Variable
37Operationoperator: 47
operands: 40
38Lambdaparameters: 60
body: 41
39ExprTuple50, 43, 51
40ExprTuple52, 42
41Conditionalvalue: 43
condition: 44
42Operationoperator: 45
operands: 46
43Operationoperator: 47
operands: 48
44Operationoperator: 49
operands: 60
45Literal
46ExprTuple50, 53, 51
47Literal
48ExprTuple52, 53
49Variable
50ExprRangelambda_map: 54
start_index: 67
end_index: 55
51ExprRangelambda_map: 56
start_index: 67
end_index: 57
52Operationoperator: 58
operands: 60
53Operationoperator: 59
operands: 60
54Lambdaparameter: 72
body: 61
55Variable
56Lambdaparameter: 72
body: 62
57Variable
58Variable
59Variable
60ExprTuple63
61IndexedVarvariable: 64
index: 72
62IndexedVarvariable: 65
index: 72
63ExprRangelambda_map: 66
start_index: 67
end_index: 68
64Variable
65Variable
66Lambdaparameter: 72
body: 69
67Literal
68Variable
69IndexedVarvariable: 70
index: 72
70Variable
71ExprTuple72
72Variable