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 P, Q, R
from proveit.logic import Forall, Implies
from proveit.logic.booleans.quantification import general_exists_Py_st_Qy, general_exists_Rz_st_Qz, general_forall_st_Qx__Px_implies_Rx
In [2]:
# build up the expression from sub-expressions
expr = 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))
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, 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)
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: 8
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple33, 36, 35
4Operationoperator: 22
operands: 5
5ExprTuple6, 7
6Operationoperator: 8
operand: 11
7Operationoperator: 22
operands: 10
8Literal
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameters: 32
body: 14
12Operationoperator: 16
operand: 20
13Operationoperator: 16
operand: 21
14Conditionalvalue: 18
condition: 19
15ExprTuple20
16Literal
17ExprTuple21
18Operationoperator: 22
operands: 23
19Operationoperator: 36
operands: 32
20Lambdaparameters: 34
body: 24
21Lambdaparameters: 37
body: 25
22Literal
23ExprTuple26, 27
24Conditionalvalue: 28
condition: 29
25Conditionalvalue: 30
condition: 31
26Operationoperator: 33
operands: 32
27Operationoperator: 35
operands: 32
28Operationoperator: 33
operands: 34
29Operationoperator: 36
operands: 34
30Operationoperator: 35
operands: 37
31Operationoperator: 36
operands: 37
32ExprTuple38
33Variable
34ExprTuple39
35Variable
36Variable
37ExprTuple40
38ExprRangelambda_map: 41
start_index: 44
end_index: 45
39ExprRangelambda_map: 42
start_index: 44
end_index: 45
40ExprRangelambda_map: 43
start_index: 44
end_index: 45
41Lambdaparameter: 53
body: 46
42Lambdaparameter: 53
body: 47
43Lambdaparameter: 53
body: 48
44Literal
45Variable
46IndexedVarvariable: 49
index: 53
47IndexedVarvariable: 50
index: 53
48IndexedVarvariable: 51
index: 53
49Variable
50Variable
51Variable
52ExprTuple53
53Variable