<snapdata remixID="14824833"><project name="*****U2L3p2-CombiningPredicates" app="Snap! 11.0.8, https://snap.berkeley.edu" version="2"><notes></notes><thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAAAAXNSR0IArs4c6QAAAiVJREFUeF7t0sEJACAAAzHdf+gKLnGfdIHCkbttxxSIClwAo/JufwEAQUgLAJjmdw4gA2kBANP8zgFkIC0AYJrfOYAMpAUATPM7B5CBtACAaX7nADKQFgAwze8cQAbSAgCm+Z0DyEBaAMA0v3MAGUgLAJjmdw4gA2kBANP8zgFkIC0AYJrfOYAMpAUATPM7B5CBtACAaX7nADKQFgAwze8cQAbSAgCm+Z0DyEBaAMA0v3MAGUgLAJjmdw4gA2kBANP8zgFkIC0AYJrfOYAMpAUATPM7B5CBtACAaX7nADKQFgAwze8cQAbSAgCm+Z0DyEBaAMA0v3MAGUgLAJjmdw4gA2kBANP8zgFkIC0AYJrfOYAMpAUATPM7B5CBtACAaX7nADKQFgAwze8cQAbSAgCm+Z0DyEBaAMA0v3MAGUgLAJjmdw4gA2kBANP8zgFkIC0AYJrfOYAMpAUATPM7B5CBtACAaX7nADKQFgAwze8cQAbSAgCm+Z0DyEBaAMA0v3MAGUgLAJjmdw4gA2kBANP8zgFkIC0AYJrfOYAMpAUATPM7B5CBtACAaX7nADKQFgAwze8cQAbSAgCm+Z0DyEBaAMA0v3MAGUgLAJjmdw4gA2kBANP8zgFkIC0AYJrfOYAMpAUATPM7B5CBtACAaX7nADKQFgAwze8cQAbSAgCm+Z0DyEBaAMA0v3MAGUgLAJjmdw4gA2kBANP8zgFkIC0AYJrf+QOC496obByqTwAAAABJRU5ErkJggg==</thumbnail><scenes select="1"><scene name="*****U2L3p2-CombiningPredicates"><notes></notes><hidden></hidden><headers></headers><code></code><blocks><block-definition s="%&apos;a&apos; ≤ %&apos;b&apos;" type="predicate" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input></inputs><script><block s="doReport"><block s="reportVariadicOr"><list><block s="reportVariadicLessThan"><list><block var="a"/><block var="b"/></list></block><block s="reportVariadicEquals"><list><block var="a"/><block var="b"/></list></block></list></block></block></script></block-definition><block-definition s="%&apos;a&apos; ≥ %&apos;b&apos;" type="predicate" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input></inputs><script><block s="doReport"><block s="reportVariadicOr"><list><block s="reportVariadicGreaterThan"><list><block var="a"/><block var="b"/></list></block><block s="reportVariadicEquals"><list><block var="a"/><block var="b"/></list></block></list></block></block></script></block-definition><block-definition s="%&apos;a&apos; ≠ %&apos;b&apos;" type="predicate" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input></inputs><script><block s="doReport"><block s="reportNot"><block s="reportVariadicEquals"><list><block var="a"/><block var="b"/></list></block></block></block></script></block-definition><block-definition s="is %&apos;mid&apos; between %&apos;low&apos; and %&apos;high&apos; ?" type="predicate" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input><input type="%s"></input></inputs><script><block s="doReport"><block s="reportVariadicAnd"><list><custom-block s="%s ≥ %s"><block var="mid"/><block var="low"/></custom-block><custom-block s="%s ≤ %s"><block var="mid"/><block var="high"/></custom-block></list></block></block></script><scripts><comment x="14.666666666666666" y="88.8" w="304.6666666666667" collapsed="false">As the lab says, it&apos;s okay to use &quot;&gt;&quot; and &quot;&lt;&quot; instead of &quot;≥&quot; and &quot;≤.&quot;</comment></scripts></block-definition><block-definition s="%&apos;p&apos; implies %&apos;q&apos;" type="predicate" category="operators"><header></header><code></code><translations></translations><inputs><input type="%b"></input><input type="%b"></input></inputs><script><block s="doReport"><block s="reportVariadicOr"><list><block s="reportNot"><block var="p"/></block><block var="q"/></list></block></block></script></block-definition><block-definition s="%&apos;p&apos; xor %&apos;q&apos;" type="predicate" category="operators"><header></header><code></code><translations></translations><inputs><input type="%b"></input><input type="%b"></input></inputs><script><block s="doReport"><block s="reportVariadicAnd"><list><block s="reportVariadicOr"><list><block var="p"/><block var="q"/></list></block><block s="reportNot"><block s="reportVariadicAnd"><list><block var="p"/><block var="q"/></list></block></block></list></block></block></script></block-definition></blocks><primitives></primitives><stage name="Stage" width="480" height="360" costume="0" color="255,255,255,1" tempo="60" threadsafe="false" penlog="false" volume="100" pan="0" lines="round" ternary="false" hyperops="true" codify="false" inheritance="true" sublistIDs="false" id="102"><pentrails>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAAAAXNSR0IArs4c6QAADoVJREFUeF7t1cEJAAAIxDDdf2m3sJ+4wEEQuuMIECBAgACBd4F9XzRIgAABAgQIjAB7AgIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECByxcQFpoRMBzwAAAABJRU5ErkJggg==</pentrails><costumes><list struct="atomic" id="103"></list></costumes><sounds><list struct="atomic" id="104"></list></sounds><variables></variables><blocks></blocks><scripts></scripts><sprites select="1"><sprite name="Sprite" idx="1" x="-974" y="54" heading="90" scale="1" volume="100" pan="0" rotation="1" draggable="false" costume="0" color="12,0,241,1" pen="tip" id="109"><costumes><list struct="atomic" id="110"></list></costumes><sounds><list struct="atomic" id="111"></list></sounds><blocks></blocks><variables></variables><scripts><script x="20" y="20"><custom-block s="%s ≤ %s"><l></l><l></l></custom-block></script><script x="20" y="53"><custom-block s="%s ≥ %s"><l></l><l></l></custom-block></script><script x="20" y="86"><custom-block s="%s ≠ %s"><l></l><l></l></custom-block></script><script x="20" y="119"><custom-block s="is %s between %s and %s ?"><l></l><l></l><l></l></custom-block></script><script x="20" y="605.1666666666667"><custom-block s="%b implies %b"><l/><l/><comment w="105.33333333333333" collapsed="true">if P then Q. TFTT</comment></custom-block></script><script x="20" y="640.1666666666667"><custom-block s="%b xor %b"><l/><l/><comment w="117.33333333333333" collapsed="true">exclusive OR. FTTF</comment></custom-block></script><comment x="20" y="675.1666666666667" w="402.6666666666667" collapsed="false">TIF iv:  There are sixteen Boolean operators:&#xD;&#xD;TTTT: Constant function, reports True (ignores both inputs)&#xD;TTTF: P OR Q&#xD;TTFT: not-Q implies not-P; P or not-Q&#xD;TTFF: P (ignores second input)&#xD;TFTT: P implies Q&#xD;TFTF: Q (ignores first input)&#xD;TFFT: P = Q (but in the Boolean domain, not general =)&#xD;TFFF: P AND Q&#xD;FTTT: not-(P AND Q), &quot;NAND&quot;&#xD;FTTF: exclusive OR. P ≠ Q&#xD;FTFT: not-Q (ignores first input)&#xD;FTFF: P and not-Q. not(P implies Q)&#xD;FFTT: not-P (ignores second input)&#xD;FFTF: not-P and Q&#xD;FFFT: not-P and not-Q, not(P or Q), &quot;NOR&quot; &#xD;FFFF: Constant function, reports False (ignores both inputs)&#xD;&#xD;That&apos;s all!  No matter how many operators you string together into a complicated expression, it&apos;ll be equivalent to one of these sixteen.  Isn&apos;t that interesting?&#xD;&#xD;If you think of each of the four letters as a binary digit, in the usual convention that True is 1 and False is 0, then these are the four-bit binary numerals (in backwards order; it&apos;s also conventional to start truth tables with True).&#xD;&#xD;Another way to think about this table is to group the four-letter codes by how many Trues they have:&#xD;&#xD;0 or 4: constant function&#xD;1: &quot;and-like&quot; or &quot;nor-like&quot; function (maybe inverting inputs), implication&#xD;3: &quot;or-like&quot;  or &quot;nand-like&quot; function (ditto), nonimplication&#xD;2: function that ignores one input, or =, or ≠.&#xD;&#xD;TIF v:  There are no firm right and wrong answers.  In certain really rare situations, even the constant functions can be useful.  (Think about a higher order function that requires a two-input Boolean operator as its input, and you don&apos;t really want to compute anything with the given inputs...)  But in general, the two constant functions aren&apos;t useful; the four functions that only use one of the two inputs are rarely useful; AND, OR, XOR, and IMPLIES (TFTT) are useful all the time, and the others are useful some of the time.&#xD;&#xD;TIF vi:  For two-input operators, we made four possible sets of inputs.&#xD;For three-input operators, there are eight possible sets (i.e., eight three-bit numerals).&#xD;So a three-input operator is represented as a string of eight letters T or F.&#xD;In other words, each operator is an eight-bit binary numeral.  There are 2^8 = 256 of them.&#xD; </comment><comment x="20" y="1269.166666666667" w="398" collapsed="false">3.1.  (a) Yes, they all work.&#xD;(b)  Clearly the last two, as one-liners, win on shortness.  The third is slightly shorter.&#xD;(c)  This one really depends on how much experience you&apos;ve had.  If your mind goes blank when you see Boolean operators, then the first one will seem clearest.  But the first one takes more thinking about cases to ensure that each of the three branches is giving the correct result.  Don&apos;t impose one correct answer on this part of the problem; let students say what they think, and have them listen to each other when they differ.&#xD;(d)  I guess this one gives the first two versions a moment in the sun.  What (d) really means, I think, is that the first two don&apos;t use composition of functions.  But that&apos;s one of the fundamental ideas of the course, and if students aren&apos;t yet happy reading compositions, make sure they practice until they /are/ happy with it.&#xD;(e)  The last one clearly wins.  Just consider the name of the function: &quot;greater than or equal to.&quot;  That&apos;s exactly what the fourth version says!&#xD;(f)  Of course there&apos;s no wrong answer; whatever each student thinks right now is that student&apos;s answer.  But you can then raise the question, which would you like to find clearest at the end of the course?</comment><comment x="20" y="1503.166666666667" w="401.3333333333333" collapsed="false">3.2.  If today is Tuesday, it tells you Mary&apos;s is closed; on other days it&apos;s open.  (Mary Chung&apos;s is a Chinese restaurant near MIT with a long history as a hacker favorite.  It&apos;s known for extra spicy food, and especially for Suan La Chow Show (https://en.wikipedia.org/wiki/Suanla_chaoshou).  It is indeed closed Tuesdays.)&#xD;&#xD;3.3  Our solution to 2.5 already uses nested conditionals. </comment></scripts></sprite></sprites></stage><variables></variables></scene></scenes></project><media name="*****U2L3p2-CombiningPredicates" app="Snap! 11.0.8, https://snap.berkeley.edu" version="2"></media></snapdata>