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 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 = Implies(Forall(instance_param_or_params = [k], instance_expr = Pk, domain = Interval(i, j)), And(ExprRange(sub_expr1, Function(P, [sub_expr1]), 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[\forall_{k \in \{i~\ldotp \ldotp~j\}}~P\left(k\right)\right] \Rightarrow \left(P\left(i\right) \land  P\left(i + 1\right) \land  \ldots \land  P\left(j\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: 23
operand: 6
3Operationoperator: 25
operands: 5
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 40
body: 10
7Operationoperator: 38
operands: 11
8Operationoperator: 38
operands: 12
9ExprTuple40
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
operand: 29
21Operationoperator: 25
operands: 26
22Operationoperator: 27
operands: 28
23Literal
24ExprTuple29
25Literal
26ExprTuple30
27Literal
28ExprTuple48, 31
29Lambdaparameter: 42
body: 32
30ExprRangelambda_map: 33
start_index: 47
end_index: 48
31Literal
32Conditionalvalue: 34
condition: 35
33Lambdaparameter: 44
body: 36
34Operationoperator: 40
operand: 42
35Operationoperator: 38
operands: 39
36Operationoperator: 40
operand: 44
37ExprTuple42
38Literal
39ExprTuple42, 43
40Variable
41ExprTuple44
42Variable
43Operationoperator: 45
operands: 46
44Variable
45Literal
46ExprTuple47, 48
47Variable
48Variable