# 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.
# import Expression classes needed to build the expression
from proveit import 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 = Forall(instance_param_or_params = [P], instance_expr = 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())

\forall_{P}~\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()

namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Operationoperator: 15
operand: 2
1ExprTuple2
2Lambdaparameter: 37
body: 4
3ExprTuple37
4Operationoperator: 5
operands: 6
5Literal
6ExprTuple7, 8
7Operationoperator: 28
operands: 9
8Operationoperator: 15
operand: 13
9ExprTuple11, 12
10ExprTuple13
11Operationoperator: 37
operand: 39
12Operationoperator: 15
operand: 18
13Lambdaparameter: 26
body: 17
14ExprTuple39
15Literal
16ExprTuple18
17Conditionalvalue: 19
condition: 20
18Lambdaparameter: 41
body: 21
19Operationoperator: 37
operand: 26
20Operationoperator: 35
operands: 23
21Conditionalvalue: 24
condition: 25
22ExprTuple26
23ExprTuple26, 40
24Operationoperator: 37
operand: 30
25Operationoperator: 28
operands: 29
26Variable
27ExprTuple30
28Literal
29ExprTuple31, 32
30Operationoperator: 33
operands: 34
31Operationoperator: 35
operands: 36
32Operationoperator: 37
operand: 41
33Literal
34ExprTuple41, 39
35Literal
36ExprTuple41, 40
37Variable
38ExprTuple41
39Literal
40Literal
41Variable