type-theoretical semantics with coercive subtyping zhaohui luo department of computer science royal...

29
Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Upload: ashlyn-byrd

Post on 17-Dec-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Type-Theoretical Semantics with Coercive Subtyping

Zhaohui LuoDepartment of Computer ScienceRoyal Holloway, University of London

Page 2: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Type theory

Combines computation and logical inference Uniformly in a single language Simple operational semantics + embedded logic

Provides structural mechanisms Natural description power Remark: “types” are natural in math. (cf, “sets” in set

theory) Has nice properties

Eg, Normalisation (decidability + consistency), Subject Reduction, Church-Rosser, … …

Is the basis of implementations of Proof assistants (ALF/Agda, Coq, Lego/Plastic, Matita,

NuPRL, … )

Page 3: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

I. Type Theory: an Introduction

Basic judgement of type theory a : A “a is an object of type A.”

Examples 3 : Nat 2, 2+1 : Nat Nat x:Nat.x : Nat Nat

How do we understand “a : A”?

Page 4: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Basics – canonical objects

Examples: A = Nat, a = 3+4, v = 7. A = NatNat, a = (x:Nat.x,x+1)(2), v = 2,3.

Page 5: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Type of natural numbers

Page 6: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Elimination rule explained

“If C holds for all canonical nats, then C holds for every nat.”

General pattern (for all inductive types): C holds for all canonical objects of …

========================================================================

C holds for every object of …

Page 7: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Inductive/dependent types: examples

Finite types (Unit, Bool, ...)Types of lists, vectors, trees, …Types of dependent functionsTypes of dependent pairs (tuples)Types of ordinals, well-orderings, ...... ...

Page 8: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Embedded logic in type theory

Propositions-as-typesformula

type example

A B A B If … then …

x:A.B(x) x:A.B(x)Every man is handsome.

Prop – totality of logical propositions Impredicative type theories such as Simple TT

(Church 40) and UTT (Luo 94) Example – predicates to formalise adjectives/verbs:

handsome : ManPropwalk : ManProp

Page 9: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Combining types with propositions: examples

-types – types of dependent pairs/tuples Intuitively, for A : Type and B(x) : Type [x:A],

(A,B) = { x,y | x :A & y : B(x) }

Examples (when B is an A-indexed proposition):

(Nat, positive) -- type of positive nats(Man, handsome) -- type of

handsome men

Page 10: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Historical remarks

Early development (from early 1900’s) Logical paradoxes (eg, SS if S = { x | x x }?) Ramified type theory (Russell) Simple type theory (Ramsay 1926 & Church 40)

Modern development (since 1970’s) Martin-Löf’s type theory (predicative) (Martin-Löf 84) Impredicative type theories

Polymorphic -calculus – F (Girard 72) Calculus of Constructions – CC (Coquand & Huet 88) Unifying Theory of dependent Types – UTT (Luo 94)

Page 11: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Nice properties: examples

Normalisation: Every computation terminates. Decidability: Given a and A, it is decidable whether

“a : A”. (Compare this with the undecidable “aA” in set theory.)

Logical consistency: “False” is not provable.Other properties

e.g., “Church-Rosser”, “Subject Reduction”, …

Remark: Based on such good properties, we have simple operational semantics can implement type theories as, eg, proof assistants

Page 12: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Applications of type theory

Application example: Interactive theorem proving and proof assistants

ALF/Agda (Sweden) and NuPRL (USA), implementing Martin-Löf’s TT

Coq (France) and Lego/Plastic (UK), implementing CIC and UTT

Formalisation of mathematics (eg, 4-colour Theorem in Coq)

Program verification (eg, security protocols) Dependently-typed programming

Cayenne (Sweden), DML (USA), Epigram (UK), ...

Today: type-theoretical semantics in linguistics

Page 13: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

II. Coercive Subtyping

Limitations of type theory? Compare with set theory:a A ------ a : AA B ------ ???

Subtyping A B ! How? Traditional notion of subtyping (“subsumptive

subtyping”) a : A A B===================================================

a : B

Q: Is this OK for type theories with canonical objects? A: No. (Why? Then what?)

Page 14: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Two different views of types

Type assignment Objects exist first – types are then assigned to objects. Overloading -terms, which may reside in different types. Examples: ML-like programming languages. Eg,

x.x : (NatNat, IntInt, AA, … )

Types as collections of canonical objects Types and their objects co-exist (one does not without the

other) Given by introduction/elimination/computation rules Embedded (consistent) logic, unique typing, … Examples: Martin-Löf’s TT and UTT.

Page 15: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Two corresponding views of subtyping

Subsumptive subtyping (for type assignment systems)Subsumption rule:

a : A A B =======================================

a : BDifficulty of subsumption with canonical objects

Q: If a is canonical in A, is it canonical in B?

If so, how would one formulate the elimination rule for B? “Bounded quantification”? (AB C:AType x:A …

Troublesome.) If not, then what? … …

Problematic …

Page 16: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Coercive subtypingResearch on coercive subtyping (Luo 1999 et al) Subtyping as abbreviation

f : B C a : A A c B ===================================================================================

f(a) = f(c(a)) : C a : A c B “a” can be regarded as an object of type

B CB[a] = CB[c(a)], ie, “a” stands for “c(a)”

Example, if we declare 1 as a coercion:

(Man, handsome) 1 Man

Coercive subtyping solves the incompatibility problem of subsumption; is adequate for TTs with canonical objects.

Page 17: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Coercive subtyping generalises/subsumes Injective/subset subtyping: Even N; Man Human. Projective/inheritance subtyping: (Man, handsome)

Man.

Implementations of coercive subtyping: Coq, Lego, Plastic, Matita

Applications, including Proof development Dependently-typed programming ... ...

Today: Coercive subtyping in type-theoretical semantics

Page 18: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Coercive subtyping is

an adequate theory of subtyping for the type theories with canonical

objects.

Page 19: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

III. Type-Theoretical Semantics

Formal semantics of NLs Montague grammar (Montague 74) Situation semantics (Barwise-Perry 83) Discourse Representation Theory (Kamp-Reyle 93)

Examples in Montague grammar Common nouns (as functional subsets of entities)

man : CN / 〔 man 〕 : e t Verbs (also as functional subsets over entities)

walk : IV / 〔 walk 〕 : e t Adjectives (as functions from subsets to subsets)

handsome : CN/CN / 〔 handsome 〕 : (et) (et)

Page 20: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Some new developments in, eg, lexical sem Reference transfers (cf, Jackendoff)

“The ham sandwich shouts.” (in a special context) Logical polysemy (cf, Pustejovsky 95)

“burn an interesting book” (“book”: both “physical” and “informational”)

Problem and solution Montague Grammar is not fit for the purpose!

(cf, work by Pustejovsky, Asher, …) Types instead of functional subsets +

coercive subtyping

Page 21: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Type-theoretical semantics: CNs as types

Type theory – “many domains/types” (cf, (Ranta 94))

Common nouns are interpreted as types〔 man 〕 : Type〔 book 〕 : Type

Verbs are interpreted as predicates (functional subsets)〔 walk 〕 : 〔 man 〕 Prop〔 John walks 〕 = 〔 walk 〕 (John) : Prop, where John : Man.

Adjectives are interpreted as predicates (functional subsets)

〔 handsome 〕 : 〔 man 〕 Prop Modified CNs are interpreted by -types

〔 handsome man 〕 = ( 〔 man 〕 , 〔 handsome 〕 )

Page 22: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

What about, eg, “A handsome man is a man” ? “Paul walks”, with Paul : 〔 handsome man 〕 ?

Solution: coercive subtyping First projection 1 as coercion: (A,B) 1

A

〔 handsome man 〕 = ( 〔man 〕 , 〔 handsome 〕 ) 1

〔man 〕 〔 Paul walks 〕 = 〔 walk 〕 (Paul) : Prop

because 〔 walk 〕 : 〔man 〕 Prop 〔 handsome man 〕 Prop.

Remark: Subtyping is crucial in type-theoretical semantics.

Page 23: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Examples involving dot-types

Dot-types AB in Generative Lexicon Theory (Pustejovsky 95) Example: PHYINFO PHYINFO PHY and PHYINFO INFO

In type-theoretical semantics,〔 book 〕 PHYINFO 〔 interesting 〕 : INFO Prop

PHYINFO Prop 〔 book 〕 Prop

〔 burn 〕 : Human PHY Prop Human PHYINFO Prop Human 〔 book 〕 Prop Human 〔 interesting book 〕 Prop

〔 John burned an interesting book 〕= b : 〔 interesting book 〕 . 〔 burn 〕 (John,b) : Prop

Page 24: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Another example – copredication (Asher 09)“John picked up and mastered the book.”〔 pick up 〕 : Human PHY Prop

Human PHYINFO Prop Human 〔 book 〕 Prop

〔 master 〕 : Human INFO Prop Human PHYINFO Prop Human 〔 book 〕 Prop

Remarks: Common nouns as types in type-theoretical semantics – so

things work. (But coercive subtyping is crucial!) Problematic if sticking to Montague’s interpretations of CNs

as functional subsets.

Page 25: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Modelling dot-types in type theory

What is AB?Inadequate accounts Intersection type Product type

Representing AB as AB with 1/2 as (implicit) coercions

where the C-condition (disjointness of A/B-components) guarantees that the coercions concerned are coherent.

Page 26: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Coercion contexts

Coercive subtyping only happens in local contexts (eg, reference transfers)Coercion contexts in type theory

Page 27: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Conclusions

Type theories with coercive subtyping provide a logical basis for formal semantics of NLs.Coercive subtyping

is crucial in giving an adequate type-theoretical semantics.

can be used to adequately model many lexical phenomena (eg, by means of dot-types) in lexical semantics.

Page 28: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London

Selected References

(Asher 09) N. Asher. Lexical Meaning in Context: A Web of Words. (Draft Book to appear in Cambridge Univ Press)

(Church 40) A. Church. A formulation of the simple theory of types. J. Of Symbolic Logic 5(1).

(Luo 94) Z. Luo. Computation and Reasoning: A Type Theory for Computer Science. Oxford Univ Press.

(Luo 99) Z. Luo. Coercive subtyping. J of Logic and Comput. 9(1). (Montague 74) R. Montague. Formal Philosophy. Yale Univ Press. (Pustejovsky 95) J. Pustejovsky. The Generative Lexicon. MIT.(Ranta 94) A. Ranta. Type-Theoretical Grammar. Oxford Univ

Press.

Page 29: Type-Theoretical Semantics with Coercive Subtyping Zhaohui Luo Department of Computer Science Royal Holloway, University of London