]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/lambda-delta/basic_rg/brgReduction.ml
basic_rg: bugfix in AST to allow attributes in global entries
[helm.git] / helm / software / lambda-delta / basic_rg / brgReduction.ml
index 4b1d287d951fe6a9d4bf12dc468a9acfe948c636..f59d84226d07039337ee248f9764c4d1865f1fc1 100644 (file)
@@ -61,14 +61,14 @@ let are_alpha_convertible f t1 t2 =
       | B.Appl (_, v1, t1), B.Appl (_, v2, t2) ->
          let f r = if r then aux f (t1, t2) else f r in
         aux f (v1, v2)
-      | B.Bind (_, b1, t1), B.Bind (_, b2, t2) ->
+      | B.Bind (b1, t1), B.Bind (b2, t2)       ->
          let f r = if r then aux f (t1, t2) else f r in
         aux_bind f (b1, b2)
       | _                                      -> f false
    and aux_bind f = function
-      | B.Abbr v1, B.Abbr v2
-      | B.Abst v1, B.Abst v2                   -> aux f (v1, v2)
-      | B.Void, B.Void                         -> f true
+      | B.Abbr (_, v1), B.Abbr (_, v2)
+      | B.Abst (_, v1), B.Abst (_, v2)         -> aux f (v1, v2)
+      | B.Void _, B.Void _                     -> f true
       | _                                      -> f false
    in
    if S.eq t1 t2 then f true else aux f (t1, t2)
@@ -80,78 +80,78 @@ let get f m i =
 let rec step f ?(delta=false) ?(rt=false) m x = 
 (*   L.warn "entering R.step"; *)
    match x with
-   | B.Sort _                -> f m None x
-   | B.GRef (a, uri)         ->
+   | B.Sort _                  -> f m None x
+   | B.GRef (_, uri)           ->
       let f = function
-         | _, _, B.Abbr v when delta ->
+         | _, _, B.Abbr (_, v) when delta ->
            P.add ~gdelta:1 (); step f ~delta ~rt m v
-         | _, _, B.Abst w when rt    ->
+         | _, _, B.Abst (_, w) when rt    ->
             P.add ~grt:1 (); step f ~delta ~rt m w      
-        | _, _, B.Void              ->
+        | _, _, B.Void _                 ->
            assert false
-        | e, _, b                   ->
+        | e, _, b                        ->
            f m (Some (e, b)) x
       in
       E.get_obj f uri
-   | B.LRef (a, i)           ->
-      let f c = function
-        | B.Abbr          ->
+   | B.LRef (_, i)             ->
+      let f c = function
+        | B.Abbr (_, v)         ->
            P.add ~ldelta:1 ();
            step f ~delta ~rt {m with c = c} v
-        | B.Abst w when rt ->
+        | B.Abst (_, w) when rt ->
             P.add ~lrt:1 ();
             step f ~delta ~rt {m with c = c} w
-        | B.Void            ->
+        | B.Void _              ->
            assert false
-        | b                 ->
+        | B.Abst (a, _) as b    ->
            let f e = f {m with c = c} (Some (e, b)) x in 
            B.apix C.err f a
       in 
       get f m i
-   | B.Cast (_, _, t)        ->
+   | B.Cast (_, _, t)          ->
       P.add ~tau:1 ();
       step f ~delta ~rt m t
-   | B.Appl (_, v, t)        ->
+   | B.Appl (_, v, t)          ->
       step f ~delta ~rt {m with s = (m.c, v) :: m.s} t   
-   | B.Bind (a, B.Abst w, t) ->
+   | B.Bind (B.Abst (a, w), t) ->
       begin match m.s with
          | []          -> f m None x
         | (c, v) :: s ->
             P.add ~beta:1 ~upsilon:(List.length s) ();
            let f c = step f ~delta ~rt {m with c = c; s = s} t in 
-           B.push f m.c ~c a (B.Abbr v) (* (B.Cast ([], w, v)) *)
+           B.push f m.c ~c (B.abbr a v) (* (B.Cast ([], w, v)) *)
       end
-   | B.Bind (a, b, t)        ->
+   | B.Bind (b, t)             ->
       P.add ~upsilon:(List.length m.s) ();
       let f c = step f ~delta ~rt {m with c = c} t in
-      B.push f m.c ~c:m.c b
+      B.push f m.c ~c:m.c b
 
 let domain f m t =
    let f r = L.unbox level; f r in
    let f m _ = function
-      | B.Bind (_, B.Abst w, _) -> f m w
-      | _                       -> error1 "not a function" m.c t
+      | B.Bind (B.Abst (_, w), _) -> f m w
+      | _                         -> error1 "not a function" m.c t
    in
    L.box level; log1 "Now scanning" m.c t;
    step f ~delta:true ~rt:true m t
 
-let push f m b = 
+let push f m b = 
    assert (m.s = []);
-   let a, i = match b with
-      | B.Abst _ -> B.Apix m.i :: a, succ m.i
-      | _        -> a, m.i
+   let b, i = match b with
+      | B.Abst (a, w) -> B.abst (B.Apix m.i :: a) w, succ m.i
+      | b             -> b, m.i
    in
    let f c = f {m with c = c; i = i} in
-   B.push f m.c ~c:m.c b
+   B.push f m.c ~c:m.c b
 
 let rec ac_nfs f ~si r m1 a1 u m2 a2 t =
    log2 "Now converting nfs" m1.c u m2.c t;
    match a1, u, a2, t with
-      | _, B.Sort (_, h1), _, B.Sort (_, h2)             ->
+      | _, B.Sort (_, h1), _, B.Sort (_, h2)                       ->
          if h1 = h2 then f r else f false 
-      | Some (e1, B.Abst _), _, Some (e2, B.Abst _), _   ->
+      | Some (e1, B.Abst _), _, Some (e2, B.Abst _), _             ->
         if e1 = e2 then ac_stacks f r m1 m2 else f false
-      | Some (e1, B.Abbr v1), _, Some (e2, B.Abbr v2), _ ->
+      | Some (e1, B.Abbr (_, v1)), _, Some (e2, B.Abbr (_, v2)), _ ->
          if e1 = e2 then
            let f r = 
               if r then f r 
@@ -168,24 +168,24 @@ let rec ac_nfs f ~si r m1 a1 u m2 a2 t =
            P.add ~gdelta:1 ();
            step (ac_nfs_rev f ~si r m2 a2 t) m1 v1
          end
-      | _, _, Some (_, B.Abbr v2), _                     ->
+      | _, _, Some (_, B.Abbr (_, v2)), _                          ->
          P.add ~gdelta:1 ();
          step (ac_nfs f ~si r m1 a1 u) m2 v2      
-      | Some (_, B.Abbr v1), _, _, _                     ->
+      | Some (_, B.Abbr (_, v1)), _, _, _                          ->
          P.add ~gdelta:1 ();
         step (ac_nfs_rev f ~si r m2 a2 t) m1 v1            
-      | _, B.Bind (a1, (B.Abst w1 as b1), t1), 
-        _, B.Bind (a2, (B.Abst w2 as b2), t2)            ->
+      | _, B.Bind ((B.Abst (_, w1) as b1), t1), 
+        _, B.Bind ((B.Abst (_, w2) as b2), t2)                     ->
         let g m1 m2 = ac f ~si r m1 t1 m2 t2 in
-         let g m1 = push (g m1) m2 a2 b2 in 
-        let f r = if r then push g m1 a1 b1 else f false in
+         let g m1 = push (g m1) m2 b2 in 
+        let f r = if r then push g m1 b1 else f false in
         ac f ~si:false r m1 w1 m2 w2      
-      | _, B.Sort _, _, B.Bind (a, b, t) when si         ->
+      | _, B.Sort _, _, B.Bind (b, t) when si                      ->
         P.add ~si:1 ();
         let f m1 m2 = ac f ~si r m1 u m2 t in
-        let f m1 = push (f m1) m2 b in
-        push f m1 b
-      | _                                                -> f false
+        let f m1 = push (f m1) m2 b in
+        push f m1 b
+      | _                                                          -> f false
 
 and ac_nfs_rev f ~si r m2 a2 t m1 a1 u = ac_nfs f ~si r m1 a1 u m2 a2 t