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