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 Card, Equals, Forall, InSet, SetOfAll
from proveit.numbers import Add, Integer, Interval, Mod, NaturalPos, greater_eq, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
expr = Lambda(N, Conditional(Forall(instance_param_or_params = [a, b, c], instance_expr = Equals(SetOfAll(instance_param_or_params = [x], instance_element = Mod(Add(c, x), N), domain = sub_expr1), Interval(zero, subtract(N, one))), domain = Integer, condition = greater_eq(Card(sub_expr1), N)), 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}~|~|\{a~\ldotp \ldotp~b\}| \geq N}~\left(\left\{\left(c + x\right) ~\textup{mod}~ N\right\}_{x \in \{a~\ldotp \ldotp~b\}} = \{0~\ldotp \ldotp~N - 1\}\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: 52
body: 2
1ExprTuple52
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 47
operands: 7
5Literal
6ExprTuple8
7ExprTuple52, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple61, 62, 59
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple20, 21, 22, 23
18Operationoperator: 24
operand: 32
19Operationoperator: 57
operands: 26
20Operationoperator: 47
operands: 27
21Operationoperator: 47
operands: 28
22Operationoperator: 47
operands: 29
23Operationoperator: 30
operands: 31
24Literal
25ExprTuple32
26ExprTuple33, 34
27ExprTuple61, 35
28ExprTuple62, 35
29ExprTuple59, 35
30Literal
31ExprTuple52, 36
32Lambdaparameter: 60
body: 38
33Literal
34Operationoperator: 55
operands: 39
35Literal
36Operationoperator: 40
operand: 53
37ExprTuple60
38Conditionalvalue: 42
condition: 43
39ExprTuple52, 44
40Literal
41ExprTuple53
42Operationoperator: 45
operands: 46
43Operationoperator: 47
operands: 48
44Operationoperator: 49
operand: 54
45Literal
46ExprTuple51, 52
47Literal
48ExprTuple60, 53
49Literal
50ExprTuple54
51Operationoperator: 55
operands: 56
52Variable
53Operationoperator: 57
operands: 58
54Literal
55Literal
56ExprTuple59, 60
57Literal
58ExprTuple61, 62
59Variable
60Variable
61Variable
62Variable