|
|
||
|
|
Start of topic | Skip to actions
RAP Seminar Notes (2007/01/10)Speaker: Walid Taha Scribe: Walid Taha and Emir Pasalic In general, we will want to have someone else other than the scribe take notes. Notes should be turned into wiki pages following the same name format as this one, and include headers following the same format as this one as well. Everyone is collectively responsible for proof reading and checking the accuracy of the notes. Everyone introduced themselves and their interests. We began learning about Concoqtion by looking at the list type and how it can be refined into a sized list type. The basic list type constructor has the form: type 'a list = Nil | Cons of 'a * 'a listThis type definition allows us to construct types such as int list, string list, or int list list. It also allows us to to construct values such as Nil : 'a list, Cons (1,Nil) : int list, and Cons (3, Cons (4, Nil)): int list. Note that parametric polymorphism prevernts us from having well-typed values such as Cons ("a", Cons (1, Nil)). But we will come back to this point later on.
Concoqotion allows us to refine this definition to get a type that reflects the size of a list in its type. First we will use fake syntax to avoid worrying about syntactic details, and then we will look at the actual syntax of Concoqtion. Students suggested that we'd like to have a type like:
type (n:nat, 'a) list = Nil : (0, 'a) list
| Cons of 'a * (n-1,'a) list : (n, 'a) list
This is essentially what we want to do, but for a variety of technical reasons, a more uniform programming language design requires us to formulate things slightly differently, and in a way that more accurately reflects the real structure of the property that we want to capture in the type. In essence, the definition we will want to us is more like:
(* int is defined as 0 | S of int *)
type (n:nat, 'a) list = Nil : (0, 'a) list
| Cons of let m in 'a * (n,'a) list : ((S n), 'a) list
In Concoqtion, the above syntax is slightly more complicated (for parsing reasons):
(* int is defined as 0 | S of int *)
type (n:'(nat), 'a) list = Nil : (0, 'a) list
| Cons of let 'm:'(nat) in 'a * ('(n),'a) list : ('(S n), 'a) list
We can write a "type system" for sized lists using a standard mathematical inference rule notation as follows:
x : a xs : (m,a) list
--------------------- -----------------------------
Nil : (0,a) list Cons(x,xs) : (S n, a) list
Topic Actions: Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r12 < r11 < r10 < r9 < r8 | 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.