logo

Expression of type Conditional

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, Lambda, N, a, b, c, x
from proveit.logic import Bijections, Forall, InSet
from proveit.numbers import Integer, Interval, Mod, NaturalPos, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [a, b, c], instance_expr = InSet(Lambda(x, Mod(x, N)), Bijections(Interval(a, b), Interval(zero, subtract(N, one)))), domain = Integer), 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\{\forall_{a, b, c \in \mathbb{Z}}~\left(\left[x \mapsto \left(x ~\textup{mod}~ N\right)\right] \in \left[\{a~\ldotp \ldotp~b\} \xrightarrow[\text{onto}]{\text{1-to-1}} \{0~\ldotp \ldotp~N - 1\}\right]\right) \textrm{ if } N \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 6
2Operationoperator: 26
operands: 5
3Literal
4ExprTuple6
5ExprTuple44, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple38, 39, 32
9Conditionalvalue: 10
condition: 11
10Operationoperator: 26
operands: 12
11Operationoperator: 13
operands: 14
12ExprTuple15, 16
13Literal
14ExprTuple17, 18, 19
15Lambdaparameter: 34
body: 21
16Operationoperator: 22
operands: 23
17Operationoperator: 26
operands: 24
18Operationoperator: 26
operands: 25
19Operationoperator: 26
operands: 27
20ExprTuple34
21Operationoperator: 28
operands: 29
22Literal
23ExprTuple30, 31
24ExprTuple38, 33
25ExprTuple39, 33
26Literal
27ExprTuple32, 33
28Literal
29ExprTuple34, 44
30Operationoperator: 36
operands: 35
31Operationoperator: 36
operands: 37
32Variable
33Literal
34Variable
35ExprTuple38, 39
36Literal
37ExprTuple40, 41
38Variable
39Variable
40Literal
41Operationoperator: 42
operands: 43
42Literal
43ExprTuple44, 45
44Variable
45Operationoperator: 46
operand: 48
46Literal
47ExprTuple48
48Literal