logoalt Hacker News

kccqzy • yesterday at 11:26 PM • 1 reply • view on HN

I disagree. In writing a proof in math you also apply successive steps. This is clear in a proof written in English, and even clearer in a Lean proof where you literally list the steps (tactics) in order. The forward and backward thing you are talking about is probably about proving A if and only if B; that’s a small category of proofs. A small category of programming tasks (like parsing and pretty printing) also need the programmer to think forwards and backwards.

The idea of making abstractions comes from mathematics. The entire field of algebra is just abstractions. Algebraists think about the group, the ring, the field rather than the underlying objects. These abstractions absolutely don’t leak. These are some of the most elegant abstractions available, and this style of abstractions is known as type classes (in Haskell) or traits (in Rust), and is far superior to programmer-derived object-oriented abstractions. Why do most programmers create abstractions that leak? Because they are only taught object-oriented programming and yet without even learning about the Liskov substitution principle.


Replies

smj-edison • today at 2:11 AM

> The forward and backward thing you are talking about is probably about proving A if and only if B

I'm aware about bidirectional implication, but that's not quite what I'm getting at. With programming I think in terms of starting with some input data, successively applying calculations, and then ending with a result. There's a step-by-stepness to it. With math I have to think of it existing in all ways, simultaneously. Equality works both directions, but variable assignment doesn't. Math functions go both ways (at least when they're bijective), but programming functions only go one way. Maybe I haven't done enough math yet, but it hurts my brain in ways that programming never has. I don't usually program contrapositively or by contradiction.

And it's true that math arguments are presented linearly, but that's because there's not really another way. I have to reconstruct the mathematical framework from the linear presentation, but it hardly feels linear once it's all brought together in my head.

> The entire field of algebra is just abstractions.

I'm afraid I haven't taken abstract algebra yet, that'll be next semester! But I hadn't considered about how algebra works with objects that satisfy certain properties, so I'm glad you've brought that up. Thus far I've mainly been done proofs in linear algebra and my intro to proofs class, so that certainly colors my understanding.