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 Add, Integer, Interval, LessEq, one
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(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))), 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~|~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) \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: 22
operand: 5
2Operationoperator: 24
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameter: 39
body: 9
6Operationoperator: 37
operands: 10
7Operationoperator: 37
operands: 11
8ExprTuple39
9Conditionalvalue: 12
condition: 13
10ExprTuple46, 14
11ExprTuple47, 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14Literal
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple46, 21
19Operationoperator: 22
operand: 28
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Literal
23ExprTuple28
24Literal
25ExprTuple29
26Literal
27ExprTuple47, 30
28Lambdaparameter: 41
body: 31
29ExprRangelambda_map: 32
start_index: 46
end_index: 47
30Literal
31Conditionalvalue: 33
condition: 34
32Lambdaparameter: 43
body: 35
33Operationoperator: 39
operand: 41
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operand: 43
36ExprTuple41
37Literal
38ExprTuple41, 42
39Variable
40ExprTuple43
41Variable
42Operationoperator: 44
operands: 45
43Variable
44Literal
45ExprTuple46, 47
46Variable
47Variable