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, Equals, Forall, InSet
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(And(ExprRange(sub_expr1, Function(P, [sub_expr1]), i, j)), Forall(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) \land  P\left(i + 1\right) \land  \ldots \land  P\left(j\right)\right) = \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: 46
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 25
operand: 6
3Operationoperator: 23
operands: 5
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 38
body: 10
7Operationoperator: 40
operands: 11
8Operationoperator: 40
operands: 12
9ExprTuple38
10Conditionalvalue: 13
condition: 14
11ExprTuple47, 15
12ExprTuple48, 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Literal
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple47, 22
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operand: 30
22Operationoperator: 27
operands: 28
23Literal
24ExprTuple29
25Literal
26ExprTuple30
27Literal
28ExprTuple48, 31
29ExprRangelambda_map: 32
start_index: 47
end_index: 48
30Lambdaparameter: 43
body: 33
31Literal
32Lambdaparameter: 42
body: 34
33Conditionalvalue: 35
condition: 36
34Operationoperator: 38
operand: 42
35Operationoperator: 38
operand: 43
36Operationoperator: 40
operands: 41
37ExprTuple42
38Variable
39ExprTuple43
40Literal
41ExprTuple43, 44
42Variable
43Variable
44Operationoperator: 45
operands: 46
45Literal
46ExprTuple47, 48
47Variable
48Variable