]> matita.cs.unibo.it Git - helm.git/commitdiff
Added a in_universe function
authorAndrea Asperti <andrea.asperti@unibo.it>
Wed, 29 Oct 2008 15:16:55 +0000 (15:16 +0000)
committerAndrea Asperti <andrea.asperti@unibo.it>
Wed, 29 Oct 2008 15:16:55 +0000 (15:16 +0000)
helm/software/components/tactics/universe.ml
helm/software/components/tactics/universe.mli

index a7418461e060603ca6546dc817f9ced288b4a998..def2279ca180072e3439506db0e854879452d437 100644 (file)
@@ -38,6 +38,21 @@ let get_candidates univ ty =
   S.elements (TI.retrieve_unifiables univ ty)
 ;;
 
+let in_universe univ ty =
+  let candidates = get_candidates univ ty in
+    List.fold_left 
+      (fun res cand ->
+        match res with
+          | Some found -> Some found
+          | None -> 
+              let candty,_ = 
+                CicTypeChecker.type_of_aux' [] [] cand CicUniv.oblivion_ugraph in
+              let same ,_ = 
+                CicReduction.are_convertible [] candty ty CicUniv.oblivion_ugraph in
+              if same then Some cand else None
+      ) None candidates
+;;
+
 let rec unfold context = function
   | Cic.Prod(name,s,t) -> 
       let t' = unfold ((Some (name,Cic.Decl s))::context) t in
index de7c2087174b4be352a1b4dc838521c167a70af4..d74895114386bced7803090144fbbe7c96312607 100644 (file)
@@ -40,6 +40,8 @@ val keys: Cic.context -> Cic.term -> Cic.term list
 (* collapse non-indexable terms, not removing coercions *)
 val key: Cic.term -> Cic.term 
 
+val in_universe: universe -> Cic.term -> Cic.term option
+
 (* indexes the term and its unfolded both without coercions *)
 val index_term_and_unfolded_term: 
   universe -> Cic.context -> Cic.term -> Cic.term -> universe