The first “fact” cannot be proven because it is false! Given the definition:
containsS :: Shape -> Coordinate -> Bool (Rectangle s1 s2) `containsS` (x,y) = let t1 = s1 / 2 t2 = s2 / 2 in -t1 <= x && x <= t1 && -t2 <= y && y <= t2 (Ellipse r1 r2) `containsS` (x,y) = (x/r1)^2 + (y/r2)^2 <= 1 |
It is not true that:
Rectangle s1 s2 `containsS` p = Rectangle (-s1) s2 `containsS` p
This can be easily seen e.g. when s1 = 4, s2 = 2, p = (1,1). However, it’s true that:
rectangle s1 s2 `containsS` p = rectangle (-s1) s2 `containsS` p
Given our updated definition of `containsS` for polygons from Exercise 8.4. To prove the second fact is trivial:
Ellipse (-r1) r2 `containsS` (x,y) = (x/(-r1))2 + (y/r2)2 <= 1 = (x2/(-r1)2) + (y/r2)2 <= 1 = (x2/r12) + (y/r2)2 <= 1 = (x/r1)2 + (y/r2)2 <= 1 = Ellipse r1 r2 `containsS` (x,y)