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, 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(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), 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(\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)\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: 47
body: 8
6Operationoperator: 35
operands: 9
7Operationoperator: 35
operands: 10
8Conditionalvalue: 11
condition: 12
9ExprTuple54, 13
10ExprTuple57, 13
11Operationoperator: 14
operand: 18
12Operationoperator: 16
operands: 17
13Literal
14Literal
15ExprTuple18
16Literal
17ExprTuple19, 20, 21
18Lambdaparameter: 59
body: 23
19ExprRangelambda_map: 24
start_index: 56
end_index: 54
20Operationoperator: 35
operands: 25
21ExprRangelambda_map: 26
start_index: 56
end_index: 57
22ExprTuple59
23Conditionalvalue: 27
condition: 28
24Lambdaparameter: 65
body: 29
25ExprTuple58, 40
26Lambdaparameter: 65
body: 30
27Operationoperator: 31
operands: 32
28Operationoperator: 35
operands: 33
29Operationoperator: 35
operands: 34
30Operationoperator: 35
operands: 36
31Literal
32ExprTuple37, 38
33ExprTuple59, 39
34ExprTuple60, 40
35Literal
36ExprTuple61, 40
37Operationoperator: 51
operands: 41
38Operationoperator: 51
operands: 42
39Literal
40Literal
41ExprTuple43, 59
42ExprTuple44, 59
43Operationoperator: 46
operands: 45
44Operationoperator: 46
operands: 47
45ExprTuple49, 48, 50
46Literal
47ExprTuple49, 58, 50
48Operationoperator: 51
operands: 52
49ExprRangelambda_map: 53
start_index: 56
end_index: 54
50ExprRangelambda_map: 55
start_index: 56
end_index: 57
51Literal
52ExprTuple58, 59
53Lambdaparameter: 65
body: 60
54Variable
55Lambdaparameter: 65
body: 61
56Literal
57Variable
58Variable
59Variable
60IndexedVarvariable: 62
index: 65
61IndexedVarvariable: 63
index: 65
62Variable
63Variable
64ExprTuple65
65Variable