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, a, b, i, j
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import And, Equals, InSet
from proveit.numbers import Complex, Mult, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Equals(Mult(a_1_to_i, one, b_1_to_j), Mult(a_1_to_i, b_1_to_j)), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), Complex), one, i), ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Complex), 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\{\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot 1\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right) = \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i}\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\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), \left(b_{1} \in \mathbb{C}\right) ,  \left(b_{2} \in \mathbb{C}\right) ,  \ldots ,  \left(b_{j} \in \mathbb{C}\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
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9, 10
7Operationoperator: 12
operands: 11
8Operationoperator: 12
operands: 13
9ExprRangelambda_map: 14
start_index: 23
end_index: 21
10ExprRangelambda_map: 15
start_index: 23
end_index: 24
11ExprTuple16, 23, 17
12Literal
13ExprTuple16, 17
14Lambdaparameter: 34
body: 18
15Lambdaparameter: 34
body: 19
16ExprRangelambda_map: 20
start_index: 23
end_index: 21
17ExprRangelambda_map: 22
start_index: 23
end_index: 24
18Operationoperator: 26
operands: 25
19Operationoperator: 26
operands: 27
20Lambdaparameter: 34
body: 28
21Variable
22Lambdaparameter: 34
body: 29
23Literal
24Variable
25ExprTuple28, 30
26Literal
27ExprTuple29, 30
28IndexedVarvariable: 31
index: 34
29IndexedVarvariable: 32
index: 34
30Literal
31Variable
32Variable
33ExprTuple34
34Variable