# Case studies

The following case studies present interesting applications of Twelf. Some of these case studies use proof techniques that are explained in the tutorials, so you may wish to read those first.

Feel free to add your own case studies here. We would welcome experience reports that document not just the Twelf code you wrote but your experience writing it. (If the goal of your article is to teach a specific Twelf technique, it should instead be a tutorial, and if your Twelf code is off-site, you should instead add it to the list of Research projects using Twelf.)

#### Beginner

A translation of the untyped lambda calculus into the SKI combinator calculus. Bracket abstraction is defined by pattern matching over LF-level lambda abstractions, making essential use of higher-order abstract syntax.
A translation of the simply-typed lambda calculus into the SKI combinator calculus. The translation is shown correct by showing that it preserves and reflects full beta-eta equality. This case study uses uses intrinsic typing and open worlds. (Roughly an extended version of the above bracket abstraction case study.)
A study of the encoding of division over the natural numbers. The definition is shown to be "correct" in a number of ways, including termination of division by a non-zero number and correctness with respect to multiplication. The former involves a use of %reduces for strong induction.
Takahashi's proof of the diamond property of parallel reduction. This case study includes lots of examples of theorems in regular worlds.
A proof of an important theorem about an intuitionistic sequent calculus. Uses lexicographic termination orderings.
The above proof of cut admissibility recast as an algorithm for normalizing λ-terms. Uses many of the proof techniques explained in the tutorials.
The Godel-Gentzen negative translation of classical logic into intuitionistic logic.
An encoding of linear logic that uses a judgment to enforce linearity, along with a proof of subject reduction for it.
Encoding a simple imperative language with state.
A particular encoding of ZF set theory in Twelf
• Twelf Data structures: