73
A Brief History of the Freedom of Expressions Matt Might http://matt.might.net /

A Brief History of the Freedom of Expressions

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A Brief History of the Freedom of Expressions

A Brief History of the Freedom of Expressions

Matt Might

http://matt.might.net/

Page 2: A Brief History of the Freedom of Expressions

Sapir-Whorf Hypothesis

Language limits

thought.

Edward Sapir Benjamin Whorf

Page 3: A Brief History of the Freedom of Expressions

Programming languages

• Where did they come from?

• What kinds of languages do we have now?

• What will they do for us tomorrow?

Page 4: A Brief History of the Freedom of Expressions

What is a programming language?

A programming language is a language that can describe a transformation from inputs to outputs...

Page 5: A Brief History of the Freedom of Expressions

What is a programming language?

...without ambiguity.

A programming language is a language that can describe a transformation from inputs to outputs...

Page 6: A Brief History of the Freedom of Expressions

Origins of programming languages

Page 7: A Brief History of the Freedom of Expressions

Origins ofmathematical notation

Page 8: A Brief History of the Freedom of Expressions

Euclid’s algorithm (300 BC)

• Greatest common divisor

• GCD(24,18) = 6

• GCD(4,6) = 2

(Probably) Euclid

Page 9: A Brief History of the Freedom of Expressions

300 BC

Page 10: A Brief History of the Freedom of Expressions

2008 AD

gcd(a, b) = (b == 0) ? a : gcd(b, a mod b)

Page 11: A Brief History of the Freedom of Expressions

Limits on the Greeks

• No notation for zero.

• No variables for unknowns.

• No symbols for operations.

• Long division required Ph.D.

• Irrational numbers punished by death.

Page 12: A Brief History of the Freedom of Expressions

Example

• The number such that four of its roots is equal to its three of its square.

• 4x = 3x2.

Page 13: A Brief History of the Freedom of Expressions

Indian numerals (596)

• Notation for zero.

• Decimal numerals.

• Calculation easier.

Brahmagupta

Page 14: A Brief History of the Freedom of Expressions

Solving quadratics (820)

Muhammad ibn Mūsā al-Khwārizmī

Page 15: A Brief History of the Freedom of Expressions

Solving quadratics (820)

Muhammad ibn Mūsā al-Khwārizmī

Page 16: A Brief History of the Freedom of Expressions

Variables (1570s)

François Viète

Page 17: A Brief History of the Freedom of Expressions

Example

• 3 + x is equal to 10 times x2.

• 3 + x = 10x2

Page 18: A Brief History of the Freedom of Expressions

Operations (Early 1600s)

William Oughtred

• Letters for variables.

• Symbols for operations.

• Led to slide rule.

Page 19: A Brief History of the Freedom of Expressions

Calculus (Late 1600s)

Isaac NewtonPrincipia (1687)

Page 20: A Brief History of the Freedom of Expressions

Calculus (Late 1600s)

Gottfried Leibniz

Page 21: A Brief History of the Freedom of Expressions

Euler (1700s)

Page 22: A Brief History of the Freedom of Expressions

The end of the reign of numbers

Page 23: A Brief History of the Freedom of Expressions

Functions

f(x) = x2 + 3

A function transforms an input into an output.

input: x output: f(x)0 3

1 4

2 7

Page 24: A Brief History of the Freedom of Expressions

A programming language is a language that can describe a transformation from inputs to outputs.

Functions

Page 25: A Brief History of the Freedom of Expressions

A programming language is a language that can describe functions.

Functions

Page 26: A Brief History of the Freedom of Expressions

Names for functions

f (x)

Page 27: A Brief History of the Freedom of Expressions

Names for functions

f

Page 28: A Brief History of the Freedom of Expressions

Names for functions

f (3)

Page 29: A Brief History of the Freedom of Expressions

Sets and Logic (1800s)

Giuseppe Peano

• Sets became objects.

• Logic became math.

• Math began unifying.

Page 30: A Brief History of the Freedom of Expressions

Sets

A set is a collection of objects.

• {1,2,3} is a set of three numbers.

• {} is the empty set.

• {{1,2,3}} is a set containing a set.

• N is the set of natural numbers.

Page 31: A Brief History of the Freedom of Expressions

Frege’s unification

• Logic as foundation.

• Sets as atoms.

• Numbers from sets.

• Functions from sets.

Gottlob Frege

Page 32: A Brief History of the Freedom of Expressions

Example

• Every even integer greater than two can be written as the sum of two primes.

• ∀n > 2 : ∃a,b : p(a) ∧ p(b) ∧ a+b = n.

Page 33: A Brief History of the Freedom of Expressions

Grundgesetze der Arithmetik

• Published in 1903.

• Foundation for math.

Page 34: A Brief History of the Freedom of Expressions

Russell’s postcard

Dear Frege,

Prof. Dr. Gottlob FregeUniversity of GöttingenGöttingen, Germany

{X | X ∉ X} ∈ {X | X ∉ X}

XOXO,Bertrand R.

Page 35: A Brief History of the Freedom of Expressions

Russell’s postcard

Dear Frege,

Prof. Dr. Gottlob FregeUniversity of GöttingenGöttingen, Germany

XOXO,Bertrand R.

U FAIL.

Page 36: A Brief History of the Freedom of Expressions

Russell’s paradox{X | X ∉ X} ∈ {X | X ∉ X}

Page 37: A Brief History of the Freedom of Expressions

Russell’s paradox

Does the set of all sets that do not contain themselves contain itself?

{X | X ∉ X} ∈ {X | X ∉ X}

Page 38: A Brief History of the Freedom of Expressions

Russell’s paradox

Does the set of all sets that do not contain themselves contain itself?

{X | X ∉ X} ∈ {X | X ∉ X}

The barber shaves all those that do not shave themselves.

Page 39: A Brief History of the Freedom of Expressions

Russell’s paradox

Does the set of all sets that do not contain themselves contain itself?

{X | X ∉ X} ∈ {X | X ∉ X}

The barber shaves all those that do not shave themselves.

But, then who shaves the barber?

Page 40: A Brief History of the Freedom of Expressions

Russell’s solution: Orders

• Problem is self-reference.

• Example: This sentence is false.

• Solution: Order sentences.

• Must reference lower orders.

• Seems to avoid paradox.

Bertrand Russell

Page 41: A Brief History of the Freedom of Expressions

Functions as foundation?

Alonzo Church

• Notation for functions.

• f(x) = x2

• f(2) = 4

• f = λx.x2

• (λx.x2)(2) = 4

Page 42: A Brief History of the Freedom of Expressions

Lambda Calculus (1920s)

Throw away everything in math, except:

x variables

f(e) function application

λx.e function definition

Page 43: A Brief History of the Freedom of Expressions

Lambda Calculus

(λx.e) v = {v/x}e.

Page 44: A Brief History of the Freedom of Expressions

The Lambda Calculus

• Numbers.

• True and false.

• Propositions.

• Sets.

• Recursive functions.

• Logic.

• ...

Can encode:

Page 45: A Brief History of the Freedom of Expressions

Another paradox

k = (λx.¬(x x)) (λx.¬(x x)) = ¬k

Page 46: A Brief History of the Freedom of Expressions

Turing machine (1936)

• Student of Church.

• Defined computability.

• Showed λ = computer.

Alan Turing

Page 47: A Brief History of the Freedom of Expressions

Modern programming languages

Page 48: A Brief History of the Freedom of Expressions

Lisp (1958)

• λ as programming language.

• S-Expression notation.

• Code as data.

• Data as code.

• Self-evaluating.

John McCarthy

Page 49: A Brief History of the Freedom of Expressions

Example

(define (factorial x) (if (= x 0) 1 (* n (factorial (- n 1)))))

Page 50: A Brief History of the Freedom of Expressions

Kinds of languages

• Declarative: Describes relationship.

• Imperative: Describes process.

Page 51: A Brief History of the Freedom of Expressions

Example: Declarative

• A PBJ is the result of placing peanut butter and jelly between two slices of bread.

Page 52: A Brief History of the Freedom of Expressions

Example: Imperative

• Place slice of bread on table.

• Add peanut butter.

• Add jelly.

• Place slice of bread on top.

Page 53: A Brief History of the Freedom of Expressions

Declarative languages

• Roots in the lambda calculus.

• Examples: Haskell, SML, Lisp/Scheme

• Easy to reason about correctness.

• Generally safe and bug free.

• Can be inefficient.

• Need to think mathematically to use them.

Page 54: A Brief History of the Freedom of Expressions

Imperative languages

• Trace roots to Babbage’s engine (1800s).

• Examples: C, C++, Java, Python.

• Hard to know if correct.

• Generally very efficient.

• Extremely dangerous.

Page 55: A Brief History of the Freedom of Expressions

45

<exploding-rocket-video />

Page 56: A Brief History of the Freedom of Expressions

46

Page 57: A Brief History of the Freedom of Expressions

47

Page 58: A Brief History of the Freedom of Expressions

48

Page 59: A Brief History of the Freedom of Expressions

49

Page 60: A Brief History of the Freedom of Expressions

PowerPoint

A fatal exception 0E has occurred at 0137:BFFA21C9. The currentapplication will be terminated.

* Press any key to terminate the current application.* Press CTRL+ALT+DEL again to restart your computer. You will

lose any unsaved information in all applicatons.

Press any key to continue _

Page 61: A Brief History of the Freedom of Expressions

<exploding-rocket-video />

51

Page 62: A Brief History of the Freedom of Expressions

51

Page 63: A Brief History of the Freedom of Expressions

The future of programming languages

Page 64: A Brief History of the Freedom of Expressions

Front lines of research

• Get the best of both worlds.

• Write program in both; prove equivalent.

• Use a mixed language: Scala, Ynot.

Page 65: A Brief History of the Freedom of Expressions

The future

• Programs won’t crash.

• Programs won’t hang.

• Programs will always do the right thing.

Page 66: A Brief History of the Freedom of Expressions

Thank youhttp://matt.might.net/

Page 67: A Brief History of the Freedom of Expressions

Example: Numbers

• 0 = λs.λz.z

• n+1 = λs.λz.s(n s z)

Page 68: A Brief History of the Freedom of Expressions

Example: True, false, if

• true = λt.λf.t

• false = λt.λf.f

• if = λb.λt.λf.(b t f )

Page 69: A Brief History of the Freedom of Expressions

Omega

ω = (λx.x x) (λx.x x) = ω

Page 70: A Brief History of the Freedom of Expressions

Fixed-point Combinator

Fix(F) = F(Fix(F))

Page 71: A Brief History of the Freedom of Expressions

Fixed points andself reference

• x2 = 1 + x

• x = x2 - 1

• x = F(x), where F = λx.x2 - 1

• x = Fix(F) = ±1

Page 72: A Brief History of the Freedom of Expressions

Recursion

• f(n) = if n=0 then 1 else n × f(n-1)

• F(f) = λn.n=0 then 1 else n × f(n-1)

• ! = Fix(F)

Page 73: A Brief History of the Freedom of Expressions

Fixed-point Combinator

Fix = λf.(λx.f (x x)) (λx.f (x x))