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