logo

Expression of type Lambda

from the theory of proveit.logic.equality

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, ExprRange, IndexedVar, Lambda, Variable, n, x
from proveit.core_expr_types import x_1_to_np1
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Add, NaturalPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [x_1_to_np1], instance_expr = Equals(IndexedVar(x, one), IndexedVar(x, Add(n, one))), condition = ExprRange(sub_expr1, Equals(IndexedVar(x, sub_expr1), IndexedVar(x, Add(sub_expr1, one))), one, n)), InSet(n, NaturalPos)))
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())
n \mapsto \left\{\forall_{x_{1}, x_{2}, \ldots, x_{n + 1}~|~\left(x_{1} = x_{1 + 1}\right), \left(x_{2} = x_{2 + 1}\right), \ldots, \left(x_{n} = x_{n + 1}\right)}~\left(x_{1} = x_{n + 1}\right) \textrm{ if } n \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
0Lambdaparameter: 31
body: 2
1ExprTuple31
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple31, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple13
12Conditionalvalue: 14
condition: 15
13ExprRangelambda_map: 16
start_index: 41
end_index: 26
14Operationoperator: 29
operands: 17
15Operationoperator: 18
operands: 19
16Lambdaparameter: 40
body: 32
17ExprTuple20, 21
18Literal
19ExprTuple22
20IndexedVarvariable: 35
index: 41
21IndexedVarvariable: 35
index: 26
22ExprRangelambda_map: 25
start_index: 41
end_index: 31
23ExprTuple41
24ExprTuple26
25Lambdaparameter: 40
body: 27
26Operationoperator: 38
operands: 28
27Operationoperator: 29
operands: 30
28ExprTuple31, 41
29Literal
30ExprTuple32, 33
31Variable
32IndexedVarvariable: 35
index: 40
33IndexedVarvariable: 35
index: 37
34ExprTuple40
35Variable
36ExprTuple37
37Operationoperator: 38
operands: 39
38Literal
39ExprTuple40, 41
40Variable
41Literal