logo

Expression of type Forall

from the theory of proveit.logic.booleans.quantification.existence

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, P, Q
from proveit.logic import Forall, Implies, SubsetEq
from proveit.logic.booleans.quantification import general_exists_in_A_Px_st_Qx, general_exists_in_B_Py_st_Qy
In [2]:
# build up the expression from sub-expressions
expr = 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))
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())
\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)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple26, 36, 49, 51
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple49, 51
12Operationoperator: 15
operand: 17
13Operationoperator: 15
operand: 18
14ExprTuple17
15Literal
16ExprTuple18
17Lambdaparameters: 34
body: 19
18Lambdaparameters: 37
body: 20
19Conditionalvalue: 21
condition: 22
20Conditionalvalue: 23
condition: 24
21Operationoperator: 26
operands: 34
22Operationoperator: 27
operands: 25
23Operationoperator: 26
operands: 37
24Operationoperator: 27
operands: 28
25ExprTuple29, 30
26Variable
27Literal
28ExprTuple31, 32
29ExprRangelambda_map: 33
start_index: 47
end_index: 48
30Operationoperator: 36
operands: 34
31ExprRangelambda_map: 35
start_index: 47
end_index: 48
32Operationoperator: 36
operands: 37
33Lambdaparameter: 56
body: 38
34ExprTuple39
35Lambdaparameter: 56
body: 40
36Variable
37ExprTuple41
38Operationoperator: 44
operands: 42
39ExprRangelambda_map: 43
start_index: 47
end_index: 48
40Operationoperator: 44
operands: 45
41ExprRangelambda_map: 46
start_index: 47
end_index: 48
42ExprTuple50, 49
43Lambdaparameter: 56
body: 50
44Literal
45ExprTuple52, 51
46Lambdaparameter: 56
body: 52
47Literal
48Variable
49Variable
50IndexedVarvariable: 53
index: 56
51Variable
52IndexedVarvariable: 54
index: 56
53Variable
54Variable
55ExprTuple56
56Variable