logo

Expression of type Conditional

from the theory of proveit.numbers.multiplication

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, Variable, b, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Complex, Mult, Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
expr = Conditional(Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Equals(Mult(a_1_to_i, Add(b_1_to_j), c_1_to_k), Add(ExprRange(sub_expr1, Mult(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j))).with_wrapping_at(2), domain = Complex).with_wrapping(), And(InSet(i, Natural), InSet(j, Natural), InSet(k, 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\{\begin{array}{l}\forall_{a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k} \in \mathbb{C}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot \left(b_{1} +  b_{2} +  \ldots +  b_{j}\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) =  \\ \left(\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{1}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{2}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \ldots +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{j}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right)\right) \end{array} \end{array}\right)\end{array} \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  k \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: 20
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8, 9
6Lambdaparameters: 10
body: 11
7Operationoperator: 42
operands: 12
8Operationoperator: 42
operands: 13
9Operationoperator: 42
operands: 14
10ExprTuple52, 44, 54
11Conditionalvalue: 15
condition: 16
12ExprTuple56, 17
13ExprTuple48, 17
14ExprTuple61, 17
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22, 23
20Literal
21ExprTuple24, 25, 26
22Operationoperator: 49
operands: 27
23Operationoperator: 37
operands: 28
24ExprRangelambda_map: 29
start_index: 60
end_index: 56
25ExprRangelambda_map: 30
start_index: 60
end_index: 48
26ExprRangelambda_map: 31
start_index: 60
end_index: 61
27ExprTuple52, 32, 54
28ExprTuple33
29Lambdaparameter: 68
body: 34
30Lambdaparameter: 68
body: 35
31Lambdaparameter: 68
body: 36
32Operationoperator: 37
operands: 38
33ExprRangelambda_map: 39
start_index: 60
end_index: 48
34Operationoperator: 42
operands: 40
35Operationoperator: 42
operands: 41
36Operationoperator: 42
operands: 43
37Literal
38ExprTuple44
39Lambdaparameter: 63
body: 45
40ExprTuple62, 46
41ExprTuple51, 46
42Literal
43ExprTuple64, 46
44ExprRangelambda_map: 47
start_index: 60
end_index: 48
45Operationoperator: 49
operands: 50
46Literal
47Lambdaparameter: 68
body: 51
48Variable
49Literal
50ExprTuple52, 53, 54
51IndexedVarvariable: 57
index: 68
52ExprRangelambda_map: 55
start_index: 60
end_index: 56
53IndexedVarvariable: 57
index: 63
54ExprRangelambda_map: 59
start_index: 60
end_index: 61
55Lambdaparameter: 68
body: 62
56Variable
57Variable
58ExprTuple63
59Lambdaparameter: 68
body: 64
60Literal
61Variable
62IndexedVarvariable: 65
index: 68
63Variable
64IndexedVarvariable: 66
index: 68
65Variable
66Variable
67ExprTuple68
68Variable