{"id":267,"date":"2018-03-12T23:14:19","date_gmt":"2018-03-12T23:14:19","guid":{"rendered":"http:\/\/loop.cs.mtu.edu\/?p=267"},"modified":"2023-10-31T00:21:52","modified_gmt":"2023-10-31T00:21:52","slug":"disproof-by-counter-example","status":"publish","type":"post","link":"https:\/\/loop.cs.mtu.edu\/index.php\/2018\/03\/12\/disproof-by-counter-example\/","title":{"rendered":"Disproof by Counter Example"},"content":{"rendered":"<div id=\"article\" style=\"text-align: justify;\">\n<p>Sometimes we need to show that a claim is false. This can be done by finding a <strong>counterexample<\/strong>. Consider any claim of the form:\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"equation_image alignnone\" src=\"https:\/\/mtu.instructure.com\/equation_images\/%255Cforall%2520x%255Cin%2520S%252C%255C%253AP_x%255Clongrightarrow%2520Q_x\" width=\"154\" height=\"20\" \/>. To show that the claim is false, we need to find a value of\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"equation_image alignnone\" title=\"x\\in S\" src=\"https:\/\/mtu.instructure.com\/equation_images\/x%255Cin%2520S\" alt=\"x\\in S\" width=\"45\" height=\"17\" \/>\u00a0for which\u00a0<img decoding=\"async\" class=\"equation_image\" title=\"P_x\" src=\"https:\/\/mtu.instructure.com\/equation_images\/P_x\" alt=\"P_x\" \/>\u00a0is true and\u00a0<img decoding=\"async\" class=\"equation_image\" title=\"Q_x\" src=\"https:\/\/mtu.instructure.com\/equation_images\/Q_x\" alt=\"Q_x\" \/>\u00a0is false.<\/p>\n<p>That is, we need to prove the negation of the above claim:\u00a0<img decoding=\"async\" class=\"equation_image\" title=\"\\exists x\\in S\\mid P_x\\wedge \\overline Q_{x} \" src=\"https:\/\/mtu.instructure.com\/equation_images\/%255Cexists%2520x%255Cin%2520S%255Cmid%2520P_x%255Cwedge%2520%255Coverline%2520Q_%257Bx%257D%2520\" alt=\"\\exists x\\in S\\mid P_x\\wedge \\overline Q_{x} \" \/>. Finding any\u00a0<img decoding=\"async\" class=\"equation_image\" title=\"x\" src=\"https:\/\/mtu.instructure.com\/equation_images\/x\" alt=\"x\" \/>\u00a0that supports the negation of the original claim is sufficient to disprove it. <!--more--><\/p>\n<\/div>\n<div id=\"example\" style=\"border-radius: 25px; border: 2px solid #73AD21; padding: 20px; width: 80%; margin: 0 auto;\">\n<p><strong>Example<\/strong><\/p>\n<p>Disprove the following claim.<\/p>\n<p><strong>Claim<\/strong>: <img decoding=\"async\" class=\"equation_image\" title=\"\\forall x,y\\in\\mathbb{R},\\:(x+y)^{2} = x^{2} + y^{2} \" src=\"https:\/\/mtu.instructure.com\/equation_images\/%255Cforall%2520x%252Cy%255Cin%255Cmathbb%257BR%257D%252C%255C%253A%2528x%2By%2529%255E%257B2%257D%2520%253D%2520x%255E%257B2%257D%2520%2B%2520y%255E%257B2%257D%2520\" alt=\"\\forall x,y\\in\\mathbb{R},\\:(x+y)^{2} = x^{2} + y^{2} \" \/><\/p>\n<p><strong>Counterexample<\/strong>:\u00a0We need to show that <img decoding=\"async\" class=\"equation_image\" title=\"\\exists x,y\\in\\mathbb{R},\\:(x+y)^{2} \\ne x^{2} + y^{2} \" src=\"https:\/\/mtu.instructure.com\/equation_images\/%255Cexists%2520x%252Cy%255Cin%255Cmathbb%257BR%257D%252C%255C%253A%2528x%2By%2529%255E%257B2%257D%2520%255Cne%2520%2520x%255E%257B2%257D%2520%2B%2520y%255E%257B2%257D%2520\" alt=\"\\exists x,y\\in\\mathbb{R},\\:(x+y)^{2} \\ne x^{2} + y^{2} \" \/><\/p>\n<p>A good idea is to try typical edge values, such as 1.<\/p>\n<p>Let\u00a0<img decoding=\"async\" class=\"equation_image\" title=\"x=y=1\" src=\"https:\/\/mtu.instructure.com\/equation_images\/x%253Dy%253D1\" alt=\"x=y=1\" \/>.<\/p>\n<p><img decoding=\"async\" class=\"equation_image\" title=\"\\begin{array}{lcr} (x+y) ^{2} \\: \\: ? \\: \\: x^{2} + y^{2} \\\\ (1+1) ^{2} \\: \\: ? \\: \\: 1^{2} + 1^{2} \\\\ \\: \\: \\: \\: \\: \\: \\: \\: \\: \\: \\: 4 \\: \\ne \\: 2 \\end{array}\" src=\"https:\/\/mtu.instructure.com\/equation_images\/%255Cbegin%257Barray%257D%257Blcr%257D%250A%2528x%2By%2529%2520%255E%257B2%257D%2520%255C%253A%2520%255C%253A%2520%253F%2520%255C%253A%2520%255C%253A%2520x%255E%257B2%257D%2520%2B%2520y%255E%257B2%257D%2520%255C%255C%250A%25281%2B1%2529%2520%255E%257B2%257D%2520%255C%253A%2520%255C%253A%2520%253F%2520%255C%253A%2520%255C%253A%25201%255E%257B2%257D%2520%2B%25201%255E%257B2%257D%2520%255C%255C%250A%255C%253A%2520%255C%253A%2520%255C%253A%2520%255C%253A%2520%255C%253A%2520%255C%253A%2520%255C%253A%2520%255C%253A%2520%255C%253A%2520%255C%253A%2520%255C%253A%25204%2520%255C%253A%2520%255Cne%2520%2520%255C%253A%25202%250A%255Cend%257Barray%257D\" alt=\"\\begin{array}{lcr} (x+y) ^{2} \\: \\: ? \\: \\: x^{2} + y^{2} \\\\ (1+1) ^{2} \\: \\: ? \\: \\: 1^{2} + 1^{2} \\\\ \\: \\: \\: \\: \\: \\: \\: \\: \\: \\: \\: 4 \\: \\ne \\: 2 \\end{array}\" \/><\/p>\n<p>When <img decoding=\"async\" class=\"equation_image\" title=\"x=y=1\" src=\"https:\/\/mtu.instructure.com\/equation_images\/x%253Dy%253D1\" alt=\"x=y=1\" \/>,\u00a0<img decoding=\"async\" class=\"equation_image\" title=\"(x+y)^{2} \\ne x^{2} + y^{2}\" src=\"https:\/\/mtu.instructure.com\/equation_images\/%2528x%2By%2529%255E%257B2%257D%2520%255Cne%2520%2520x%255E%257B2%257D%2520%2B%2520y%255E%257B2%257D\" alt=\"(x+y)^{2} \\ne x^{2} + y^{2}\" \/>.<br \/>\nThus disproving the original claim.<\/p>\n<\/div>\n<div id=\"article\" style=\"text-align: justify;\">\n<p>&nbsp;<\/p>\n<p>Of course, it is unusual to disprove a claim on the first attempt. If an inspection of the problem and some back-of-the-envelope calculations do not pan out, you may want to write a program to search for a counterexample.<\/p>\n<p>A <strong>Fermat Number<\/strong> is a number of the form:\u00a0<strong>f(x) = <img decoding=\"async\" class=\"equation_image\" title=\"2^{2^{x} }+1\" src=\"https:\/\/mtu.instructure.com\/equation_images\/2%255E%257B2%255E%257Bx%257D%2520%257D%2B1\" alt=\"2^{2^{x} }+1\" \/><\/strong>. Fermat numbers were first studied by mathematician Pierre de Fermat, who conjectured\u00a0that all Fermat numbers are prime. Let&#8217;s try to disprove his conjecture claim.<\/p>\n<p><strong>Claim<\/strong>: <img decoding=\"async\" class=\"equation_image\" title=\"\\forall x\\in\\mathbb{N},\\:2^{2^x}+1 \\text{ is prime. }\" src=\"https:\/\/mtu.instructure.com\/equation_images\/%255Cforall%2520x%255Cin%255Cmathbb%257BN%257D%252C%255C%253A2%255E%257B2%255Ex%257D%2B1%2520%2520%255Ctext%257B%2520is%2520prime.%2520%257D\" alt=\"\\forall x\\in\\mathbb{N},\\:2^{2^x}+1 \\text{ is prime. }\" \/><\/p>\n<p><strong>Counterexample<\/strong>:\u00a0We need to show that <img decoding=\"async\" class=\"equation_image\" title=\"\\exists x\\in\\mathbb{N},\\:2^{2^x}+1 \\text{ is not prime. }\" src=\"https:\/\/mtu.instructure.com\/equation_images\/%255Cexists%2520x%255Cin%255Cmathbb%257BN%257D%252C%255C%253A2%255E%257B2%255Ex%257D%2B1%2520%2520%255Ctext%257B%2520is%2520not%2520prime.%2520%257D\" alt=\"\\exists x\\in\\mathbb{N},\\:2^{2^x}+1 \\text{ is not prime. }\" \/><\/p>\n<p>A good idea is to try typical edge cases such as <img decoding=\"async\" class=\"equation_image\" title=\"x=0\" src=\"https:\/\/mtu.instructure.com\/equation_images\/x%253D0\" alt=\"x=0\" \/>\u00a0and\u00a0<img decoding=\"async\" class=\"equation_image\" title=\"x=1\" src=\"https:\/\/mtu.instructure.com\/equation_images\/x%253D1\" alt=\"x=1\" \/>.<\/p>\n<table>\n<tbody>\n<tr>\n<th><strong><img decoding=\"async\" class=\"equation_image\" title=\"x\" src=\"https:\/\/mtu.instructure.com\/equation_images\/x\" alt=\"x\" \/><\/strong><\/th>\n<th><strong><img decoding=\"async\" class=\"equation_image\" title=\"2^{2^{x} }+1\" src=\"https:\/\/mtu.instructure.com\/equation_images\/2%255E%257B2%255E%257Bx%257D%2520%257D%2B1\" alt=\"2^{2^{x} }+1\" \/><\/strong><\/th>\n<th><strong>Prime?<\/strong><\/th>\n<\/tr>\n<tr>\n<td><strong>0<\/strong><\/td>\n<td><strong>3<\/strong><\/td>\n<td><strong>&#x2714;<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>1<\/strong><\/td>\n<td><strong>5<\/strong><\/td>\n<td><strong>&#x2714;<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>That didn&#8217;t work, so let&#8217;s write a program to systematically try all values of <em>x<\/em> to see if there is break in the pattern.<\/p>\n<p>First, we need a way to determine if\u00a0<img decoding=\"async\" class=\"equation_image\" title=\"2^{2^{x} }+1\" src=\"https:\/\/mtu.instructure.com\/equation_images\/2%255E%257B2%255E%257Bx%257D%2520%257D%2B1\" alt=\"2^{2^{x} }+1\" \/> is prime. Let&#8217;s write a method that returns the first prime divisor of a given number <i>m<\/i>. If the first prime divisor of the number <i>m<\/i> equals\u00a0<i>m<\/i>, then the number <i>m<\/i> is prime.<\/p>\n<pre>public static BigInteger primeDivisor(BigInteger n ) {\n   \/\/ All primes are greater than 1 \n   if ( n.compareTo( BigInteger.ONE ) &lt;= 0 )\n      return BigInteger.valueOf( -1L );\n   \/\/ 2 is the only even prime\n   if ( n.mod( BigInteger.valueOf( 2L ) )\n         .compareTo( BigInteger.ZERO ) == 0 ) \n      return BigInteger.valueOf( 2L ); \n   \/\/ Check for divisibility\n   for( BigInteger i = BigInteger.valueOf( 3L ); \n        i.pow( 2 ).compareTo( n ) &lt;= 0; \n        i = i.add( BigInteger.valueOf( 2L ) ) ) {\n      \/\/ Does i divide n?\n      if ( n.mod( i ).compareTo(BigInteger.ZERO) == 0 ) \n         return i; \/\/ n is not prime\n    }\n    return n; \/\/ n is prime\n}<\/pre>\n<p>We use <span style=\"font-family: monospace;\">BigInteger<\/span> values because the value of <img decoding=\"async\" class=\"equation_image\" title=\"2^{2^{x} }+1\" src=\"https:\/\/mtu.instructure.com\/equation_images\/2%255E%257B2%255E%257Bx%257D%2520%257D%2B1\" alt=\"2^{2^{x} }+1\" \/> will get large very quickly and exceed the maximum number that can be stored in a <span style=\"font-family: monospace;\">long<\/span><\/p>\n<div id=\"callout\" style=\"border-radius: 25px; border: 2px solid #7321AD; padding: 20px; width: 80%; margin: 0 auto;\"><strong>The BigInteger Data Type<\/strong><br \/>\nThe BigInteger class is used for mathematical operations which involve very large numbers that are outside the limit of all available primitive data types. For integers, this means numbers smaller than -9223372036854775808 or larger than\u00a09223372036854775807, which are Long.MIN_VALUE and Long.MAX_VALUE, respectively.<\/div>\n<p>&nbsp;<\/p>\n<div>Now we write code to exhaustively try all values of\u00a0<em>x<\/em> starting with 0. Well, not all values of <em>x<\/em>. We will stop when x is 30 to avoid integer overflow. Placing such a boundary on the search is pragmatic and recognizes that we may not be able to identify a counterexample with our available computing resources.<\/div>\n<div><\/div>\n<div>Let&#8217;s write the code to display each x and f(x) and indicate if f(x) is prime in a table.<\/div>\n<\/div>\n<div>\n<pre>\/\/ Print the header row\nSystem.out.printf(\"%2s %-10s prime?%n\", \"x\", \"f(x)\" );\n\/\/ stop at x = 30 to prevent integer overflow\nfor( int x = 0; x &lt;= 30; x++ ) {\n   BigInteger result = \n       BigInteger.valueOf( 2L )\n                 .pow( (int) Math.pow( 2, x ) )\n                 .add( BigInteger.ONE);\n   System.out.printf(\"%2d %-10s \", x, result );\n   BigInteger divisor = primeDivisor( result );\n   if ( divisor != result ) {\n      \/\/ result is not prime\n      System.out.printf(\"No: Divisible by %d%n\", divisor );\n      break;\n   }\n   \/\/ result is prime\n   System.out.println( \"Yes\" );\n}<\/pre>\n<\/div>\n<div><\/div>\n<div>The table generated by the above code is presented below.<\/div>\n<div><\/div>\n<div id=\"article\" style=\"text-align: justify;\">\n<table>\n<tbody>\n<tr>\n<th><strong><img decoding=\"async\" class=\"equation_image\" title=\"x\" src=\"https:\/\/mtu.instructure.com\/equation_images\/x\" alt=\"x\" \/><\/strong><\/th>\n<th><strong><img decoding=\"async\" class=\"equation_image\" title=\"2^{2^{x} }+1\" src=\"https:\/\/mtu.instructure.com\/equation_images\/2%255E%257B2%255E%257Bx%257D%2520%257D%2B1\" alt=\"2^{2^{x} }+1\" \/><\/strong><\/th>\n<th><strong>Prime?<\/strong><\/th>\n<\/tr>\n<tr>\n<td><strong>0<\/strong><\/td>\n<td><strong>3<\/strong><\/td>\n<td><b>Yes<\/b><\/td>\n<\/tr>\n<tr>\n<td><strong>1<\/strong><\/td>\n<td><strong>5<\/strong><\/td>\n<td><b>Yes<\/b><\/td>\n<\/tr>\n<tr>\n<td><strong>2<\/strong><\/td>\n<td><strong>17<\/strong><\/td>\n<td><b>Yes<\/b><\/td>\n<\/tr>\n<tr>\n<td><strong>3<\/strong><\/td>\n<td><strong>257<\/strong><\/td>\n<td><b>Yes<\/b><\/td>\n<\/tr>\n<tr>\n<td><strong>4<\/strong><\/td>\n<td><strong>65537<\/strong><\/td>\n<td><b>Yes<\/b><\/td>\n<\/tr>\n<tr>\n<td><strong>5<\/strong><\/td>\n<td><strong>4294967297<\/strong><\/td>\n<td><strong>No! Divisible by 641<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>When <img decoding=\"async\" class=\"equation_image\" title=\"x=5\" src=\"https:\/\/mtu.instructure.com\/equation_images\/x%253D5\" alt=\"x=5\" \/>,\u00a0<img decoding=\"async\" class=\"equation_image\" title=\"2^{2^{x} } \" src=\"https:\/\/mtu.instructure.com\/equation_images\/2%255E%257B2%255E%257Bx%257D%2520%257D%2520\" alt=\"2^{2^{x} } \" \/>\u00a0is not prime. Thus disproving the original claim.<\/p>\n<p>We are in good company. The\u00a0conjecture was originally refuted by Leonhard Euler in 1732, but he had to do the calculations by hand.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes we need to show that a claim is false. This can be done by finding a counterexample. Consider any claim of the form:\u00a0. To show that the claim is false, we need to find a value of\u00a0\u00a0for which\u00a0\u00a0is true and\u00a0\u00a0is false. That is, we need to prove the negation of the above claim:\u00a0. Finding &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/loop.cs.mtu.edu\/index.php\/2018\/03\/12\/disproof-by-counter-example\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Disproof by Counter Example&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[29],"class_list":["post-267","post","type-post","status-publish","format-standard","hentry","category-intermediate","tag-math"],"_links":{"self":[{"href":"https:\/\/loop.cs.mtu.edu\/index.php\/wp-json\/wp\/v2\/posts\/267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/loop.cs.mtu.edu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/loop.cs.mtu.edu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/loop.cs.mtu.edu\/index.php\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/loop.cs.mtu.edu\/index.php\/wp-json\/wp\/v2\/comments?post=267"}],"version-history":[{"count":11,"href":"https:\/\/loop.cs.mtu.edu\/index.php\/wp-json\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":357,"href":"https:\/\/loop.cs.mtu.edu\/index.php\/wp-json\/wp\/v2\/posts\/267\/revisions\/357"}],"wp:attachment":[{"href":"https:\/\/loop.cs.mtu.edu\/index.php\/wp-json\/wp\/v2\/media?parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/loop.cs.mtu.edu\/index.php\/wp-json\/wp\/v2\/categories?post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/loop.cs.mtu.edu\/index.php\/wp-json\/wp\/v2\/tags?post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}