logo

Expression of type Forall

from the theory of proveit.logic.booleans.disjunction

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 Exists, Forall, Implies, Or
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(Exists(instance_param_or_params = [k], instance_expr = Pk, domain = Interval(i, j)), Or(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[\exists_{k \in \{i~\ldotp \ldotp~j\}}~P\left(k\right)\right] \Rightarrow \left(P\left(i\right) \lor  P\left(i + 1\right) \lor  \ldots \lor  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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 32
body: 5
4ExprTuple32
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple39, 14
12Operationoperator: 15
operand: 21
13Operationoperator: 17
operands: 18
14Operationoperator: 19
operands: 20
15Literal
16ExprTuple21
17Literal
18ExprTuple22
19Literal
20ExprTuple40, 23
21Lambdaparameter: 34
body: 24
22ExprRangelambda_map: 25
start_index: 39
end_index: 40
23Literal
24Conditionalvalue: 26
condition: 27
25Lambdaparameter: 36
body: 28
26Operationoperator: 32
operand: 34
27Operationoperator: 30
operands: 31
28Operationoperator: 32
operand: 36
29ExprTuple34
30Literal
31ExprTuple34, 35
32Variable
33ExprTuple36
34Variable
35Operationoperator: 37
operands: 38
36Variable
37Literal
38ExprTuple39, 40
39Variable
40Variable