CSC151.01 2015S, Class 15: Boolean Values and Predicate Procedures
==================================================================

_Overview_

* Preliminaries.
    * Admin.
    * Upcoming Work.
    * Extra Credit.
    * Questions.
* Boolean values.
* Predicates - Procedures that return Boolean values.
* Combining booleans with `and` and `or`.

Preliminaries
-------------

### Admin

* Continue partners!
* Mentor session Monday at 7:00 p.m.
* Just in case it's not clear: If I find that you have posted your exam
  work online, including via social media, I will report you for ethical
  violations and, unless prevented by College policy, will fail you in
  the class.
* Friday the 13th falls on Friday this month.  Be careful.
* Weekly PSA.

### Upcoming Work

* [Homework](../assignments/assignment.04.html).
    * Due Tuesday night at 10:30 p.m.
* No lab writeup for today
* Reading for Monday:
    * [Transforming Images](../readings/transforming-images-reading.html)

### Extra Credit Opportunities

#### Academic 

* TEDx Grinnell, February 21
* Pioneer Diversity Council talk

#### Peer Support (Morning Section)

* Swimming, Conference Championships, February 13-15, The Osgood
* Indoor track and field, Saturday.
* Julia's radio show, "The Hot Box".  Wednesday night/Thursday morning 
  1:00-2:00 a.m.  

### Recommended, But no EC

* 2 <3 GC day next Wednesday.

### Questions

Some Ideas from the Reading
---------------------------

* Why do we care about Boolean values?
    * At low levels, we care about only two values (0 and 1).  False
      and True correspond well to those two values.
* Can computers be built with different models other than 0/1?
    * Yes
    * Quantum states: Color and spin
    * Mechanical computers: Analog gives you more ranges
* Do we care about Boolean values even if there are no computers?
    * Boole came up with these ideas before there were computers
    * Ways of talking about "truthiness"
    * Two values is the first step from one possibility to many
      possibilities.
* Booleans can also be used to introduce choice into our programs.
* Why does Racket separate world into false and everything else?
* Let's think about another operation: implication (written =>)
* Table: a => b

          b  T  F
        a    
        T    T  F
        F    T  T

Exercise
--------

Write a function to implement implication

    (define =>
      (lambda (a b)
        ...))

A careful approach: List the cases in which the table is true.

    (define =>
      (lambda (a b)
        (or case-1
            case-2
            case-3)))

* case-1 (top-left): `(and a b)`
* case-2 (bottom-left): `(and (not a) b)`
* case-3 (bottom-right): `(and (not a) (not b))`

So

    (define =>
      (lambda (a b)
        (or (and a b)
            (and (not a) b)
            (and (not a) (not b)))))

Another solution: Work with the columns

    (define =>
      (lambda (a b)
        (or b (not a))))

Another solution: Work with the rows

    (define =>
      (lambda (a b)
        (or (not f)

Another solution: List the false value and negate

     (define =>
       (lambfa (a b)
         (not (and a (not b)))))

The fun of De Morgan's Law

     `(not (or a b))` is equivalent to `(and (not a ) (not b))`
     `(not (and a b))` is equivalent to `(or (not a ) (not b))`
     `(not (not a))` is equivalent to `a`

Note that this only holds in a true/false world.  It does not hold
in a truish/false world.

Followup Questions
------------------

* How many unary Boolean functions are there?  
    * Four!  
        * T->T,F->F
        * T->T,F->T
        * T->F,F->F
        * T->F,F->T
* How many binary Boolean functions are there?
    * Sixteen!
