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
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(Card(SetOfAll(instance_param_or_params = [x], instance_element = Mod(Add(x, c), N), domain = sub_expr1)), N), 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(x + c\right) ~\textup{mod}~ N\right\}_{x \in \{a~\ldotp \ldotp~b\}}| = N\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: 43
operands: 7
5Literal
6ExprTuple8
7ExprTuple46, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple54, 55, 53
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 46
16Literal
17ExprTuple19, 20, 21, 22
18Operationoperator: 34
operand: 29
19Operationoperator: 43
operands: 24
20Operationoperator: 43
operands: 25
21Operationoperator: 43
operands: 26
22Operationoperator: 27
operands: 28
23ExprTuple29
24ExprTuple54, 30
25ExprTuple55, 30
26ExprTuple53, 30
27Literal
28ExprTuple46, 31
29Operationoperator: 32
operand: 36
30Literal
31Operationoperator: 34
operand: 47
32Literal
33ExprTuple36
34Literal
35ExprTuple47
36Lambdaparameter: 52
body: 38
37ExprTuple52
38Conditionalvalue: 39
condition: 40
39Operationoperator: 41
operands: 42
40Operationoperator: 43
operands: 44
41Literal
42ExprTuple45, 46
43Literal
44ExprTuple52, 47
45Operationoperator: 48
operands: 49
46Variable
47Operationoperator: 50
operands: 51
48Literal
49ExprTuple52, 53
50Literal
51ExprTuple54, 55
52Variable
53Variable
54Variable
55Variable