logo

Expression of type Lambda

from the theory of proveit.numbers.number_sets.real_numbers

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, Lambda, a, b, x, y
from proveit.logic import And, Equals, Implies, InSet
from proveit.numbers import Add, Integer, IntervalOO, LessEq, RealPos, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Lambda([a, b, x, y], Conditional(Implies(InSet(y, IntervalOO(subtract(x, a), Add(x, b))), Equals(y, x)), And(InSet(a, RealPos), InSet(b, RealPos), InSet(x, Integer), InSet(y, Integer), LessEq(a, one), LessEq(b, 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())
\left(a, b, x, y\right) \mapsto \left\{\left(y \in \left(x - a,x + b\right)\right) \Rightarrow \left(y = x\right) \textrm{ if } a \in \mathbb{R}^+ ,  b \in \mathbb{R}^+ ,  x \in \mathbb{Z} ,  y \in \mathbb{Z} ,  a \leq 1 ,  b \leq 1\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
1ExprTuple45, 42, 41, 30
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14, 15, 16
9Operationoperator: 23
operands: 17
10Operationoperator: 18
operands: 19
11Operationoperator: 23
operands: 20
12Operationoperator: 23
operands: 21
13Operationoperator: 23
operands: 22
14Operationoperator: 23
operands: 24
15Operationoperator: 26
operands: 25
16Operationoperator: 26
operands: 27
17ExprTuple30, 28
18Literal
19ExprTuple30, 41
20ExprTuple45, 29
21ExprTuple42, 29
22ExprTuple41, 31
23Literal
24ExprTuple30, 31
25ExprTuple45, 32
26Literal
27ExprTuple42, 32
28Operationoperator: 33
operands: 34
29Literal
30Variable
31Literal
32Literal
33Literal
34ExprTuple35, 36
35Operationoperator: 38
operands: 37
36Operationoperator: 38
operands: 39
37ExprTuple41, 40
38Literal
39ExprTuple41, 42
40Operationoperator: 43
operand: 45
41Variable
42Variable
43Literal
44ExprTuple45
45Variable