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, Equals, Forall
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 = Conditional(Equals(And(ExprRange(sub_expr1, Function(P, [sub_expr1]), i, j)), Forall(instance_param_or_params = [k], instance_expr = Pk, domain = Interval(i, j))), 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())
\left\{\left(P\left(i\right) \land  P\left(i + 1\right) \land  \ldots \land  P\left(j\right)\right) = \left[\forall_{k \in \{i~\ldotp \ldotp~j\}}~P\left(k\right)\right] \textrm{ if } i \leq \left(j + 1\right)\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
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple34, 9
7Operationoperator: 10
operands: 11
8Operationoperator: 12
operand: 17
9Operationoperator: 14
operands: 15
10Literal
11ExprTuple16
12Literal
13ExprTuple17
14Literal
15ExprTuple35, 18
16ExprRangelambda_map: 19
start_index: 34
end_index: 35
17Lambdaparameter: 30
body: 20
18Literal
19Lambdaparameter: 29
body: 21
20Conditionalvalue: 22
condition: 23
21Operationoperator: 25
operand: 29
22Operationoperator: 25
operand: 30
23Operationoperator: 27
operands: 28
24ExprTuple29
25Variable
26ExprTuple30
27Literal
28ExprTuple30, 31
29Variable
30Variable
31Operationoperator: 32
operands: 33
32Literal
33ExprTuple34, 35
34Variable
35Variable