1 / 30

Lexicografie computationala Feb., 2012

Lexicografie computationala Feb., 2012. Anca Dinu University of Bucharest. Introduction. When we construct meaning representations systematically, we integrate information from two different sources:

oriole
Download Presentation

Lexicografie computationala Feb., 2012

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lexicografie computationalaFeb., 2012 Anca Dinu University of Bucharest

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

  3. 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.

  4. 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).

  5. 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.

  6. 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.

  7. 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)

  8. 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

  9. 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)

  10. 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.

  11. 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}.

  12. 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.

  13. 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)]]

  14. 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

  15. 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.

  16. 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.

  17. 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.

  18. 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.

  19. 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.

  20. 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.

  21. Types in lambda calculus • Untyped lambda calculus. We never specifythe 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.

  22. 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.

  23. 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.

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

  25. 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.

  26. 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.

  27. 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.

  28. 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.

  29. 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.

  30. Next lecture: • Generative lexicon

More Related