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, n
from proveit.core_expr_types import P__y_1_to_n, Q__y_1_to_n, y_1_to_n
from proveit.logic import Forall, InSet
from proveit.logic.booleans.quantification import general_exists_Px_st_Qx
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [P, Q], instance_expr = Forall(instance_param_or_params = [y_1_to_n], instance_expr = general_exists_Px_st_Qx, conditions = [P__y_1_to_n, Q__y_1_to_n])), 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}~\left[\forall_{y_{1}, y_{2}, \ldots, y_{n}~|~P\left(y_{1}, y_{2}, \ldots, y_{n}\right), Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~\left[\exists_{x_{1}, x_{2}, \ldots, x_{n}~|~Q\left(x_{1}, x_{2}, \ldots, x_{n}\right)}~P\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right]\right] \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: 10
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple36, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple28, 29
9Operationoperator: 10
operand: 12
10Literal
11ExprTuple12
12Lambdaparameters: 24
body: 13
13Conditionalvalue: 14
condition: 15
14Operationoperator: 16
operand: 20
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20
18Literal
19ExprTuple21, 22
20Lambdaparameters: 30
body: 23
21Operationoperator: 28
operands: 24
22Operationoperator: 29
operands: 24
23Conditionalvalue: 25
condition: 26
24ExprTuple27
25Operationoperator: 28
operands: 30
26Operationoperator: 29
operands: 30
27ExprRangelambda_map: 31
start_index: 35
end_index: 36
28Variable
29Variable
30ExprTuple32
31Lambdaparameter: 41
body: 33
32ExprRangelambda_map: 34
start_index: 35
end_index: 36
33IndexedVarvariable: 37
index: 41
34Lambdaparameter: 41
body: 38
35Literal
36Variable
37Variable
38IndexedVarvariable: 39
index: 41
39Variable
40ExprTuple41
41Variable