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, 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 = 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\{\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..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple29, 9
7Operationoperator: 11
operand: 13
8Operationoperator: 11
operand: 14
9Literal
10ExprTuple13
11Literal
12ExprTuple14
13Lambdaparameters: 17
body: 15
14Lambdaparameters: 19
body: 16
15Operationoperator: 18
operands: 17
16Operationoperator: 18
operands: 19
17ExprTuple20
18Variable
19ExprTuple21
20ExprRangelambda_map: 22
start_index: 30
end_index: 29
21ExprRangelambda_map: 22
start_index: 30
end_index: 23
22Lambdaparameter: 31
body: 24
23Operationoperator: 25
operands: 26
24IndexedVarvariable: 27
index: 31
25Literal
26ExprTuple29, 30
27Variable
28ExprTuple31
29Variable
30Literal
31Variable