juan_gandhi: (Default)
[personal profile] juan_gandhi
It's a known puzzle from the depths of object-oriented teaching: is Circle a subclass or Ellipse. From school we know it is; but as we read in books, for programmers, it is not. How come? Oh, "Liskov principle". They use Liskov principle to scare kids.

Actually we know that a circle is an ellipse with both axes being the same length.

But in programming, an ellipse is something different. It is at least stretchable. And it is also moveable. Somehow it is not rotatable, but we can skip it for simplicity.

An ellipse in programming is (almost) always horizontal; it can be moved (by changing coordinates of its center) and it can be stretched/compressed by changing its height and width. Sure a stretchable ellipse is neither an ellipse nor a circle, not even a stretchable circle. A stretchable circle stretches equally in all directions.

That's it, no? Questions? Objections?

Date: 2011-01-25 03:21 am (UTC)
yigal_s: (Default)
From: [personal profile] yigal_s
* it depends on the axiom of choice actually

How comes? In what way?

Date: 2011-01-25 03:58 am (UTC)
From: [identity profile] ivan-gandhi.livejournal.com
See, a stretchable ellipse is a class of ellipses. There's an epimorphism from ellipses to stretchable ellipses; the fact that this epimorphism splits is due to AC: see http://ncatlab.org/nlab/show/axiom+of+choice (http://ncatlab.org/nlab/show/axiom+of+choice).

I can give you an example when this is not the case.

Imagine a curve in space that projects (vertically) on an ellipse. This curve loops twice, in space. So for every point on ellipse there are two points projecting onto it. If we limit ourselves with continuous mappings only, we cannot split this projection.

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

June 2025

S M T W T F S
1 2345 6 7
8 9 10 11 121314
15161718 1920 21
222324252627 28
29 30     

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 3rd, 2025 08:57 pm
Powered by Dreamwidth Studios