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, n
from proveit.logic import Forall, Implies, InSet
from proveit.logic.booleans.quantification import general_exists_Py_st_Qy, general_exists_Rz_st_Qz, general_forall_st_Qx__Px_implies_Rx
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_forall_st_Qx__Px_implies_Rx, Implies(general_exists_Py_st_Qy, general_exists_Rz_st_Qz).with_wrapping_at(2)).with_wrapping_at(2)), 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_{n}~|~Q\left(x_{1}, x_{2}, \ldots, x_{n}\right)}~\left(P\left(x_{1}, x_{2}, \ldots, x_{n}\right) \Rightarrow R\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[\exists_{y_{1}, y_{2}, \ldots, y_{n}~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~P\left(y_{1}, y_{2}, \ldots, y_{n}\right)\right] \Rightarrow  \\ \left[\exists_{z_{1}, z_{2}, \ldots, z_{n}~|~Q\left(z_{1}, z_{2}, \ldots, z_{n}\right)}~R\left(z_{1}, z_{2}, \ldots, z_{n}\right)\right] \end{array} \end{array}\right) \end{array} \end{array}\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: 13
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple50, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple38, 41, 40
9Operationoperator: 27
operands: 10
10ExprTuple11, 12
11Operationoperator: 13
operand: 16
12Operationoperator: 27
operands: 15
13Literal
14ExprTuple16
15ExprTuple17, 18
16Lambdaparameters: 37
body: 19
17Operationoperator: 21
operand: 25
18Operationoperator: 21
operand: 26
19Conditionalvalue: 23
condition: 24
20ExprTuple25
21Literal
22ExprTuple26
23Operationoperator: 27
operands: 28
24Operationoperator: 41
operands: 37
25Lambdaparameters: 39
body: 29
26Lambdaparameters: 42
body: 30
27Literal
28ExprTuple31, 32
29Conditionalvalue: 33
condition: 34
30Conditionalvalue: 35
condition: 36
31Operationoperator: 38
operands: 37
32Operationoperator: 40
operands: 37
33Operationoperator: 38
operands: 39
34Operationoperator: 41
operands: 39
35Operationoperator: 40
operands: 42
36Operationoperator: 41
operands: 42
37ExprTuple43
38Variable
39ExprTuple44
40Variable
41Variable
42ExprTuple45
43ExprRangelambda_map: 46
start_index: 49
end_index: 50
44ExprRangelambda_map: 47
start_index: 49
end_index: 50
45ExprRangelambda_map: 48
start_index: 49
end_index: 50
46Lambdaparameter: 58
body: 51
47Lambdaparameter: 58
body: 52
48Lambdaparameter: 58
body: 53
49Literal
50Variable
51IndexedVarvariable: 54
index: 58
52IndexedVarvariable: 55
index: 58
53IndexedVarvariable: 56
index: 58
54Variable
55Variable
56Variable
57ExprTuple58
58Variable