Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
how to upset the ocaml type system....
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-08-28 (21:21)
From: David Allsopp <dra-news@m...>
Subject: RE: [Caml-list] how to upset the ocaml type system....
> are there any other examples that exhibit worst-case complexity ?

let pair = fun x -> (fun y -> (fun z -> ((z x) y)))
  let x1 = fun y -> (pair y) y
    let x2 = fun y -> x1 (x1 y)
      let x3 = fun y -> x2 (x2 y)
        let x4 = fun y -> x3 (x3 y)
          let x5 = fun y -> x4 (x4 y)
            x5 (fun y -> y);;

This one computes much faster (by which I mean the type checker does get
there in a few minutes!) but demonstrates the exponential blow-up of the
length of a type compared with the code it comes from (the type of this
expression 131070 lines long on my console...). It is translated from p. 29 (Slide 25) which
is itself from Mairson, H. G. (1990). Deciding ML typability is complete for
deterministic exponential time. (In Proc. 17th ACM Symposium on Principles
of Programming Languages, pp. 382--401.)