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 A, B, Conditional, P, Q, n
from proveit.logic import Forall, Implies, InSet, SubsetEq
from proveit.logic.booleans.quantification import general_exists_in_A_Px_st_Qx, general_exists_in_B_Py_st_Qy
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [P, Q, A, B], instance_expr = Implies(general_exists_in_A_Px_st_Qx, general_exists_in_B_Py_st_Qy).with_wrapping_at(2), condition = SubsetEq(A, B)), 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, A, B~|~A \subseteq B}~\left(\begin{array}{c} \begin{array}{l} \left[\exists_{x_{1}, x_{2}, \ldots, x_{n} \in A~|~Q\left(x_{1}, x_{2}, \ldots, x_{n}\right)}~P\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right] \Rightarrow  \\ \left[\exists_{y_{1}, y_{2}, \ldots, y_{n} \in B~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~P\left(y_{1}, y_{2}, \ldots, y_{n}\right)\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: 3
operand: 6
2Operationoperator: 48
operands: 5
3Literal
4ExprTuple6
5ExprTuple52, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple30, 40, 53, 55
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operands: 13
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16, 17
14Literal
15ExprTuple53, 55
16Operationoperator: 19
operand: 21
17Operationoperator: 19
operand: 22
18ExprTuple21
19Literal
20ExprTuple22
21Lambdaparameters: 38
body: 23
22Lambdaparameters: 41
body: 24
23Conditionalvalue: 25
condition: 26
24Conditionalvalue: 27
condition: 28
25Operationoperator: 30
operands: 38
26Operationoperator: 31
operands: 29
27Operationoperator: 30
operands: 41
28Operationoperator: 31
operands: 32
29ExprTuple33, 34
30Variable
31Literal
32ExprTuple35, 36
33ExprRangelambda_map: 37
start_index: 51
end_index: 52
34Operationoperator: 40
operands: 38
35ExprRangelambda_map: 39
start_index: 51
end_index: 52
36Operationoperator: 40
operands: 41
37Lambdaparameter: 60
body: 42
38ExprTuple43
39Lambdaparameter: 60
body: 44
40Variable
41ExprTuple45
42Operationoperator: 48
operands: 46
43ExprRangelambda_map: 47
start_index: 51
end_index: 52
44Operationoperator: 48
operands: 49
45ExprRangelambda_map: 50
start_index: 51
end_index: 52
46ExprTuple54, 53
47Lambdaparameter: 60
body: 54
48Literal
49ExprTuple56, 55
50Lambdaparameter: 60
body: 56
51Literal
52Variable
53Variable
54IndexedVarvariable: 57
index: 60
55Variable
56IndexedVarvariable: 58
index: 60
57Variable
58Variable
59ExprTuple60
60Variable