FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 1. ÚVOD DO PŘEDMĚTU, LAMBDA CALCULUS

Similar documents
11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations

Lambda Calculus.

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 4. LISP: PROMĚNNÉ, DALŠÍ VLASTNOSTI FUNKCÍ, BLOKY, MAPOVACÍ FUNKCIONÁLY, ITERAČNÍ CYKLY,

VU Semantik von Programmiersprachen

SOFTWARE ARCHITECTURE 6. LISP

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 2. ÚVOD DO LISPU: ATOMY, SEZNAMY, FUNKCE,

Programming Languages 2nd edition Tucker and Noonan"

Com S 541. Programming Languages I

Chapter 5: The Untyped Lambda Calculus

CSCI.4430/6969 Programming Languages Lecture Notes

Topic I. Introduction and motivation References: Chapter 1 of Concepts in programming languages by J. C. Mitchell. CUP, 2003.

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 3. LISP: ZÁKLADNÍ FUNKCE, POUŽÍVÁNÍ REKURZE,

Programming Language Pragmatics

One of a number of approaches to a mathematical challenge at the time (1930): Constructibility

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages. Lambda calculus

General Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design

Functional Languages. Hwansoo Han

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

Introduction to the l-calculus

Chapter 11 :: Functional Languages

Lecture 9: More Lambda Calculus / Types

- M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete. - true = λ u. λ v. u. - false = λ u. λ v.

A Quick Overview. CAS 701 Class Presentation 18 November Department of Computing & Software McMaster University. Church s Lambda Calculus

Programming Languages, Summary CSC419; Odelia Schwartz

Concepts of Programming Languages

Programming Paradigms and Languages Introduction. dr Robert Kowalczyk WMiI UŁ

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 5. LISP: MAKRA, DATOVÁ STRUKTURA ZÁZNAM

11. Security Techniques on Smart Cards

n λxy.x n y, [inc] [add] [mul] [exp] λn.λxy.x(nxy) λmn.m[inc]0 λmn.m([add]n)0 λmn.n([mul]m)1

CS383 PROGRAMMING LANGUAGES. Kenny Q. Zhu Dept. of Computer Science Shanghai Jiao Tong University

4/19/2018. Chapter 11 :: Functional Languages

Introduction to the Lambda Calculus. Chris Lomont

Anders Møller Michael Schwartzbach Erik Ernst Hans Hüttel

Introduction to Scientific Computing Languages

Functional Languages. CSE 307 Principles of Programming Languages Stony Brook University

Introduction to Scientific Computing Languages

Seminar in Programming Languages

Introduction. A. Bellaachia Page: 1

CS 314 Principles of Programming Languages

Which of the following is not true of FORTRAN?

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

Lambda Calculus. Variables and Functions. cs3723 1

λ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods

CS 242. Fundamentals. Reading: See last slide

Kurt Gödel and Computability Theory

Concepts in Programming Languages

Lambda Calculus. Gunnar Gotshalks LC-1

MIDTERM EXAMINATION. CSE 130: Principles of Programming Languages. Professor Goguen. February 16, points total

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

What Is Computer Science? The Scientific Study of Computation. Expressing or Describing

Programming Languages (CSCI 4430/6430) History, Syntax, Semantics, Essentials, Paradigms

Recursive Definitions, Fixed Points and the Combinator

Lambda Calculus LC-1

Lecture 15: Iteration and Recursion

CS 3304 Comparative Languages. Lecture 1: Introduction

Functional Programming

CIS 500 Software Foundations Fall September 25

Control Flow February 9, Lecture 7

Early computers (1940s) cost millions of dollars and were programmed in machine language. less error-prone method needed

Part I. Historical Origins

Parallel scan on linked lists

CSc 520. Course Outline (Subject to change) Course Outline (Subject to change)... Principles of Programming Languages. Christian Collberg

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

Chapter 5: The Untyped Lambda Calculus

Functional Programming. Big Picture. Design of Programming Languages

Lecture 09. Ada to Software Engineering. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

15. Functional Programming

Lambda Calculus. CS 550 Programming Languages Jeremy Johnson

Organization of Programming Languages CS3200/5200N. Lecture 11

Presented By : Abhinav Aggarwal CSI-IDD, V th yr Indian Institute of Technology Roorkee. Joint work with: Prof. Padam Kumar

Recursion. Lecture 6: More Lambda Calculus Programming. Fixed Points. Recursion

CS A331 Programming Language Concepts

CSC 326H1F, Fall Programming Languages. What languages do you know? Instructor: Ali Juma. A survey of counted loops: FORTRAN

CMSC 330: Organization of Programming Languages

Lecture 5: The Untyped λ-calculus

Untyped Lambda Calculus

Functional Programming

Concepts of Programming Languages

ITT8060 Advanced Programming

CSCI 3136 Principles of Programming Languages

Last class. CS Principles of Programming Languages. Introduction. Outline

CSc 372 Comparative Programming Languages

Untyped Lambda Calculus

Parallel Connected Components

CSC312 Principles of Programming Languages : Functional Programming Language. Copyright 2006 The McGraw-Hill Companies, Inc.

Denotational Semantics. Domain Theory

CS 6110 S14 Lecture 1 Introduction 24 January 2014

CMSC 330: Organization of Programming Languages. Lambda Calculus

COMP 201: Principles of Programming

Lambda Calculus. Lambda Calculus

Programming Languages

Urmas Tamm Tartu 2013

Functions as data. Massimo Merro. 9 November Massimo Merro The Lambda language 1 / 21

Programming Systems in Artificial Intelligence Functional Programming

Why are there so many programming languages?

More Lambda Calculus and Intro to Type Systems

From the λ-calculus to Functional Programming Drew McDermott Posted

Simply-Typed Lambda Calculus

Principles in Programming: Orientation & Lecture 1. SWE2004: Principles in Programming Spring 2014 Euiseong Seo

Transcription:

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 1. ÚVOD DO PŘEDMĚTU, LAMBDA CALCULUS 2011 Jan Janoušek MI-FLP Evropský sociální fond Praha & EU: Investujeme do vaší budoucnosti

Funkcionální a logické programování (Functional and Logic Programming) Jan Janoušek Katedra teoretické informatiky Fakulta informačních technologií ČVUT v Praze February 14, 2011

PRAVIDLA PREDMETU Ucitelé: prednášky: doc. Ing. Jan Janoušek, Ph.D. cvicení: Ing. Martin Poliak Predmet se zabývá funkcionálním a logickým programováním. Vysvetluje základní principy techto paradigmat neimperativního programování a podrobne se venuje programování v jazycích Lisp a Prolog. Dále jsou studenti seznámeni se základními principy implementace jazyku Lisp a Prolog. Semestrální práce se zabývá naprogramováním chování agenta hrajícího hru vybíjená. Další informace www stránka predmetu: https://edux.fit.cvut.cz/courses/mi-flp/start

IMPERATIVE PROGRAMMING LANGUAGES The main idea: the program describes the sequence of statements how to compute. Typical language constructions: variables, assign statement, iterative cycles (for, while,...). Strongly connected with von Neumann architecture of computers (memory, processor, I/O): the state of the run of a program is represented by variables. Procedural: Fortran, Cobol, Basic, Algol, C, Ada, Pascal,... Object oriented: C++, Perl, Python, Java, Smalltalk, PHP, C#,...

NONIMPERATIVE PROGRAMMING LANGUAGES The main idea: the program expresses what to compute. Typical language constructions: recursion, rules, function definitions, constraints,... They are often use in domain specific descriptions of problems (databases), artificial intelligence,... Functional (based on evaluation of functions): LISP, Haskell, Mathematica, ML, XSLT, XQuery, F#... Domain specific (description of domain specific problems): SQL, Flex,... Logic (based on evaluation of mathematical logic): Prolog, Godel,......

LAMBDA CALCULUS THE SMALLEST UNIVERSAL PROGRAMMING LANGUAGE AND A THEORETICAL FOUNDATION FOR FUNCTIONAL PROGRAMMING

HISTORY Alonzo Church (1903 1995) Professor at Princeton (1929 1967) and UCLA (1967 1990). Had a few successful graduate students, including Stephen Kleene (Regular expressions) Michael O. Rabin (Nondeterministic automata) Dana Scott (Formal programming language semantics) Alan Turing (Turing machines)

TURING MACHINES VS. LAMBDA CALCULUS In 1936: Alan Turing invented the Turing machine Alonzo Church invented the lambda calculus In 1937: Turing proved that the two models were equivalent, i.e., that they define the same class of computable functions (ie. recursively enumerable languages). Functional languages are the lambda calculus with a more syntax.

THE SYNTAX OF THE LAMBDA CALCULUS < expression > ::= < name > < function > < application > < expression > ::= ( < expression > ) < name > ::= constant variable < function > ::= λ variable. < expression > < application > ::= < expression > < expression > Constants are numbers and built-in functions; variables are identifiers.

SIMPLE EXAMPLES (+( 5 6)( 8 3)) prefix notation Evaluation: select a redex and evaluate it: (+( 5 6)( 8 3)) (+ 30 ( 8 3)) (+ 30 24) 54

A SIMPLE EXAMPLE OF FUNCTION The only other thing in the lambda calculus is lambda abstraction: a notation for defining unnamed functions. (λ x. + x 1) That function of x that adds x to 1. Function application associates left-to-right: (+ 3 4) ((+ 3) 4) 7

BETA-REDUCTION Evaluation of a lambda abstraction beta-reduction is just substitution: (λ x. + x 1)4 (+ 4 1) 5 The argument may appear more than once (λ x. + x x)4 (+ 4 4) 8 or not at all (λ x. + 1 2)4 3

BETA-REDUCTION Functions may be arguments: (λ f. f 3)(λ x. + x 1) (λ x. + x 1)3 4

FREE AND BOUND VARIABLES (λ x. + x y)4 Here, x is like a function argument but y is like a global variable. Technically, x occurs bound and y occurs free in (λ x. + x y) However, both x and y occur free in (+xy)