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 ExprTuple, Function, P, 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
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Function(P, []), Forall(instance_param_or_params = [n], instance_expr = 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), domain = 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(P\left(\right), \forall_{n \in \mathbb{N}}~\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}\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 25
operands: 3
2Operationoperator: 18
operand: 5
3ExprTuple
4ExprTuple5
5Lambdaparameter: 36
body: 7
6ExprTuple36
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple36, 16
14Operationoperator: 18
operand: 20
15Operationoperator: 18
operand: 21
16Literal
17ExprTuple20
18Literal
19ExprTuple21
20Lambdaparameters: 24
body: 22
21Lambdaparameters: 26
body: 23
22Operationoperator: 25
operands: 24
23Operationoperator: 25
operands: 26
24ExprTuple27
25Variable
26ExprTuple28
27ExprRangelambda_map: 29
start_index: 37
end_index: 36
28ExprRangelambda_map: 29
start_index: 37
end_index: 30
29Lambdaparameter: 38
body: 31
30Operationoperator: 32
operands: 33
31IndexedVarvariable: 34
index: 38
32Literal
33ExprTuple36, 37
34Variable
35ExprTuple38
36Variable
37Literal
38Variable