X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Fbasic_rg%2FbrgReduction.ml;h=12e63765971c269b1679b23030c4520a69e7d037;hb=f00757144b2cd7e6457fed55dbc1309d11a542dc;hp=f9d0a200c782cf3f0c4208402ae0897ba879f799;hpb=c52a5748465e24374aec569bf74fc85e5bbb075a;p=helm.git diff --git a/helm/software/lambda-delta/basic_rg/brgReduction.ml b/helm/software/lambda-delta/basic_rg/brgReduction.ml index f9d0a200c..12e637659 100644 --- a/helm/software/lambda-delta/basic_rg/brgReduction.ml +++ b/helm/software/lambda-delta/basic_rg/brgReduction.ml @@ -13,14 +13,15 @@ module U = NUri module C = Cps module S = Share module L = Log +module Y = Entity module P = Output module B = Brg module O = BrgOutput module E = BrgEnvironment -type machine = { - c: B.context; - s: (B.context * B.term) list; +type kam = { + c: B.lenv; + s: (B.lenv * B.term) list; i: int } @@ -29,12 +30,12 @@ type machine = { let level = 5 let log1 s c t = - let sc, st = s ^ " in the context", "the term" in - L.log O.specs level (L.ct_items1 sc c st t) + let sc, st = s ^ " in the environment", "the term" in + L.log O.specs level (L.et_items1 sc c st t) let log2 s cu u ct t = - let s1, s2, s3 = s ^ " in the context", "the term", "and in the context" in - L.log O.specs level (L.ct_items2 s1 cu s2 u ~sc2:s3 ~c2:ct s2 t) + let s1, s2, s3 = s ^ " in the environment", "the term", "and in the environment" in + L.log O.specs level (L.et_items2 s1 cu s2 u ~sc2:s3 ~c2:ct s2 t) let are_alpha_convertible err f t1 t2 = let rec aux f = function @@ -45,10 +46,10 @@ let are_alpha_convertible err f t1 t2 = if U.eq u1 u2 then f () else err () | B.Cast (_, v1, t1), B.Cast (_, v2, t2) | B.Appl (_, v1, t1), B.Appl (_, v2, t2) -> - let f () = aux f (t1, t2) in + let f _ = aux f (t1, t2) in aux f (v1, v2) | B.Bind (b1, t1), B.Bind (b2, t2) -> - let f () = aux f (t1, t2) in + let f _ = aux f (t1, t2) in aux_bind f (b1, b2) | _ -> err () and aux_bind f = function @@ -59,8 +60,8 @@ let are_alpha_convertible err f t1 t2 = in if S.eq t1 t2 then f () else aux f (t1, t2) -let get f m i = - B.get C.err f m.c i +let get err f m i = + B.get err f m.c i (* to share *) let rec step f ?(delta=false) ?(rt=false) m x = @@ -69,16 +70,18 @@ let rec step f ?(delta=false) ?(rt=false) m x = | B.Sort _ -> f m None x | B.GRef (_, uri) -> let f = function - | _, _, B.Abbr (_, v) when delta -> + | _, _, Y.Abbr v when delta -> P.add ~gdelta:1 (); step f ~delta ~rt m v - | _, _, B.Abst (_, w) when rt -> + | _, _, Y.Abst w when rt -> P.add ~grt:1 (); step f ~delta ~rt m w - | _, _, B.Void _ -> - assert false - | e, _, b -> - f m (Some (e, b)) x + | a, _, Y.Abbr v -> + let f e = f m (Some (e, B.Abbr (a, v))) x in + Y.apix C.err f a + | a, _, Y.Abst w -> + let f e = f m (Some (e, B.Abst (a, w))) x in + Y.apix C.err f a in - E.get_obj f uri + E.get_entity C.err f uri | B.LRef (_, i) -> let f c = function | B.Abbr (_, v) -> @@ -91,9 +94,9 @@ let rec step f ?(delta=false) ?(rt=false) m x = assert false | B.Abst (a, _) as b -> let f e = f {m with c = c} (Some (e, b)) x in - B.apix C.err f a + Y.apix C.err f a in - get f m i + get C.err f m i | B.Cast (_, _, t) -> P.add ~tau:1 (); step f ~delta ~rt m t @@ -115,7 +118,7 @@ let rec step f ?(delta=false) ?(rt=false) m x = let push f m b = assert (m.s = []); let b, i = match b with - | B.Abst (a, w) -> B.abst (B.Apix m.i :: a) w, succ m.i + | B.Abst (a, w) -> B.abst (Y.Apix m.i :: a) w, succ m.i | b -> b, m.i in let f c = f {m with c = c; i = i} in @@ -130,10 +133,7 @@ let rec ac_nfs err f ~si m1 a1 u m2 a2 t = if e1 = e2 then ac_stacks err f m1 m2 else err () | Some (e1, B.Abbr (_, v1)), _, Some (e2, B.Abbr (_, v2)), _ -> if e1 = e2 then - let err () = - P.add ~gdelta:2 (); - ac err f ~si m1 v1 m2 v2 - in + let err _ = P.add ~gdelta:2 (); ac err f ~si m1 v1 m2 v2 in ac_stacks err f m1 m2 else if e1 < e2 then begin P.add ~gdelta:1 (); @@ -152,7 +152,7 @@ let rec ac_nfs err f ~si m1 a1 u m2 a2 t = _, B.Bind ((B.Abst (_, w2) as b2), t2) -> let f m1 m2 = ac err f ~si m1 t1 m2 t2 in let f m1 = push (f m1) m2 b2 in - let f () = push f m1 b1 in + let f _ = push f m1 b1 in ac err f ~si:false m1 w1 m2 w2 | _, B.Sort _, _, B.Bind (b, t) when si -> P.add ~si:1 (); @@ -179,14 +179,14 @@ and ac_stacks err f m1 m2 = (* Interface functions ******************************************************) -let empty_machine = { - c = B.empty_context; s = []; i = 0 +let empty_kam = { + c = B.empty_lenv; s = []; i = 0 } -let get f m i = +let get err f m i = assert (m.s = []); let f c = f in - get f m i + get err f m i let xwhd f m t = L.box level; log1 "Now scanning" m.c t; @@ -195,18 +195,16 @@ let xwhd f m t = let are_convertible err f ?(si=false) mu u mw w = L.box level; log2 "Now converting" mu.c u mw.c w; - let f () = L.unbox level; f () in - let err () = ac err f ~si mu u mw w in + let f x = L.unbox level; f x in + let err _ = ac err f ~si mu u mw w in (* if S.eq mu mw then are_alpha_convertible err f u w else *) err () -let message1 st1 m t1 = - L.ct_items1 "In the context" m.c st1 t1 - -let message3 st1 st2 ?sm3 st3 m1 t1 t2 ?m3 t3 = - let sm1 = "In the context" in - match sm3, m3 with - | Some sm3, Some m3 -> - L.ct_items3 sm1 m1.c st1 t1 st2 t2 ~sc3:sm3 ~c3:m3.c st3 t3 - | None, None -> - L.ct_items3 sm1 m1.c st1 t1 st2 t2 st3 t3 - | _ -> assert false +(* error reporting **********************************************************) + +let pp_term m frm t = O.specs.L.pp_term m.c frm t + +let pp_lenv frm m = O.specs.L.pp_lenv frm m.c + +let specs = { + L.pp_term = pp_term; L.pp_lenv = pp_lenv +}