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 Exists, Implies, Or
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 = Lambda(P, Conditional(Implies(Exists(instance_param_or_params = [k], instance_expr = Pk, domain = Interval(i, j)), Or(ExprRange(sub_expr1, Function(P, [sub_expr1]), 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())
P \mapsto \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) \textrm{ if } i \leq \left(j + 1\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 29
body: 2
1ExprTuple29
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple36, 11
9Operationoperator: 12
operand: 18
10Operationoperator: 14
operands: 15
11Operationoperator: 16
operands: 17
12Literal
13ExprTuple18
14Literal
15ExprTuple19
16Literal
17ExprTuple37, 20
18Lambdaparameter: 31
body: 21
19ExprRangelambda_map: 22
start_index: 36
end_index: 37
20Literal
21Conditionalvalue: 23
condition: 24
22Lambdaparameter: 33
body: 25
23Operationoperator: 29
operand: 31
24Operationoperator: 27
operands: 28
25Operationoperator: 29
operand: 33
26ExprTuple31
27Literal
28ExprTuple31, 32
29Variable
30ExprTuple33
31Variable
32Operationoperator: 34
operands: 35
33Variable
34Literal
35ExprTuple36, 37
36Variable
37Variable