Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Twelf

From Wikipedia, the free encyclopedia

Twelf is an implementation of the logical frameworkLF developed byFrank Pfenning and Carsten Schürmann atCarnegie Mellon University.[1] It is used forlogic programming and for the formalization ofprogramming language theory.

Introduction

[edit]
Further information:LF (logical framework)

At its simplest, a Twelf program (called a "signature") is a collection of declarations oftype families (relations) and constants that inhabit those type families. For example, the following is the standard definition of the natural numbers, withz standing for zero ands the successor operator.

nat:type.z:nat.s:nat->nat.

Herenat is a type, andz ands are constant terms. As adependently typed system, types can be indexed by terms, which allows the definition of more interesting type families. Here is a definition of addition:

plus:nat->nat->nat->type.plus_zero:{M:nat}plusMzM.plus_succ:{M:nat}{N:nat}{P:nat}plusM(sN)(sP)<-plusMNP.

The type familyplus is read as a relation between three natural numbersM,N andP, such thatM + N = P. We then give the constants that define the relation: the constantplus_zero indicates thatM + 0 = M. The quantifier{M:nat} can be read as "for allM of typenat".

The constantplus_succ defines the case for when the second argument is the successor of some other numberN (seepattern matching). The result is the successor ofP, whereP is the sum ofM andN. Thisrecursive call is made via the subgoalplus M N P, introduced with<-. The arrow can be understood operationally as Prolog's:-, or as logical implication ("if M + N = P, then M + (s N) = (s P)"), or most faithfully to the type theory, as the type of the constantplus_succ ("when given a term of typeplus M N P, return a term of typeplus M (s N) (s P)").

Twelf features type reconstruction and supports implicit parameters, so in practice, one usually does not need to explicitly write{M:nat} (etc.) above.

These simple examples do not display LF's higher-order features, nor any of its theorem checking capabilities. See the Twelf distribution for its included examples.

Uses

[edit]

Logic programming

[edit]

Twelf signatures can be executed via a search procedure. Its core is more sophisticated thanProlog, since it is higher-order and dependently typed, but it is restricted to pure operators: there is no cut or other extralogical operators (such as ones for performingI/O) as are often found in Prolog implementations, which may make it less well-suited for practical logic programming applications. Some uses of Prolog's cut rule can be obtained by declaring that certain operators belong to deterministic type families, which avoids recalculation. Also, likeλProlog, Twelf generalizesHorn clauses tohereditary Harrop formulas, which allow for logically well-founded operational notions of fresh-name generation and scoped extension of the clause database.

Formalizing mathematics

[edit]

Twelf is mainly used today as a system for formalizing mathematics, especially the metatheory ofprogramming languages. As such, it is closely related toCoq andIsabelle/HOL/HOL Light. However, unlike those systems, Twelf proofs are typically developed by hand. Despite this, for the problem domains at which it excels, Twelf proofs are often shorter and easier to develop than in the automated, general-purpose systems.

Twelf's built-in notion of binding and substitution facilitates the encoding of programming languages and logics, most of which make use of binding and substitution, which can often be directly encoded throughhigher-order abstract syntax (HOAS), where the meta-language's binders represent the object-level binders. Thus standard theorems such as type-preserving substitution andalpha conversion come "for free".

Twelf has been used to formalize many different logics and programming languages (examples are included with the distribution). Among the larger projects are a proof of safety forStandard ML,[2] a foundationaltyped assembly language system from CMU,[3] and a foundationalproof carrying code system from Princeton.

Implementation

[edit]

Twelf is written in Standard ML, and binaries are available for Linux and Windows. As of 2006[update], it is under active development, mostly at Carnegie Mellon University.[needs update]

See also

[edit]

References

[edit]
  1. ^Pfenning, Frank; Carsten Schürmann (July 1999).System description: Twelf - a meta-logical framework for deductive systems(PDF). Proceedings of the 16th International Conference on Automated Deduction (CADE-16). Retrieved2019-05-08.
  2. ^Lee, Daniel; Karl Crary;Robert Harper (January 2007).Towards a Mechanized Metatheory of Standard ML(PDF). Proceedings of the 2007 Symposium on thePrinciples of Programming Languages.Nice, France. Retrieved2007-02-08.
  3. ^Crary, Karl (2003).Toward a Foundational Typed Assembly Language(PDF). Proceedings of the 2003 Symposium on thePrinciples of Programming Languages. Retrieved2007-02-08.

External links

[edit]
ML programming
Software
Implementations,
dialects
Caml
Standard ML
Dependent ML
Programming tools
Theorem provers,
proof assistants
Community
Designers
  • Lennart Augustsson (Lazy ML)
  • Damien Doligez (OCaml)
  • Gérard Huet (Caml)
  • Xavier Leroy (Caml, OCaml)
  • Robin Milner (ML)
  • Don Sannella (Extended ML)
  • Don Syme (F#)
  • Retrieved from "https://en.wikipedia.org/w/index.php?title=Twelf&oldid=1241740500"
    Categories:
    Hidden categories:

    [8]ページ先頭

    ©2009-2025 Movatter.jp