logo

Expression of type ExprTuple

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, ExprTuple, Function, Lambda, P, Pk, Variable, i, j, k
from proveit.logic import And, Exists, Forall, Implies, InSet, Or
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 = ExprTuple(Lambda([i, j], Conditional(Forall(instance_param_or_params = [P], instance_expr = Implies(Exists(instance_param_or_params = [k], instance_expr = Pk, domain = Interval(i, j)), Or(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(\left(i, j\right) \mapsto \left\{\forall_{P~|~i \leq \left(j + 1\right)}~\left(\left[\exists_{k \in \{i~\ldotp \ldotp~j\}}~P\left(k\right)\right] \Rightarrow \left(P\left(i\right) \lor  P\left(i + 1\right) \lor  \ldots \lor  P\left(j\right)\right)\right) \textrm{ if } i \in \mathbb{Z} ,  j \in \mathbb{Z}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 49
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 43
body: 13
10Operationoperator: 41
operands: 14
11Operationoperator: 41
operands: 15
12ExprTuple43
13Conditionalvalue: 16
condition: 17
14ExprTuple50, 18
15ExprTuple51, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18Literal
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple50, 25
23Operationoperator: 26
operand: 32
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operands: 31
26Literal
27ExprTuple32
28Literal
29ExprTuple33
30Literal
31ExprTuple51, 34
32Lambdaparameter: 45
body: 35
33ExprRangelambda_map: 36
start_index: 50
end_index: 51
34Literal
35Conditionalvalue: 37
condition: 38
36Lambdaparameter: 47
body: 39
37Operationoperator: 43
operand: 45
38Operationoperator: 41
operands: 42
39Operationoperator: 43
operand: 47
40ExprTuple45
41Literal
42ExprTuple45, 46
43Variable
44ExprTuple47
45Variable
46Operationoperator: 48
operands: 49
47Variable
48Literal
49ExprTuple50, 51
50Variable
51Variable