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

From dftwiki3
Jump to: navigation, search
Line 139: Line 139:
 
|}
 
|}
  
 +
When ''a'' is true, '''not''' ''a'' is false, and conversely.
 +
 +
====An Example====
 +
 +
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:
 +
 +
''isgood'' = ( ''choc'' '''or''' ''fruit'' ) '''and''' ( '''not''' ''HG'' )
 +
 +
Any ice cream container for which ''choc'' or ''fruit'' is true, and which is not ''HG'' will match our friend's taste.
 +
 +
We could represent this boolean function with a truth table as well.
 +
 +
{| border="1" cellpadding="10" cellspacing="0"
 +
! choc
 +
! fruit
 +
! HG
 +
! choc or fruit
 +
! not HG
 +
! ( choc or fruit ) and ( not HG )
 +
|-
 +
|
 +
| F
 +
| F
 +
| F 
 +
| F 
 +
| T 
 +
| F
 +
|-
 +
| F
 +
| F
 +
| T
 +
| F
 +
| F
 +
| F
 +
|-
 +
| F
 +
| T
 +
| F
 +
| T
 +
| T
 +
| T
 +
|-
 +
| F
 +
| T
 +
| T
 +
| T
 +
| F
 +
| F
 +
|-
 +
| T
 +
| F
 +
| F
 +
| T
 +
| T
 +
| T
 +
|-
 +
| T
 +
| F
 +
| T
 +
| T
 +
| F
 +
| F
 +
|-
 +
| T
 +
| T
 +
| F
 +
|  T
 +
|  T
 +
| T
 +
|-
 +
| T
 +
| T
 +
| T
 +
|  T
 +
| F
 +
| F
 +
|-
 +
|}
 +
  
====Example====
 
  
 
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 21:11, 30 January 2012

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


This section is only visible to computers located at Smith College