logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(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())
\left(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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 43
body: 3
2ExprTuple43
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 41
operands: 8
6Literal
7ExprTuple9
8ExprTuple43, 10
9Lambdaparameters: 47
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 29
16Literal
17ExprTuple19, 20, 21
18Operationoperator: 32
operand: 27
19Operationoperator: 41
operands: 23
20Operationoperator: 41
operands: 24
21Operationoperator: 25
operands: 26
22ExprTuple27
23ExprTuple48, 28
24ExprTuple49, 28
25Literal
26ExprTuple29, 43
27Operationoperator: 30
operand: 34
28Literal
29Operationoperator: 32
operand: 45
30Literal
31ExprTuple34
32Literal
33ExprTuple45
34Lambdaparameter: 44
body: 36
35ExprTuple44
36Conditionalvalue: 37
condition: 38
37Operationoperator: 39
operands: 40
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple44, 43
41Literal
42ExprTuple44, 45
43Variable
44Variable
45Operationoperator: 46
operands: 47
46Literal
47ExprTuple48, 49
48Variable
49Variable