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, x
from proveit.logic import And, Card, Equals, InSet, SetOfAll
from proveit.numbers import Integer, Interval, Mod, greater_eq, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
expr = Lambda([a, b], Conditional(Equals(SetOfAll(instance_param_or_params = [x], instance_element = Mod(x, N), domain = sub_expr1), Interval(zero, subtract(N, one))), And(InSet(a, Integer), InSet(b, Integer), greater_eq(Card(sub_expr1), N))))
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\right) \mapsto \left\{\left\{x ~\textup{mod}~ N\right\}_{x \in \{a~\ldotp \ldotp~b\}} = \{0~\ldotp \ldotp~N - 1\} \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  |\{a~\ldotp \ldotp~b\}| \geq N\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 45
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12
8Operationoperator: 13
operand: 20
9Operationoperator: 44
operands: 15
10Operationoperator: 36
operands: 16
11Operationoperator: 36
operands: 17
12Operationoperator: 18
operands: 19
13Literal
14ExprTuple20
15ExprTuple21, 22
16ExprTuple46, 23
17ExprTuple47, 23
18Literal
19ExprTuple40, 24
20Lambdaparameter: 41
body: 26
21Literal
22Operationoperator: 27
operands: 28
23Literal
24Operationoperator: 29
operand: 42
25ExprTuple41
26Conditionalvalue: 31
condition: 32
27Literal
28ExprTuple40, 33
29Literal
30ExprTuple42
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operand: 43
34Literal
35ExprTuple41, 40
36Literal
37ExprTuple41, 42
38Literal
39ExprTuple43
40Variable
41Variable
42Operationoperator: 44
operands: 45
43Literal
44Literal
45ExprTuple46, 47
46Variable
47Variable