logo

Expression of type Conditional

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 Conditional, ExprRange, Function, P, Pk, Variable, i, j, k
from proveit.logic import And, Forall, Implies, InSet
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(And(ExprRange(sub_expr1, Function(P, [sub_expr1]), i, j)), Forall(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) \land  P\left(i + 1\right) \land  \ldots \land  P\left(j\right)\right) \Rightarrow \left[\forall_{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: 19
operand: 5
2Operationoperator: 17
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameter: 29
body: 9
6Operationoperator: 31
operands: 10
7Operationoperator: 31
operands: 11
8ExprTuple29
9Operationoperator: 12
operands: 13
10ExprTuple38, 14
11ExprTuple39, 14
12Literal
13ExprTuple15, 16
14Literal
15Operationoperator: 17
operands: 18
16Operationoperator: 19
operand: 22
17Literal
18ExprTuple21
19Literal
20ExprTuple22
21ExprRangelambda_map: 23
start_index: 38
end_index: 39
22Lambdaparameter: 34
body: 24
23Lambdaparameter: 33
body: 25
24Conditionalvalue: 26
condition: 27
25Operationoperator: 29
operand: 33
26Operationoperator: 29
operand: 34
27Operationoperator: 31
operands: 32
28ExprTuple33
29Variable
30ExprTuple34
31Literal
32ExprTuple34, 35
33Variable
34Variable
35Operationoperator: 36
operands: 37
36Literal
37ExprTuple38, 39
38Variable
39Variable