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, P, Q, R, m, n
from proveit.logic import And, Forall, Implies, InSet
from proveit.logic.booleans.quantification import general_bundled_forall_Pxy_if_Qx, general_nested_forall_Pxy_if_Qx
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [P, Q, R], instance_expr = Implies(general_nested_forall_Pxy_if_Qx, general_bundled_forall_Pxy_if_Qx).with_wrapping_at(1)), And(InSet(m, NaturalPos), InSet(n, 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())
\left\{\forall_{P, Q, R}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{x_{1}, x_{2}, \ldots, x_{m}~|~Q\left(x_{1}, x_{2}, \ldots, x_{m}\right)}~\left[\forall_{y_{1}, y_{2}, \ldots, y_{n}~|~R\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)}~P\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)\right]\right] \\  \Rightarrow \left[\forall_{x_{1}, x_{2}, \ldots, x_{m}, y_{1}, y_{2}, \ldots, y_{n}~|~Q\left(x_{1}, x_{2}, \ldots, x_{m}\right), R\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)}~P\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)\right] \end{array} \end{array}\right) \textrm{ if } m \in \mathbb{N}^+ ,  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: 26
operand: 5
2Operationoperator: 28
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 8
body: 9
6Operationoperator: 11
operands: 10
7Operationoperator: 11
operands: 12
8ExprTuple38, 34, 39
9Operationoperator: 13
operands: 14
10ExprTuple44, 15
11Literal
12ExprTuple47, 15
13Literal
14ExprTuple16, 17
15Literal
16Operationoperator: 26
operand: 20
17Operationoperator: 26
operand: 21
18ExprTuple20
19ExprTuple21
20Lambdaparameters: 35
body: 22
21Lambdaparameters: 40
body: 23
22Conditionalvalue: 24
condition: 31
23Conditionalvalue: 36
condition: 25
24Operationoperator: 26
operand: 30
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple30
28Literal
29ExprTuple31, 37
30Lambdaparameters: 32
body: 33
31Operationoperator: 34
operands: 35
32ExprTuple42
33Conditionalvalue: 36
condition: 37
34Variable
35ExprTuple41
36Operationoperator: 38
operands: 40
37Operationoperator: 39
operands: 40
38Variable
39Variable
40ExprTuple41, 42
41ExprRangelambda_map: 43
start_index: 46
end_index: 44
42ExprRangelambda_map: 45
start_index: 46
end_index: 47
43Lambdaparameter: 53
body: 48
44Variable
45Lambdaparameter: 53
body: 49
46Literal
47Variable
48IndexedVarvariable: 50
index: 53
49IndexedVarvariable: 51
index: 53
50Variable
51Variable
52ExprTuple53
53Variable