]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/tactics/proofEngineHelpers.ml
1. bug fixed in generalize_pattern: a lazy const_tac should have been
[helm.git] / helm / software / components / tactics / proofEngineHelpers.ml
index 7d223a4437b4d9fe232032315b9ec8c933a17a6a..e45c13257d54003e2dbee36171e84463417127e1 100644 (file)
@@ -640,6 +640,32 @@ let lookup_type metasenv context hyp =
    in
    aux 1 context
 
+let find_hyp name =
+ let rec find_hyp n =
+  function
+     [] -> assert false
+   | Some (Cic.Name s,Cic.Decl ty)::_ when name = s ->
+      Cic.Rel n, CicSubstitution.lift n ty
+   | Some (Cic.Name s,Cic.Def _)::_ when name = s -> assert false (*CSC: not implemented yet! But does this make any sense?*)
+   | _::tl -> find_hyp (n+1) tl
+ in
+  find_hyp 1
+;;
+
+(* sort pattern hypotheses from the smallest to the highest Rel *)
+let sort_pattern_hyps context (t,hpatterns,cpattern) =
+ let hpatterns =
+  List.sort
+   (fun (id1,_) (id2,_) ->
+     let t1,_ = find_hyp id1 context in
+     let t2,_ = find_hyp id2 context in
+     match t1,t2 with
+        Cic.Rel n1, Cic.Rel n2 -> compare n1 n2
+      | _,_ -> assert false) hpatterns
+ in
+  t,hpatterns,cpattern
+;;
+
 (* FG: **********************************************************************)
 
 let get_name context index =