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 Bijections, Forall, InSet
from proveit.numbers import Add, Integer, Interval, Mod, NaturalPos, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
expr = Lambda(N, Conditional(Forall(instance_param_or_params = [a, b, c], instance_expr = InSet(Lambda(x, Mod(Add(x, c), N)), Bijections(Interval(a, b), Interval(zero, subtract(N, one)))), domain = Integer), InSet(N, NaturalPos)))
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())
N \mapsto \left\{\forall_{a, b, c \in \mathbb{Z}}~\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]\right) \textrm{ if } N \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 48
body: 2
1ExprTuple48
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 28
operands: 7
5Literal
6ExprTuple8
7ExprTuple48, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple40, 41, 45
11Conditionalvalue: 12
condition: 13
12Operationoperator: 28
operands: 14
13Operationoperator: 15
operands: 16
14ExprTuple17, 18
15Literal
16ExprTuple19, 20, 21
17Lambdaparameter: 44
body: 23
18Operationoperator: 24
operands: 25
19Operationoperator: 28
operands: 26
20Operationoperator: 28
operands: 27
21Operationoperator: 28
operands: 29
22ExprTuple44
23Operationoperator: 30
operands: 31
24Literal
25ExprTuple32, 33
26ExprTuple40, 34
27ExprTuple41, 34
28Literal
29ExprTuple45, 34
30Literal
31ExprTuple35, 48
32Operationoperator: 37
operands: 36
33Operationoperator: 37
operands: 38
34Literal
35Operationoperator: 46
operands: 39
36ExprTuple40, 41
37Literal
38ExprTuple42, 43
39ExprTuple44, 45
40Variable
41Variable
42Literal
43Operationoperator: 46
operands: 47
44Variable
45Variable
46Literal
47ExprTuple48, 49
48Variable
49Operationoperator: 50
operand: 52
50Literal
51ExprTuple52
52Literal