logo

Expression of type Conditional

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 Conditional, ExprRange, Function, P, Pk, Variable, i, j, k
from proveit.logic import And, Exists, Forall, Implies, InSet, Or
from proveit.numbers import Integer, Interval
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Forall(instance_param_or_params = [P], instance_expr = Implies(Or(ExprRange(sub_expr1, Function(P, [sub_expr1]), i, j)), Exists(instance_param_or_params = [k], instance_expr = Pk, domain = Interval(i, j)))), And(InSet(i, Integer), InSet(j, 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())
\left\{\forall_{P}~\left(\left(P\left(i\right) \lor  P\left(i + 1\right) \lor  \ldots \lor  P\left(j\right)\right) \Rightarrow \left[\exists_{k \in \{i~\ldotp \ldotp~j\}}~P\left(k\right)\right]\right) \textrm{ if } i \in \mathbb{Z} ,  j \in \mathbb{Z}\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8, 9
7Lambdaparameter: 31
body: 11
8Operationoperator: 33
operands: 12
9Operationoperator: 33
operands: 13
10ExprTuple31
11Operationoperator: 14
operands: 15
12ExprTuple40, 16
13ExprTuple41, 16
14Literal
15ExprTuple17, 18
16Literal
17Operationoperator: 19
operands: 20
18Operationoperator: 21
operand: 24
19Literal
20ExprTuple23
21Literal
22ExprTuple24
23ExprRangelambda_map: 25
start_index: 40
end_index: 41
24Lambdaparameter: 36
body: 26
25Lambdaparameter: 35
body: 27
26Conditionalvalue: 28
condition: 29
27Operationoperator: 31
operand: 35
28Operationoperator: 31
operand: 36
29Operationoperator: 33
operands: 34
30ExprTuple35
31Variable
32ExprTuple36
33Literal
34ExprTuple36, 37
35Variable
36Variable
37Operationoperator: 38
operands: 39
38Literal
39ExprTuple40, 41
40Variable
41Variable