Where have we been?
Scheme -
define, lambda, if, zero?, 0, add1
computation as an extension of algebra
struct recursion -- mirror your input
generative recursion
accumulator recursion, loops
side-effects: set-struct-field!, set!, print, read
imperative programming, assembly language
In Jam, some opcodes are redundant. What would a minimal set be?
In fact, which is more powerful -- Scheme or JAM?
(digression:
why the names car
and cdr
?)
In 1930's, people trying to formalize "computation"
lambda calculus -- Church 1936
Turing Machine -- Turing 1936
recursive functions -- Go:del, Kleene 1936
deduction systems -- Post 1943
register machines (JAM) -- 1946
Church-Turing thesis: all notions of "computability" are the same! Can we compute anything we like? No:
;; Loop forever. ;; (define (loop x) (loop (add1 x))) ;; halt: program, input --> boolean ;; return #t if prog eventually stops given inp; #f otherwise. ;; (define (halt prog inp) ...)
I claim we can't write this function halt
.
Proof by contradiction: Pretend we could write it,
and reach a contradition
("Assuming my broker wasn't lying, i have $1M in bank.")
Okay, supposing we *could* write halt in scheme. Then,
(define (twisted prog) (if (halt prog prog) (loop 17) true)) ;; twisted: takes a program, and
;; loops forever if prog halts given itself as input; ;; returns if prog runs forever given itself as input.
Question: what is
(twisted twisted)
?
(twisted twisted)
loops forever.
Then (by description of twisted), "twisted halts given itself as input".
Where to go from here:
CS is *not* about programming. ("CS is no more about computers than
astronomy is about telescopes")
Comp212: more programming, and program design; object-oriented (java)
circuit design (elec 326); comp arch: comp/elec 320;
Compilers, OS.
networks, security.
applications: databases, graphics, ai, (robotics).
theory: comp280; comp481
(user-interfaces are usually given scant notice, yet are arguably the most important feature of any program people will use.)
;; loop: --> [never returns] ;; (define (loop) (loop)) ;; halt: program, input --> boolean ;; Return #t if prog eventually stops given inp; #f otherwise. ;; (define (halt prog inp) ...) #| I claim we can't write this functionhalt
. Proof by contradiction: Pretend we could write it, and reach a contradiction
("Assuming my broker wasn't lying, i have $1M in bank.") ; Okay, supposing we *could* write halt in scheme. Then, |# (define (twisted prog) (if (halt prog prog) (loop) true)) ;; twisted: takes a program, and
;; loops forever if prog halts given itself as input; ;; returns if prog runs forever given itself as input. #| Question: what is(twisted twisted)
?
(twisted twisted)
loops forever.
Then (by description of twisted), "twisted halts given itself as input".