logo

Expression of type Lambda

from the theory of proveit.numbers.modular

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, c
from proveit.logic import And, InSet, NotEquals
from proveit.numbers import Abs, Add, LessEq, Mod, ModAbs, Real, subtract, zero
In [2]:
# build up the expression from sub-expressions
expr = Lambda([a, b, c], Conditional(LessEq(ModAbs(subtract(Mod(Add(b, a), c), b), c), Abs(a)), And(InSet(a, Real), InSet(b, Real), InSet(c, Real), NotEquals(c, zero))))
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, c\right) \mapsto \left\{\left|\left(\left(b + a\right) ~\textup{mod}~ c\right) - b\right|_{\textup{mod}\thinspace c} \leq \left|a\right| \textrm{ if } a \in \mathbb{R} ,  b \in \mathbb{R} ,  c \in \mathbb{R} ,  c \neq 0\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
1ExprTuple40, 39, 36
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14
9Operationoperator: 15
operands: 16
10Operationoperator: 17
operand: 40
11Operationoperator: 21
operands: 19
12Operationoperator: 21
operands: 20
13Operationoperator: 21
operands: 22
14Operationoperator: 23
operands: 24
15Literal
16ExprTuple25, 36
17Literal
18ExprTuple40
19ExprTuple40, 26
20ExprTuple39, 26
21Literal
22ExprTuple36, 26
23Literal
24ExprTuple36, 27
25Operationoperator: 37
operands: 28
26Literal
27Literal
28ExprTuple29, 30
29Operationoperator: 31
operands: 32
30Operationoperator: 33
operand: 39
31Literal
32ExprTuple35, 36
33Literal
34ExprTuple39
35Operationoperator: 37
operands: 38
36Variable
37Literal
38ExprTuple39, 40
39Variable
40Variable