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 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(x, 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(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]\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: 46
body: 2
1ExprTuple46
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 28
operands: 7
5Literal
6ExprTuple8
7ExprTuple46, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple40, 41, 34
11Conditionalvalue: 12
condition: 13
12Operationoperator: 28
operands: 14
13Operationoperator: 15
operands: 16
14ExprTuple17, 18
15Literal
16ExprTuple19, 20, 21
17Lambdaparameter: 36
body: 23
18Operationoperator: 24
operands: 25
19Operationoperator: 28
operands: 26
20Operationoperator: 28
operands: 27
21Operationoperator: 28
operands: 29
22ExprTuple36
23Operationoperator: 30
operands: 31
24Literal
25ExprTuple32, 33
26ExprTuple40, 35
27ExprTuple41, 35
28Literal
29ExprTuple34, 35
30Literal
31ExprTuple36, 46
32Operationoperator: 38
operands: 37
33Operationoperator: 38
operands: 39
34Variable
35Literal
36Variable
37ExprTuple40, 41
38Literal
39ExprTuple42, 43
40Variable
41Variable
42Literal
43Operationoperator: 44
operands: 45
44Literal
45ExprTuple46, 47
46Variable
47Operationoperator: 48
operand: 50
48Literal
49ExprTuple50
50Literal