Lecture 8: The Meaning of Life, Searching for Truth and The Stuff Primitives are Made Of (and a smattering of Quantum Physics) CS655: Programming Languages David Evans University of.

Download Report

Transcript Lecture 8: The Meaning of Life, Searching for Truth and The Stuff Primitives are Made Of (and a smattering of Quantum Physics) CS655: Programming Languages David Evans University of.

Lecture 8:
The Meaning of Life,
Searching for Truth
and The Stuff
Primitives are Made
Of (and a smattering
of Quantum Physics)
CS655: Programming Languages
David Evans
University of Virginia
http://www.cs.virginia.edu/~evans
Computer Science
Menu
• An Important Scientific Discovery!
(with major implications for
Programming Languages)
• Pictorial Calculi
• Searching for the Truth
• Token Rewards
• Manifest is online only today
13 Feb 2001
CS 655: Lecture 8
2
Scientific Discovery
Announced over Weekend
• Human genome is about half as big as
previously thought – only about 30,000
genes!
• Genetic code for 2 humans differs in
only 2.1 million genetic letters (4 million
bits = 0.5 MB)
13 Feb 2001
CS 655: Lecture 8
3
How big is .5 MB?
• 1/3 of a floppy disk
• <1% of Windows 2000
• Lecture Slides 1, 2 and 3
13 Feb 2001
CS 655: Lecture 8
4
Nature vs. C++
• Microsoft Windows 2000: 50M lines of
C++ code ~ 5GB of data
• Difference between Windows 2000 and
Linux: essentially, all 50M lines ~ 5GB.
• Nature: Human: 30,000 genes (~3.1B
base pairs ~ 1.5GB)
• Difference between me and Michael
Jordan = 0.5MB
13 Feb 2001
CS 655: Lecture 8
5
Nature vs. C++
• The differences between any two people
are at least 1000x more interesting than the
differences between Linux and Windows
2000
• Hence, nature’s programming language is:
5GB/.5MB * 1000 =
~10M times more expressive than C++
or ~100,000 times more expressive than Scheme
13 Feb 2001
CS 655: Lecture 8
6
Is DNA Really a
Programming Language?
13 Feb 2001
CS 655: Lecture 8
7
Nerdy Linguist’s Definition
A description of pairs (S, M),
where S stands for sound, or any
kind of surface forms, and M
stands for meaning. A theory of
language must specify the
properties of S and M, and how
they are related.
13 Feb 2001
CS 655: Lecture 8
8
Programming Language
(Definition from Lecture 1)
A description of pairs (S, M),
where S stands for sound, or
any kind of surface forms, and
M stands for meaning intended
to be read and written by
humans and processed by
machines.
13 Feb 2001
CS 655: Lecture 8
9
Stuff Programming Languages
are Made Of
• Primitives
My best guess: sequence that encodes a protein
• Means of Combination
?? Morphogenesis? Not well understood (by anyone).
This is where most of the 100Kx improvement over
Scheme comes from!?!
• Means of Abstraction
DNA itself – separate proteins from their encoding
Genes – group DNA by function (sort of)
Chromosomes – package Genes together
Organisms – packages for reproducing Genes
13 Feb 2001
CS 655: Lecture 8
10
Biology is (becoming) a
subfield of Computer Science
• Biological mechanisms are mostly
understood (proteomics still has a way
to go)
• What is not understood is how those are
combined to create meaning
• Alex Hartemink (faculty candidate in
Computational Biology), Monday 3:30
13 Feb 2001
CS 655: Lecture 8
11
Pictorial Calculi
• Keenan’s paper
• Any important
pictorial calculi?
13 Feb 2001
CS 655: Lecture 8
12
13 Feb 2001
CS 655: Lecture 8
13
Feynman Diagrams
• Pictorial calculi for understanding
quantum electrodynamics
• Simple notations:
electron
photon
• Rules for combining and manipulating
that calculate electromagnetic
interactions
13 Feb 2001
CS 655: Lecture 8
14
Richard Feynman (1918-1988)
• Nobel Prize in Physics, 1965 (for work
stemming from Feynman Diagrams)
• Leader in quantum computing (PS2)
• Leader in nanotechnology
• Co-taught computing course using (prepublication) Wizard book
• Every aspiring scientist should read “Surely
You’re Joking, Mr. Feynman” and “What
Do You Care What Other People Think”
13 Feb 2001
CS 655: Lecture 8
15
Lambda Calculus
Summary so Far
• Rules for substitution
• Rules for reduction (only -reduction
does real work: substitution)
• Normal form (no more reductions
possible)
• On faith: if you do outermost -reduction
first, you find the normal form if there is
one
13 Feb 2001
CS 655: Lecture 8
16
Lambda Calculus Intuition
• Lambda expression corresponds to a
computation
• Normal form is that value of that
computation
• But...can we do useful computations
without primitives?
13 Feb 2001
CS 655: Lecture 8
17
In search of the truth?
• What does true mean?
• True is something that when used as
the first operand of if, makes the value
of the if the value of its second operand:
if T M N  M
13 Feb 2001
CS 655: Lecture 8
18
Don’t search for T, search for if
T  xy. x
F  xy. y
if  pca . pca
13 Feb 2001
CS 655: Lecture 8
19
Finding the Truth
T  xy. x
F  xy. y
if  pca . pca
Is the if necessary?
if T M N
((pca . pca) (xy. x)) M N
 (ca . (x.(y. x)) ca)) M N
  (x.(y. x)) M N
 (y. M )) N  M
Prakash’s proof messed this up (p. 5)!
13 Feb 2001
CS 655: Lecture 8
20
and and or?
and  xy. if x y F
or  xy. if x T y
13 Feb 2001
CS 655: Lecture 8
21
What is three-ness?
trois
3
III
13 Feb 2001
CS 655: Lecture 8
22
Meaning of Numbers
• “Three-ness” is something who’s
successor is “four-ness”
• “Three-ness” is something who’s
predecessor is “two-ness”
• “Zero” is special. It has a successor
“one-ness”, but no predecessor.
13 Feb 2001
CS 655: Lecture 8
23
Meaning of Numbers
pred (succ N)  N
succ (pred N)  N
succ (pred (succ N))  succ N
...
zero? Zero  T
zero? (succ Zero)  F
zero? (pred (succ Zero))  T
...
13 Feb 2001
CS 655: Lecture 8
24
Is this enough?
• Can we define add with pred, succ,
zero? and Zero?
add  xy.if (zero? x) y
(add (pred x) (succ y))
13 Feb 2001
CS 655: Lecture 8
25
Can we define lambda
expressions that behave like
Zero, zero?, pred and succ?
Hint: what if we had cons and cdr?
13 Feb 2001
CS 655: Lecture 8
26
Numbers are Lists...
zero? x = null? x
pred x = cdr x
succ x = cons F x
13 Feb 2001
CS 655: Lecture 8
27
Cons and car
cons  xy.(z.z xy)
car  p.p T
car cons M N
= p.p T (xy.(z.z xy)) M N
  T (xy.(z.z xy)) M N
  T (z.z M N)
 M
13 Feb 2001
CS 655: Lecture 8
28
Cdr too!
cons  xy.(z.z xy)
car  p.p T
cdr  p.p F
cdr cons M N
= p.p F (xy.(z.z xy)) M N
  F (xy.(z.z xy)) M N
  F (z.z M N)
 N
13 Feb 2001
CS 655: Lecture 8
29
Null and null?
Null = p.p
null? = x.x T
null? Null   (x.x T) p.p
  p.p T   T
13 Feb 2001
CS 655: Lecture 8
30
null? (cons Null Null)
  (x.x T) (xy.(z.z xy) p.p p.p)
 (x.x T) (z.z p.p p.p)
 (z.z p.p p.p) T
 (T p.p p.p)
 xy. x p.p p.p
 p.p  T (but is it equivalent to F?)
Figure it out, or what I did wrong for a token reward...
13 Feb 2001
CS 655: Lecture 8
31
Counting
0I
1  cons F 0
2  cons F 1
3  cons F 2
...
succ  x.cons F x
pred  x.cdr x
13 Feb 2001
CS 655: Lecture 8
32
Arithmetic
Zero?  x.x T
Zero? 0 = (x.x T) I = T
Zero? 1 = (x.x T) [F, I] = F
succ  x.[F, x]
pred  x.x F
pred 1 = (x.x F) [F, I] = [F, I]F = I = 0
pred 0 = (x.x F) I = IF = F
13 Feb 2001
CS 655: Lecture 8
33
Factorial
mult 
xy. if (zero? x) 0
(add y (mult (pred x) y))
fact 
x. if (zero? x) 1
(mult x (fact (pred x)))
Recursive definitions should make you uncomfortable.
Need for definitions should also bother you.
13 Feb 2001
CS 655: Lecture 8
34
Summary
• All you need is application and abstraction
and you can compute anything
• This is just one way of representing
numbers, booleans, etc. – many others
are possible
• Integers, booleans, if, while, +, *, =, <,
subtyping, multiple inheritance, etc. are for
wimps! Real programmers only use .
13 Feb 2001
CS 655: Lecture 8
35
Token Rewards
Haiyong – repeatuntil problem
in PS1 solution
Chris – problem with
Prakash’s proof (p. 5).
13 Feb 2001
CS 655: Lecture 8
36