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 Card, Equals, Forall, InSet, SetOfAll
from proveit.numbers import Add, Integer, Interval, Mod, NaturalPos, greater_eq, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
expr = Conditional(Forall(instance_param_or_params = [a, b, c], instance_expr = Equals(SetOfAll(instance_param_or_params = [x], instance_element = Mod(Add(x, c), N), domain = sub_expr1), Interval(zero, subtract(N, one))), domain = Integer, condition = greater_eq(Card(sub_expr1), N)), 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}~|~|\{a~\ldotp \ldotp~b\}| \geq N}~\left(\left\{\left(x + c\right) ~\textup{mod}~ N\right\}_{x \in \{a~\ldotp \ldotp~b\}} = \{0~\ldotp \ldotp~N - 1\}\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: 45
operands: 5
3Literal
4ExprTuple6
5ExprTuple50, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple59, 60, 58
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operands: 13
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16, 17
14Literal
15ExprTuple18, 19, 20, 21
16Operationoperator: 22
operand: 30
17Operationoperator: 55
operands: 24
18Operationoperator: 45
operands: 25
19Operationoperator: 45
operands: 26
20Operationoperator: 45
operands: 27
21Operationoperator: 28
operands: 29
22Literal
23ExprTuple30
24ExprTuple31, 32
25ExprTuple59, 33
26ExprTuple60, 33
27ExprTuple58, 33
28Literal
29ExprTuple50, 34
30Lambdaparameter: 57
body: 36
31Literal
32Operationoperator: 53
operands: 37
33Literal
34Operationoperator: 38
operand: 51
35ExprTuple57
36Conditionalvalue: 40
condition: 41
37ExprTuple50, 42
38Literal
39ExprTuple51
40Operationoperator: 43
operands: 44
41Operationoperator: 45
operands: 46
42Operationoperator: 47
operand: 52
43Literal
44ExprTuple49, 50
45Literal
46ExprTuple57, 51
47Literal
48ExprTuple52
49Operationoperator: 53
operands: 54
50Variable
51Operationoperator: 55
operands: 56
52Literal
53Literal
54ExprTuple57, 58
55Literal
56ExprTuple59, 60
57Variable
58Variable
59Variable
60Variable