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, L, b, 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, ModAbs, Natural, Real, RealPos
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_j], instance_expr = Forall(instance_param_or_params = [L], instance_expr = Equals(ModAbs(Add(a_1_to_i, Mod(b, L), c_1_to_j), L), ModAbs(Add(a_1_to_i, b, c_1_to_j), L)).with_wrapping_at(2), domain = RealPos), domain = Real), And(InSet(i, Natural), InSet(j, Natural)))
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_{1}, a_{2}, \ldots, a_{i}, b, c_{1}, c_{2}, \ldots, c_{j} \in \mathbb{R}}~\left[\forall_{L \in \mathbb{R}^+}~\left(\begin{array}{c} \begin{array}{l} \left|a_{1} +  a_{2} +  \ldots +  a_{i} + \left(b ~\textup{mod}~ L\right)+ c_{1} +  c_{2} +  \ldots +  c_{j}\right|_{\textup{mod}\thinspace L} =  \\ \left|a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right|_{\textup{mod}\thinspace L} \end{array} \end{array}\right)\right] \textrm{ if } i \in \mathbb{N} ,  j \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: 14
operand: 5
2Operationoperator: 16
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 48
body: 8
6Operationoperator: 35
operands: 9
7Operationoperator: 35
operands: 10
8Conditionalvalue: 11
condition: 12
9ExprTuple55, 13
10ExprTuple58, 13
11Operationoperator: 14
operand: 18
12Operationoperator: 16
operands: 17
13Literal
14Literal
15ExprTuple18
16Literal
17ExprTuple19, 20, 21
18Lambdaparameter: 60
body: 23
19ExprRangelambda_map: 24
start_index: 57
end_index: 55
20Operationoperator: 35
operands: 25
21ExprRangelambda_map: 26
start_index: 57
end_index: 58
22ExprTuple60
23Conditionalvalue: 27
condition: 28
24Lambdaparameter: 66
body: 29
25ExprTuple59, 40
26Lambdaparameter: 66
body: 30
27Operationoperator: 31
operands: 32
28Operationoperator: 35
operands: 33
29Operationoperator: 35
operands: 34
30Operationoperator: 35
operands: 36
31Literal
32ExprTuple37, 38
33ExprTuple60, 39
34ExprTuple61, 40
35Literal
36ExprTuple62, 40
37Operationoperator: 42
operands: 41
38Operationoperator: 42
operands: 43
39Literal
40Literal
41ExprTuple44, 60
42Literal
43ExprTuple45, 60
44Operationoperator: 47
operands: 46
45Operationoperator: 47
operands: 48
46ExprTuple50, 49, 51
47Literal
48ExprTuple50, 59, 51
49Operationoperator: 52
operands: 53
50ExprRangelambda_map: 54
start_index: 57
end_index: 55
51ExprRangelambda_map: 56
start_index: 57
end_index: 58
52Literal
53ExprTuple59, 60
54Lambdaparameter: 66
body: 61
55Variable
56Lambdaparameter: 66
body: 62
57Literal
58Variable
59Variable
60Variable
61IndexedVarvariable: 63
index: 66
62IndexedVarvariable: 64
index: 66
63Variable
64Variable
65ExprTuple66
66Variable