{"id":714,"date":"2013-06-29T00:40:00","date_gmt":"2013-06-29T00:40:00","guid":{"rendered":"http:\/\/www.themissingdocs.net\/wordpress\/?p=714"},"modified":"2013-06-29T00:40:00","modified_gmt":"2013-06-29T00:40:00","slug":"binary-functions","status":"publish","type":"post","link":"https:\/\/www.themissingdocs.net\/?p=714","title":{"rendered":"Binary Functions"},"content":{"rendered":"<p>There are 16 binary functions over 2 variables.\u00a0 This is a simple consequence of there being 4 input possibilities and only 2 output possibilities for each.\u00a0 In computer programming we frequently use &#8216;and&#8217; and &#8216;or&#8217;, less often &#8216;xor&#8217;, but that still leaves 13 more.<\/p>\n<p>Lets take a closer look at all 16.\u00a0 For brevity I will label each by their outputs for the inputs F,F T,F F,T T,T &#8211; so &#8216;and&#8217; is FFFT.<\/p>\n<ol>\n<li>TTTT &#8211; &#8216;always true&#8217;.\u00a0 Not very interesting, but it exists.<\/li>\n<li>FFFF &#8211; &#8216;always false&#8217;.\u00a0 Again not very interesting.<\/li>\n<li>FFFT &#8211; &#8216;and&#8217;.\u00a0 Well known and used in programming frequently.<\/li>\n<li>TTTF &#8211; &#8216;not and&#8217;.\u00a0 Simple combination of the negation function with the and.<\/li>\n<li>FTTT &#8211; &#8216;or&#8217;.\u00a0 Well known and used in programming frequently.<\/li>\n<li>TFFF &#8211; &#8216;not or&#8217;.\u00a0 Simple combination of negation and &#8216;or&#8217;.<\/li>\n<li>FTTF &#8211; &#8216;xor&#8217;.\u00a0 Not quite as well known as &#8216;or&#8217;, but simply &#8216;or&#8217; where it can&#8217;t be both.<\/li>\n<li>TFFT &#8211; &#8216;not xor&#8217;.\u00a0 Again a simple combination of negation and &#8216;xor&#8217;.\u00a0 But it is also the A == B scenario and thus xor can also be described as A != B.<\/li>\n<li>FFTT &#8211; &#8216;B is true&#8217;.\u00a0 First parameter is ignored, and second is just passed through.<\/li>\n<li>TTFF &#8211; &#8216;B is not true&#8217;.\u00a0 Again just the negation of the one before.<\/li>\n<li>FTFT &#8211; &#8216;A is true&#8217;.\u00a0 This time the second parameter is ignored.<\/li>\n<li>TFTF &#8211; &#8216;A is not true&#8217;.\u00a0 Yet another simple negation.<\/li>\n<li>TFTT &#8211; &#8216;A implies B&#8217;.\u00a0 If A is true, B must be true, but otherwise anything goes.<\/li>\n<li>FTFF &#8211; &#8216;A and (not B)&#8217;.\u00a0 This is also the negation of &#8216;A implies B&#8217; but programming sees combinations of &#8216;and&#8217; and &#8216;not&#8217; far more frequently.<\/li>\n<li>TTFT &#8211; &#8216;B implies A&#8217;.\u00a0 If B is true, A must be true.<\/li>\n<li>FFTF &#8211; &#8216;(not A) and B&#8217;.\u00a0 As for 14, but reversed.<\/li>\n<\/ol>\n<p>So, why did I list all these?\u00a0 So I could categorize them.<\/p>\n<ul>\n<li>Really, really boring: TTTT, FFFF &#8211; No interest in the inputs.<\/li>\n<li>Boring: FFTT, TTFF, FTFT, TFTF &#8211; Only one input is used.<\/li>\n<li>&#8216;And&#8217; variants: FFFT, TFFF, FFTF, FTFF &#8211; Only one scenario is true.<\/li>\n<li>&#8216;Or&#8217; variants: FTTT, TTTF, TFTT, TTFT &#8211; Three scenarios are true.<\/li>\n<li>Strongly linked: TFFT, FTTF &#8211; Two scenarios are true, and both inputs are used.<\/li>\n<\/ul>\n<p>I am now going to state that I think &#8216;and&#8217; variants are actually boring as well.\u00a0 Since there is only one possible true state, they all result in you being able to say something about A or something about B, in isolation.\u00a0 The problem is separable.\u00a0 Which is just the nature of &#8216;and&#8217;, but it makes it less interesting to me.<\/p>\n<p>This leaves 6 &#8216;interesting&#8217; functions.\u00a0 A is the same as B.\u00a0 A is the opposite of B (xor).\u00a0 A implies B.\u00a0 B implies A.\u00a0 Not both false (or).\u00a0 Not both true (nand).<\/p>\n<p>Of these, &#8216;or&#8217; is obviously the most commonly used in programming.\u00a0 Interestingly, despite being a fundamental element of predicate logic, I have not yet worked with a programming language where A implies B has its own operator, you have to do B or not A, which is a bit clumsy.<\/p>\n<p>Where does this thought train lead me&#8230; well maybe I will have more to say on this topic another time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are 16 binary functions over 2 variables.\u00a0 This is a simple consequence of there being 4 input possibilities and only 2 output possibilities for each.\u00a0 In computer programming we frequently use &#8216;and&#8217; and &#8216;or&#8217;, less often &#8216;xor&#8217;, but that still leaves 13 more. Lets take a closer look at all 16.\u00a0 For brevity I &hellip; <a href=\"https:\/\/www.themissingdocs.net\/?p=714\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Binary Functions<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-714","post","type-post","status-publish","format-standard","hentry","category-random-musings"],"_links":{"self":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/posts\/714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=714"}],"version-history":[{"count":0,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/posts\/714\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}