logo

Expression of type Lambda

from the theory of proveit.numbers.exponentiation

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, k, m
from proveit.core_expr_types import k_1_to_m
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Complex, Exp, NaturalPos, one
from proveit.numbers.exponentiation import prod_a_raise_ki__1_to_m
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([a, k_1_to_m], Conditional(Equals(prod_a_raise_ki__1_to_m, Exp(a, Add(k_1_to_m))), And(InSet(a, Complex), ExprRange(sub_expr1, InSet(IndexedVar(k, sub_expr1), NaturalPos), one, m))))
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, k_{1}, k_{2}, \ldots, k_{m}\right) \mapsto \left\{\left(a^{k_{1}} \cdot  a^{k_{2}} \cdot  \ldots \cdot  a^{k_{m}}\right) = a^{k_{1} +  k_{2} +  \ldots +  k_{m}} \textrm{ if } a \in \mathbb{C}, \left(k_{1} \in \mathbb{N}^+\right) ,  \left(k_{2} \in \mathbb{N}^+\right) ,  \ldots ,  \left(k_{m} \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
0Lambdaparameters: 1
body: 2
1ExprTuple35, 28
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9Operationoperator: 13
operands: 14
10Operationoperator: 30
operands: 15
11Operationoperator: 25
operands: 16
12ExprRangelambda_map: 17
start_index: 33
end_index: 34
13Literal
14ExprTuple18
15ExprTuple35, 19
16ExprTuple35, 20
17Lambdaparameter: 39
body: 21
18ExprRangelambda_map: 22
start_index: 33
end_index: 34
19Operationoperator: 23
operands: 24
20Literal
21Operationoperator: 25
operands: 26
22Lambdaparameter: 39
body: 27
23Literal
24ExprTuple28
25Literal
26ExprTuple36, 29
27Operationoperator: 30
operands: 31
28ExprRangelambda_map: 32
start_index: 33
end_index: 34
29Literal
30Literal
31ExprTuple35, 36
32Lambdaparameter: 39
body: 36
33Literal
34Variable
35Variable
36IndexedVarvariable: 37
index: 39
37Variable
38ExprTuple39
39Variable