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
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(Equals(And(ExprRange(sub_expr1, Function(P, [sub_expr1]), i, j)), Forall(instance_param_or_params = [k], instance_expr = Pk, domain = Interval(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(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] \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: 27
body: 2
1ExprTuple27
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple36, 11
9Operationoperator: 12
operands: 13
10Operationoperator: 14
operand: 19
11Operationoperator: 16
operands: 17
12Literal
13ExprTuple18
14Literal
15ExprTuple19
16Literal
17ExprTuple37, 20
18ExprRangelambda_map: 21
start_index: 36
end_index: 37
19Lambdaparameter: 32
body: 22
20Literal
21Lambdaparameter: 31
body: 23
22Conditionalvalue: 24
condition: 25
23Operationoperator: 27
operand: 31
24Operationoperator: 27
operand: 32
25Operationoperator: 29
operands: 30
26ExprTuple31
27Variable
28ExprTuple32
29Literal
30ExprTuple32, 33
31Variable
32Variable
33Operationoperator: 34
operands: 35
34Literal
35ExprTuple36, 37
36Variable
37Variable