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 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(x, 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(x ~\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, 25
2Conditionalvalue: 3
condition: 4
3Operationoperator: 19
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12
8Lambdaparameter: 27
body: 14
9Operationoperator: 15
operands: 16
10Operationoperator: 19
operands: 17
11Operationoperator: 19
operands: 18
12Operationoperator: 19
operands: 20
13ExprTuple27
14Operationoperator: 21
operands: 22
15Literal
16ExprTuple23, 24
17ExprTuple31, 26
18ExprTuple32, 26
19Literal
20ExprTuple25, 26
21Literal
22ExprTuple27, 37
23Operationoperator: 29
operands: 28
24Operationoperator: 29
operands: 30
25Variable
26Literal
27Variable
28ExprTuple31, 32
29Literal
30ExprTuple33, 34
31Variable
32Variable
33Literal
34Operationoperator: 35
operands: 36
35Literal
36ExprTuple37, 38
37Variable
38Operationoperator: 39
operand: 41
39Literal
40ExprTuple41
41Literal