]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/cic_unification/cicUnification.ml
* (Head) beta reduction functions factorized
[helm.git] / helm / ocaml / cic_unification / cicUnification.ml
index 5e2eaba0046fca7544454395852a995acc258ca6..7a67c8248e4e5d72d7986166cd5ec9f5401213cc 100644 (file)
@@ -50,29 +50,6 @@ let type_of_aux' metasenv subst context term ugraph =
 let exists_a_meta l = 
   List.exists (function Cic.Meta _ -> true | _ -> false) l
 
-let rec beta_reduce =
-  function
-      (Cic.Appl (Cic.Lambda (_,_,t)::he'::tl')) ->
-        let he'' = CicSubstitution.subst he' t in
-          if tl' = [] then
-            he''
-          else
-            beta_reduce (Cic.Appl(he''::tl'))
-    | t -> t
-(* 
-let rec deref subst =
-  let snd (_,a,_) = a in
-  function
-      Cic.Meta(n,l) as t -> 
-        (try 
-           deref subst
-             (CicSubstitution.subst_meta 
-                l (snd (CicUtil.lookup_subst n subst))) 
-         with 
-           CicUtil.Subst_not_found _ -> t)
-    | t -> t
-;; *)
-
 let rec deref subst t =
   let snd (_,a,_) = a in
   match t with
@@ -86,10 +63,10 @@ let rec deref subst t =
     | Cic.Appl(Cic.Meta(n,l)::args) ->
         (match deref subst (Cic.Meta(n,l)) with
            | Cic.Lambda _ as t -> 
-               deref subst (beta_reduce (Cic.Appl(t::args)))
+               deref subst (CicReduction.head_beta_reduce (Cic.Appl(t::args)))
            | r -> Cic.Appl(r::args))
     | Cic.Appl(((Cic.Lambda _) as t)::args) ->
-           deref subst (beta_reduce (Cic.Appl(t::args)))
+           deref subst (CicReduction.head_beta_reduce (Cic.Appl(t::args)))
     | t -> t
 ;; 
 
@@ -481,7 +458,7 @@ debug_print ("restringo Meta n." ^ (string_of_int n) ^ "on variable n." ^ (strin
               (try 
                  let (_,t,_) = CicUtil.lookup_subst i subst in
                  let lifted = S.subst_meta l t in
-                 let reduced = beta_reduce (Cic.Appl (lifted::args)) in
+                 let reduced = CicReduction.head_beta_reduce (Cic.Appl (lifted::args)) in
                    fo_unif_subst 
                     test_equality_only 
                      subst context metasenv reduced t2 ugraph
@@ -496,7 +473,7 @@ debug_print ("restringo Meta n." ^ (string_of_int n) ^ "on variable n." ^ (strin
               (* (try 
                  let (_,t,_) = CicUtil.lookup_subst i subst in
                  let lifted = S.subst_meta l t in
-                 let reduced = beta_reduce (Cic.Appl (lifted::args)) in
+                 let reduced = CicReduction.head_beta_reduce (Cic.Appl (lifted::args)) in
                    fo_unif_subst 
                      test_equality_only 
                      subst context metasenv t1 reduced ugraph