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, LessEq, Mod, NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
sub_expr2 = Card(sub_expr1)
expr = Conditional(Forall(instance_param_or_params = [a, b], instance_expr = Equals(Card(SetOfAll(instance_param_or_params = [x], instance_element = Mod(x, N), domain = sub_expr1)), sub_expr2), domain = Integer, condition = LessEq(sub_expr2, 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\}| \leq N}~\left(|\left\{x ~\textup{mod}~ N\right\}_{x \in \{a~\ldotp \ldotp~b\}}| = |\{a~\ldotp \ldotp~b\}|\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: 38
operands: 5
3Literal
4ExprTuple6
5ExprTuple40, 7
6Lambdaparameters: 44
body: 8
7Literal
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 26
13Literal
14ExprTuple16, 17, 18
15Operationoperator: 29
operand: 24
16Operationoperator: 38
operands: 20
17Operationoperator: 38
operands: 21
18Operationoperator: 22
operands: 23
19ExprTuple24
20ExprTuple45, 25
21ExprTuple46, 25
22Literal
23ExprTuple26, 40
24Operationoperator: 27
operand: 31
25Literal
26Operationoperator: 29
operand: 42
27Literal
28ExprTuple31
29Literal
30ExprTuple42
31Lambdaparameter: 41
body: 33
32ExprTuple41
33Conditionalvalue: 34
condition: 35
34Operationoperator: 36
operands: 37
35Operationoperator: 38
operands: 39
36Literal
37ExprTuple41, 40
38Literal
39ExprTuple41, 42
40Variable
41Variable
42Operationoperator: 43
operands: 44
43Literal
44ExprTuple45, 46
45Variable
46Variable