logo

Expression of type Lambda

from the theory of proveit.core_expr_types.tuples

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, Lambda, f, i, j
from proveit.core_expr_types import merge_series_conditions, merge_series_equiv, x_0_to_jmi
from proveit.logic import Forall, InSet
from proveit.numbers import Natural, subtract
In [2]:
# build up the expression from sub-expressions
expr = Lambda([f, i, j], Conditional(Forall(instance_param_or_params = [x_0_to_jmi], instance_expr = merge_series_equiv, condition = merge_series_conditions), InSet(subtract(j, i), Natural)))
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, i, j\right) \mapsto \left\{\forall_{x_{0}, x_{1}, \ldots, x_{j - i}~|~\left(x_{0} = f\left(i + 0\right)\right), \left(x_{1} = f\left(i + 1\right)\right), \ldots, \left(x_{j - i} = f\left(i + \left(j - i\right)\right)\right)}~\left(\begin{array}{c} \begin{array}{l} \left(x_{0}, x_{1}, \ldots, x_{j - i}\right) =  \\ \left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right)\right) \end{array} \end{array}\right) \textrm{ if } \left(j - i\right) \in \mathbb{N}\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
1ExprTuple40, 45, 32
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple25, 10
9Lambdaparameters: 17
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 30
operands: 14
13Operationoperator: 15
operands: 16
14ExprTuple17, 18
15Literal
16ExprTuple19
17ExprTuple20
18ExprTuple21
19ExprRangelambda_map: 22
start_index: 24
end_index: 25
20ExprRangelambda_map: 23
start_index: 24
end_index: 25
21ExprRangelambda_map: 26
start_index: 45
end_index: 32
22Lambdaparameter: 46
body: 27
23Lambdaparameter: 46
body: 34
24Literal
25Operationoperator: 43
operands: 28
26Lambdaparameter: 46
body: 29
27Operationoperator: 30
operands: 31
28ExprTuple32, 33
29Operationoperator: 40
operand: 46
30Literal
31ExprTuple34, 35
32Variable
33Operationoperator: 36
operand: 45
34IndexedVarvariable: 38
index: 46
35Operationoperator: 40
operand: 42
36Literal
37ExprTuple45
38Variable
39ExprTuple46
40Variable
41ExprTuple42
42Operationoperator: 43
operands: 44
43Literal
44ExprTuple45, 46
45Variable
46Variable