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
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
expr = Conditional(Equals(Card(SetOfAll(instance_param_or_params = [x], instance_element = Mod(Add(c, x), N), domain = sub_expr1)), N), 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(c + x\right) ~\textup{mod}~ N\right\}_{x \in \{a~\ldotp \ldotp~b\}}| = N \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, 35
5Literal
6ExprTuple8, 9, 10, 11
7Operationoperator: 23
operand: 18
8Operationoperator: 32
operands: 13
9Operationoperator: 32
operands: 14
10Operationoperator: 32
operands: 15
11Operationoperator: 16
operands: 17
12ExprTuple18
13ExprTuple43, 19
14ExprTuple44, 19
15ExprTuple41, 19
16Literal
17ExprTuple35, 20
18Operationoperator: 21
operand: 25
19Literal
20Operationoperator: 23
operand: 36
21Literal
22ExprTuple25
23Literal
24ExprTuple36
25Lambdaparameter: 42
body: 27
26ExprTuple42
27Conditionalvalue: 28
condition: 29
28Operationoperator: 30
operands: 31
29Operationoperator: 32
operands: 33
30Literal
31ExprTuple34, 35
32Literal
33ExprTuple42, 36
34Operationoperator: 37
operands: 38
35Variable
36Operationoperator: 39
operands: 40
37Literal
38ExprTuple41, 42
39Literal
40ExprTuple43, 44
41Variable
42Variable
43Variable
44Variable