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, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
expr = ExprTuple(Lambda([a, b, c], Conditional(Equals(SetOfAll(instance_param_or_params = [x], instance_element = Mod(Add(x, c), N), domain = sub_expr1), Interval(zero, subtract(N, one))), 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(x + c\right) ~\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} ,  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
2ExprTuple53, 54, 52
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14, 15
10Operationoperator: 16
operand: 24
11Operationoperator: 49
operands: 18
12Operationoperator: 39
operands: 19
13Operationoperator: 39
operands: 20
14Operationoperator: 39
operands: 21
15Operationoperator: 22
operands: 23
16Literal
17ExprTuple24
18ExprTuple25, 26
19ExprTuple53, 27
20ExprTuple54, 27
21ExprTuple52, 27
22Literal
23ExprTuple44, 28
24Lambdaparameter: 51
body: 30
25Literal
26Operationoperator: 47
operands: 31
27Literal
28Operationoperator: 32
operand: 45
29ExprTuple51
30Conditionalvalue: 34
condition: 35
31ExprTuple44, 36
32Literal
33ExprTuple45
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operands: 40
36Operationoperator: 41
operand: 46
37Literal
38ExprTuple43, 44
39Literal
40ExprTuple51, 45
41Literal
42ExprTuple46
43Operationoperator: 47
operands: 48
44Variable
45Operationoperator: 49
operands: 50
46Literal
47Literal
48ExprTuple51, 52
49Literal
50ExprTuple53, 54
51Variable
52Variable
53Variable
54Variable