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 A, Conditional, ExprRange, Lambda, Variable, i, j
from proveit.logic import And, Forall, InSet
from proveit.numbers import Add, Integer, LessEq, one
In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, j], Conditional(Forall(instance_param_or_params = [A], instance_expr = And(ExprRange(Variable("_a", latex_format = r"{_{-}a}"), A, i, j)), conditions = [A, 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_{A~|~A, i \leq \left(j + 1\right)}~\left(A \land  A \land  ..\left(j - i - 2\right) \times.. \land  A\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: 1
body: 2
1ExprTuple29, 34
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 20
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameter: 28
body: 12
9Operationoperator: 14
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple28
12Conditionalvalue: 16
condition: 17
13ExprTuple29, 18
14Literal
15ExprTuple34, 18
16Operationoperator: 20
operands: 19
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22
20Literal
21ExprTuple28, 23
22ExprRangelambda_map: 24
start_index: 29
end_index: 34
23Operationoperator: 25
operands: 26
24Lambdaparameter: 31
body: 28
25Literal
26ExprTuple29, 30
27ExprTuple31
28Variable
29Variable
30Operationoperator: 32
operands: 33
31Variable
32Literal
33ExprTuple34, 35
34Variable
35Literal