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, ExprRange, IndexedVar, K, V, Variable, b, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.linear_algebra import TensorProd, VecAdd, VecSpaces
from proveit.logic import And, Equals, Forall, Implies, InSet
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = TensorProd(a_1_to_i, VecAdd(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, b_1_to_j, c_1_to_k], instance_expr = Implies(InSet(sub_expr2, V), Equals(VecAdd(ExprRange(sub_expr1, TensorProd(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j)), sub_expr2).with_wrapping_at(2)).with_wrapping_at(2)).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), And(InSet(i, Natural), InSet(j, Natural), 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}, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(b_{1} +  b_{2} +  \ldots +  b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \in V\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{1}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) +  \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{2}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) +  \ldots +  \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{j}{\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(b_{1} +  b_{2} +  \ldots +  b_{j}\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}\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: 18
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8, 9
6Lambdaparameter: 37
body: 11
7Operationoperator: 33
operands: 12
8Operationoperator: 33
operands: 13
9Operationoperator: 33
operands: 14
10ExprTuple37
11Conditionalvalue: 15
condition: 16
12ExprTuple58, 17
13ExprTuple52, 17
14ExprTuple62, 17
15Operationoperator: 18
operand: 22
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22
20Literal
21ExprTuple37, 23
22Lambdaparameters: 24
body: 25
23Operationoperator: 26
operand: 30
24ExprTuple53, 48, 55
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple30
28Literal
29ExprTuple31, 32
30Variable
31Operationoperator: 33
operands: 34
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple39, 37
35Literal
36ExprTuple38, 39
37Variable
38Operationoperator: 45
operands: 40
39Operationoperator: 49
operands: 41
40ExprTuple42
41ExprTuple53, 43, 55
42ExprRangelambda_map: 44
start_index: 61
end_index: 52
43Operationoperator: 45
operands: 46
44Lambdaparameter: 65
body: 47
45Literal
46ExprTuple48
47Operationoperator: 49
operands: 50
48ExprRangelambda_map: 51
start_index: 61
end_index: 52
49Literal
50ExprTuple53, 54, 55
51Lambdaparameter: 70
body: 56
52Variable
53ExprRangelambda_map: 57
start_index: 61
end_index: 58
54IndexedVarvariable: 63
index: 65
55ExprRangelambda_map: 60
start_index: 61
end_index: 62
56IndexedVarvariable: 63
index: 70
57Lambdaparameter: 70
body: 64
58Variable
59ExprTuple65
60Lambdaparameter: 70
body: 66
61Literal
62Variable
63Variable
64IndexedVarvariable: 67
index: 70
65Variable
66IndexedVarvariable: 68
index: 70
67Variable
68Variable
69ExprTuple70
70Variable