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, 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 = 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\{\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..
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
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9, 10, 11, 12
7Operationoperator: 13
operand: 21
8Operationoperator: 46
operands: 15
9Operationoperator: 36
operands: 16
10Operationoperator: 36
operands: 17
11Operationoperator: 36
operands: 18
12Operationoperator: 19
operands: 20
13Literal
14ExprTuple21
15ExprTuple22, 23
16ExprTuple50, 24
17ExprTuple51, 24
18ExprTuple49, 24
19Literal
20ExprTuple41, 25
21Lambdaparameter: 48
body: 27
22Literal
23Operationoperator: 44
operands: 28
24Literal
25Operationoperator: 29
operand: 42
26ExprTuple48
27Conditionalvalue: 31
condition: 32
28ExprTuple41, 33
29Literal
30ExprTuple42
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operand: 43
34Literal
35ExprTuple40, 41
36Literal
37ExprTuple48, 42
38Literal
39ExprTuple43
40Operationoperator: 44
operands: 45
41Variable
42Operationoperator: 46
operands: 47
43Literal
44Literal
45ExprTuple48, 49
46Literal
47ExprTuple50, 51
48Variable
49Variable
50Variable
51Variable