__ in Ocaml extracted from Coq -


ocaml code extracted coq includes (in cases) type __ , function __ defined follows:

type __ = obj.t let __ = let rec f _ = obj.repr f in obj.repr f 

the documentation says in past, such type defined unit (and __ taken ()) there exist (rare) cases value of type __ applied value of type __.

__ uses undocumented functions of obj module ocaml, seems defined totally polymorphic function eats arguments (whatever number).

is there documentation regarding cases __ cannot eliminated , values of type applied values of same type, both theoretical (construct coq terms elimination impossible) , practical (show realistic case occurs) point of view?

the references cited in readme give nice overview of erasure problem. specifically, both this report , this article exaplain in detail how type schemes , logical parts of cic terms erased, , why 1 must have __ x = __. problem not __ may applied itself, may applied anything @ all.

unfortunately, not @ clear if having behavior important in non-pathological case. motivation given there able extract any coq term, , documents not mention cases interesting practical standpoint. example given on 3 one:

definition foo (x : type) (f : nat -> x) (g : x -> nat) := g (f 0). definition bar := foo true (fun _ => i). 

executing recursive extraction bar. gives following result:

type __ = obj.t let __ = let rec f _ = obj.repr f in obj.repr f  type nat = | o | s of nat  (** val foo : (nat -> 'a1) -> ('a1 -> nat) -> nat **)  let foo f g =   g (f o)  (** val bar : (__ -> nat) -> nat **)  let bar =   foo (obj.magic __) 

since foo polymorphic on type, there no way of simplifying f o application on body, because have computational content. however, since prop subtype of type, foo can applied true, happens in bar. when try reduce bar, thus, have __ being applied o.

this particular case not interesting, because possible inline foo:

let bar g =   g __ 

since true can't applied anything, if g corresponds legal coq term, __ argument wouldn't applied anything, , therefore safe have __ = () (i believe). however, there cases not possible know in advance whether erased term can further applied or not, makes general definition __ necessary. check out instance fun example here, near end of file.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -