Functional Problem Solving (CSC 151 2015S) : EBoards

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


Overview

Preliminaries

Admin

Upcoming Work

Extra Credit Opportunities

Academic

Peer Support (Morning Section)

Recommended, But no EC

Questions

Some Ideas from the Reading

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)))

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