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, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
expr = Lambda([a, b, c], Conditional(Equals(SetOfAll(instance_param_or_params = [x], instance_element = Mod(Add(c, x), N), domain = sub_expr1), Interval(zero, subtract(N, one))), 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\}} = \{0~\ldotp \ldotp~N - 1\} \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
1ExprTuple52, 53, 50
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14
9Operationoperator: 15
operand: 23
10Operationoperator: 48
operands: 17
11Operationoperator: 38
operands: 18
12Operationoperator: 38
operands: 19
13Operationoperator: 38
operands: 20
14Operationoperator: 21
operands: 22
15Literal
16ExprTuple23
17ExprTuple24, 25
18ExprTuple52, 26
19ExprTuple53, 26
20ExprTuple50, 26
21Literal
22ExprTuple43, 27
23Lambdaparameter: 51
body: 29
24Literal
25Operationoperator: 46
operands: 30
26Literal
27Operationoperator: 31
operand: 44
28ExprTuple51
29Conditionalvalue: 33
condition: 34
30ExprTuple43, 35
31Literal
32ExprTuple44
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operand: 45
36Literal
37ExprTuple42, 43
38Literal
39ExprTuple51, 44
40Literal
41ExprTuple45
42Operationoperator: 46
operands: 47
43Variable
44Operationoperator: 48
operands: 49
45Literal
46Literal
47ExprTuple50, 51
48Literal
49ExprTuple52, 53
50Variable
51Variable
52Variable
53Variable