Functional Problem Solving (CSC 151 2015S) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric] - [Calendar]
Current: [Assignment] [EBoard am] [EBoard pm] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards am] [EBoards pm] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2014F)] [Weinman (2014F)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Book Office Hours] - [Issue Tracker (Course)]
Overview
and and or.Table: a => b
b T F
a
T T F
F T T
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)))
(and a b)(and (not a) b)(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.