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, Equals, Exists, Forall, 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 = Equals(Or(ExprRange(sub_expr1, Function(P, [sub_expr1]), i, j)), Exists(instance_param_or_params = [k], instance_expr = Pk, domain = Interval(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(P\left(i\right) \lor  P\left(i + 1\right) \lor  \ldots \lor  P\left(j\right)\right) = \left[\exists_{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()
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: 40
body: 12
9Operationoperator: 42
operands: 13
10Operationoperator: 42
operands: 14
11ExprTuple40
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
operands: 26
23Operationoperator: 27
operand: 32
24Operationoperator: 29
operands: 30
25Literal
26ExprTuple31
27Literal
28ExprTuple32
29Literal
30ExprTuple50, 33
31ExprRangelambda_map: 34
start_index: 49
end_index: 50
32Lambdaparameter: 45
body: 35
33Literal
34Lambdaparameter: 44
body: 36
35Conditionalvalue: 37
condition: 38
36Operationoperator: 40
operand: 44
37Operationoperator: 40
operand: 45
38Operationoperator: 42
operands: 43
39ExprTuple44
40Variable
41ExprTuple45
42Literal
43ExprTuple45, 46
44Variable
45Variable
46Operationoperator: 47
operands: 48
47Literal
48ExprTuple49, 50
49Variable
50Variable