logo

Expression of type Conditional

from the theory of proveit.numbers.numerals.decimals

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, k, m, n
from proveit.logic import And, Equals, InSet
from proveit.numbers import DecimalSequence, Digits, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(a, sub_expr1)
sub_expr3 = IndexedVar(d, sub_expr1)
sub_expr4 = IndexedVar(c, sub_expr1)
sub_expr5 = ExprRange(sub_expr1, b, one, n)
sub_expr6 = ExprRange(sub_expr1, sub_expr2, one, m)
sub_expr7 = ExprRange(sub_expr1, sub_expr3, one, k)
sub_expr8 = ExprRange(sub_expr1, sub_expr4, one, n)
expr = Conditional(Equals(DecimalSequence(sub_expr6, sub_expr5, sub_expr7), DecimalSequence(sub_expr6, sub_expr8, sub_expr7)), And(ExprRange(sub_expr1, InSet(sub_expr2, Digits), one, m), InSet(b, Digits), ExprRange(sub_expr1, InSet(sub_expr4, Digits), one, n), ExprRange(sub_expr1, InSet(sub_expr3, Digits), one, k), Equals([sub_expr5], [sub_expr8])))
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\{\texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ b, b, ..\left(n - 3\right) \times.., b ~ d_{1}, d_{2}, \ldots, d_{k}) = \texttt{\#}(a_{1}, a_{2}, \ldots, a_{m} ~ c_{1}, c_{2}, \ldots, c_{n} ~ d_{1}, d_{2}, \ldots, d_{k}) \textrm{ if } \left(a_{1} \in \mathbb{N}^{\leq 9}\right) ,  \left(a_{2} \in \mathbb{N}^{\leq 9}\right) ,  \ldots ,  \left(a_{m} \in \mathbb{N}^{\leq 9}\right) ,  b \in \mathbb{N}^{\leq 9}, \left(c_{1} \in \mathbb{N}^{\leq 9}\right) ,  \left(c_{2} \in \mathbb{N}^{\leq 9}\right) ,  \ldots ,  \left(c_{n} \in \mathbb{N}^{\leq 9}\right), \left(d_{1} \in \mathbb{N}^{\leq 9}\right) ,  \left(d_{2} \in \mathbb{N}^{\leq 9}\right) ,  \ldots ,  \left(d_{k} \in \mathbb{N}^{\leq 9}\right) ,  \left(b, b, ..\left(n - 3\right) \times.., b\right) = \left(c_{1}, c_{2}, \ldots, c_{n}\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: 20
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple8, 9, 10, 11, 12
6Operationoperator: 14
operands: 13
7Operationoperator: 14
operands: 15
8ExprRangelambda_map: 16
start_index: 44
end_index: 30
9Operationoperator: 35
operands: 17
10ExprRangelambda_map: 18
start_index: 44
end_index: 45
11ExprRangelambda_map: 19
start_index: 44
end_index: 32
12Operationoperator: 20
operands: 21
13ExprTuple22, 37, 23
14Literal
15ExprTuple22, 38, 23
16Lambdaparameter: 52
body: 24
17ExprTuple48, 41
18Lambdaparameter: 52
body: 25
19Lambdaparameter: 52
body: 26
20Literal
21ExprTuple27, 28
22ExprRangelambda_map: 29
start_index: 44
end_index: 30
23ExprRangelambda_map: 31
start_index: 44
end_index: 32
24Operationoperator: 35
operands: 33
25Operationoperator: 35
operands: 34
26Operationoperator: 35
operands: 36
27ExprTuple37
28ExprTuple38
29Lambdaparameter: 52
body: 39
30Variable
31Lambdaparameter: 52
body: 40
32Variable
33ExprTuple39, 41
34ExprTuple49, 41
35Literal
36ExprTuple40, 41
37ExprRangelambda_map: 42
start_index: 44
end_index: 45
38ExprRangelambda_map: 43
start_index: 44
end_index: 45
39IndexedVarvariable: 46
index: 52
40IndexedVarvariable: 47
index: 52
41Literal
42Lambdaparameter: 52
body: 48
43Lambdaparameter: 52
body: 49
44Literal
45Variable
46Variable
47Variable
48Variable
49IndexedVarvariable: 50
index: 52
50Variable
51ExprTuple52
52Variable