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.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 = 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())
\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}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()(1)('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 13
operand: 7
4Operationoperator: 13
operand: 8
5ExprTuple7
6ExprTuple8
7Lambdaparameters: 22
body: 9
8Lambdaparameters: 27
body: 10
9Conditionalvalue: 11
condition: 18
10Conditionalvalue: 23
condition: 12
11Operationoperator: 13
operand: 17
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17
15Literal
16ExprTuple18, 24
17Lambdaparameters: 19
body: 20
18Operationoperator: 21
operands: 22
19ExprTuple29
20Conditionalvalue: 23
condition: 24
21Variable
22ExprTuple28
23Operationoperator: 25
operands: 27
24Operationoperator: 26
operands: 27
25Variable
26Variable
27ExprTuple28, 29
28ExprRangelambda_map: 30
start_index: 33
end_index: 31
29ExprRangelambda_map: 32
start_index: 33
end_index: 34
30Lambdaparameter: 40
body: 35
31Variable
32Lambdaparameter: 40
body: 36
33Literal
34Variable
35IndexedVarvariable: 37
index: 40
36IndexedVarvariable: 38
index: 40
37Variable
38Variable
39ExprTuple40
40Variable