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
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(Card(SetOfAll(instance_param_or_params = [x], instance_element = Mod(Add(c, x), N), domain = sub_expr1)), N), 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(c + x\right) ~\textup{mod}~ N\right\}_{x \in \{a~\ldotp \ldotp~b\}}| = N\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: 41
operands: 5
3Literal
4ExprTuple6
5ExprTuple44, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple52, 53, 50
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operands: 13
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16, 44
14Literal
15ExprTuple17, 18, 19, 20
16Operationoperator: 32
operand: 27
17Operationoperator: 41
operands: 22
18Operationoperator: 41
operands: 23
19Operationoperator: 41
operands: 24
20Operationoperator: 25
operands: 26
21ExprTuple27
22ExprTuple52, 28
23ExprTuple53, 28
24ExprTuple50, 28
25Literal
26ExprTuple44, 29
27Operationoperator: 30
operand: 34
28Literal
29Operationoperator: 32
operand: 45
30Literal
31ExprTuple34
32Literal
33ExprTuple45
34Lambdaparameter: 51
body: 36
35ExprTuple51
36Conditionalvalue: 37
condition: 38
37Operationoperator: 39
operands: 40
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple43, 44
41Literal
42ExprTuple51, 45
43Operationoperator: 46
operands: 47
44Variable
45Operationoperator: 48
operands: 49
46Literal
47ExprTuple50, 51
48Literal
49ExprTuple52, 53
50Variable
51Variable
52Variable
53Variable