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, LessEq, Mod, NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
sub_expr2 = Card(sub_expr1)
expr = Lambda(N, Conditional(Forall(instance_param_or_params = [a, b], instance_expr = Equals(Card(SetOfAll(instance_param_or_params = [x], instance_element = Mod(x, N), domain = sub_expr1)), sub_expr2), domain = Integer, condition = LessEq(sub_expr2, 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\}| \leq N}~\left(|\left\{x ~\textup{mod}~ N\right\}_{x \in \{a~\ldotp \ldotp~b\}}| = |\{a~\ldotp \ldotp~b\}|\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: 42
body: 2
1ExprTuple42
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 40
operands: 7
5Literal
6ExprTuple8
7ExprTuple42, 9
8Lambdaparameters: 46
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17, 28
15Literal
16ExprTuple18, 19, 20
17Operationoperator: 31
operand: 26
18Operationoperator: 40
operands: 22
19Operationoperator: 40
operands: 23
20Operationoperator: 24
operands: 25
21ExprTuple26
22ExprTuple47, 27
23ExprTuple48, 27
24Literal
25ExprTuple28, 42
26Operationoperator: 29
operand: 33
27Literal
28Operationoperator: 31
operand: 44
29Literal
30ExprTuple33
31Literal
32ExprTuple44
33Lambdaparameter: 43
body: 35
34ExprTuple43
35Conditionalvalue: 36
condition: 37
36Operationoperator: 38
operands: 39
37Operationoperator: 40
operands: 41
38Literal
39ExprTuple43, 42
40Literal
41ExprTuple43, 44
42Variable
43Variable
44Operationoperator: 45
operands: 46
45Literal
46ExprTuple47, 48
47Variable
48Variable