{"id":39,"date":"2007-08-03T22:16:05","date_gmt":"2007-08-04T05:16:05","guid":{"rendered":"http:\/\/www.elbeno.com\/haskell_soe_blog\/?p=39"},"modified":"2008-01-08T07:11:36","modified_gmt":"2008-01-08T15:11:36","slug":"exercise-810","status":"publish","type":"post","link":"https:\/\/www.elbeno.com\/haskell_soe_blog\/?p=39","title":{"rendered":"Exercise 8.10"},"content":{"rendered":"<p>The first &#8220;fact&#8221; cannot be proven because it is false! Given the definition:<\/p>\n<pre lang=\"haskell\">containsS :: Shape -> Coordinate -> Bool\r\n(Rectangle s1 s2) `containsS` (x,y)\r\n    = let t1 = s1 \/ 2\r\n          t2 = s2 \/ 2\r\n      in -t1 <= x &#038;&#038; x <= t1 &#038;&#038; -t2 <= y &#038;&#038; y <= t2\r\n(Ellipse r1 r2) `containsS` (x,y)\r\n    = (x\/r1)^2 + (y\/r2)^2 <= 1<\/pre>\n<p>It is not true that:<\/p>\n<pre>Rectangle s1 s2 `containsS` p = Rectangle (-s1) s2 `containsS` p<\/pre>\n<p>This can be easily seen e.g. when <tt>s1 = 4<\/tt>, <tt>s2 = 2<\/tt>, <tt>p = (1,1)<\/tt>. However, it's true that:<\/p>\n<pre>rectangle s1 s2 `containsS` p = rectangle (-s1) s2 `containsS` p<\/pre>\n<p>Given our updated definition of <tt>`containsS`<\/tt> for polygons from <a href=\"http:\/\/www.elbeno.com\/haskell_soe_blog\/?p=33\">Exercise 8.4<\/a>. To prove the second fact is trivial:<\/p>\n<pre>Ellipse (-r1) r2 `containsS` (x,y)\r\n= (x\/(-r1))<sup>2<\/sup> + (y\/r2)<sup>2<\/sup> <= 1\r\n= (x<sup>2<\/sup>\/(-r1)<sup>2<\/sup>) + (y\/r2)<sup>2<\/sup> <= 1\r\n= (x<sup>2<\/sup>\/r1<sup>2<\/sup>) + (y\/r2)<sup>2<\/sup> <= 1\r\n= (x\/r1)<sup>2<\/sup> + (y\/r2)<sup>2<\/sup> <= 1\r\n= Ellipse r1 r2 `containsS` (x,y)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The first &#8220;fact&#8221; 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<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/posts\/39"}],"collection":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=39"}],"version-history":[{"count":0,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/posts\/39\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}