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, ExprTuple, Lambda, 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 = ExprTuple(Lambda([m, n], 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(\left(m, n\right) \mapsto \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..\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
2ExprTuple47, 50
3Conditionalvalue: 4
condition: 5
4Operationoperator: 29
operand: 8
5Operationoperator: 31
operands: 7
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 14
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple41, 37, 42
12Operationoperator: 16
operands: 17
13ExprTuple47, 18
14Literal
15ExprTuple50, 18
16Literal
17ExprTuple19, 20
18Literal
19Operationoperator: 29
operand: 23
20Operationoperator: 29
operand: 24
21ExprTuple23
22ExprTuple24
23Lambdaparameters: 38
body: 25
24Lambdaparameters: 43
body: 26
25Conditionalvalue: 27
condition: 34
26Conditionalvalue: 39
condition: 28
27Operationoperator: 29
operand: 33
28Operationoperator: 31
operands: 32
29Literal
30ExprTuple33
31Literal
32ExprTuple34, 40
33Lambdaparameters: 35
body: 36
34Operationoperator: 37
operands: 38
35ExprTuple45
36Conditionalvalue: 39
condition: 40
37Variable
38ExprTuple44
39Operationoperator: 41
operands: 43
40Operationoperator: 42
operands: 43
41Variable
42Variable
43ExprTuple44, 45
44ExprRangelambda_map: 46
start_index: 49
end_index: 47
45ExprRangelambda_map: 48
start_index: 49
end_index: 50
46Lambdaparameter: 56
body: 51
47Variable
48Lambdaparameter: 56
body: 52
49Literal
50Variable
51IndexedVarvariable: 53
index: 56
52IndexedVarvariable: 54
index: 56
53Variable
54Variable
55ExprTuple56
56Variable