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 Function, Lambda, f, g, k, l, m, n
from proveit.logic import Equals, Forall, Implies
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([f, g], Forall(instance_param_or_params = [m, n], instance_expr = 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))), domain = 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(f, g\right) \mapsto \left[\forall_{m, n \in \mathbb{Z}}~\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)\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
1ExprTuple44, 45
2Operationoperator: 16
operand: 4
3ExprTuple4
4Lambdaparameters: 53
body: 5
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15
12Operationoperator: 16
operand: 21
13Operationoperator: 33
operands: 18
14Operationoperator: 47
operands: 19
15Operationoperator: 47
operands: 20
16Literal
17ExprTuple21
18ExprTuple22, 23
19ExprTuple54, 24
20ExprTuple55, 24
21Lambdaparameter: 49
body: 25
22Operationoperator: 27
operand: 31
23Operationoperator: 27
operand: 32
24Literal
25Conditionalvalue: 29
condition: 30
26ExprTuple31
27Literal
28ExprTuple32
29Operationoperator: 33
operands: 34
30Operationoperator: 47
operands: 35
31Lambdaparameter: 50
body: 36
32Lambdaparameter: 50
body: 37
33Literal
34ExprTuple38, 39
35ExprTuple49, 51
36Conditionalvalue: 40
condition: 42
37Conditionalvalue: 41
condition: 42
38Operationoperator: 44
operand: 49
39Operationoperator: 45
operand: 49
40Operationoperator: 44
operand: 50
41Operationoperator: 45
operand: 50
42Operationoperator: 47
operands: 48
43ExprTuple49
44Variable
45Variable
46ExprTuple50
47Literal
48ExprTuple50, 51
49Variable
50Variable
51Operationoperator: 52
operands: 53
52Literal
53ExprTuple54, 55
54Variable
55Variable