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 Card, Equals, Forall, InSet, SetOfAll
from proveit.numbers import 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], instance_expr = Equals(SetOfAll(instance_param_or_params = [x], instance_element = Mod(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 \in \mathbb{Z}~|~|\{a~\ldotp \ldotp~b\}| \geq N}~\left(\left\{x ~\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: 49
body: 2
1ExprTuple49
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 45
operands: 7
5Literal
6ExprTuple8
7ExprTuple49, 9
8Lambdaparameters: 54
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17, 18
15Literal
16ExprTuple19, 20, 21
17Operationoperator: 22
operand: 29
18Operationoperator: 53
operands: 24
19Operationoperator: 45
operands: 25
20Operationoperator: 45
operands: 26
21Operationoperator: 27
operands: 28
22Literal
23ExprTuple29
24ExprTuple30, 31
25ExprTuple55, 32
26ExprTuple56, 32
27Literal
28ExprTuple49, 33
29Lambdaparameter: 50
body: 35
30Literal
31Operationoperator: 36
operands: 37
32Literal
33Operationoperator: 38
operand: 51
34ExprTuple50
35Conditionalvalue: 40
condition: 41
36Literal
37ExprTuple49, 42
38Literal
39ExprTuple51
40Operationoperator: 43
operands: 44
41Operationoperator: 45
operands: 46
42Operationoperator: 47
operand: 52
43Literal
44ExprTuple50, 49
45Literal
46ExprTuple50, 51
47Literal
48ExprTuple52
49Variable
50Variable
51Operationoperator: 53
operands: 54
52Literal
53Literal
54ExprTuple55, 56
55Variable
56Variable