logo

Expression of type Conditional

from the theory of proveit.numbers.addition.subtraction

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, a, b, c, d, e, i, j, k
from proveit.core_expr_types import a_1_to_i, c_1_to_j, e_1_to_k
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Complex, Neg, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Equals(Add(a_1_to_i, b, c_1_to_j, Neg(d), e_1_to_k), Add(a_1_to_i, c_1_to_j, e_1_to_k)), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), InSet(b, Complex), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), Complex), one, j), InSet(d, Complex), ExprRange(sub_expr1, InSet(IndexedVar(e, sub_expr1), Complex), one, k), Equals(b, d)))
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\{\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j} - d+ e_{1} +  e_{2} +  \ldots +  e_{k}\right) = \left(a_{1} +  a_{2} +  \ldots +  a_{i}+ c_{1} +  c_{2} +  \ldots +  c_{j}+ e_{1} +  e_{2} +  \ldots +  e_{k}\right) \textrm{ if } \left(a_{1} \in \mathbb{C}\right) ,  \left(a_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{C}\right) ,  b \in \mathbb{C}, \left(c_{1} \in \mathbb{C}\right) ,  \left(c_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(c_{j} \in \mathbb{C}\right) ,  d \in \mathbb{C}, \left(e_{1} \in \mathbb{C}\right) ,  \left(e_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(e_{k} \in \mathbb{C}\right) ,  b = d\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: 22
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple8, 9, 10, 11, 12, 13
6Operationoperator: 15
operands: 14
7Operationoperator: 15
operands: 16
8ExprRangelambda_map: 17
start_index: 39
end_index: 35
9Operationoperator: 43
operands: 18
10ExprRangelambda_map: 19
start_index: 39
end_index: 37
11Operationoperator: 43
operands: 20
12ExprRangelambda_map: 21
start_index: 39
end_index: 40
13Operationoperator: 22
operands: 23
14ExprTuple25, 31, 26, 24, 27
15Literal
16ExprTuple25, 26, 27
17Lambdaparameter: 54
body: 28
18ExprTuple31, 49
19Lambdaparameter: 54
body: 29
20ExprTuple45, 49
21Lambdaparameter: 54
body: 30
22Literal
23ExprTuple31, 45
24Operationoperator: 32
operand: 45
25ExprRangelambda_map: 34
start_index: 39
end_index: 35
26ExprRangelambda_map: 36
start_index: 39
end_index: 37
27ExprRangelambda_map: 38
start_index: 39
end_index: 40
28Operationoperator: 43
operands: 41
29Operationoperator: 43
operands: 42
30Operationoperator: 43
operands: 44
31Variable
32Literal
33ExprTuple45
34Lambdaparameter: 54
body: 46
35Variable
36Lambdaparameter: 54
body: 47
37Variable
38Lambdaparameter: 54
body: 48
39Literal
40Variable
41ExprTuple46, 49
42ExprTuple47, 49
43Literal
44ExprTuple48, 49
45Variable
46IndexedVarvariable: 50
index: 54
47IndexedVarvariable: 51
index: 54
48IndexedVarvariable: 52
index: 54
49Literal
50Variable
51Variable
52Variable
53ExprTuple54
54Variable