Lexicografie computationala Feb., 2012

Similar documents
Pure Lambda Calculus. Lecture 17

1 Scope, Bound and Free Occurrences, Closed Terms

CS 6110 S14 Lecture 1 Introduction 24 January 2014

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

Introduction to the Lambda Calculus. Chris Lomont

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

Lambda Calculus. Variables and Functions. cs3723 1

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

Introduction to Lambda Calculus. Lecture 5 CS 565 1/24/08

Lambda Calculus. Lecture 4 CS /26/10

Introduction to Lambda Calculus. Lecture 7 CS /08/09

9/23/2014. Why study? Lambda calculus. Church Rosser theorem Completeness of Lambda Calculus: Turing Complete

Lambda Calculus. Lambda Calculus

VU Semantik von Programmiersprachen

Fundamentals and lambda calculus

Fundamentals and lambda calculus. Deian Stefan (adopted from my & Edward Yang s CSE242 slides)

Introduction to the Lambda Calculus

Type Systems Winter Semester 2006

Activity. CSCI 334: Principles of Programming Languages. Lecture 4: Fundamentals II. What is computable? What is computable?

CITS3211 FUNCTIONAL PROGRAMMING

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

Programming Language Concepts: Lecture 19

Introduction to the λ-calculus

> module Lambda where > import Data.List -- I need some standard list functions

Chapter 5: The Untyped Lambda Calculus

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

The Untyped Lambda Calculus

Pure (Untyped) λ-calculus. Andrey Kruglyak, 2010

Formal Systems and their Applications

Programming Languages

Formal Semantics. Aspects to formalize. Lambda calculus. Approach

Recursive Definitions, Fixed Points and the Combinator

LING 130: Quantified Noun Phrases

The Lambda Calculus. 27 September. Fall Software Foundations CIS 500. The lambda-calculus. Announcements

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

Lambda Calculus and Extensions as Foundation of Functional Programming

Lecture 5: The Untyped λ-calculus

CSE 505: Concepts of Programming Languages

Functional Programming and λ Calculus. Amey Karkare Dept of CSE, IIT Kanpur

COMP80 Lambda Calculus Programming Languages Slides Courtesy of Prof. Sam Guyer Tufts University Computer Science History Big ideas Examples:

Chapter 5: The Untyped Lambda Calculus

COMP 1130 Lambda Calculus. based on slides by Jeff Foster, U Maryland

Concepts of programming languages

Untyped Lambda Calculus

Lecture Notes on Data Representation

The Untyped Lambda Calculus

The Untyped Lambda Calculus

CIS 500 Software Foundations Fall September 25

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

CS 4110 Programming Languages & Logics. Lecture 17 Programming in the λ-calculus

5. Introduction to the Lambda Calculus. Oscar Nierstrasz

Untyped Lambda Calculus

CS 242. Fundamentals. Reading: See last slide

Less naive type theory

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

Logical Verification Course Notes. Femke van Raamsdonk Vrije Universiteit Amsterdam

Programming Language Features. CMSC 330: Organization of Programming Languages. Turing Completeness. Turing Machine.

CMSC 330: Organization of Programming Languages

10.6 Theoretical Foundations

CMPUT 325 : Lambda Calculus Basics. Lambda Calculus. Dr. B. Price and Dr. R. Greiner. 13th October 2004

TILC: The Interactive Lambda-Calculus Tracer 1

Course Notes Equational Programming: Lambda Calculus. Femke van Raamsdonk

Constraint-based Analysis. Harry Xu CS 253/INF 212 Spring 2013

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.

Functional Programming

dynamically typed dynamically scoped

Part I. Historical Origins

CMSC 330: Organization of Programming Languages

(Refer Slide Time: 4:00)

The Typed λ Calculus and Type Inferencing in ML

CMSC 330: Organization of Programming Languages. Lambda Calculus

Calculus of Inductive Constructions

3.1 λ-calculus: Syntax

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

Discourse Representation Theory Building Discourse Representations

CMSC 330: Organization of Programming Languages

From the λ-calculus to Functional Programming Drew McDermott Posted

Organization of Programming Languages CS3200/5200N. Lecture 11

An Inverse Lambda Calculus Algorithm. For Natural Language Processing. Marcos Alvarez Gonzalez

CMSC 330: Organization of Programming Languages. Lambda Calculus

An Introduction to the Lambda Calculus

Lecture slides & distribution files:

Introductory Example

lambda calculus History 11/28/13 Jianguo Lu A formal system designed to inves:gate func:on defini:on, func:on applica:on, and recursion.

Higher-Order Logic. Specification and Verification with Higher-Order Logic

1 Introduction. 3 Syntax

Lecture #3: Lambda Calculus. Last modified: Sat Mar 25 04:05: CS198: Extra Lecture #3 1

Interpretations of Classical Logic Using λ-calculus. Freddie Agestam

Functional Languages. Hwansoo Han

Urmas Tamm Tartu 2013

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Programming Languages Third Edition

M. Snyder, George Mason University LAMBDA CALCULUS. (untyped)

Functional Programming

Denotational Semantics. Domain Theory

Lambda Calculus. Concepts in Programming Languages Recitation 6:

Introduction to lambda calculus Part 3

Lambda Calculus. Adrian Groza. Department of Computer Science Technical University of Cluj-Napoca

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein

Transcription:

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 * 3 + 1 = 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 λ (xx) y Normal 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.

Types in lambda calculus 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