X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Fbasic_rg%2FbrgOutput.ml;h=186349a1c6161d47a7c4817663c7124b3dcd6076;hb=da284829d696ab53dfa437e169fa669c8e58de7d;hp=a9cec439ac06c5aafcc1719828e8f034db432244;hpb=2e451dca46e509fd7e7772f3d2e438c189ce10a1;p=helm.git diff --git a/helm/software/lambda-delta/basic_rg/brgOutput.ml b/helm/software/lambda-delta/basic_rg/brgOutput.ml index a9cec439a..186349a1c 100644 --- a/helm/software/lambda-delta/basic_rg/brgOutput.ml +++ b/helm/software/lambda-delta/basic_rg/brgOutput.ml @@ -14,10 +14,10 @@ module F = Format module C = Cps module U = NUri module L = Log +module O = Options module Y = Entity module X = Library module H = Hierarchy -module O = Output module B = Brg (* nodes count **************************************************************) @@ -47,13 +47,13 @@ let initial_counters = { } let rec count_term_binder f c e = function - | B.Abst (_, w) -> + | B.Abst w -> let c = {c with tabsts = succ c.tabsts; nodes = succ c.nodes} in count_term f c e w - | B.Abbr (_, v) -> + | B.Abbr v -> let c = {c with tabbrs = succ c.tabbrs; xnodes = succ c.xnodes} in count_term f c e v - | B.Void _ -> + | B.Void -> let c = {c with tvoids = succ c.tvoids; xnodes = succ c.xnodes} in f c @@ -61,15 +61,13 @@ and count_term f c e = function | B.Sort _ -> f {c with tsorts = succ c.tsorts; nodes = succ c.nodes} | B.LRef (_, i) -> - let err _ = f {c with tlrefs = succ c.tlrefs; nodes = succ c.nodes} in - let f _ = function - | B.Abst _ - | B.Void _ -> + begin match B.get e i with + | _, _, _, B.Abst _ + | _, _, _, B.Void -> f {c with tlrefs = succ c.tlrefs; nodes = succ c.nodes} - | B.Abbr _ -> + | _, _, _, B.Abbr _ -> f {c with tlrefs = succ c.tlrefs; xnodes = succ c.xnodes} - in - B.get err f e i + end | B.GRef (_, u) -> let c = if Cps.list_mem ~eq:U.eq u c.uris @@ -85,8 +83,8 @@ and count_term f c e = function let c = {c with tappls = succ c.tappls; nodes = succ c.nodes} in let f c = count_term f c e t in count_term f c e v - | B.Bind (b, t) -> - let f c = count_term f c (B.push e b) t in + | B.Bind (a, b, t) -> + let f c = count_term f c (B.push e B.empty a b) t in count_term_binder f c e b let count_entity f c = function @@ -94,11 +92,11 @@ let count_entity f c = function let c = {c with eabsts = succ c.eabsts; nodes = succ c.nodes; uris = u :: c.uris } in - count_term f c B.empty_lenv w + count_term f c B.empty w | _, _, Y.Abbr v -> let c = {c with eabbrs = succ c.eabbrs; xnodes = succ c.xnodes} in - count_term f c B.empty_lenv v - | _, _, Y.Void -> assert false + count_term f c B.empty v + | _, _, Y.Void -> assert false let print_counters f c = let terms = @@ -125,98 +123,85 @@ let print_counters f c = (* supplementary annotation *************************************************) -let attrs_of_binder f = function - | B.Abst (a, _) - | B.Abbr (a, _) - | B.Void a -> f a - let rec does_not_occur f n r = function - | B.Null -> f true - | B.Cons (c, _, b) -> + | B.Null -> f true + | B.Cons (e, _, a, _) -> let f n1 r1 = - if n1 = n && r1 = r then f false else does_not_occur f n r c + if n1 = n && r1 = r then f false else does_not_occur f n r e in - attrs_of_binder (Y.name C.err f) b + Y.name C.err f a -let rename f c a = - let rec aux f c n r = +let rename f e a = + let rec aux f e n r = let f = function | true -> f n r - | false -> aux f c (n ^ "'") r + | false -> aux f e (n ^ "_") r in - does_not_occur f n r c + does_not_occur f n r e in let f n0 r0 = let f n r = if n = n0 && r = r0 then f a else f (Y.Name (n, r) :: a) in - aux f c n0 r0 + aux f e n0 r0 in Y.name C.err f a -let rename_bind f c = function - | B.Abst (a, w) -> let f a = f (B.abst a w) in rename f c a - | B.Abbr (a, v) -> let f a = f (B.abbr a v) in rename f c a - | B.Void a -> let f a = f (B.Void a) in rename f c a - (* lenv/term pretty printing ************************************************) -let name frm a = +let name err frm a = let f n = function | true -> F.fprintf frm "%s" n | false -> F.fprintf frm "^%s" n in - Y.name C.err f a + Y.name err f a -let rec pp_term c frm = function - | B.Sort (_, h) -> +let rec pp_term e frm = function + | B.Sort (_, h) -> let err _ = F.fprintf frm "@[*%u@]" h in let f s = F.fprintf frm "@[%s@]" s in - H.get_sort err f h - | B.LRef (_, i) -> + H.string_of_sort err f h + | B.LRef (_, i) -> let err _ = F.fprintf frm "@[#%u@]" i in - let f _ = function - | B.Abst (a, _) - | B.Abbr (a, _) - | B.Void a -> F.fprintf frm "@[%a@]" name a - in - if !O.indexes then err () else B.get err f c i - | B.GRef (_, s) -> + if !O.indexes then err () else + let _, _, a, b = B.get e i in + F.fprintf frm "@[%a@]" (name err) a + | B.GRef (_, s) -> F.fprintf frm "@[$%s@]" (U.string_of_uri s) - | B.Cast (_, u, t) -> - F.fprintf frm "@[{%a}.%a@]" (pp_term c) u (pp_term c) t - | B.Appl (_, v, t) -> - F.fprintf frm "@[(%a).%a@]" (pp_term c) v (pp_term c) t - | B.Bind (B.Abst (a, w), t) -> + | B.Cast (_, u, t) -> + F.fprintf frm "@[{%a}.%a@]" (pp_term e) u (pp_term e) t + | B.Appl (_, v, t) -> + F.fprintf frm "@[(%a).%a@]" (pp_term e) v (pp_term e) t + | B.Bind (a, B.Abst w, t) -> let f a = - let cc = B.push c (B.abst a w) in - F.fprintf frm "@[[%a:%a].%a@]" name a (pp_term c) w (pp_term cc) t + let ee = B.push e B.empty a (B.abst w) in + F.fprintf frm "@[[%a:%a].%a@]" (name C.err) a (pp_term e) w (pp_term ee) t in - rename f c a - | B.Bind (B.Abbr (a, v), t) -> + rename f e a + | B.Bind (a, B.Abbr v, t) -> let f a = - let cc = B.push c (B.abbr a v) in - F.fprintf frm "@[[%a=%a].%a@]" name a (pp_term c) v (pp_term cc) t + let ee = B.push e B.empty a (B.abbr v) in + F.fprintf frm "@[[%a=%a].%a@]" (name C.err) a (pp_term e) v (pp_term ee) t in - rename f c a - | B.Bind (B.Void a, t) -> + rename f e a + | B.Bind (a, B.Void, t) -> let f a = - let cc = B.push c (B.Void a) in - F.fprintf frm "@[[%a].%a@]" name a (pp_term cc) t + let ee = B.push e B.empty a B.Void in + F.fprintf frm "@[[%a].%a@]" (name C.err) a (pp_term ee) t in - rename f c a + rename f e a -let pp_lenv frm c = - let pp_entry f c = function +let pp_lenv frm e = + let pp_entry f e c a b x = f x (*match b with | B.Abst (a, w) -> - let f a = F.fprintf frm "@,@[%a : %a@]" name a (pp_term c) w; f () in - rename f c a + let f a = F.fprintf frm "@,@[%a : %a@]" (name C.err) a (pp_term e) w; f a in + rename f x a | B.Abbr (a, v) -> - let f a = F.fprintf frm "@,@[%a = %a@]" name a (pp_term c) v; f () in + let f a = F.fprintf frm "@,@[%a = %a@]" (name C.err) a (pp_term e) v; f a in rename f c a | B.Void a -> - let f a = F.fprintf frm "@,%a" name a; f () in + let f a = F.fprintf frm "@,%a" (name C.err) a; f a in rename f c a - in - B.rev_iter C.start pp_entry c +*) in + B.fold_right ignore pp_entry e B.empty let specs = { L.pp_term = pp_term; L.pp_lenv = pp_lenv @@ -229,16 +214,16 @@ let rec exp_term e t out tab = match t with let a = let err _ = a in let f s = Y.Name (s, true) :: a in - H.get_sort err f l + H.string_of_sort err f l in let attrs = [X.position l; X.name a] in X.tag X.sort attrs out tab | B.LRef (a, i) -> let a = - let err _ = a in + let err _ = a in let f n r = Y.Name (n, r) :: a in - let f _ b = attrs_of_binder (Y.name err f) b in - B.get err f e i + let _, _, a, b = B.get e i in + Y.name err f a in let attrs = [X.position i; X.name a] in X.tag X.lref attrs out tab @@ -254,20 +239,20 @@ let rec exp_term e t out tab = match t with let attrs = [] in X.tag X.appl attrs ~contents:(exp_term e v) out tab; exp_term e t out tab - | B.Bind (b, t) -> - let b = rename_bind C.start e b in - exp_bind e b out tab; - exp_term (B.push e b) t out tab + | B.Bind (a, b, t) -> + let a = rename C.start e a in + exp_bind e a b out tab; + exp_term (B.push e B.empty a b) t out tab -and exp_bind e b out tab = match b with - | B.Abst (a, w) -> +and exp_bind e a b out tab = match b with + | B.Abst w -> let attrs = [X.name a; X.mark a] in X.tag X.abst attrs ~contents:(exp_term e w) out tab - | B.Abbr (a, v) -> + | B.Abbr v -> let attrs = [X.name a; X.mark a] in X.tag X.abbr attrs ~contents:(exp_term e v) out tab - | B.Void a -> + | B.Void -> let attrs = [X.name a; X.mark a] in X.tag X.void attrs out tab -let export_term = exp_term B.empty_lenv +let export_term = exp_term B.empty