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, x
from proveit.logic import Card, Equals, Forall, InSet, SetOfAll
from proveit.numbers import 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], instance_expr = Equals(SetOfAll(instance_param_or_params = [x], instance_element = Mod(x, 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 \in \mathbb{Z}~|~|\{a~\ldotp \ldotp~b\}| \geq N}~\left(\left\{x ~\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: 43
operands: 5
3Literal
4ExprTuple6
5ExprTuple47, 7
6Lambdaparameters: 52
body: 8
7Literal
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple17, 18, 19
15Operationoperator: 20
operand: 27
16Operationoperator: 51
operands: 22
17Operationoperator: 43
operands: 23
18Operationoperator: 43
operands: 24
19Operationoperator: 25
operands: 26
20Literal
21ExprTuple27
22ExprTuple28, 29
23ExprTuple53, 30
24ExprTuple54, 30
25Literal
26ExprTuple47, 31
27Lambdaparameter: 48
body: 33
28Literal
29Operationoperator: 34
operands: 35
30Literal
31Operationoperator: 36
operand: 49
32ExprTuple48
33Conditionalvalue: 38
condition: 39
34Literal
35ExprTuple47, 40
36Literal
37ExprTuple49
38Operationoperator: 41
operands: 42
39Operationoperator: 43
operands: 44
40Operationoperator: 45
operand: 50
41Literal
42ExprTuple48, 47
43Literal
44ExprTuple48, 49
45Literal
46ExprTuple50
47Variable
48Variable
49Operationoperator: 51
operands: 52
50Literal
51Literal
52ExprTuple53, 54
53Variable
54Variable