|
|
||
|
|
Start of topic | Skip to actions
Discussion of Next Topic
We will study interpreters next. Sets we talked about:
1 and 2 can be expressed as datatypes, 3 cannot. E and T are constants, while gamma and t are indices into the set. Given a particular gamma, x may not be typable, but this is not true in general. An example of a similar set is List(t), which takes a t argument. However, it can be expressed as a datatype, while the previous cannot. For the previous set, you must examine the t argument to determine membership. To determine membership of List(t), you simply must prove the argument has type t.
This is a very simple requirement, unlike the gamma term e \in \gamma \turn \dot : t iff
Typed terms are a subset of untyped terms in the same way balanced trees are a subset of trees, or sized lists are a subset of lists. \gamma (x) = t ---------------- \gamma \turn x : t \gamma , x:t1 \turn e: t2 ---------------- \gamma \turn \lambda x.e : t1 -> t2 \gamma \turn e1 : t1 -> t2 \gamma \turn e2 : t1 ---------------- \gamma \turn e1 e2 : t2 But we want to modify our BNF to simplify these rules. The modified BNF is:
n \in \mathbb{N}
e ::= #n | \lambda .e | e e | i
using static distance or De Bruijn naming.
Since variables are now defined by naturals, we can describe the case where e = #n using induction on the structure of the natural: ---------------- \gamma ,t \turn #0 : t \gamma \turn #(n) : t ---------------- \gamma ,t' \turn #(n+1) : tA trivial change needs to be made to the lambda case as well: \gamma ,t1 \turn e: t2 ---------------- \gamma \turn \lambda .e : t1 -> t2Now we can write the concoqtion type to represent this:
type (env, typ) term =
| TVarZero
let env':envType in
: (env' * typ, typ) term
| TVarPlus
let env':envType in
let t':typeType in
of (env, typ) term
: (env' * t', typ) term
| ...
Homework:
Topic Actions: Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r4 < r3 < r2 < r1 | More topic actions
Webs: Main | TWiki | Africa | EmbeddedSystems | Gpce | Houston | International | K12 | MetaOCaml | MulticoreOCR | ProgrammingLanguages | RAP | RIDL | Sandbox | SpeechClub | Teaching | Texbot | WG211 Web Actions: |
|
This work is licensed under a Creative Commons Attribution 2.5 License. Please follow our citation guidelines.