|
| ||
|
|
Start of topic | Skip to actions
Updating OCaml for ConcoqtionRight now Concoqtion uses OCaml version 3.08, but we may want to update it to 3.09? 3.08 was originally chosen because 3.09 wasn't released back then, but now that it is, we want someone to work out the differences and update the OCaml underlying Concoqtion. Emir is going to be busy so he probably won't be able to do it. Anyone?Typing copy2Joseph brought up a point about typing copy2. The paper gives three ways to make trees of size n (all values same):
type m X = | Z : '(0) X | S1 of let m:'(nat) in m X : (1 + 2*m) X | S2 of let m:'(nat) in m X : (2 + 2*m) XWith this representation, n can be represented by a type that is lg(n) deep. There's also a bijection to the natural numbers (it is isomorphic in that sense), so any natural number can be represented by this type. This mirrors the type of copy2, split into cases according to the numerical parameter: copy2 x 0 copy2 x (2 * m + 1) copy2 x (2 * m + 2)This is an example of the fact that whenever you have a well-founded recursion, you can type it to make it a structural recursion on the structure that represents the type. That's the (type-) theoretical side of the story. Practically, we need to write an X_of_int. This is O(log n) so it's still efficient but involves much more scaffolding than the untyped version. Algorithms like copy2 have indexed types implicit in them (when we casually analyze copy2, we naturally think of indexed types) so it's natural to type it that way and be sure of its correctness. We can also use existentials to type copy2. This gives weaker typing, but is worth a try. We need an existential of pairs and not a pair of existentials, to encode a mutual constraint on the pair's elements. Thus type 'a exists_tree = | E of let m:'(nat) in '(m) tree ;;wouldn't work because when we open up the existential in a match statement, we are forced to write like match blah, blah with | E |i:'(nat)| _, E |j:'(nat)| _ -> ...and we can't express the fact that i = j+1. Instead, we need
type 'a exists_subtrees =
| E of let m:'(nat) in ('(1+m) tree, '(m) tree)
;;
MiscWe should push through all the examples to see if we stumble on anything interesting. HW for next time do delete (assume all values are unique). Topic Actions: Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: 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.