-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mostly sprucing up the percent-directive pages
- Loading branch information
1 parent
6a30a24
commit 11a13a6
Showing
45 changed files
with
26,208 additions
and
26,232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
%%! title: Troubleshooting mode checking errors | ||
%%! description: There are some common pitfalls when dealing with mode checking, but many have simple solutions | ||
|
||
%{! | ||
There are some common pitfalls when you're dealing with [`%mode`](/wiki/percent-mode/) declarations. | ||
|
||
## Basic mode checking errors | ||
|
||
Say we give a definition of the natural numbers with addition: !}% | ||
|
||
nat: type. | ||
z: nat. | ||
s: nat -> nat. | ||
|
||
plus: nat -> nat -> nat -> type. | ||
%mode plus +N1 +N2 -N3. | ||
|
||
pz: plus z N N. | ||
ps: plus (s N1) N2 (s N3) | ||
<- plus N1 N2 N3. | ||
|
||
%{! The input of `plus` is the first and second positions, and the output of `plus` is the third position, which means that whenever there are [ground](/wiki/ground/) objects in the first and second positions, that must force a ground object in the third position. | ||
|
||
If one of the output arguments is not forced to be a ground, which would be the case if the output of plus no longer matched the output of the [[subgoal]], then we get an error: | ||
|
||
```checkedtwelf | ||
px: plus (s N1) N2 (s N) | ||
<- plus N1 N2 N3. | ||
``` | ||
|
||
Another problem occurs when the _inputs_ to a subgoal are not known to be ground, which would happen if we mis-named one of the inputs to the subgoal. | ||
|
||
```checkedtwelf | ||
py: plus (s N1) N2 (s N3) | ||
<- plus N N2 N3. | ||
``` | ||
|
||
## Ordering subgoals | ||
|
||
Mode checking considers subgoals _in order_, i.e. from top to bottom when the subgoals are written out in the standard style using backwards arrows. The order of subgoals matters very much for mode checking. Say we have an identity function that maps inputs (the first position) to outputs (the second position). !}% | ||
|
||
id: nat -> nat -> type. | ||
%mode id +N1 -N2. | ||
|
||
id/refl: id N N. | ||
|
||
%{! The rule ``ps'`` below passes the mode checker, because the call to ``id`` takes the ground argument ``N1`` and creates a ground output ``N1'``, which is then used in the derivation for ``plus N1' N2 N3``. | ||
|
||
```checkedtwelf | ||
ps': plus (s N1) N2 (s N3) | ||
<- id N1 N1' | ||
<- plus N1' N2 N3. | ||
``` | ||
|
||
However, if we reverse the order of the two subgoals, even though the result is logically equivalent, Twelf considers ``plus N1' N2 N3`` before ``id N1 N1'``, and so does consider ``N1'`` to be ground when it encounters it; thus, complaining accordingly: | ||
|
||
```checkedtwelf | ||
ps': plus (s N1) N2 (s N3) | ||
<- plus N1' N2 N3 | ||
<- id N1 N1'. | ||
``` | ||
|
||
!}% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,7 @@ | ||
%%! title: "External documentation" | ||
%%! next: false | ||
|
||
%{! | ||
|
||
The Twelf [User's Guide](/wiki/users-guide/) was the basic reference manual | ||
for Twelf prior to the Twelf Wiki, and is still the authoritative source for | ||
some topics. | ||
|
||
Besides information on this wiki, there have been a number of papers and | ||
tutorials explaining how to use Twelf for various purposes, as well as | ||
commentary on using Twelf. | ||
|
||
### Tutorials | ||
|
||
- Andrew Appel's [Hints on Proving Theorems in | ||
Twelf](http://www.cs.princeton.edu/~appel/twelf-tutorial/) describes a | ||
particular methodology for using Twelf that is rather different than the | ||
strategy of proving [metatheorems](/wiki/metatheorem/) that predominates on | ||
this wiki (also known as "the particular strange way they do it at | ||
Princeton"). | ||
- John Boyland's [Using Twelf to Prove Type | ||
Theorems](https://cs.nju.edu.cn/_upload/tpl/00/aa/170/template170/proof/using-twelf.pdf) | ||
john is a tutorial and experience report. | ||
- Dan Licata and Bob Harper have written a survey article called [Mechanizing | ||
Metatheory in a Logical Framework](http://www.cs.cmu.edu/~drl/pubs/hl06mechanizing/hl06mechanizing.pdf). | ||
This paper provides a more formal introduction to the modern way of thinking | ||
about LF and Twelf than this site does. | ||
- Alberto Momigliano's [A Practical Approach to Co-induction in | ||
Twelf](http://www.cs.nott.ac.uk/types06/slides/am.pdf) describes a technique | ||
for encoding Twelf-unfriendly co-inductive proofs as Twelf-friendly induction | ||
proofs (slides from a talk at TYPES 2006). | ||
- John Altidor's | ||
[tutorial](http://jgaltidor.github.io/typetheory_paper.pdf) and | ||
[slides](http://jgaltidor.github.io/twelf_slides.pdf) are accessible to folks | ||
without a strong background in programming language foundations. | ||
|
||
### Experience reports and commentary | ||
|
||
- [The POPLmark Challenge](https://www.seas.upenn.edu/~plclub/poplmark/) has | ||
commentary on the [POPLmark submission from Carnegie | ||
Mellon](https://www.seas.upenn.edu/~plclub/poplmark/cmu.html) that uses Twelf. | ||
- Andrew Appel and Xavier Leroy's [A list-machine benchmark for mechanized | ||
metatheory](https://www.cs.princeton.edu/~appel/listmachine/) serves as both | ||
a tutorial and an experience report on using Twelf to prove theroems about | ||
compilers. | ||
See [Introductions to Twelf](/wiki/introductions-to-twelf/) | ||
|
||
!}% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.