logo
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, ExprTuple, Lambda, n
from proveit.core_expr_types import P__x_1_to_n, P__x_1_to_np1, x_1_to_n, x_1_to_np1
from proveit.logic import Forall, Implies, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(n, Conditional(Implies(Forall(instance_param_or_params = [x_1_to_n], instance_expr = P__x_1_to_n), Forall(instance_param_or_params = [x_1_to_np1], instance_expr = P__x_1_to_np1)).with_wrapping_at(2), InSet(n, 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(n \mapsto \left\{\begin{array}{c} \begin{array}{l} \left[\forall_{x_{1}, x_{2}, \ldots, x_{n}}~P\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right] \Rightarrow  \\ \left[\forall_{x_{1}, x_{2}, \ldots, x_{n + 1}}~P\left(x_{1}, x_{2}, \ldots, x_{n + 1}\right)\right] \end{array} \end{array} \textrm{ if } n \in \mathbb{N}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 32
body: 3
2ExprTuple32
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple32, 12
10Operationoperator: 14
operand: 16
11Operationoperator: 14
operand: 17
12Literal
13ExprTuple16
14Literal
15ExprTuple17
16Lambdaparameters: 20
body: 18
17Lambdaparameters: 22
body: 19
18Operationoperator: 21
operands: 20
19Operationoperator: 21
operands: 22
20ExprTuple23
21Variable
22ExprTuple24
23ExprRangelambda_map: 25
start_index: 33
end_index: 32
24ExprRangelambda_map: 25
start_index: 33
end_index: 26
25Lambdaparameter: 34
body: 27
26Operationoperator: 28
operands: 29
27IndexedVarvariable: 30
index: 34
28Literal
29ExprTuple32, 33
30Variable
31ExprTuple34
32Variable
33Literal
34Variable