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, Forall, InSet
from proveit.numbers import DecimalSequence, Digits, Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = ExprRange(sub_expr1, b, one, n)
sub_expr3 = ExprRange(sub_expr1, IndexedVar(a, sub_expr1), one, m)
sub_expr4 = ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, n)
sub_expr5 = ExprRange(sub_expr1, IndexedVar(d, sub_expr1), one, k)
expr = Conditional(Forall(instance_param_or_params = [sub_expr3, b, sub_expr4, sub_expr5], instance_expr = Equals(DecimalSequence(sub_expr3, sub_expr2, sub_expr5), DecimalSequence(sub_expr3, sub_expr4, sub_expr5)), domain = Digits, condition = Equals([sub_expr2], [sub_expr4])), And(InSet(m, Natural), InSet(n, 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\{\forall_{a_{1}, a_{2}, \ldots, a_{m}, b, c_{1}, c_{2}, \ldots, c_{n}, d_{1}, d_{2}, \ldots, d_{k} \in \mathbb{N}^{\leq 9}~|~\left(b, b, ..\left(n - 3\right) \times.., b\right) = \left(c_{1}, c_{2}, \ldots, c_{n}\right)}~\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})\right) \textrm{ if } m \in \mathbb{N} ,  n \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: 19
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8, 9
6Lambdaparameters: 10
body: 11
7Operationoperator: 50
operands: 12
8Operationoperator: 50
operands: 13
9Operationoperator: 50
operands: 14
10ExprTuple37, 63, 53, 38
11Conditionalvalue: 15
condition: 16
12ExprTuple45, 17
13ExprTuple60, 17
14ExprTuple47, 17
15Operationoperator: 35
operands: 18
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 24, 25, 26, 27
21Operationoperator: 29
operands: 28
22Operationoperator: 29
operands: 30
23ExprRangelambda_map: 31
start_index: 59
end_index: 45
24Operationoperator: 50
operands: 32
25ExprRangelambda_map: 33
start_index: 59
end_index: 60
26ExprRangelambda_map: 34
start_index: 59
end_index: 47
27Operationoperator: 35
operands: 36
28ExprTuple37, 52, 38
29Literal
30ExprTuple37, 53, 38
31Lambdaparameter: 67
body: 39
32ExprTuple63, 56
33Lambdaparameter: 67
body: 40
34Lambdaparameter: 67
body: 41
35Literal
36ExprTuple42, 43
37ExprRangelambda_map: 44
start_index: 59
end_index: 45
38ExprRangelambda_map: 46
start_index: 59
end_index: 47
39Operationoperator: 50
operands: 48
40Operationoperator: 50
operands: 49
41Operationoperator: 50
operands: 51
42ExprTuple52
43ExprTuple53
44Lambdaparameter: 67
body: 54
45Variable
46Lambdaparameter: 67
body: 55
47Variable
48ExprTuple54, 56
49ExprTuple64, 56
50Literal
51ExprTuple55, 56
52ExprRangelambda_map: 57
start_index: 59
end_index: 60
53ExprRangelambda_map: 58
start_index: 59
end_index: 60
54IndexedVarvariable: 61
index: 67
55IndexedVarvariable: 62
index: 67
56Literal
57Lambdaparameter: 67
body: 63
58Lambdaparameter: 67
body: 64
59Literal
60Variable
61Variable
62Variable
63Variable
64IndexedVarvariable: 65
index: 67
65Variable
66ExprTuple67
67Variable