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, a, b, i, j, x, y
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import And, Equals, InSet
from proveit.numbers import Complex, Mult, one, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda([a_1_to_i, x, y, b_1_to_j], Conditional(Equals(Mult(a_1_to_i, subtract(x, y), b_1_to_j), subtract(Mult(a_1_to_i, x, b_1_to_j), Mult(a_1_to_i, y, b_1_to_j))).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), InSet(x, Complex), InSet(y, Complex), ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Complex), one, j)))))
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(a_{1}, a_{2}, \ldots, a_{i}, x, y, b_{1}, b_{2}, \ldots, b_{j}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot \left(x - y\right)\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right) =  \\ \left(\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot x\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right) - \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot y\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right)\right) \end{array} \end{array} \textrm{ if } \left(a_{1} \in \mathbb{C}\right) ,  \left(a_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{C}\right) ,  x \in \mathbb{C} ,  y \in \mathbb{C}, \left(b_{1} \in \mathbb{C}\right) ,  \left(b_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(b_{j} \in \mathbb{C}\right)\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
2ExprTuple42, 35, 43, 44
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14, 15
10Operationoperator: 40
operands: 16
11Operationoperator: 27
operands: 17
12ExprRangelambda_map: 18
start_index: 48
end_index: 46
13Operationoperator: 32
operands: 19
14Operationoperator: 32
operands: 20
15ExprRangelambda_map: 21
start_index: 48
end_index: 49
16ExprTuple42, 22, 44
17ExprTuple23, 24
18Lambdaparameter: 55
body: 25
19ExprTuple35, 37
20ExprTuple43, 37
21Lambdaparameter: 55
body: 26
22Operationoperator: 27
operands: 28
23Operationoperator: 40
operands: 29
24Operationoperator: 38
operand: 36
25Operationoperator: 32
operands: 31
26Operationoperator: 32
operands: 33
27Literal
28ExprTuple35, 34
29ExprTuple42, 35, 44
30ExprTuple36
31ExprTuple50, 37
32Literal
33ExprTuple51, 37
34Operationoperator: 38
operand: 43
35Variable
36Operationoperator: 40
operands: 41
37Literal
38Literal
39ExprTuple43
40Literal
41ExprTuple42, 43, 44
42ExprRangelambda_map: 45
start_index: 48
end_index: 46
43Variable
44ExprRangelambda_map: 47
start_index: 48
end_index: 49
45Lambdaparameter: 55
body: 50
46Variable
47Lambdaparameter: 55
body: 51
48Literal
49Variable
50IndexedVarvariable: 52
index: 55
51IndexedVarvariable: 53
index: 55
52Variable
53Variable
54ExprTuple55
55Variable