logo

Expression of type Lambda

from the theory of proveit.logic.booleans.conjunction

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, Forall, Implies, InSet
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(And(ExprRange(sub_expr1, Function(P, [sub_expr1]), i, j)), Forall(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) \land  P\left(i + 1\right) \land  \ldots \land  P\left(j\right)\right) \Rightarrow \left[\forall_{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: 38
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 20
operand: 6
3Operationoperator: 18
operands: 5
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 30
body: 10
7Operationoperator: 32
operands: 11
8Operationoperator: 32
operands: 12
9ExprTuple30
10Operationoperator: 13
operands: 14
11ExprTuple39, 15
12ExprTuple40, 15
13Literal
14ExprTuple16, 17
15Literal
16Operationoperator: 18
operands: 19
17Operationoperator: 20
operand: 23
18Literal
19ExprTuple22
20Literal
21ExprTuple23
22ExprRangelambda_map: 24
start_index: 39
end_index: 40
23Lambdaparameter: 35
body: 25
24Lambdaparameter: 34
body: 26
25Conditionalvalue: 27
condition: 28
26Operationoperator: 30
operand: 34
27Operationoperator: 30
operand: 35
28Operationoperator: 32
operands: 33
29ExprTuple34
30Variable
31ExprTuple35
32Literal
33ExprTuple35, 36
34Variable
35Variable
36Operationoperator: 37
operands: 38
37Literal
38ExprTuple39, 40
39Variable
40Variable