Difference between revisions of "CSC103: DT's Notes 1"

From dftwiki3
Jump to: navigation, search
Line 141: Line 141:
 
When ''a'' is true, '''not''' ''a'' is false, and conversely.  
 
When ''a'' is true, '''not''' ''a'' is false, and conversely.  
  
====An Example====
+
====An Example and Exercise====
  
 
Assume we want to build a logical machine that can use the logical operators '''and''', '''or''' and '''not''' to help me buy ice cream for a friend.  The friend in question has very specific taste, and likes ice cream with chocolate in it, ice cream with fruit in it, but not Haagen Dazs ice cream.  So we can devise three boolean variables that can be true of false depending on three properties of a container of ice cream: ''choc'', ''fruit'', and ''HG''.  ''choc'' is true if the ice cream contains some chocolate.  ''fruit'' is true if the ice cream contains fruits, and ''HG'' is true if the ice cream is from Haagen Dazs.  A boolean function, or expression, we're going to call it ''isgood'', containing ''choc'', ''fruit'', and ''HG'' that turns true whenever the ice cream is one our friend will like would be this:
 
Assume we want to build a logical machine that can use the logical operators '''and''', '''or''' and '''not''' to help me buy ice cream for a friend.  The friend in question has very specific taste, and likes ice cream with chocolate in it, ice cream with fruit in it, but not Haagen Dazs ice cream.  So we can devise three boolean variables that can be true of false depending on three properties of a container of ice cream: ''choc'', ''fruit'', and ''HG''.  ''choc'' is true if the ice cream contains some chocolate.  ''fruit'' is true if the ice cream contains fruits, and ''HG'' is true if the ice cream is from Haagen Dazs.  A boolean function, or expression, we're going to call it ''isgood'', containing ''choc'', ''fruit'', and ''HG'' that turns true whenever the ice cream is one our friend will like would be this:
Line 217: Line 217:
 
|}
 
|}
 
   
 
   
 +
The important parts of the table above are the first 3 columns and the last one.  The first 3 columns list all the possibilities of having three boolean variables take all possible values of true and false.  That corresponds to 2 x 2 x 2 = 8 rows.  Let's take Row 4.  It corresponds to the case ''choc'' = false, ''fruit'' = true, and ''HG'' = true.  The fourth column shows the result of '''or'''-ing ''choc'' and ''fruit''.  Looking at the truth table for '''or''' above, we see that the result of false with true is true.  Hence the T on the fourth row, fourth column.  Column 5 contains '''not''' ''HG''.  Since ''HG'' is true on Row 4, then '''not''' ''HG'' is false.  The sixth column represent the '''and''' of Column 4 with Column 5.  If we '''and''' true and false, the truth table for '''and''' says the result is false.  Hence that particular ice cream would not be good for our friend.  That makes sense, our friend said no ice cream from Haagen Dazs, and the one with just picked does. 
  
 +
Below are some questions for you to figure out:
 +
;Question 1
 +
: Which row of the table would correspond to a container of Ben and Jerry's vanilla ice cream?  Would our friend like it?
 +
 +
;Question 2
 +
: How about a container of Ben and Jerry's strawberry chocolate ice cream?
 +
 +
;Question 3
 +
: Assume that our friend has a younger brother with a different boolean equation for ice cream.  His equation is ( ('''not''' choc) '''and''' ''fruit'') and ( ''HG'' or ( not ''HG'' ) ).  Give an example of several ice cream flavors and makers the brother will like.
 +
 +
;Question 4 (challenging)
 +
: Can you find an ice cream flavor and maker that both our friend and his/her younger brother will like?
  
 
Assume that I'm interested in buying ice cream for three friends: Edna, Liz, and Frida.  Before going to the store I probe my friends for their taste in ice cream.  Edna likes anything with chocolate, but doesn't like anything with fruit.  She also doesn't like  
 
Assume that I'm interested in buying ice cream for three friends: Edna, Liz, and Frida.  Before going to the store I probe my friends for their taste in ice cream.  Edna likes anything with chocolate, but doesn't like anything with fruit.  She also doesn't like  

Revision as of 22:25, 30 January 2012

--© D. Thiebaut 08:10, 30 January 2012 (EST)


This section is only visible to computers located at Smith College