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

_Overview_

* Preliminaries.
    * Admin.
    * Upcoming Work.
    * Extra Credit.
    * Questions.
* Questions on the reading
* An exercise
* Debrief on the exercise 
* Additional questions and issues

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 (Afternoon Section)

* Swimming, Conference Championships, February 13-15, The Osgood
* Indoor track and field, Saturday.
* Men's Basketball vs. Knox, next Wednesday at 7:30 p.m., New Darby

### Recommended, But no EC

* 2 <3 GC day next Wednesday.
* Reggaeton Gardner tonight 9-1.
* Reminder: If you'd bothered to go to Salsa club, you would dance
  better tonight.
  
### Questions

* If I go to two days of the swim meet (and I'm not a swimmer), will I get
  two units of extra credit?  Yes.

Boolean values
--------------

* Two primary values: true (#t) and false (#f), along with operations
  on those values.
* Why are we learning these things?
    * They will be useful when we write conditionals
    * Another way to get the computer to do something
    * Computers think in 0's and 1's (only two values), so thinking in 
      a world of two values is helpful

Thinking About Boolean Functions
--------------------------------

* Useful to think about functions from Boolean values to Boolean values
* `equal?` and `=` both give truth values as output.
    * `check-equal?` and `check-=`
* At the most basic level, `and` and `or` are functions that take
  Boolean input values and give Boolean outputs.  `not`.
* How might you explain to someone what `and`, `or`, or `not` means?
    * `and` - if both inputs are true, the output is true
    * `or` - if either input is true, the output is true
    * `not` - if the input is true, the output is false
* Using that definition, what is the value of `(and #t #f)`?

                  input/a
        AND    True    False
    i
    n  True    True    False
    p
    u  False   False   False
    t
    /
    b

                  input/a
        OR     True    False
    i
    n  True    True    True  
    p
    u  False   True    False
    t
    /
    b

An Exercise
-----------

Create the implies function

                  input/a
        =>     True    False
    i
    n  True    True    False
    p
    u  False   True    True
    t
    /
    b

### Solutions ...

List all the cases in which => holdsa

* (and a b)
* "a is false and b is true" `(and (not a) b)`
* "both a and b are false": `(and (not a) (not b))`

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

A good strategy: Gives you long answers, but gives you an answer

Simplifying the answer: If b holds, we don't care about a

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

Another approach: Just eliminate the falses

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

Will we know whnat to do in the other cases?

New Question: How many different Boolean functions are there?

* We've seen three Boolean functions on two inputs
* How many different Boolean functions on two inputs are there?
* Simpler question: How many different Boolean functions on one
  input are there?
