# 08.03.07

## Exercise 8.10

Posted in Uncategorized at 10:16 pm by admin

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)```

## 1 Comment »

1. fero said,

July 22, 2008 at 12:00 pm

IMHO
Rectangle s1 s2 `containsS` p = Rectangle (-s1) s2 `containsS` p
is not true only because you didn’t updated definition of Rectangle `containsS`p for negative sidelengths. I didn’t updated it as well because we were not asked to do it but I think we should. If a side length x is e.g. 10 then p should meet
-5<=px && px<=5
but if x = – 10then p should meet
5<=px && px<=-5
which has no sense.