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, Card, Equals, InSet, SetOfAll
from proveit.numbers import Add, Integer, Interval, Mod, greater_eq
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
expr = Lambda([a, b, c], Conditional(Equals(Card(SetOfAll(instance_param_or_params = [x], instance_element = Mod(Add(c, x), N), domain = sub_expr1)), N), And(InSet(a, Integer), InSet(b, Integer), InSet(c, 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, c\right) \mapsto \left\{|\left\{\left(c + x\right) ~\textup{mod}~ N\right\}_{x \in \{a~\ldotp \ldotp~b\}}| = N \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \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: 1
body: 2
1ExprTuple45, 46, 43
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 37
7Literal
8ExprTuple10, 11, 12, 13
9Operationoperator: 25
operand: 20
10Operationoperator: 34
operands: 15
11Operationoperator: 34
operands: 16
12Operationoperator: 34
operands: 17
13Operationoperator: 18
operands: 19
14ExprTuple20
15ExprTuple45, 21
16ExprTuple46, 21
17ExprTuple43, 21
18Literal
19ExprTuple37, 22
20Operationoperator: 23
operand: 27
21Literal
22Operationoperator: 25
operand: 38
23Literal
24ExprTuple27
25Literal
26ExprTuple38
27Lambdaparameter: 44
body: 29
28ExprTuple44
29Conditionalvalue: 30
condition: 31
30Operationoperator: 32
operands: 33
31Operationoperator: 34
operands: 35
32Literal
33ExprTuple36, 37
34Literal
35ExprTuple44, 38
36Operationoperator: 39
operands: 40
37Variable
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple43, 44
41Literal
42ExprTuple45, 46
43Variable
44Variable
45Variable
46Variable