> The book expected them to do a proof by cases, with some sort of case split on the order of a , b , and c . What they turned in was mostly pretty good, actually, but while grading it I became disgusted with the whole thing and thought there has to be a better way. This is how it's done in the Idris standard library[1]: total minimumAssociative : (l,c,r : Nat) -> minimum l (minimum c r) = minimum (minimum l c) r min…
That's doing induction its arguments, which relies on them being naturals - it's not an approach that would generalise to reals.
What would Dijkstra do? Proving the associativity of min
11–20 of 32 posts
Re: What would Dijkstra do? Proving the associativity of min
#12This is the definition that leads to the ugly proof by cases. Right there is the problem. There's nothing wrong with proof by cases. People suck at it, but machines do it just fine. I ran into this years ago in the early days of program proving. The kind of proofs that mathematicians like are not the kind you really want to use to get work done by machine.
I personally pride myself on my ability to analyze situations by cases, and to grind through normally-opaque walls to find proofs, but we should always keep in mind that it is the hardest way. It's like fishing for algorithms.
Re: What would Dijkstra do? Proving the associativity of min
#13Start with the case definition of min.
Notice that min(a,b) Let d = min(a,min(b,c)) and e = min(min(a,b),c)
Then d Same goes for e.
Since e is in {a,b,c} and d <= a, d <= b, d <= c, it must follow that d <= e. And by symmetry e <= d. So d=e.
Re: What would Dijkstra do? Proving the associativity of min
#14Earlier quoted context omitted.
That's doing induction its arguments, which relies on them being naturals - it's not an approach that would generalise to reals.
I think that's necessary, since the order on the full set of reals isn't constructively decideable, so min isn't even a total function there.
Re: What would Dijkstra do? Proving the associativity of min
#15Here's the solution I thought of, which is pretty similar. Start with the case definition of min. Notice that min(a,b) Let d = min(a,min(b,c)) and e = min(min(a,b),c) Then d Same goes for e. Since e is in {a,b,c} and d <= a, d <= b, d <= c, it must follow that d <= e. And by symmetry e <= d. So d=e.
Re: What would Dijkstra do? Proving the associativity of min
#16Earlier quoted context omitted.
I think that's necessary, since the order on the full set of reals isn't constructively decideable, so min isn't even a total function there.
Almost all reals are not computable, but as far as I know min is total - given two reals (represented as e.g. lazy infinite decimal sequences), computing their min is trivial.
Re: What would Dijkstra do? Proving the associativity of min
#17Here's the solution I thought of, which is pretty similar. Start with the case definition of min. Notice that min(a,b) Let d = min(a,min(b,c)) and e = min(min(a,b),c) Then d Same goes for e. Since e is in {a,b,c} and d <= a, d <= b, d <= c, it must follow that d <= e. And by symmetry e <= d. So d=e.
Similar? In my opinion this is much faster, easier, and less burdened by notation.
Re: What would Dijkstra do? Proving the associativity of min
#18Earlier quoted context omitted.
Almost all reals are not computable, but as far as I know min is total - given two reals (represented as e.g. lazy infinite decimal sequences), computing their min is trivial.
Unless when they happen to be equal. Then it never halts.
Re: What would Dijkstra do? Proving the associativity of min
#19Earlier quoted context omitted.
Similar? In my opinion this is much faster, easier, and less burdened by notation.
It's certainly a nice solution, but OP's solution has the nice property of working directly on a universality definition, which makes the argument more general. For example, the universality argument also works for the infimum and gcd operations.
Re: What would Dijkstra do? Proving the associativity of min
#20Similarly you can show that gcd and lcm are associative, once you know their universal properties (for gcd, being the one common divisor that every common divisor divides; for lcm, the corresponding dual property). Similarly the associativity (up to unique diagram-fitting isomorphism) of products (or even fibered products) in any category (when they exist). The really high horse here is called "Yoneda embedding", but…