Skip to content

Commit 8f886cf

Browse files
committed
[examples/lambda] Update documentation in examples/lambda/basics
1 parent 4954936 commit 8f886cf

File tree

2 files changed

+58
-12
lines changed

2 files changed

+58
-12
lines changed

examples/lambda/basics/README

+41-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,55 @@
1+
appFOLDLScript.sml
2+
Defines iterated (left-associated) application in Λ so that
3+
4+
M @* [M1; M2] = (M @@ M1) @@ M2
5+
16
basic_swapScript.sml
27
Very basic theory of swaps over strings (the swapstr constant), and
38
permutations (which take a list of pairs of strings to swap). Also
49
defines the NEW constant, which is used everywhere (including in
5-
the dB and nc developments above).
10+
the dB and nc developments in other-modesls).
11+
12+
binderLib.{sig,sml}
13+
Tools for doing proofs with terms that include binders, including
14+
function definition and facilities from NEWLib.
15+
16+
ctermScript.sml
17+
Defines a type like Λ(A) with A a set of additional constants,
18+
introduced, for example, in Barendregt §5.2. In HOL, the A is a
19+
type variable so that we get α cterms with constructors APP, LAM,
20+
CONST and VAR.
21+
22+
generic_termsScript.sml
23+
Defines a large type of trees with α-equivalent binders over
24+
strings that can be used as the basis for the definition of a
25+
number of "nominal" types. The genind constant provides a way of
26+
encoding a variety of subsets of this type, as described in
27+
notes.txt.
28+
29+
NEWLib.{sig,sml}
30+
simple tactics to use with the NEW constant.
31+
32+
nomdatatype.{sig,sml}
33+
Some very rudimentary code to provide some automation in the
34+
definition of types built from generic_terms (as above).
635

736
nomsetScript.sml
837
A more involved theory of permutations and their actions on
938
arbitrary types (the "nominal sets"). Includes the notion of
1039
support.
1140

12-
NEWLib.{sig,sml}
13-
simple tactics to use with the NEW constant.
14-
15-
binderLib.{sig,sml}
16-
Tools for doing proofs with terms that include binders, including
17-
function definition and facilities from NEWLib.
41+
notes.txt
42+
Tries to explain the genind + generic_terms technology for building
43+
new types with binders.
1844

19-
pretermScript.sml termScript.sml
20-
Using a quotient over raw syntax from pretermTheory, establishes a
21-
type of lambda calculus terms, and defines substitution, the notion
22-
of free variable and permutations over that type. Proves some
23-
simple lemmas about substitution. For example,
45+
termScript.sml
46+
Constructs the classic type of lambda terms, with three
47+
constructors, called Λ in lots of places. Does this by constructing
48+
a subtype of the “generic” terms. Defines various flavours of
49+
substitution proves some simple lemmas about these. For example,
2450

2551
lemma14a: |- [VAR x/x] t = t
2652

53+
termSyntax.{sig,sml}
54+
Standard HOL-style syntactic support for programmatically
55+
manipulating terms of type “:term”.

examples/lambda/basics/notes.txt

+17
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ So there are four constructors: the three standard ones, and another one that ta
2121

2222
If you look at the LAMi_def (LAMi is the labelled redex constructor) in that file, you’ll see how the two term arguments get split apart the two lists (one is bound; one is not). Note that when you have no terms in the bound scope (as happens in APP), you still have to provide a bound variable (ARB in the definitions), but there is a theorem that says all choices of bound variables result in the same g.term (GLAM_NIL_EQ).
2323

24+
The ctermScript.sml example in this directory is yet another example, where the type is characterised by
25+
26+
Λ(A) ::= v | Λ(A) Λ(A) | cₐ (a ∈ A) | λv. Λ(A)
27+
28+
The CONST constructor corresponding to the cₐ clause above is encoded by a third disjunct in the lp predicate, and by having the GLAM type variable be
29+
30+
:unit (* APP *) + unit (* LAM *) + α (* CONST *)
31+
2432
The last thing to understand is the vp and lp predicates that restrict the new type to be a subset of the full generic term universe.
2533

2634
These predicates encode the possible shapes of the new recursive type. See the lp definition at the top of labelledTermsScript:
@@ -32,6 +40,15 @@ These predicates encode the possible shapes of the new recursive type. See the
3240

3341
This is the predicate specifying what’s allowed in the case of GLAM. There are three possibilities. Each picks out one of the possible data forms and then constrains the tns and uns list. These lists "correspond" to the two list arguments that are passed to GLAM. The first clause above says that if the data component is an INL, then tns must be empty, and there must be two values in the uns list. This is encoding APP, which does indeed require two term arguments, but where these are not bound. The second possibility corresponds to LAM, and insists on one element in tns and none in uns. The one element of tns corresponds to the one term argument of LAM. Finally, the third argument corresponds to the LAMi case, where there is a term in each list.
3442

43+
In cterm, the definition is
44+
45+
val lp = “(λn (d:unit + unit + 'a) tns uns.
46+
n = 0 ∧ ISL d ∧ tns = [] ∧ uns = [0;0] ∨
47+
n = 0 ∧ ISR d ∧ ISL (OUTR d) ∧ tns = [0] ∧ uns = [] ∨
48+
n = 0 ∧ ISR d ∧ ISR (OUTR d) ∧ tns = [] ∧ uns = [])”
49+
50+
where the third clause is there for the CONST constructor: there are no recursive occurrences (subject to binding or otherwise), but there is an α-value required.
51+
3552
Now, finally, why the numbers? So, this scheme is meant to allow for multiple types to be defined at once, where there’s mutual recursion. If you do that, you specify different numbers at the head of the clause, and in the sub-lists. I think this will work, and there is an example in
3653

3754
examples/logic/foltypesScript.sml

0 commit comments

Comments
 (0)