Lexicografie computationala Feb., 2012 Anca Dinu University of Bucharest.

Slides:



Advertisements
Similar presentations
Types and Programming Languages Lecture 7 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Advertisements

Some non-recursive tricks. The Lambda expression. More on Let, Let*, apply and funcall.
10 October 2006 Foundations of Logic and Constraint Programming 1 Unification ­An overview Need for Unification Ranked alfabeths and terms. Substitutions.
First-Order Logic (and beyond)
The lambda calculus David Walker CS 441. the lambda calculus Originally, the lambda calculus was developed as a logic by Alonzo Church in 1932 –Church.
Elements of Lambda Calculus Functional Programming Academic Year Alessandro Cimatti
Lambda Calculus and Lisp PZ03J. Lambda Calculus The lambda calculus is a model for functional programming like Turing machines are models for imperative.
Functional Programming COMP2003 A course on functional programming using Common Lisp Dr Eleni Mangina
Class 39: Universality cs1120 Fall 2009 David Evans University of Virginia.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 39: Lambda Calculus.
MATHEMATICAL FOUNDATIONS SUPPLEMENTAL MATERIAL – NOT ON EXAM.
Catriel Beeri Pls/Winter 2004/5 functional-language 1 Substitution Semantics of FL – a simple functional language FL is EL + (non-recursive) function creation.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
Computability and Complexity 9-1 Computability and Complexity Andrei Bulatov Logic Reminder (Cnt’d)
Advanced Formal Methods Lecture 2: Lambda calculus Mads Dam KTH/CSC Course 2D1453, Some material from B. Pierce: TAPL + some from G. Klein, NICTA.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
Introduction to Computability Theory
Foundations of Programming Languages: Introduction to Lambda Calculus
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
Catriel Beeri Pls/Winter 2004/5 type reconstruction 1 Type Reconstruction & Parametric Polymorphism  Introduction  Unification and type reconstruction.
The lambda calculus David Walker CS 441. the lambda calculus Originally, the lambda calculus was developed as a logic by Alonzo Church in 1932 –Church.
Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.
Comp 205: Comparative Programming Languages Semantics of Functional Languages Term- and Graph-Rewriting The λ-calculus Lecture notes, exercises, etc.,
Slides 01 1 Type-Free λ-Calculus The λ-calculus is a family of prototype programming languages invented by the logician, Alonzo Church, in the 1930's.
C. Varela1 Lambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators Carlos Varela Rennselaer.
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Introduction Even though the syntax of Scheme is simple, it can be very difficult to determine the semantics of an expression. Hacker’s approach: Run it.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
October 2004csa4050: Semantics II1 CSA4050: Advanced Topics in NLP Semantics II The Lambda Calculus Semantic Representation Encoding in Prolog.
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
1st-order Predicate Logic (FOL)
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.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Extending the Definition of Exponents © Math As A Second Language All Rights Reserved next #10 Taking the Fear out of Math 2 -8.
Chapter Twenty-ThreeModern Programming Languages1 Formal Semantics.
Database Management Systems, R. Ramakrishnan1 Relational Calculus Chapter 4.
Formal Semantics Chapter Twenty-ThreeModern Programming Languages, 2nd ed.1.
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 Relational Algebra and Calculas Chapter 4, Part A.
Semantic Construction lecture 2. Semantic Construction Is there a systematic way of constructing semantic representation from a sentence of English? This.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Albert Gatt LIN3021 Formal Semantics Lecture 4. In this lecture Compositionality in Natural Langauge revisited: The role of types The typed lambda calculus.
CSE 230 The -Calculus. Background Developed in 1930’s by Alonzo Church Studied in logic and computer science Test bed for procedural and functional PLs.
1 Formal Semantics. 2 Why formalize? ML is tricky, particularly in corner cases generalizable type variables? polymorphic references? exceptions? Some.
Principles of programming languages 9: Lambda calculus Isao Sasano Department of Information Science and Engineering.
Lambda Calculus Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 11.
Lesson2 Lambda Calculus Basics 1/10/02 Chapter 5.1, 5.2.
Implementing a Dependently Typed λ -Calculus Ali Assaf Abbie Desrosiers Alexandre Tomberg.
-Calculus Kangwon National University 임현승 Programming Languages These slides are based on the slides by Prof. Sungwoo Park at POSTECH.
Lambda Calculus CSE 340 – Principles of Programming Languages Fall 2015 Adam Doupé Arizona State University
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.
CS321 Functional Programming 2 © JAS The λ Calculus This is a formal system to capture the ideas of function abstraction and application introduced.
C H A P T E R E I G H T Functional Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
6/21/20161 Programming Languages and Compilers (CS 421) Reza Zamani Based in part on slides by Mattox Beckman,
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L03-1 September 14, 2006http:// -calculus: A Basis for.
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Unit – 3 :LAMBDA CALCULUS AND FUNCTIONAL PROGRAMMING
Lambda Calculus CSE 340 – Principles of Programming Languages
CS 611: Lecture 9 More Lambda Calculus: Recursion, Scope, and Substitution September 17, 1999 Cornell University Computer Science Department Andrew Myers.
Corky Cartwright January 18, 2017
Lesson2 Lambda Calculus Basics
Programming Languages and Compilers (CS 421)
Announcements Quiz 6 HW7 due Tuesday, October 30
Announcements Exam 2 on Friday, November 2nd Topics
L Calculus.
CSE S. Tanimoto Lambda Calculus
Presentation transcript:

Lexicografie computationala Feb., 2012 Anca Dinu University of Bucharest

Introduction When we construct meaning representations systematically, we integrate information from two different sources: 1. The lexical items (i.e. the words from the lexicon) in a sentence give us the basic ingredients for our representation. 2. Syntactic structure tells us how the semantic contributions of the parts of a sentence are to be joined together.

Introduction Semantic information flows from the lexicon, where each lexical item is associated with a representation. What kind of representation and how does it look like we will see in the next lectures (Pustejowski’s generative lexicon). For now, we are concerned with a theory used to combine the information in the lexicon, i.e. lambda calculus. One of the reasons for doing so is that the way we will combine the lexical entries partially determines their form.

Lambda calculus History Leibniz had as ideal the following. 1) Create a ‘universal language' in which all possible problems can be stated. 2) Find a decision method to solve all the problems stated in the universal language. Point (1) of Leibniz' ideal is fulfilled by taking some form of set theory formulated in the language of first order predicate logic. This was the situation after Frege and Russell (or Zermelo).

History Point (2) of Leibniz' ideal was solved in 1936, in a negative way, independently by Alonzo Church and Alan Turing. In order to do so, they needed a formalization of the intuitive notion of ‘decidable' or ‘computable'. Church and Turing did this in two different ways by introducing two models of computation: lambda calculus and Turing machines, respectively.

History The λ-calculus can be called the smallest universal programming language of the world. Its syntax has 3 lines. The calculus consists of a single transformation rule (variable substitution) and a single function definition scheme. Nevertheless, it is rather involved.

Informal syntax of λ λ is a binding operator, just like “ ∃ ” or “ ∀ ”. Consequently, it always binds something (a variable), taking scope over some expression that (usually) contains occurrences of the bound variable. More practically, λ always occurs in the following configuration: (λ var body)

Formal syntax of lamda calculus Definition. Assume given an infinite set V of variables, denoted by x, y, z etc. The set of lambda terms is given by the following Backus-Naur Form: Lambda terms: M, N ::= x | (MN) | (λx.M) aplication abstraction

Examples (λ x.2 * x + 1) λ x.man(x) λ x λy.love(x,y) λQ λP. [ ∀ x [Q(x) -> P(x)]] (every) λQ λP. [ ∃ x [Q(x) & P(x)]] (some)

Convention. We omit outermost parentheses. For instance, we write MN instead of (MN). Applications associate to the left; thus, MNP means (MN)P and fxyz means ((fx)y)z. The body of a lambda abstraction (the part after the dot) extends as far to the right as possible. In particular, λx.MN means λx.(MN), and not (λx.M)N. Multiple lambda abstractions can be contracted; thus λxyz.M will abbreviate λx λyλz.M.

Free vs. bound variables An occurrence of a variable x inside a term of the form λx.N is said to be bound. The corresponding x is called a binder, and we say that the subterm N is the scope of the binder. A variable occurrence that is not bound is free. A lambda term is called closed if it contains no free variables. For example, in the term M = (λx.xy)(λy.yz) x is bound, z is free; y has both a free and a bound occurrence. The set of free variables of M is {y, z}.

Reduction rules: β-reduction Nothing happens until a λ-binding form occurs in construction with an argument, thus: ((λ var body) argument) Then, it is possible to reduce the expression to a simpler form by means of β-reduction (sometimes with the help of α-reduction and η-reduction). The main idea is to replace every free occurrence of the variable "var" in "body" with "argument”: (λ x.M)N = M[x := N], where [x := N] denotes substitution of N for x.

Reduction rules: β-reduction Exemple: (λ x.2 * x + 1)3= 2 * = 7; (lambda var ((fn1 var) & (fn2 var))) argument = ((fn1 argument) & (fn2 argument)) Every man walks. λQ λP. [ ∀ x [Q(x) -> P(x)]] man walk = λP [ ∀ x [man(x) -> P(x)]] walk = [ ∀ x [man(x) -> walk(x)]]

Church-Rosser Theorem or confluence (Evaluation order independence) If and when an expression is reduced to the extent that the substitution rule can no longer be applied, it is said to be in normal form. Ex: Not Normal Normal λ (xx) y y (λ y(f y)) a fa (λ x(λ y(xy))) a λ y(ay) (λ xx) (λ xx) xx (λ x(xx)) y yy (λ x(xy)) (λ x(xx)) yy

Church-Rosser Theorem or confluence (Evaluation order independence) There are λ -expressions which do not have normal form. Ex: (λx.xx)(λx.xx) (the size remains the same) (λ x.xx)(λ y.yyy) (the size increases) The Church-Roser theorem says, however, that if it is possible to reduce a given λ-expression to its normal form, then we always get the same expression regardless of the order in which we perform reductions of subexpressions.

Reduction rules: α-reduction Unfortunately, applying β-reduction indiscriminately can cause trouble when the body contains binding operators. Consider: ((λ x. (λ y. (x y))) y) β-reduction: substitute "y" in for "x" in the body "(λ y (x y))" ==> (λ y (y y)) Wrong result! The solution is to make use of alphabetic variants. Roughly, two expressions are "alphabetic variants" if they are identical except perhaps for the choice of variable symbols.

Reduction rules: α-reduction To create an alphabetic variant for "(λ var body)", simply replace each free occurrence of "var“ with a variable symbol not occurring anywhere in "body“. This transformation is called α-reduction. The crucial property of the reduced form is that each λ operator binds the same number of variables in the same positions within its body.

Reduction rules: α-reduction Ex. of alphabetic variants : 1. ((λ x x) x) α-reduction on "(λ x x)", substituting "y" for "x" ==> ((λ y y) x) 2. ((λ x x)(λ x (x x))) α-reduction on "(λ x x)", substituting “y" for "x" ==> ((λ y y)(λ x (x x))) 3. (λ x (λ x (x x))) α-reduction on "(λ x (λ x (x x)))", substituting "y" for "x" ==> (λ y (λ x (x x))) The third example may look surprising; α-reduction targets only free occurrences of the variable (free relative to the λ body). Since the second λ binds the last two occurrences of "x", α-reduction won't touch them.

Reduction rules: α-reduction Now, back to the original problem. The way to deal with "((λ x (λ y (x y))) y)", is to first take an alphabetic variant (apply α-reduction). ((λx (λy (x y))) y) α-reduction on "(λy (x y))", substituting "y1" for "y" ==> ((λx (λy1 (x y1))) y) β- reduction, substituting "y" for "x" ==> (λy1 (y y1)) It usually takes some practice to know when it is necessary to use an alphabetic variant. The safest strategy is to automatically apply α-reduction to every binding operator before each application of β- reduction. This order explains the naming α and β reduction.

Semantics of lambda operator The following rule completely characterizes the meaning of the λ-operator. First, let "[*]^g" mean "the denotation of ‘*’ with respect to the assignment function g, where an assignment function is a function mapping variable symbols onto values, and g[u/v] is that assignment function exactly like g except that it maps the variable v onto the value u. In words, the meaning of a λ-form that binds the variable v when applied to an argument a is the meaning of the body b evaluated with respect to an assignment function that sets the value of v equal to the denotation of a.

Types in lambda calculus Untyped lambda calculus. We never specify the type of any expression. Thus we never specify the domain or codomain of any function; very flexible, but very unsafe, because we might run into situations where we try to apply a function to an argument that it does not understand.

Types in lambda calculus Simply-typed lambda calculus (most commonly used in linguistics). In the simply-typed lambda calculus, we always completely specify the type of every expression. This is very similar to the situation in set theory. We never allow the application of a function to an argument unless the type of the argument is the same as the domain of the function.

Types in lambda calculus Polymorphically typed lambda calculus. This is an intermediate situation, where we may specify, for instance, that a term has a type of the form X -> X for all X, without actually specifying X. Helpful in linguistics and used in functional programming languages such as Haskell.

Types in lambda calculus Definition: 1. e is a type. 2. t is a type. 3. If a and b are types, then a -> b is a (complex) type. 4. Notational variant: sometimes (π 1,π 2 ) is used instead of π 1 ->π 2.

Types in lambda calculus A simple type tree: t e e->t Function Application: If α is of type a, and β is of type a -> b, then β(α) is of type b.

Types in lambda calculus. What do we need complex types for? They are the types that get assigned to λ- expressions: a λ-abstraction of the form λx.P is of type π1->π2, where π1 is the type of the λ-bound variable x, and π2 is the type of the scope of the abstraction P.

Types in lambda calculus. For example, the type of the abstraction λx.men(x) is e->t. The reason is that x is a first order variable ranging over individuals, hence of type e, and man(x) is a first-order formula, hence of type t.

The application λy.woman(y) λx.men(x) is not admissible (it is not well-typed), because the type of the argument λx.men(x) is e->t and the type of variable y from λy.woman(y) is e (the type of λy.woman(y) is e->t). So they don't match. Types in lambda calculus

Consider the following expression: λx.men(x)Mary The application is allowed (it is well-typed), because variable x from λx.men(x) is of type e (λx.men(x) is of type e->t) and Mary is also of type e. The result after β-reduction is men(Mary). To prohibit this result, we need fine grained information in the lexicon.

Next lecture: Generative lexicon