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 Add, 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(Add(c, 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(\left(c + x\right) ~\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
5ExprTuple46, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple38, 39, 42
9Conditionalvalue: 10
condition: 11
10Operationoperator: 26
operands: 12
11Operationoperator: 13
operands: 14
12ExprTuple15, 16
13Literal
14ExprTuple17, 18, 19
15Lambdaparameter: 43
body: 21
16Operationoperator: 22
operands: 23
17Operationoperator: 26
operands: 24
18Operationoperator: 26
operands: 25
19Operationoperator: 26
operands: 27
20ExprTuple43
21Operationoperator: 28
operands: 29
22Literal
23ExprTuple30, 31
24ExprTuple38, 32
25ExprTuple39, 32
26Literal
27ExprTuple42, 32
28Literal
29ExprTuple33, 46
30Operationoperator: 35
operands: 34
31Operationoperator: 35
operands: 36
32Literal
33Operationoperator: 44
operands: 37
34ExprTuple38, 39
35Literal
36ExprTuple40, 41
37ExprTuple42, 43
38Variable
39Variable
40Literal
41Operationoperator: 44
operands: 45
42Variable
43Variable
44Literal
45ExprTuple46, 47
46Variable
47Operationoperator: 48
operand: 50
48Literal
49ExprTuple50
50Literal