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, a, b, c, f, fx, x
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, Sum, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda(f, Forall(instance_param_or_params = [a, b, c], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Sum(index_or_indices = sub_expr1, summand = Function(f, [subtract(x, c)]), domain = Interval(Add(a, c), Add(b, c)))), 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())
f \mapsto \left[\forall_{a, b, c \in \mathbb{Z}}~\left(\left(\sum_{x = a}^{b} f\left(x\right)\right) = \left(\sum_{x = a + c}^{b + c} f\left(x - c\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
0Lambdaparameter: 36
body: 2
1ExprTuple36
2Operationoperator: 3
operand: 5
3Literal
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple56, 57, 58
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple16, 17, 18
14Operationoperator: 20
operand: 25
15Operationoperator: 20
operand: 26
16Operationoperator: 38
operands: 22
17Operationoperator: 38
operands: 23
18Operationoperator: 38
operands: 24
19ExprTuple25
20Literal
21ExprTuple26
22ExprTuple56, 27
23ExprTuple57, 27
24ExprTuple58, 27
25Lambdaparameter: 47
body: 28
26Lambdaparameter: 47
body: 29
27Literal
28Conditionalvalue: 30
condition: 31
29Conditionalvalue: 32
condition: 33
30Operationoperator: 36
operand: 47
31Operationoperator: 38
operands: 35
32Operationoperator: 36
operand: 41
33Operationoperator: 38
operands: 39
34ExprTuple47
35ExprTuple47, 40
36Variable
37ExprTuple41
38Literal
39ExprTuple47, 42
40Operationoperator: 45
operands: 43
41Operationoperator: 54
operands: 44
42Operationoperator: 45
operands: 46
43ExprTuple56, 57
44ExprTuple47, 48
45Literal
46ExprTuple49, 50
47Variable
48Operationoperator: 51
operand: 58
49Operationoperator: 54
operands: 53
50Operationoperator: 54
operands: 55
51Literal
52ExprTuple58
53ExprTuple56, 58
54Literal
55ExprTuple57, 58
56Variable
57Variable
58Variable