25
Coq and Nuprl Wojciech Moczydłowski History World, type system Inductive types in Coq Extraction in Coq Other features of Coq

Coq and Nuprl Wojciech Moczydłowski

  • Upload
    marion

  • View
    43

  • Download
    0

Embed Size (px)

DESCRIPTION

Coq and Nuprl Wojciech Moczydłowski. History World, type system Inductive types in Coq Extraction in Coq Other features of Coq. Coq Lambda calculus with types. Church, Curry, Howard, Girard, Huet, Coquand, Paulin-Mohring. Nuprl Type theory. Russell, Church, Curry, Howard, - PowerPoint PPT Presentation

Citation preview

Page 1: Coq and Nuprl Wojciech Moczydłowski

Coq and NuprlWojciech Moczydłowski

• History

• World, type system

• Inductive types in Coq

• Extraction in Coq

• Other features of Coq

Page 2: Coq and Nuprl Wojciech Moczydłowski

History

Coq

Lambda calculus

with types.

Church, Curry,

Howard, Girard,

Huet, Coquand,

Paulin-Mohring.

Nuprl

Type theory.

Russell, Church,

Curry, Howard,

Martin-Löf,

Nuprl group.

Page 3: Coq and Nuprl Wojciech Moczydłowski

Ideology

Coq

A Calculus of

Inductive

Constructions.

Not assuming

stance on

FOM.

Nuprl

A foundational

system, intented

to represent

constructive

mathematics.

Propositions-as-types principle

Page 4: Coq and Nuprl Wojciech Moczydłowski

Type system: Judgements

Coq

t : T

t is of type T

Nuprl

s=t : T

s is equal to t in

type T

T=S

types T and S are equal

Page 5: Coq and Nuprl Wojciech Moczydłowski

Consistency

Coq

1. Syntactic -

proof-theoretic

methods,

strong

normalization.

2. Semantic -

models in

(domain,set,

category) theory.

Nuprl

1. Syntactic - no strong normalization.

2. Semantic - Allen, Howe, Moran.

Domain models

for Martin-Löf’s

type theory

Page 6: Coq and Nuprl Wojciech Moczydłowski

Rules

Coq

Only typing rules.

Core λC has <10 rules (PTS presentation).

Inductive definitions - probably about <20 more.

Extraction - ???

Reduction - ???

Marketing

Nuprl

Judgements + extraction terms + tactics.

More than 100 rules.

Page 7: Coq and Nuprl Wojciech Moczydłowski

World

Coq (8.0)

Set, Typei

predicative

Prop

impredicative

Note: In Coq 7.2

Set impredicative

as well

Nuprl

Completely

predicative

Page 8: Coq and Nuprl Wojciech Moczydłowski

Type system

Coq

Closed. No really

new types can be

added.

Nuprl

Open-ended. New

types can and are

being added.

Type system

Page 9: Coq and Nuprl Wojciech Moczydłowski

Logic

Coq

Only universal

quantifier built-in.

Rest defined

using inductive

types (including equality).

Can also use

Girard’s ideas.

Nuprl

All the logic

built-in.

Logic

Page 10: Coq and Nuprl Wojciech Moczydłowski

Coq - inductive definitions

• Very generic mechanism.

• Used to define logic, natural numbers, lists, inductive predicates and others...

• To each inductive definition correspond generated principles of induction and recursion.

Page 11: Coq and Nuprl Wojciech Moczydłowski

Coq - inductive typesLogic

Inductive False := .

Inductive True := I : True.

Inductive and (A B : Prop) : Prop

:= conj A B A /\ B.

Inductive or (A B : Prop) : Prop :=

or_introl : A A \/ B |

or_intror : B A \/ B.

Coq - inductive types Logic

Page 12: Coq and Nuprl Wojciech Moczydłowski

Natural numbers

Coq

Another inductive type.

Nuprl

Built-in construct.

Page 13: Coq and Nuprl Wojciech Moczydłowski

Coq - inductive types Natural numbers

Inductive nat := 0 : nat |

S : nat nat.

Recursion:

P : nat Set,

P 0 ( n : nat. P n P (S n)) n : nat. P n

Page 14: Coq and Nuprl Wojciech Moczydłowski

Coq - inductive types Natural numbers

Inductive nat := 0 : nat |

S : nat nat.

Induction:

P : nat Prop,

P 0 ( n : nat. P n P (S n)) n : nat. P n

Page 15: Coq and Nuprl Wojciech Moczydłowski

Coq - inductive types List

Inductive List (A:Set) : Set :=

Nil : List A

| Cons : A List A List A

Recursion:

A P : List A Set.

P (Nil A) ( a : A, l : List A. P l P (a::l))

l : List A.

Page 16: Coq and Nuprl Wojciech Moczydłowski

Coq - inductive types List

Inductive List (A:Set) : Set :=

Nil : List A

| Cons : A List A List A

Induction:

A P : List A Prop.

P (Nil A) ( a : A, l : List A. P l P (a::l))

l : List A.

Page 17: Coq and Nuprl Wojciech Moczydłowski

Coq - inductive types <=

Inductive le (n:nat) : nat Prop := le_n : le n n |    le_S : m:nat,

le n m le n (S m).

Page 18: Coq and Nuprl Wojciech Moczydłowski

Coq - extraction

• External mechanism.

• Proof irrelevance - Prop doesn’t contain computational content and isn’t supposed to. Set and Type hierarchy, however, do.

Coq - extraction

Page 19: Coq and Nuprl Wojciech Moczydłowski

Coq - extraction

Ind. ex (A : x) (P:A y) : z

ex_intro : x : A, P x ex A P.

• (x, y, z) = (Type, Prop, Prop)

No computational content

Notation: exists x : A, P x

Coq - extraction

Page 20: Coq and Nuprl Wojciech Moczydłowski

Coq - extraction

Ind. ex (A : x) (P:A y) : z

ex_intro : x : A, P x ex A P.

• (x, y, z) = (Set, Prop, Set)

Witness is extracted, proof not.

Notation: { x : A | P x }

Coq - extraction

Page 21: Coq and Nuprl Wojciech Moczydłowski

Coq - extraction

Ind. ex (A : x) (P:A y) : z

ex_intro : x : A, P x ex A P.

• (x, y, z) = (Set, Set, Set)

Everything is extracted.

Isomorphic to type.

Notation: { x : A & P x }

Coq - extraction

Page 22: Coq and Nuprl Wojciech Moczydłowski

Programming language

Coq

Not very strong,

due to strong

normalization.

Restrictions on

possible

programs -

structural

recursion.

Nuprl

Full power of Y

combinator.

Programming language

Page 23: Coq and Nuprl Wojciech Moczydłowski

Environment

Coq

Text-mode

interface for user

interaction.

External graphic

environment is

being developed.

Nuprl

Sophisticated

programming

environment,

integrated editor,

library

management etc.

Environment

Page 24: Coq and Nuprl Wojciech Moczydłowski

Installation and system requirements

Coq

Installation: easy.

Sys.req: Modest.

Systems:

Windows, Unix

(Linux/ MacOS/ Solaris...).

Nuprl

Installation: hard.

Sys.req: High.

Systems: Unix

Installation and system requirements

Page 25: Coq and Nuprl Wojciech Moczydłowski

Coq - other informations

• User base: over 250 people subscribed to the mailing list.

• New book: Coq’Art (2004).

• Website: coq.inria.fr

• Documentation tools.

• Why - a tool for proving correctness of imperative programs. Can use Coq as a backend prover.

Coq - other informations