Programming Languages

Slides:



Advertisements
Similar presentations
Class 39: Universality cs1120 Fall 2009 David Evans University of Virginia.
Advertisements

Copyright © Cengage Learning. All rights reserved.
Dr. Philip Cannata 1 Programming Languages Genesis of Some Programming Languages (My kind of Fiction)
This is not the Title of our Seminar
Foundations of Programming Languages: Introduction to Lambda Calculus
CS1001 Lecture 22. Overview Mechanizing Reasoning Mechanizing Reasoning G ö del ’ s Incompleteness Theorem G ö del ’ s Incompleteness Theorem.
Lecture 24: Gödel’s Proof CS150: Computer Science
Class 36: Proofs about Unprovability David Evans University of Virginia cs1120.
David Evans CS200: Computer Science University of Virginia Computer Science Class 24: Gödel’s Theorem.
Dr. Philip Cannata 1 Midterm Review. Dr. Philip Cannata 2.
CS 330 Programming Languages 11 / 21 / 2006 Instructor: Michael Eckmann.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
Lambda Calculus History and Syntax. History The lambda calculus is a formal system designed to investigate function definition, function application and.
1 CO Games Development 2 Week 21 Turing Machines & Computability Gareth Bellaby.
Propositional Logic Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma Guadalajara
Course Overview and Road Map Computability and Logic.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Great Theoretical Ideas in Computer Science.
CS6133 Software Specification and Verification
Thinking in Methodologies Class Notes. Gödel’s Theorem.
Artificial Intelligence “Introduction to Formal Logic” Jennifer J. Burg Department of Mathematics and Computer Science.
Lambda Calculus CSE 340 – Principles of Programming Languages Fall 2015 Adam Doupé Arizona State University
Dr. Philip Cannata 1 Simple Lisp John McCarthy Alonzo Church David Hilbert, Jules Richard, G. G. Berry, Georg Cantor, Bertrand Russell, Kurt Gödel, Alan.
CSE 311 Foundations of Computing I Lecture 26 Cardinality, Countability & Computability Autumn 2011 CSE 3111.
Computation Motivating questions: What does “computation” mean? What are the similarities and differences between computation in computers and in natural.
David Evans CS200: Computer Science University of Virginia Computer Science Class 32: The Meaning of Truth.
Albert Gatt LIN3021 Formal Semantics Lecture 3. Aims This lecture is divided into two parts: 1. We make our first attempts at formalising the notion of.
CSE 311: Foundations of Computing Fall 2014 Lecture 27: Cardinality.
Thales’ Legacy: What Is A Proof? Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 27April 22, 2004Carnegie Mellon.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
Fall 2013 Lecture 27: Turing machines and decidability CSE 311: Foundations of Computing.
CS5205: Foundations in Programming Languages
Conditional Expressions
CS 550 Programming Languages Jeremy Johnson
Unit – 3 :LAMBDA CALCULUS AND FUNCTIONAL PROGRAMMING
Lambda Calculus CSE 340 – Principles of Programming Languages
Gödel's Legacy: The Limits Of Logics
Discrete Mathematics for Computer Science
Lecture 1 – Formal Logic.
Chapter 3 The Logic of Quantified Statements
Programming Languages
Programming Languages
Resolution in the Propositional Calculus
More on Lambda Calculus
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
CS154, Lecture 11: Self Reference, Foundation of Mathematics
Great Theoretical Ideas in Computer Science
Lecture 2 Propositional Logic
CLASSICAL LOGIC and FUZZY LOGIC
Homework: Friday Read Section 4.1. In particular, you must understand the proofs of Theorems 4.1, 4.2, 4.3, and 4.4, so you can do this homework. Exercises.
Programming Languages
CS 1813 – Discrete Mathematics
Lecture 22: Gödel’s Theorem CS200: Computer Science
First Order Logic Rosen Lecture 3: Sept 11, 12.
Class 37: Making Lists, Numbers and Recursion from Glue Alone
PROGRAMMING IN HASKELL
CS21 Decidability and Tractability
MA/CSSE 474 More Math Review Theory of Computation
Computer Security: Art and Science, 2nd Edition
Great Theoretical Ideas in Computer Science
CSNB234 ARTIFICIAL INTELLIGENCE
Computer Science cpsc322, Lecture 20
Predicates and Quantifiers
Lecture 8 CS 1813 – Discrete Mathematics
This Lecture Substitution model
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
CSE S. Tanimoto Lambda Calculus
Programming Languages
CO Games Development 2 Week 21 Turing Machines & Computability
Presentation transcript:

Programming Languages Genesis of Some Programming Languages (My kind of Fiction)

This Course Jython in Java High Level Languages Java (Object Oriented) 10 High Level Languages Java (Object Oriented) ASP RDF (Horn Clause Deduction, Semantic Web) This Course Jython in Java Relation

In the Beginning (p b)

Function Bodies With the same goals as Alfred Whitehead and Bertrand Russell in Principia Mathematica (i.e., to rid mathematics of the paradoxes of the infinite and to show that mathematics is consistent) but also to avoid the complexities of mathematical logic - “The foundations of elementary arithmetic established by means of the recursive mode of thought, without use of apparent variables ranging over infinite domains” – Thoralf Skolem, 1923 Thoralf Skolem In a small town there is only one barber. This man is defined to be the one who shaves all the men who do not shave themselves. The question is then asked, 'Who shaves the barber?' If the barber doesn't shave himself, then -- by definition -- he does. And, if the barber does shave himself, then -- by definition -- he does not. or Consider the statement 'This statement is false.‘ If the statement is false, then it is true; and if the statement is true, then it is false. This article can be found in “From Frege to Gödel: A Source Book in Mathematical Logic, 1879-1931 (Source Books in the History of the Sciences)” A function is called primitive recursive if there is a finite sequence of functions ending with f such that each function is a successor, constant or identity function or is defined from preceding functions in the sequence by substitution or recursion.

Lambda Calculus Arithmetic def true = select_first def false = select_second def zero = λx.x def succ = λn.λs.((s false) n) def pred = λn.(((iszero n) zero) (n select_second)) def iszero = λn.(n select_first) one = (succ zero) (λn.λs.((s false) n) zero) λs.((s false) zero) two = (succ one) (λn.λs.((s false) n) λs.((s false) zero)) λs.((s false) λs.((s false) zero)) three = (succ two) (λn.λs.((s false) n) λs.((s false) λs.((s false) zero))) λs.((s false) λs.((s false) λs.((s false) zero))) (iszero zero) (λn.(n select_first) λx.x) (λx.x select_first) select_first def identity = x.x def self_apply = s.(s s) def apply = func.arg.(func arg) def select_first = first.second.first def select_second =first.second.second def cond= e1.e2.c.((c e1) e2) For more but different details see Section 22.3 of the textbook. (iszero one) (λn.(n select_first) λs.((s false) zero) ) (λs.((s false) zero) select_first) ((select_first false) zero)

Lambda Calculus Arithmetic ADDITION def addf = λf.λx.λy. if iszero y then x else f f (succ x)(pred y) def add = λx.λy. else addf addf (succ x)(pred y) add one two (((λx.λy. else addf addf (succ x)(pred y)) one) two) if iszero two then one else addf addf (succ one)(pred two) addf addf (succ one)(pred two) ((((λf.λx.λy else f f (succ x)(pred y)) addf) (succ one))(pred two)) if iszero (pred two) then (succ one) else addf addf (succ (succ one))(pred (pred two)) addf addf (succ (succ one)) (pred (pred two)) else f f (succ x)(pred y)) addf) (succ (succ one)))(pred (pred two))) if iszero (pred (pred two)) then (succ (succ one) else addf addf (succ (succ (succ one))) (pred (pred (pred two))) (succ (succ one)) three Multiplication def multf = λf.λx.λy. if iszero y then zero else add x (f x (pred y))) def recursive λf.(λs.(f (s s)) λs.(f (s s))) def mult = recursive multf = λx.λy else add x ((λs.(multf (s s)) λs.(multf (s s))) x (pred y)) Church-Turing thesis: no formal language is more powerful than the lambda calculus or the Turing machine which are both equivalent in expressive power.

Function Bodies using Combinators A function is called primitive recursive if there is a finite sequence of functions ending with f such that each function is a successor, constant or identity function or is defined from preceding functions in the sequence by substitution or recursion. s f g x = f x (g x) k x y   = x b f g x = f (g x) c f g x = f x g y f     = f (y f) cond p f g x = if p x then f x else g x -- Some Primitive Recursive Functions on Natural Numbers pradd x z = y (b (cond ((==) 0) (k z)) (b (s (b (+) (k 1)) ) (c b pred))) x prmul x z = y (b (cond ((==) 0) (k 0)) (b (s (b (+) (k z)) ) (c b pred))) x prexp x z = y (b (cond ((==) 0) (k 1)) (b (s (b (*) (k x)) ) (c b pred))) z prfac x   = y (b (cond ((==) 0) (k 1)) (b (s (*)           ) (c b pred))) x -- Alternative formulation pradd1 x z = y (b (cond ((==) 0) (k z)) (b (s (b (+) (k 1))      ) (c b pred))) x prmul1 x z = y (b (cond ((==) 0) (k 0)) (b (s (b (pradd1) (k z)) ) (c b pred))) x prexp1 x z = y (b (cond ((==) 0) (k 1)) (b (s (b (prmul1) (k x)) ) (c b pred))) z prfac1 x   = y (b (cond ((==) 0) (k 1)) (b (s (prmul1)           ) (c b pred))) x No halting problem here but not Turing complete either Implies recursion or bounded loops, if-then-else constructs and run-time stack. see the BlooP language in

A Strange Proposal s f g x = f x (g x) k x y   = x b f g x = f (g x) c f g x = f x g y f     = f (y f) cond p f g x = if p x then f x else g x -- Some Primitive Recursive Functions on Natural Numbers pradd x z = y (b (cond ((==) 0) (k z)) (b (s (b (+) (k 1)) ) (c b pred))) x prmul x z = y (b (cond ((==) 0) (k 0)) (b (s (b (+) (k z)) ) (c b pred))) x prexp x z = y (b (cond ((==) 0) (k 1)) (b (s (b (*) (k x)) ) (c b pred))) z prfac x   = y (b (cond ((==) 0) (k 1)) (b (s (*)           ) (c b pred))) x To find Primitive Recursive Functions, try something like the following: prf x z = y (b (cond ((==) 0) (k A)) (b (s AAAAAA . . . AAAAAAAAAA ) (c b pred))) A | Where each A is a possibly different element of {x z 0 1 + * s k b c ( ) “”} but at least having parentheses match. Gödel may be lurking! haskell type checker that rules out bad combinations

John McCarthy’s Takeaway -- Primitive Recursive Functions on Lists are more interesting than PRFs on Numbers prlen x    = y (b (cond ((==) []) (k 0))  (b (s (b (+) (k 1)) ) (c b cdr))) x prsum x   = y (b (cond ((==) []) (k 0))  (b (s (b (+) (car)) ) (c b cdr))) x prprod x  = y (b (cond ((==) []) (k 1))  (b (s (b (*) (car)) ) (c b cdr))) x prmap f x = y (b (cond ((==) []) (k [])) (b (s (b (:) (f)  ) ) (c b cdr))) x   -- prmap (\ x -> (car x) + 2) [1,2,3] or                                                                                 -- prmap (\ x -> pradd (car x) 2) [1,2,3] prfoo x   = y (b (cond ((==) []) (k [])) (b (s (b (:) (cdr)) ) (c b cdr))) x -- A programming language should have first-class functions as (b p1 p2 . . . Pn), substitution, lists with car, cdr and cons operations and recursion. car (f:r) = f cdr (f:r) = r : -- cons

Are these just meaningless symbols? / ASP Other Takeaways ? Combinators for RDF? 3rd Gen. PLs 2nd Gen. PLs Pattern 1 (Modus Tollens): Q :- (P1, P2). -Q  -(P1, P2) Pattern 2 (Affirming a Conjunct): P1. -(P1, P2)  -P2 Pattern 3: P2. -P2  Contradiction 1st Gen. PLs No Gödel FORTRAN DTRAN MTRAN Formula Translation Data Translation Meaning Translation Are these just meaningless symbols? s f g x = f x (g x) k x y   = x b f g x = f (g x) c f g x = f x g y f     = f (y f) cond p f g x = if p x then f x else g x -- Some Primitive Recursive Functions on Natural Numbers pradd x z = y (b (cond ((==) 0) (k z)) (b (s (b (+) (k 1)) ) (c b pred))) x prmul x z = y (b (cond ((==) 0) (k 0)) (b (s (b (+) (k z)) ) (c b pred))) x prexp x z = y (b (cond ((==) 0) (k 1)) (b (s (b (*) (k x)) ) (c b pred))) z prfac x   = y (b (cond ((==) 0) (k 1)) (b (s (*)           ) (c b pred))) x

Notions of Truth Propositions: SciAmer. Dec. 2011, p. 57 – The commons view also aims at convergence toward truth, of course. . . . We have for a couple of millennia in the West thought of knowledge as a system of settled, consistent truths. Propositions: Statements that can be either True or False Truth: Are there well formed propositional formulas (i.e., Statements) that return True when their input is True truth1 :: (Bool -> Bool) -> Bool truth1 wff = (wff True) truth2 :: (Bool -> Bool -> Bool) -> Bool truth2 wff = (wff True True) ( \ p -> not p) ( \ p q -> (p && q) || (not p ==> q)) ( \ p q -> not p ==> q) ( \ p q -> (not p && q) && (not p ==> q) ) 1. prfac x = y (b (cond ((==) 0) (k 1)) (b (s (*) ) (c b pred))) x 2. not P(proof, s) && Q(g, s) - I am a statement that is not provable. If Gödel's statement is true, then it is a example of something that is true for which there is no proof (Incomplete). If Gödel's statement is false, then it has a proof and that proof proves the false Gödel statement true (Unsound). 3. If it was never possible for it not to be True that something was going to exist, and it will never be possible for it not to be True that something existed in the past then it is impossible for Truth ever to have had a beginning or ever to have an end. That is, it was never possible that Truth cannot be conceived not to exist. 4. If R is something that can be conceived not to exist and T is something that cannot be conceived not to exist and T is greater than R and God is that, than which nothing greater can be conceived, then God exists and is Truth.

Good Books to Have for a Happy Life  From Frege to Gödel: My Favorite