logo

Expression of type Lambda

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, Lambda, i, j, x, y
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Complex, Mult, Natural, subtract
In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, j], Conditional(Forall(instance_param_or_params = [a_1_to_i, x, y, b_1_to_j], instance_expr = 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), domain = Complex), And(InSet(i, Natural), InSet(j, 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(i, j\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{i}, x, y, b_{1}, b_{2}, \ldots, b_{j} \in \mathbb{C}}~\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}\right) \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple58, 61
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 20
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 44
operands: 13
10Operationoperator: 44
operands: 14
11ExprTuple54, 47, 55, 56
12Conditionalvalue: 15
condition: 16
13ExprTuple58, 17
14ExprTuple61, 17
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22, 23
20Literal
21ExprTuple24, 25, 26, 27
22Operationoperator: 52
operands: 28
23Operationoperator: 39
operands: 29
24ExprRangelambda_map: 30
start_index: 60
end_index: 58
25Operationoperator: 44
operands: 31
26Operationoperator: 44
operands: 32
27ExprRangelambda_map: 33
start_index: 60
end_index: 61
28ExprTuple54, 34, 56
29ExprTuple35, 36
30Lambdaparameter: 67
body: 37
31ExprTuple47, 49
32ExprTuple55, 49
33Lambdaparameter: 67
body: 38
34Operationoperator: 39
operands: 40
35Operationoperator: 52
operands: 41
36Operationoperator: 50
operand: 48
37Operationoperator: 44
operands: 43
38Operationoperator: 44
operands: 45
39Literal
40ExprTuple47, 46
41ExprTuple54, 47, 56
42ExprTuple48
43ExprTuple62, 49
44Literal
45ExprTuple63, 49
46Operationoperator: 50
operand: 55
47Variable
48Operationoperator: 52
operands: 53
49Literal
50Literal
51ExprTuple55
52Literal
53ExprTuple54, 55, 56
54ExprRangelambda_map: 57
start_index: 60
end_index: 58
55Variable
56ExprRangelambda_map: 59
start_index: 60
end_index: 61
57Lambdaparameter: 67
body: 62
58Variable
59Lambdaparameter: 67
body: 63
60Literal
61Variable
62IndexedVarvariable: 64
index: 67
63IndexedVarvariable: 65
index: 67
64Variable
65Variable
66ExprTuple67
67Variable