logo

Expression of type Lambda

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, 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 = 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(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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 48
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 8
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8
6Literal
7ExprTuple9, 10
8Lambdaparameter: 42
body: 12
9Operationoperator: 40
operands: 13
10Operationoperator: 40
operands: 14
11ExprTuple42
12Conditionalvalue: 15
condition: 16
13ExprTuple49, 17
14ExprTuple50, 17
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22, 23
20Literal
21ExprTuple49, 24
22Operationoperator: 25
operand: 31
23Operationoperator: 27
operands: 28
24Operationoperator: 29
operands: 30
25Literal
26ExprTuple31
27Literal
28ExprTuple32
29Literal
30ExprTuple50, 33
31Lambdaparameter: 44
body: 34
32ExprRangelambda_map: 35
start_index: 49
end_index: 50
33Literal
34Conditionalvalue: 36
condition: 37
35Lambdaparameter: 46
body: 38
36Operationoperator: 42
operand: 44
37Operationoperator: 40
operands: 41
38Operationoperator: 42
operand: 46
39ExprTuple44
40Literal
41ExprTuple44, 45
42Variable
43ExprTuple46
44Variable
45Operationoperator: 47
operands: 48
46Variable
47Literal
48ExprTuple49, 50
49Variable
50Variable