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, n
from proveit.core_expr_types import a_1_to_n
from proveit.logic import And, Equals, InSet, Or
from proveit.numbers import Complex, Mult, ZeroSet, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(a, sub_expr1)
expr = Lambda([a_1_to_n], Conditional(InSet(Mult(a_1_to_n), ZeroSet), And(ExprRange(sub_expr1, InSet(sub_expr2, Complex), one, n), Or(ExprRange(sub_expr1, Equals(sub_expr2, zero), one, n)))))
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_{n}\right) \mapsto \left\{\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{n}\right) \in \left\{0\right\} \textrm{ if } \left(a_{1} \in \mathbb{C}\right) ,  \left(a_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(a_{n} \in \mathbb{C}\right) ,  \left(a_{1} = 0\right) \lor  \left(a_{2} = 0\right) \lor  \ldots \lor  \left(a_{n} = 0\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: 12
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 22
operands: 4
3Operationoperator: 5
operands: 6
4ExprTuple7, 8
5Literal
6ExprTuple9, 10
7Operationoperator: 11
operands: 12
8Operationoperator: 13
operand: 32
9ExprRangelambda_map: 15
start_index: 25
end_index: 26
10Operationoperator: 16
operands: 17
11Literal
12ExprTuple18
13Literal
14ExprTuple32
15Lambdaparameter: 35
body: 19
16Literal
17ExprTuple20
18ExprRangelambda_map: 21
start_index: 25
end_index: 26
19Operationoperator: 22
operands: 23
20ExprRangelambda_map: 24
start_index: 25
end_index: 26
21Lambdaparameter: 35
body: 31
22Literal
23ExprTuple31, 27
24Lambdaparameter: 35
body: 28
25Literal
26Variable
27Literal
28Operationoperator: 29
operands: 30
29Literal
30ExprTuple31, 32
31IndexedVarvariable: 33
index: 35
32Literal
33Variable
34ExprTuple35
35Variable