logo

Expression of type ExprTuple

from the theory of proveit.numbers.multiplication

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, ExprTuple, IndexedVar, Lambda, 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.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Complex, Mult, Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
expr = ExprTuple(Lambda([i, j, k], Conditional(Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Equals(Mult(a_1_to_i, Add(b_1_to_j), c_1_to_k), Add(ExprRange(sub_expr1, Mult(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j))).with_wrapping_at(2), domain = Complex).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(\left(i, j, k\right) \mapsto \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} \in \mathbb{C}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot \left(b_{1} +  b_{2} +  \ldots +  b_{j}\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) =  \\ \left(\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{1}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{2}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \ldots +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{j}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right)\right) \end{array} \end{array}\right)\end{array} \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  k \in \mathbb{N}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple59, 51, 64
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 23
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11, 12
9Lambdaparameters: 13
body: 14
10Operationoperator: 45
operands: 15
11Operationoperator: 45
operands: 16
12Operationoperator: 45
operands: 17
13ExprTuple55, 47, 57
14Conditionalvalue: 18
condition: 19
15ExprTuple59, 20
16ExprTuple51, 20
17ExprTuple64, 20
18Operationoperator: 21
operands: 22
19Operationoperator: 23
operands: 24
20Literal
21Literal
22ExprTuple25, 26
23Literal
24ExprTuple27, 28, 29
25Operationoperator: 52
operands: 30
26Operationoperator: 40
operands: 31
27ExprRangelambda_map: 32
start_index: 63
end_index: 59
28ExprRangelambda_map: 33
start_index: 63
end_index: 51
29ExprRangelambda_map: 34
start_index: 63
end_index: 64
30ExprTuple55, 35, 57
31ExprTuple36
32Lambdaparameter: 71
body: 37
33Lambdaparameter: 71
body: 38
34Lambdaparameter: 71
body: 39
35Operationoperator: 40
operands: 41
36ExprRangelambda_map: 42
start_index: 63
end_index: 51
37Operationoperator: 45
operands: 43
38Operationoperator: 45
operands: 44
39Operationoperator: 45
operands: 46
40Literal
41ExprTuple47
42Lambdaparameter: 66
body: 48
43ExprTuple65, 49
44ExprTuple54, 49
45Literal
46ExprTuple67, 49
47ExprRangelambda_map: 50
start_index: 63
end_index: 51
48Operationoperator: 52
operands: 53
49Literal
50Lambdaparameter: 71
body: 54
51Variable
52Literal
53ExprTuple55, 56, 57
54IndexedVarvariable: 60
index: 71
55ExprRangelambda_map: 58
start_index: 63
end_index: 59
56IndexedVarvariable: 60
index: 66
57ExprRangelambda_map: 62
start_index: 63
end_index: 64
58Lambdaparameter: 71
body: 65
59Variable
60Variable
61ExprTuple66
62Lambdaparameter: 71
body: 67
63Literal
64Variable
65IndexedVarvariable: 68
index: 71
66Variable
67IndexedVarvariable: 69
index: 71
68Variable
69Variable
70ExprTuple71
71Variable