logo

Expression of type Lambda

from the theory of proveit.numbers.summation

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, Function, Lambda, f, g, k, l, m, n
from proveit.logic import And, Equals, Forall, Implies, InSet
from proveit.numbers import Integer, Interval, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = [l]
sub_expr3 = Interval(m, n)
expr = Lambda([m, n], Conditional(Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(Function(f, sub_expr1), Function(g, sub_expr1)), domain = sub_expr3), Equals(Sum(index_or_indices = sub_expr2, summand = Function(f, sub_expr2), domain = sub_expr3), Sum(index_or_indices = sub_expr2, summand = Function(g, sub_expr2), domain = sub_expr3))), And(InSet(m, Integer), InSet(n, Integer))))
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(m, n\right) \mapsto \left\{\left[\forall_{k \in \{m~\ldotp \ldotp~n\}}~\left(f\left(k\right) = g\left(k\right)\right)\right] \Rightarrow \left(\left(\sum_{l = m}^{n} f\left(l\right)\right) = \left(\sum_{l = m}^{n} g\left(l\right)\right)\right) \textrm{ if } m \in \mathbb{Z} ,  n \in \mathbb{Z}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 49
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Operationoperator: 12
operand: 17
9Operationoperator: 29
operands: 14
10Operationoperator: 43
operands: 15
11Operationoperator: 43
operands: 16
12Literal
13ExprTuple17
14ExprTuple18, 19
15ExprTuple50, 20
16ExprTuple51, 20
17Lambdaparameter: 45
body: 21
18Operationoperator: 23
operand: 27
19Operationoperator: 23
operand: 28
20Literal
21Conditionalvalue: 25
condition: 26
22ExprTuple27
23Literal
24ExprTuple28
25Operationoperator: 29
operands: 30
26Operationoperator: 43
operands: 31
27Lambdaparameter: 46
body: 32
28Lambdaparameter: 46
body: 33
29Literal
30ExprTuple34, 35
31ExprTuple45, 47
32Conditionalvalue: 36
condition: 38
33Conditionalvalue: 37
condition: 38
34Operationoperator: 40
operand: 45
35Operationoperator: 41
operand: 45
36Operationoperator: 40
operand: 46
37Operationoperator: 41
operand: 46
38Operationoperator: 43
operands: 44
39ExprTuple45
40Variable
41Variable
42ExprTuple46
43Literal
44ExprTuple46, 47
45Variable
46Variable
47Operationoperator: 48
operands: 49
48Literal
49ExprTuple50, 51
50Variable
51Variable