logo

Expression of type Lambda

from the theory of proveit.numbers.number_sets.natural_numbers

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, P, m, n
from proveit.logic import And, Forall, Implies
from proveit.numbers import NaturalPos, P_mAddOne, Pm, Pn, Pone
In [2]:
# build up the expression from sub-expressions
expr = Lambda(P, Implies(And(Pone, Forall(instance_param_or_params = [m], instance_expr = P_mAddOne, domain = NaturalPos, condition = Pm)), Forall(instance_param_or_params = [n], instance_expr = Pn, domain = 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())
P \mapsto \left(\left(P\left(1\right) \land \left[\forall_{m \in \mathbb{N}^+~|~P\left(m\right)}~P\left(m + 1\right)\right]\right) \Rightarrow \left[\forall_{n \in \mathbb{N}^+}~P\left(n\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: 35
body: 2
1ExprTuple35
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 26
operands: 7
6Operationoperator: 13
operand: 11
7ExprTuple9, 10
8ExprTuple11
9Operationoperator: 35
operand: 37
10Operationoperator: 13
operand: 16
11Lambdaparameter: 24
body: 15
12ExprTuple37
13Literal
14ExprTuple16
15Conditionalvalue: 17
condition: 18
16Lambdaparameter: 39
body: 19
17Operationoperator: 35
operand: 24
18Operationoperator: 33
operands: 21
19Conditionalvalue: 22
condition: 23
20ExprTuple24
21ExprTuple24, 38
22Operationoperator: 35
operand: 28
23Operationoperator: 26
operands: 27
24Variable
25ExprTuple28
26Literal
27ExprTuple29, 30
28Operationoperator: 31
operands: 32
29Operationoperator: 33
operands: 34
30Operationoperator: 35
operand: 39
31Literal
32ExprTuple39, 37
33Literal
34ExprTuple39, 38
35Variable
36ExprTuple39
37Literal
38Literal
39Variable