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, ExprRange, IndexedVar, L, Variable, a, b, c, i, j
from proveit.core_expr_types import a_1_to_i, c_1_to_j
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Mod, Real, RealPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Forall(instance_param_or_params = [L], instance_expr = Equals(Mod(Add(a_1_to_i, Mod(b, L), c_1_to_j), L), Mod(Add(a_1_to_i, b, c_1_to_j), L)).with_wrapping_at(2), domain = RealPos), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Real), one, i), InSet(b, Real), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), Real), one, j)))
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_{L \in \mathbb{R}^+}~\left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + \left(b ~\textup{mod}~ L\right)+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) ~\textup{mod}~ L\right) =  \\ \left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) ~\textup{mod}~ L\right) \end{array} \end{array}\right) \textrm{ if } \left(a_{1} \in \mathbb{R}\right) ,  \left(a_{2} \in \mathbb{R}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{R}\right) ,  b \in \mathbb{R}, \left(c_{1} \in \mathbb{R}\right) ,  \left(c_{2} \in \mathbb{R}\right) ,  \ldots ,  \left(c_{j} \in \mathbb{R}\right)\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: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8, 9, 10
7Lambdaparameter: 48
body: 12
8ExprRangelambda_map: 13
start_index: 45
end_index: 43
9Operationoperator: 24
operands: 14
10ExprRangelambda_map: 15
start_index: 45
end_index: 46
11ExprTuple48
12Conditionalvalue: 16
condition: 17
13Lambdaparameter: 54
body: 18
14ExprTuple47, 29
15Lambdaparameter: 54
body: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 24
operands: 22
18Operationoperator: 24
operands: 23
19Operationoperator: 24
operands: 25
20Literal
21ExprTuple26, 27
22ExprTuple48, 28
23ExprTuple49, 29
24Literal
25ExprTuple50, 29
26Operationoperator: 40
operands: 30
27Operationoperator: 40
operands: 31
28Literal
29Literal
30ExprTuple32, 48
31ExprTuple33, 48
32Operationoperator: 35
operands: 34
33Operationoperator: 35
operands: 36
34ExprTuple38, 37, 39
35Literal
36ExprTuple38, 47, 39
37Operationoperator: 40
operands: 41
38ExprRangelambda_map: 42
start_index: 45
end_index: 43
39ExprRangelambda_map: 44
start_index: 45
end_index: 46
40Literal
41ExprTuple47, 48
42Lambdaparameter: 54
body: 49
43Variable
44Lambdaparameter: 54
body: 50
45Literal
46Variable
47Variable
48Variable
49IndexedVarvariable: 51
index: 54
50IndexedVarvariable: 52
index: 54
51Variable
52Variable
53ExprTuple54
54Variable