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 And, Forall, Implies
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [n]
sub_expr2 = Forall(instance_param_or_params = [x_1_to_n], instance_expr = P__x_1_to_n)
expr = ExprTuple(And(Function(P, []), Forall(instance_param_or_params = sub_expr1, instance_expr = Implies(sub_expr2, Forall(instance_param_or_params = [x_1_to_np1], instance_expr = P__x_1_to_np1)).with_wrapping_at(2), domain = Natural)), Forall(instance_param_or_params = sub_expr1, instance_expr = sub_expr2, 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) \land \left[\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], \forall_{n \in \mathbb{N}}~\left[\forall_{x_{1}, x_{2}, \ldots, x_{n}}~P\left(x_{1}, x_{2}, \ldots, x_{n}\right)\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: 3
operands: 4
2Operationoperator: 25
operand: 8
3Literal
4ExprTuple6, 7
5ExprTuple8
6Operationoperator: 32
operands: 9
7Operationoperator: 25
operand: 12
8Lambdaparameter: 43
body: 11
9ExprTuple
10ExprTuple12
11Conditionalvalue: 21
condition: 16
12Lambdaparameter: 43
body: 14
13ExprTuple43
14Conditionalvalue: 15
condition: 16
15Operationoperator: 17
operands: 18
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple43, 23
21Operationoperator: 25
operand: 27
22Operationoperator: 25
operand: 28
23Literal
24ExprTuple27
25Literal
26ExprTuple28
27Lambdaparameters: 31
body: 29
28Lambdaparameters: 33
body: 30
29Operationoperator: 32
operands: 31
30Operationoperator: 32
operands: 33
31ExprTuple34
32Variable
33ExprTuple35
34ExprRangelambda_map: 36
start_index: 44
end_index: 43
35ExprRangelambda_map: 36
start_index: 44
end_index: 37
36Lambdaparameter: 45
body: 38
37Operationoperator: 39
operands: 40
38IndexedVarvariable: 41
index: 45
39Literal
40ExprTuple43, 44
41Variable
42ExprTuple45
43Variable
44Literal
45Variable