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 Lambda, f, i, j, x
from proveit.core_expr_types import Len, f_i_to_j, range_i_to_jp1
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda([f, x], Forall(instance_param_or_params = [i, j], instance_expr = Equals(Len(operands = [f_i_to_j, x]), Len(operands = [range_i_to_jp1])), condition = InSet(Len(operands = [f_i_to_j]), 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, x\right) \mapsto \left[\forall_{i, j~|~|\left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right)\right)| \in \mathbb{N}}~\left(|\left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right), x\right)| = |\left(i, \left(i + 1\right), \ldots, \left(j + 1\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
1ExprTuple34, 22
2Operationoperator: 3
operand: 5
3Literal
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple28, 32
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple16, 17
14Operationoperator: 20
operands: 18
15Operationoperator: 20
operands: 19
16Operationoperator: 20
operands: 21
17Literal
18ExprTuple24, 22
19ExprTuple23
20Literal
21ExprTuple24
22Variable
23ExprRangelambda_map: 25
start_index: 28
end_index: 26
24ExprRangelambda_map: 27
start_index: 28
end_index: 32
25Lambdaparameter: 36
body: 36
26Operationoperator: 29
operands: 30
27Lambdaparameter: 36
body: 31
28Variable
29Literal
30ExprTuple32, 33
31Operationoperator: 34
operand: 36
32Variable
33Literal
34Variable
35ExprTuple36
36Variable