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, ExprRange, IndexedVar, Lambda, Variable, a, b, c, i, j
from proveit.core_expr_types import a_1_to_i, c_1_to_j
from proveit.logic import And, Equals, InSet
from proveit.numbers import Complex, Mult, Neg, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([a_1_to_i, b, c_1_to_j], Conditional(Equals(Neg(Mult(a_1_to_i, Neg(b), c_1_to_j)), Mult(a_1_to_i, b, c_1_to_j)), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), InSet(b, Complex), ExprRange(sub_expr1, InSet(IndexedVar(c, 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(a_{1}, a_{2}, \ldots, a_{i}, b, c_{1}, c_{2}, \ldots, c_{j}\right) \mapsto \left\{\left(-\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot \left(-b\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{j}\right)\right) = \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{j}\right) \textrm{ if } \left(a_{1} \in \mathbb{C}\right) ,  \left(a_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{C}\right) ,  b \in \mathbb{C}, \left(c_{1} \in \mathbb{C}\right) ,  \left(c_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(c_{j} \in \mathbb{C}\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 14
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12
8Operationoperator: 32
operand: 18
9Operationoperator: 21
operands: 14
10ExprRangelambda_map: 15
start_index: 35
end_index: 31
11Operationoperator: 24
operands: 16
12ExprRangelambda_map: 17
start_index: 35
end_index: 36
13ExprTuple18
14ExprTuple26, 38, 28
15Lambdaparameter: 43
body: 19
16ExprTuple38, 29
17Lambdaparameter: 43
body: 20
18Operationoperator: 21
operands: 22
19Operationoperator: 24
operands: 23
20Operationoperator: 24
operands: 25
21Literal
22ExprTuple26, 27, 28
23ExprTuple37, 29
24Literal
25ExprTuple39, 29
26ExprRangelambda_map: 30
start_index: 35
end_index: 31
27Operationoperator: 32
operand: 38
28ExprRangelambda_map: 34
start_index: 35
end_index: 36
29Literal
30Lambdaparameter: 43
body: 37
31Variable
32Literal
33ExprTuple38
34Lambdaparameter: 43
body: 39
35Literal
36Variable
37IndexedVarvariable: 40
index: 43
38Variable
39IndexedVarvariable: 41
index: 43
40Variable
41Variable
42ExprTuple43
43Variable