]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/cic/libraryObjects.ml
ocaml 3.09 transition
[helm.git] / helm / ocaml / cic / libraryObjects.ml
index f7613fe1949789b496cc7820d583d3d774c91620..967318721736a1e1d3a081f165ce63b6608c86e3 100644 (file)
  * http://helm.cs.unibo.it/
  *)
 
-(*CSC: how can we choose between the two libraries? *)
-let eq_URI =
- MatitaLibraryObjects.Equality.eq_URI
+(**** TABLES ****)
+
+(* eq, sym_eq, trans_eq, eq_ind, eq_ind_R *)
+let eq_URIs_ref =
+ ref [HelmLibraryObjects.Logic.eq_URI,
+      HelmLibraryObjects.Logic.sym_eq_URI,
+      HelmLibraryObjects.Logic.trans_eq_URI,
+      HelmLibraryObjects.Logic.eq_ind_URI,
+      HelmLibraryObjects.Logic.eq_ind_r_URI];;
+
+let true_URIs_ref = ref [HelmLibraryObjects.Logic.true_URI]
+let false_URIs_ref = ref [HelmLibraryObjects.Logic.false_URI]
+let absurd_URIs_ref = ref [HelmLibraryObjects.Logic.absurd_URI]
+
+
+(**** SET_DEFAULT ****)
+
+exception NotRecognized;;
+
+(* insert an element in front of the list, removing from the list all the
+   previous elements with the same key associated *)
+let insert_unique e extract l =
+ let uri = extract e in
+ let l' =
+  List.filter (fun x -> let uri' = extract x in not (UriManager.eq uri uri')) l
+ in
+  e :: l'
+
+let set_default what l =
+  match what,l with
+    "equality",[eq_URI;sym_eq_URI;trans_eq_URI;eq_ind_URI;eq_ind_r_URI] ->
+      eq_URIs_ref :=
+       insert_unique (eq_URI,sym_eq_URI,trans_eq_URI,eq_ind_URI,eq_ind_r_URI)
+        (fun x,_,_,_,_ -> x) !eq_URIs_ref
+  | "true",[true_URI] ->
+      true_URIs_ref := insert_unique true_URI (fun x -> x) !true_URIs_ref
+  | "false",[false_URI] ->
+      false_URIs_ref := insert_unique false_URI (fun x -> x) !false_URIs_ref
+  | "absurd",[absurd_URI] ->
+      absurd_URIs_ref := insert_unique absurd_URI (fun x -> x) !absurd_URIs_ref
+  | _,_ -> raise NotRecognized
+
+(**** LOOKUP FUNCTIONS ****)
+
+let eq_URI () = let eq,_,_,_,_ = List.hd !eq_URIs_ref in eq
 
 let is_eq_URI uri =
- UriManager.eq uri HelmLibraryObjects.Logic.eq_URI ||
- UriManager.eq uri MatitaLibraryObjects.Equality.eq_URI
-
-exception Not_recognized;;
-
-let something_URI coq matita ~eq =
- if UriManager.eq eq HelmLibraryObjects.Logic.eq_URI then coq
- else if UriManager.eq eq MatitaLibraryObjects.Equality.eq_URI then matita
- else raise Not_found
-
-let eq_ind_URI =
- something_URI
-  HelmLibraryObjects.Logic.eq_ind_URI
-  MatitaLibraryObjects.Equality.eq_ind_URI
-
-let eq_ind_r_URI =
- something_URI
-  HelmLibraryObjects.Logic.eq_ind_r_URI
-  MatitaLibraryObjects.Equality.eq_ind_r_URI
-
-let sym_eq_URI =
- something_URI
-  HelmLibraryObjects.Logic.sym_eq_URI
-  MatitaLibraryObjects.Equality.sym_eq_URI
-
-let trans_eq_URI =
- something_URI
-  HelmLibraryObjects.Logic.trans_eq_URI
-  MatitaLibraryObjects.Equality.trans_eq_URI
-
-let true_URI = MatitaLibraryObjects.Logic.true_URI
-let false_URI = MatitaLibraryObjects.Logic.false_URI
-let absurd_URI = MatitaLibraryObjects.Logic.absurd_URI
+ List.exists (fun (eq,_,_,_,_) -> UriManager.eq eq uri) !eq_URIs_ref
+
+let sym_eq_URI ~eq:uri =
+ try
+  let _,x,_,_,_ = List.find (fun eq,_,_,_,_ -> UriManager.eq eq uri) !eq_URIs_ref in x
+ with Not_found -> raise NotRecognized
+
+let trans_eq_URI ~eq:uri =
+ try
+  let _,_,x,_,_ = List.find (fun eq,_,_,_,_ -> UriManager.eq eq uri) !eq_URIs_ref in x
+ with Not_found -> raise NotRecognized
+
+let eq_ind_URI ~eq:uri =
+ try
+  let _,_,_,x,_ = List.find (fun eq,_,_,_,_ -> UriManager.eq eq uri) !eq_URIs_ref in x
+ with Not_found -> raise NotRecognized
+
+let eq_ind_r_URI ~eq:uri =
+ try
+  let _,_,_,_,x = List.find (fun eq,_,_,_,_ -> UriManager.eq eq uri) !eq_URIs_ref in x
+ with Not_found -> raise NotRecognized
+
+let true_URI () = List.hd !true_URIs_ref
+let false_URI () = List.hd !false_URIs_ref
+let absurd_URI () = List.hd !absurd_URIs_ref