types.mli 3.02 KB
Newer Older
1
2
3
type label = int
type atom  = int
type const = Integer of int | Atom of atom | String of string
4

5
6
(** Algebra **)

7
8
type node
type descr
9

10
11
val make: unit -> node
val define: node -> descr -> unit
12

13
14
val cons: descr -> node
val internalize: node -> node
15

16
17
val id: node -> int
val descr: node -> descr
18

19

20
21
(** Boolean connectives **)

22
23
24
25
26
27
val cup    : descr -> descr -> descr
val cap    : descr -> descr -> descr
val diff   : descr -> descr -> descr
val neg    : descr -> descr
val empty  : descr
val any    : descr
28

29
30
(** Constructors **)

31
32
33
34
35
36
37
val interval : int -> int -> descr
val atom     : atom -> descr
val times    : node -> node -> descr
val arrow    : node -> node -> descr
val record   : label -> bool -> node -> descr
val string   : Strings.Regexp.regexp -> descr
val constant : const -> descr
38

39
40
41
42
43
44
45
(** Positive systems and least solutions **)

module Positive :
sig
  type v
  val forward: unit -> v
  val define: v -> v -> unit
46
  val ty: descr -> v
47
48
49
  val cup: v list -> v
  val times: v -> v -> v

50
  val solve: v -> node
51
52
end

53
54
55
56
57
58
59
60
(** Labels and atom names **)

val mk_atom  : string -> atom
val atom_name : atom -> string

val label : string -> label
val label_name : label -> string

61
62
63
(** Normalization **)

module Product : sig
64
  val any : descr
65
66
67

  (* List of non-empty rectangles *)
  type t = (descr * descr) list
68
  val get: descr -> t
69
70
71
72
73
74
75
76
77
  val pi1: t -> descr
  val pi2: t -> descr
    
  (* Intersection with (pi1,Any) *)
  val restrict_1: t -> descr -> t

  (* List of non-empty rectangles whose first projection
     are pair-wise disjunct *)
  type normal = t
78
  val normal: descr -> t
79
80
81
end

module Record : sig
82
  val any : descr
83

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
  (* List of maps label -> (optional, content) *)
  type t = (label, (bool * descr)) SortedMap.t list
  val get: descr -> t
  val is_empty: t -> bool
  val restrict_label_present: t -> label -> t
  val restrict_field: t -> label -> descr -> t
  val restrict_label_absent: t -> label -> t
  val project_field: t -> label -> descr

  type normal = 
      [ `Success
      | `Fail
      | `Label of label * (descr * normal) list * normal ]
  val normal: descr -> normal

  val project : descr -> label -> descr
100
    (* Raise Not_found if label is not necessarily present *)
101
102
end

103
104
module Arrow : sig
  val any : descr
105

106
107
108
  type t
  val get: descr -> t
    (* Always succeed; no check <= Arrow.any *)
109

110
111
112
113
114
115
116
  val domain: t -> descr
  val apply: t -> descr -> descr
    (* Always succeed; no check on the domain *)
end


val normalize : node -> node
117

118
(** Subtyping and sample values **)
119

120
121
122
val is_empty : descr -> bool
val non_empty: descr -> bool
val subtype  : descr -> descr -> bool
123

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
module Sample :
sig
  type t =
    | Int of int
    | Atom of atom
    | String of string
    | Pair of t * t
    | Record of (label * t) list
    | Fun of (node * node) list

  val get : descr -> t
	(** 
	  Extract a sample value from a non empty type;
	  raise Not_found for an empty type
	**)
139
140
end

141
142
module Print :
sig
143
144
  val print : Format.formatter -> node -> unit
  val print_descr: Format.formatter -> descr -> unit
145
  val print_sample : Format.formatter -> Sample.t -> unit
146
end
147

148
val check: descr -> unit