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, c, x
from proveit.logic import And, Card, Equals, InSet, SetOfAll
from proveit.numbers import Add, Integer, Interval, Mod, greater_eq
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
expr = ExprTuple(Lambda([a, b, c], Conditional(Equals(Card(SetOfAll(instance_param_or_params = [x], instance_element = Mod(Add(c, x), N), domain = sub_expr1)), N), And(InSet(a, Integer), InSet(b, Integer), InSet(c, Integer), greater_eq(Card(sub_expr1), N)))))
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(\left(a, b, c\right) \mapsto \left\{|\left\{\left(c + x\right) ~\textup{mod}~ N\right\}_{x \in \{a~\ldotp \ldotp~b\}}| = N \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \in \mathbb{Z} ,  |\{a~\ldotp \ldotp~b\}| \geq 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
1Lambdaparameters: 2
body: 3
2ExprTuple46, 47, 44
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 38
8Literal
9ExprTuple11, 12, 13, 14
10Operationoperator: 26
operand: 21
11Operationoperator: 35
operands: 16
12Operationoperator: 35
operands: 17
13Operationoperator: 35
operands: 18
14Operationoperator: 19
operands: 20
15ExprTuple21
16ExprTuple46, 22
17ExprTuple47, 22
18ExprTuple44, 22
19Literal
20ExprTuple38, 23
21Operationoperator: 24
operand: 28
22Literal
23Operationoperator: 26
operand: 39
24Literal
25ExprTuple28
26Literal
27ExprTuple39
28Lambdaparameter: 45
body: 30
29ExprTuple45
30Conditionalvalue: 31
condition: 32
31Operationoperator: 33
operands: 34
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple37, 38
35Literal
36ExprTuple45, 39
37Operationoperator: 40
operands: 41
38Variable
39Operationoperator: 42
operands: 43
40Literal
41ExprTuple44, 45
42Literal
43ExprTuple46, 47
44Variable
45Variable
46Variable
47Variable