TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

What would Dijkstra do? Proving the associativity of min

89 pointsby selffabout 5 years ago

7 comments

im3w1labout 5 years ago
Here&#x27;s the solution I thought of, which is pretty similar.<p>Start with the case definition of min.<p>Notice that min(a,b) &lt;= a, min(a,b) &lt;= b and min(a,b) in {a,b}<p>Let d = min(a,min(b,c)) and e = min(min(a,b),c)<p>Then d &lt;= a, d &lt;= b, d &lt;= c and d in {a,b,c}<p>Same goes for e.<p>Since e is in {a,b,c} and d &lt;= a, d &lt;= b, d &lt;= c, it must follow that d &lt;= e. And by symmetry e &lt;= d. So d=e.
评论 #22554365 未加载
kmillabout 5 years ago
The Dedekind cut formulation of the real numbers is that a real number is defined to be a nonempty &quot;downwards closed&quot; subset of rational numbers. Then the min operation corresponds to taking intersections, and taking intersections is associative.<p>It&#x27;s cool they figured something like this out from first principles.<p>edit: oops, somehow didn&#x27;t notice arnarbi already mentioned this!
评论 #22555260 未加载
评论 #22555188 未加载
generationPabout 5 years ago
Similarly 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).<p>The really high horse here is called &quot;Yoneda embedding&quot;, but there is not much gained from going that high.
评论 #22555053 未加载
arnarbiabout 5 years ago
I think a shorter way to write that is to first note the downset representation of reals. Then your definition of min is just the set intersection and there&#x27;s nothing more to show.
评论 #22552264 未加载
评论 #22555508 未加载
Animatsabout 5 years ago
<i>This is the definition that leads to the ugly proof by cases.</i><p>Right there is the problem. There&#x27;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.
评论 #22553643 未加载
nickdrozdabout 5 years ago
&gt; 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.<p>This is how it&#x27;s done in the Idris standard library[1]:<p><pre><code> total minimumAssociative : (l,c,r : Nat) -&gt; minimum l (minimum c r) = minimum (minimum l c) r minimumAssociative Z c r = Refl minimumAssociative (S k) Z r = Refl minimumAssociative (S k) (S j) Z = Refl minimumAssociative (S k) (S j) (S i) = rewrite minimumAssociative k j i in Refl </code></pre> [1] Or prelude, or whatever it&#x27;s called. <a href="https:&#x2F;&#x2F;github.com&#x2F;idris-lang&#x2F;Idris-dev&#x2F;blob&#x2F;master&#x2F;libs&#x2F;prelude&#x2F;Prelude&#x2F;Nat.idr#L772" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;idris-lang&#x2F;Idris-dev&#x2F;blob&#x2F;master&#x2F;libs&#x2F;pre...</a>
评论 #22552329 未加载
评论 #22552309 未加载
Tomminnabout 5 years ago
I find proofs like this weird.<p>I can never quite understand what it means to say anything beyond:<p>&quot;whichever of {a,b,c} is the smallest is the answer to both sides&quot;.<p><i>Who is this audience</i> for which all this extra ink carries extra meaning? <i>What additional insight</i> can you have possibly communicated to them?
评论 #22562209 未加载
评论 #22555929 未加载