logo

Expression of type Forall

from the theory of proveit.logic.booleans.conjunction

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 ExprRange, Function, P, Pk, Variable, i, j, k
from proveit.logic import And, Forall, Implies
from proveit.numbers import Integer, Interval
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Forall(instance_param_or_params = [i, j], instance_expr = Forall(instance_param_or_params = [P], instance_expr = Implies(And(ExprRange(sub_expr1, Function(P, [sub_expr1]), i, j)), Forall(instance_param_or_params = [k], instance_expr = Pk, domain = Interval(i, j)))), domain = Integer)
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_{i, j \in \mathbb{Z}}~\left[\forall_{P}~\left(\left(P\left(i\right) \land  P\left(i + 1\right) \land  \ldots \land  P\left(j\right)\right) \Rightarrow \left[\forall_{k \in \{i~\ldotp \ldotp~j\}}~P\left(k\right)\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: 22
operand: 2
1ExprTuple2
2Lambdaparameters: 40
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 22
operand: 8
5Operationoperator: 20
operands: 7
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameter: 32
body: 12
9Operationoperator: 34
operands: 13
10Operationoperator: 34
operands: 14
11ExprTuple32
12Operationoperator: 15
operands: 16
13ExprTuple41, 17
14ExprTuple42, 17
15Literal
16ExprTuple18, 19
17Literal
18Operationoperator: 20
operands: 21
19Operationoperator: 22
operand: 25
20Literal
21ExprTuple24
22Literal
23ExprTuple25
24ExprRangelambda_map: 26
start_index: 41
end_index: 42
25Lambdaparameter: 37
body: 27
26Lambdaparameter: 36
body: 28
27Conditionalvalue: 29
condition: 30
28Operationoperator: 32
operand: 36
29Operationoperator: 32
operand: 37
30Operationoperator: 34
operands: 35
31ExprTuple36
32Variable
33ExprTuple37
34Literal
35ExprTuple37, 38
36Variable
37Variable
38Operationoperator: 39
operands: 40
39Literal
40ExprTuple41, 42
41Variable
42Variable