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, N, a, b, c, x
from proveit.logic import And, Bijections, InSet
from proveit.numbers import Add, Integer, Interval, Mod, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
expr = Lambda([a, b, c], Conditional(InSet(Lambda(x, Mod(Add(x, c), N)), Bijections(Interval(a, b), Interval(zero, subtract(N, one)))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, 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(a, b, c\right) \mapsto \left\{\left[x \mapsto \left(\left(x + c\right) ~\textup{mod}~ N\right)\right] \in \left[\{a~\ldotp \ldotp~b\} \xrightarrow[\text{onto}]{\text{1-to-1}} \{0~\ldotp \ldotp~N - 1\}\right] \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \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
1ExprTuple31, 32, 36
2Conditionalvalue: 3
condition: 4
3Operationoperator: 19
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12
8Lambdaparameter: 35
body: 14
9Operationoperator: 15
operands: 16
10Operationoperator: 19
operands: 17
11Operationoperator: 19
operands: 18
12Operationoperator: 19
operands: 20
13ExprTuple35
14Operationoperator: 21
operands: 22
15Literal
16ExprTuple23, 24
17ExprTuple31, 25
18ExprTuple32, 25
19Literal
20ExprTuple36, 25
21Literal
22ExprTuple26, 39
23Operationoperator: 28
operands: 27
24Operationoperator: 28
operands: 29
25Literal
26Operationoperator: 37
operands: 30
27ExprTuple31, 32
28Literal
29ExprTuple33, 34
30ExprTuple35, 36
31Variable
32Variable
33Literal
34Operationoperator: 37
operands: 38
35Variable
36Variable
37Literal
38ExprTuple39, 40
39Variable
40Operationoperator: 41
operand: 43
41Literal
42ExprTuple43
43Literal