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 And, Card, Equals, InSet, SetOfAll
from proveit.numbers import 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(x, N), domain = sub_expr1), Interval(zero, subtract(N, one))), And(InSet(a, Integer), InSet(b, 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\{x ~\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} ,  |\{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
7Operationoperator: 12
operand: 19
8Operationoperator: 43
operands: 14
9Operationoperator: 35
operands: 15
10Operationoperator: 35
operands: 16
11Operationoperator: 17
operands: 18
12Literal
13ExprTuple19
14ExprTuple20, 21
15ExprTuple45, 22
16ExprTuple46, 22
17Literal
18ExprTuple39, 23
19Lambdaparameter: 40
body: 25
20Literal
21Operationoperator: 26
operands: 27
22Literal
23Operationoperator: 28
operand: 41
24ExprTuple40
25Conditionalvalue: 30
condition: 31
26Literal
27ExprTuple39, 32
28Literal
29ExprTuple41
30Operationoperator: 33
operands: 34
31Operationoperator: 35
operands: 36
32Operationoperator: 37
operand: 42
33Literal
34ExprTuple40, 39
35Literal
36ExprTuple40, 41
37Literal
38ExprTuple42
39Variable
40Variable
41Operationoperator: 43
operands: 44
42Literal
43Literal
44ExprTuple45, 46
45Variable
46Variable