aboutsummaryrefslogtreecommitdiffhomepage
path: root/contrib/extraction/mlutil.mli
blob: af931b6486fb82bf4e8d25463d769db740ab0cda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(***********************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team    *)
(* <O___,, *        INRIA-Rocquencourt  &  LRI-CNRS-Orsay              *)
(*   \VV/  *************************************************************)
(*    //   *      This file is distributed under the terms of the      *)
(*         *       GNU Lesser General Public License Version 2.1       *)
(***********************************************************************)

(*i $Id$ i*)

open Names
open Term
open Miniml

(*s Special identifiers. [prop_name] is to be used for propositions
    and will be printed as [_] in concrete (Caml) code. *)

val anonymous : identifier
val prop_name : identifier

(*s Utility functions over ML terms. [occurs n t] checks whether [Rel
    n] occurs (freely) in [t]. [ml_lift] is de Bruijn
    lifting. [ml_subst e t] substitutes [e] for [Rel 1] in [t]. *)

val occurs : int -> ml_ast -> bool

val ml_lift : int -> ml_ast -> ml_ast

val ml_subst : ml_ast -> ml_ast -> ml_ast

(*s Some transformations of ML terms. [betared_ast] and [betared_ecl] reduce
    all beta redexes (when the argument does not occur, it is just
    thrown away; when it occurs exactly once it is substituted; otherwise
    a let in redex is created for clarity) *)

val betared_ast : ml_ast -> ml_ast
val betared_decl : ml_decl -> ml_decl

val uncurrify_ast : ml_ast -> ml_ast
val uncurrify_decl : ml_decl -> ml_decl

(*s Optimization. *)

module Refset : Set.S with type elt = global_reference

type extraction_params = {
  modular : bool;       (* modular extraction *)
  no_opt : bool;        (* no optimization at all *)
  to_keep : Refset.t;   (* globals to keep *)
  to_expand : Refset.t; (* globals to expand *)
}

val optimize : extraction_params -> ml_decl list -> ml_decl list

(*s Table for direct extractions to ML values. *)

val is_ml_extraction : global_reference -> bool
val find_ml_extraction : global_reference -> string

val ml_extractions : unit -> Refset.t