You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pset3: theorems bst_strict_monotone_increasing and bst_strict_monotone_decreasing_mirror are degenerate #1
(Thanks for these problem sets, which I've been very much enjoying as I learn Coq.)
In Pset3, the two monotonicity-related theorems are degenerate in the following sense:
bst_strict_monotone_increasing: Under the assumptions of the theorem, namely that f : nat -> nat has a right inverse and is strictly monotone, we can prove f = id. This makes the theorem trivial.
bst_strict_monotone_decreasing_mirror: The theorem assumes that f : nat -> nat is strictly decreasing, but there is no such function. Thus the theorem can be proven by showing that the hypotheses are contradictory.
I assume this is just an accident caused by using nat for convenience, since various other totally-ordered sets (such as the integers or the rationals) wouldn't have this problem.
(Edit: Fixed accidentally saying f has a left inverse. f has a right inverse, because the left inverse of g is f. The important thing is that it causes f to be onto.)
On further thought, there are actually two underlying issues.
It's too strong to require that f be onto. That rules out perfectly reasonable functions such as f(x) = x^2, which is strictly increasing on the natural numbers. This is a problem for both theorem statements.
There are no strictly decreasing functions from nat to nat. This is a problem for the second theorem statement only.
For issue 1, the root cause is the way Q is specified. All we actually need is, if P = {x_1,...,x_n}, then Q = {f(x_1),...,f(x_n)}. The current conditions are too strong. We can fix by defining Q as follows: Q := fun a => exists x, a = f x /\ P x.
For issue 2, either a non-nat set is needed (e.g. general integers would be fine), or the monotonicity condition must be weakened. The second fix is self-contained to the theorem statement, so that's what I use below.
Here are my proposed fixed theorem statements:
Theorem bst_strict_monotone_increasing_fixed : forall tr P f,
bst tr P ->
(forall x y, x < y <-> f x < f y) ->
bst (tree_map f tr) (fun a => exists x, a = f x /\ P x).
Theorem bst_strict_monotone_decreasing_mirror_fixed : forall tr P f,
bst tr P ->
(forall x y, P x -> P y -> x < y <-> f x > f y) ->
bst (mirror (tree_map f tr)) (fun a => exists x, a = f x /\ P x).
Activity
malcolmsharpe commentedon Aug 24, 2022
Update with a proposed fix:
On further thought, there are actually two underlying issues.
fbe onto. That rules out perfectly reasonable functions such asf(x) = x^2, which is strictly increasing on the natural numbers. This is a problem for both theorem statements.nattonat. This is a problem for the second theorem statement only.For issue 1, the root cause is the way
Qis specified. All we actually need is, ifP = {x_1,...,x_n}, thenQ = {f(x_1),...,f(x_n)}. The current conditions are too strong. We can fix by definingQas follows:Q := fun a => exists x, a = f x /\ P x.For issue 2, either a non-
natset is needed (e.g. general integers would be fine), or the monotonicity condition must be weakened. The second fix is self-contained to the theorem statement, so that's what I use below.Here are my proposed fixed theorem statements: