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, LessEq, Mod
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
sub_expr2 = Card(sub_expr1)
expr = ExprTuple(Lambda([a, b], Conditional(Equals(Card(SetOfAll(instance_param_or_params = [x], instance_element = Mod(x, N), domain = sub_expr1)), sub_expr2), And(InSet(a, Integer), InSet(b, Integer), LessEq(sub_expr2, 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\}}| = |\{a~\ldotp \ldotp~b\}| \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  |\{a~\ldotp \ldotp~b\}| \leq 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: 38
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 20
7Literal
8ExprTuple10, 11, 12
9Operationoperator: 23
operand: 18
10Operationoperator: 32
operands: 14
11Operationoperator: 32
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple18
14ExprTuple39, 19
15ExprTuple40, 19
16Literal
17ExprTuple20, 34
18Operationoperator: 21
operand: 25
19Literal
20Operationoperator: 23
operand: 36
21Literal
22ExprTuple25
23Literal
24ExprTuple36
25Lambdaparameter: 35
body: 27
26ExprTuple35
27Conditionalvalue: 28
condition: 29
28Operationoperator: 30
operands: 31
29Operationoperator: 32
operands: 33
30Literal
31ExprTuple35, 34
32Literal
33ExprTuple35, 36
34Variable
35Variable
36Operationoperator: 37
operands: 38
37Literal
38ExprTuple39, 40
39Variable
40Variable