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 Integer, Interval
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(Or(ExprRange(sub_expr1, Function(P, [sub_expr1]), i, j)), Exists(instance_param_or_params = [k], instance_expr = Pk, domain = Interval(i, j)))), 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}~\left(\left(P\left(i\right) \lor  P\left(i + 1\right) \lor  \ldots \lor  P\left(j\right)\right) \Rightarrow \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: 40
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 8
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8
6Literal
7ExprTuple9, 10
8Lambdaparameter: 32
body: 12
9Operationoperator: 34
operands: 13
10Operationoperator: 34
operands: 14
11ExprTuple32
12Operationoperator: 15
operands: 16
13ExprTuple41, 17
14ExprTuple42, 17
15Literal
16ExprTuple18, 19
17Literal
18Operationoperator: 20
operands: 21
19Operationoperator: 22
operand: 25
20Literal
21ExprTuple24
22Literal
23ExprTuple25
24ExprRangelambda_map: 26
start_index: 41
end_index: 42
25Lambdaparameter: 37
body: 27
26Lambdaparameter: 36
body: 28
27Conditionalvalue: 29
condition: 30
28Operationoperator: 32
operand: 36
29Operationoperator: 32
operand: 37
30Operationoperator: 34
operands: 35
31ExprTuple36
32Variable
33ExprTuple37
34Literal
35ExprTuple37, 38
36Variable
37Variable
38Operationoperator: 39
operands: 40
39Literal
40ExprTuple41, 42
41Variable
42Variable