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 Add, Integer, Interval, LessEq, one
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(Forall(instance_param_or_params = [k], instance_expr = Pk, domain = Interval(i, j)), And(ExprRange(sub_expr1, Function(P, [sub_expr1]), i, j))), condition = LessEq(i, Add(j, one))), 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~|~i \leq \left(j + 1\right)}~\left(\left[\forall_{k \in \{i~\ldotp \ldotp~j\}}~P\left(k\right)\right] \Rightarrow \left(P\left(i\right) \land  P\left(i + 1\right) \land  \ldots \land  P\left(j\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: 25
operand: 2
1ExprTuple2
2Lambdaparameters: 48
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 25
operand: 8
5Operationoperator: 27
operands: 7
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameter: 42
body: 12
9Operationoperator: 40
operands: 13
10Operationoperator: 40
operands: 14
11ExprTuple42
12Conditionalvalue: 15
condition: 16
13ExprTuple49, 17
14ExprTuple50, 17
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22, 23
20Literal
21ExprTuple49, 24
22Operationoperator: 25
operand: 31
23Operationoperator: 27
operands: 28
24Operationoperator: 29
operands: 30
25Literal
26ExprTuple31
27Literal
28ExprTuple32
29Literal
30ExprTuple50, 33
31Lambdaparameter: 44
body: 34
32ExprRangelambda_map: 35
start_index: 49
end_index: 50
33Literal
34Conditionalvalue: 36
condition: 37
35Lambdaparameter: 46
body: 38
36Operationoperator: 42
operand: 44
37Operationoperator: 40
operands: 41
38Operationoperator: 42
operand: 46
39ExprTuple44
40Literal
41ExprTuple44, 45
42Variable
43ExprTuple46
44Variable
45Operationoperator: 47
operands: 48
46Variable
47Literal
48ExprTuple49, 50
49Variable
50Variable