logo

Expression of type Forall

from the theory of proveit.logic.booleans

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, P, PofA, Q, QofA
from proveit.logic import Boolean, Forall, Implies, QimplPofFalse, QimplPofTrue
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [P, Q], instance_expr = Forall(instance_param_or_params = [A], instance_expr = Implies(QofA, PofA), domain = Boolean), conditions = [QimplPofTrue, QimplPofFalse])
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~|~Q\left(\top\right) \Rightarrow P\left(\top\right), Q\left(\bot\right) \Rightarrow P\left(\bot\right)}~\left[\forall_{A \in \mathbb{B}}~\left(Q\left(A\right) \Rightarrow P\left(A\right)\right)\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: 7
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple35, 34
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13
11Lambdaparameter: 37
body: 14
12Operationoperator: 23
operands: 15
13Operationoperator: 23
operands: 16
14Conditionalvalue: 17
condition: 18
15ExprTuple19, 20
16ExprTuple21, 22
17Operationoperator: 23
operands: 24
18Operationoperator: 25
operands: 26
19Operationoperator: 34
operand: 32
20Operationoperator: 35
operand: 32
21Operationoperator: 34
operand: 33
22Operationoperator: 35
operand: 33
23Literal
24ExprTuple29, 30
25Literal
26ExprTuple37, 31
27ExprTuple32
28ExprTuple33
29Operationoperator: 34
operand: 37
30Operationoperator: 35
operand: 37
31Literal
32Literal
33Literal
34Variable
35Variable
36ExprTuple37
37Variable