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, 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 = PofA, domain = Boolean, condition = QofA), 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}~|~Q\left(A\right)}~P\left(A\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
3ExprTuple26, 34
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 23
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameter: 37
body: 13
11Operationoperator: 15
operands: 14
12Operationoperator: 15
operands: 16
13Conditionalvalue: 17
condition: 18
14ExprTuple19, 20
15Literal
16ExprTuple21, 22
17Operationoperator: 26
operand: 37
18Operationoperator: 23
operands: 24
19Operationoperator: 34
operand: 30
20Operationoperator: 26
operand: 30
21Operationoperator: 34
operand: 31
22Operationoperator: 26
operand: 31
23Literal
24ExprTuple28, 29
25ExprTuple30
26Variable
27ExprTuple31
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operand: 37
30Literal
31Literal
32Literal
33ExprTuple37, 36
34Variable
35ExprTuple37
36Literal
37Variable