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, Lambda, P, Q, R
from proveit.logic import Implies
from proveit.logic.booleans.quantification import general_bundled_forall_Pxy_if_Qx, general_nested_forall_Pxy_if_Qx
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([P, Q, R], Implies(general_nested_forall_Pxy_if_Qx, general_bundled_forall_Pxy_if_Qx).with_wrapping_at(1)))
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(\left(P, Q, R\right) \mapsto \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)\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple28, 24, 29
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 16
operand: 10
7Operationoperator: 16
operand: 11
8ExprTuple10
9ExprTuple11
10Lambdaparameters: 25
body: 12
11Lambdaparameters: 30
body: 13
12Conditionalvalue: 14
condition: 21
13Conditionalvalue: 26
condition: 15
14Operationoperator: 16
operand: 20
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20
18Literal
19ExprTuple21, 27
20Lambdaparameters: 22
body: 23
21Operationoperator: 24
operands: 25
22ExprTuple32
23Conditionalvalue: 26
condition: 27
24Variable
25ExprTuple31
26Operationoperator: 28
operands: 30
27Operationoperator: 29
operands: 30
28Variable
29Variable
30ExprTuple31, 32
31ExprRangelambda_map: 33
start_index: 36
end_index: 34
32ExprRangelambda_map: 35
start_index: 36
end_index: 37
33Lambdaparameter: 43
body: 38
34Variable
35Lambdaparameter: 43
body: 39
36Literal
37Variable
38IndexedVarvariable: 40
index: 43
39IndexedVarvariable: 41
index: 43
40Variable
41Variable
42ExprTuple43
43Variable