Logical and Functional Programming

Slides:



Advertisements
Similar presentations
Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
Advertisements

1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
Programming Languages Language Design Issues Why study programming languages Language development Software architectures Design goals Attributes of a good.
Logic Programming Languages. Objective To introduce the concepts of logic programming and logic programming languages To introduce a brief description.
CS 101 Course Summary December 5, Big Ideas Abstraction Problem solving Fundamentals of programming.
Dr. Muhammed Al-Mulhem ICS An Introduction to Functional Programming.
SOFTWARE SYSTEMS SOFTWARE APPLICATIONS SOFTWARE PROGRAMMING LANGUAGES.
David Evans CS200: Computer Science University of Virginia Computer Science Class 31: Universal Turing Machines.
CS 415: Programming Languages Chapter 1 Aaron Bloomfield Fall 2005.
CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be.
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Evolution of Programming Languages Generations of PLs.
COMPUTER PROGRAMS AND LANGUAGES Chapter 4. Developing a computer program Programs are a set (series) of instructions Programmers determine The instructions.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
1 Functional Programming In Text: Chapter Chapter 2: Evolution of the Major Programming Languages Outline Functional programming (FP) basics A bit.
1 Programming Language History and Evolution In Text: Chapter 2.
1 COMP313A Functional Programming (1). 2 Main Differences with Imperative Languages Say more about what is computed as opposed to how Pure functional.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
The Teacher Computing Computer Languages [Computing]
1 ML fun x -> e e 1 e 2 0, 1, 2,..., +, -,... true, false, if e then e else e patterns datatypes exceptions structures functors let f x = e variables These.
1 Programming Languages Fundamentals Cao Hoaøng Truï Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa TP. HCM.
CS4026 Formal Models of Computation Part II The Logic Model Lecture 2 – Prolog: History and Introduction.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Introduction to Prolog. Outline What is Prolog? Prolog basics Prolog Demo Syntax: –Atoms and Variables –Complex Terms –Facts & Queries –Rules Examples.
1-1 An Introduction to Functional Programming Sept
-Calculus Kangwon National University 임현승 Programming Languages These slides are based on the slides by Prof. Sungwoo Park at POSTECH.
Programming Languages
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
Lisp "List Processing". Lisp history John McCarthy developed the basics behind Lisp during the 1956 Dartmouth Summer Research Project on Artificial Intelligence.
Chapter 9 ProgrammingLanguages.  Describe the evolution of programming languages from machine language to high-level languages.  Understand how a program.
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
Abdul Rahim Ahmad MITM 613 Intelligent System Chapter 10: Tools.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
Programming Language Theory 2014, 1 Chapter 1 :: Introduction Origin : Michael L. Scott School of Computer & Information Engineering,
Software Engineering Algorithms, Compilers, & Lifecycle.
Programming Language Paradigms ITSK2314 Lecture 3.
CPS120 Introduction to Computer Science High Level Language: Paradigms.
Programming Paradigms, Software Architectural Patterns, and MVC CS 378 – Mobile Computing for iOS Dr. William C. Bulko.
Programming Language History and Evolution
Chapter 1. Introduction.
Programming Languages 2nd edition Tucker and Noonan
Functional Programming
Computer Languages [Computing] Computing.
Programming paradigms
CS 3304 Comparative Languages
Introduction to programming languages, Algorithms & flowcharts
Why study programming languages?
Introduction to programming languages, Algorithms & flowcharts
PROGRAMMING LANGUAGES
CSCI-235 Micro-Computer Applications
Functional Programming
Programming Language History and Evolution
Introduction to programming languages, Algorithms & flowcharts
Logic Programming Languages
Programming Languages 2nd edition Tucker and Noonan
High Level Programming Languages
Low Level Programming Languages
Introduction to Computer Programming
Principles of Programming Languages
Overview of Programming Paradigms
An Introduction to Programming
School of Computer & Information Engineering,
Presentation transcript:

Logical and Functional Programming Computational Models Evolution of Languages Logical Programming

Computational Models Programming language design amounts to a model, or abstract description, of computation Most languages based upon computation model where Arithmetic operations Variable assignments Calling procedures, looping, etc. Three computational models

Alan Turing’s Model Read/write characters on a tape under control of a “program” Suggests a physical machine Assignment, control structures Specify how results computed What is computed is implicit Imperative Languages like C++, Fortran, Pascal, Cobol, etc., based on this model.

Church’s Model - Equivalent to Turing’s Model Involves “lambda calculus” and formalizes ideas of mathematical functions Formal rules govern how to apply a function to its arguments Repeated use of rules  reduces mathematical expression to its value Program is one BIG function anyway Functional Programming Languages like Lisp, SASL based on Church’s model

Predicate Calculus Model OLD Solution of systems of logical equations Logical Programming Languages like Prolog based on Predicate Calculus Model Also known as Declarative Languages Specify what is to be computed, without the detail of how

Evolution of Languages Ada PROLOG (70’s France) Pascal LISP (60s) Algol SASL Fortran Mercury (95) Scheme (75) Haskell (87)

Evolution of Languages Software Engineering drove evolution of imperative languages Artificial Intelligence drove evolution of non-imperative languages Aside: 4GLS (non-imperative  imperative)

Prolog – Programming in Logic Prolog is simple Collection of facts (concrete relations) And rules (patterns of relations)

Simple program dog (fido). --fact spotted (fido). --fact dalmation (X) :- dog(X), spotted(X). --rule Semantics of rule: if X is a dog and is spotted, then X is a dalmation

Syntax :- (if) , (and) % comment Variables – Uppercase letter to start Objects – lower case letter to start

Prolog is interactive Program does nothing until programmer adds a question or a query ?- dalmation (fido). Prolog system answers Yes. The facts and rules determine substitutions for variables in query (unification)

Can add to program Query Response No. leopard (leo). spotted (leo). ?-dalmation (leo). Response No.

Want to know all spotted? That is, “For what X is X spotted?” Query ?-spotted(X). Answer X=fido. F8 X=leo. F8 No.

Prolog is interpreted Applications Allows flexibility Can add new facts and rules anytime. Applications Knowledge of representation and reasoning Symbolic manipulation e.g., validating well-formed prefix expressions

Homework Due next Wednesday: Type in fido example and run Come with questions if NOT working Turn in program and output, if it is.