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, 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 = [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)))
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~|~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)
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: 14
operand: 2
1ExprTuple2
2Lambdaparameter: 31
body: 4
3ExprTuple31
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple38, 13
11Operationoperator: 14
operand: 20
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operands: 19
14Literal
15ExprTuple20
16Literal
17ExprTuple21
18Literal
19ExprTuple39, 22
20Lambdaparameter: 33
body: 23
21ExprRangelambda_map: 24
start_index: 38
end_index: 39
22Literal
23Conditionalvalue: 25
condition: 26
24Lambdaparameter: 35
body: 27
25Operationoperator: 31
operand: 33
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operand: 35
28ExprTuple33
29Literal
30ExprTuple33, 34
31Variable
32ExprTuple35
33Variable
34Operationoperator: 36
operands: 37
35Variable
36Literal
37ExprTuple38, 39
38Variable
39Variable