X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Fbasic_rg%2FbrgOutput.ml;h=66c7ed3d87a980350f00e2532ca5992e276fb841;hb=f23388dbd51574725a11b0ab5373f09838a32ab5;hp=dcefefa2efb758ca1922bceca594573bce6427f0;hpb=c45c77de154323feaf5bf6aee98c86b95361b9ae;p=helm.git diff --git a/helm/software/lambda-delta/basic_rg/brgOutput.ml b/helm/software/lambda-delta/basic_rg/brgOutput.ml index dcefefa2e..66c7ed3d8 100644 --- a/helm/software/lambda-delta/basic_rg/brgOutput.ml +++ b/helm/software/lambda-delta/basic_rg/brgOutput.ml @@ -10,7 +10,11 @@ V_______________________________________________________________ *) module P = Printf +module F = Format +module U = NUri +module C = Cps module L = Log +module H = Hierarchy module B = Brg type counters = { @@ -25,16 +29,23 @@ type counters = { tabbrs: int } +let indexes = ref false + let initial_counters = { eabsts = 0; eabbrs = 0; tsorts = 0; tlrefs = 0; tgrefs = 0; tcasts = 0; tappls = 0; tabsts = 0; tabbrs = 0 } -let count_term_binder f c = function - | B.Abst -> f {c with tabsts = succ c.tabsts} - | B.Abbr -> f {c with tabbrs = succ c.tabbrs} +let rec count_term_binder f c = function + | B.Abst w -> + let c = {c with tabsts = succ c.tabsts} in + count_term f c w + | B.Abbr v -> + let c = {c with tabbrs = succ c.tabbrs} in + count_term f c v + | B.Void -> f c -let rec count_term f c = function +and count_term f c = function | B.Sort _ -> f {c with tsorts = succ c.tsorts} | B.LRef _ -> @@ -49,22 +60,25 @@ let rec count_term f c = function let c = {c with tappls = succ c.tappls} in let f c = count_term f c t in count_term f c v - | B.Bind (_, b, u, t) -> + | B.Bind (_, b, t) -> let f c = count_term_binder f c b in - let f c = count_term f c t in - count_term f c u + count_term f c t let count_obj_binder f c = function - | B.Abst -> f {c with eabsts = succ c.eabsts} - | B.Abbr -> f {c with eabbrs = succ c.eabbrs} + | B.Abst w -> + let c = {c with eabsts = succ c.eabsts} in + count_term f c w + | B.Abbr v -> + let c = {c with eabbrs = succ c.eabbrs} in + count_term f c v + | B.Void -> f c -let count_obj f c (b, t) = - let f c = count_obj_binder f c b in - count_term f c t +let count_obj f c (_, _, b) = + count_obj_binder f c b let count_item f c = function - | Some (obj, _) -> count_obj f c obj - | None -> f c + | Some obj -> count_obj f c obj + | None -> f c let print_counters f c = let terms = @@ -85,3 +99,52 @@ let print_counters f c = L.warn (P.sprintf " Abstraction items: %6u" c.tabsts); L.warn (P.sprintf " Abbreviation items: %6u" c.tabbrs); f () + +let rec pp_term c frm = function + | B.Sort h -> + let f = function + | Some s -> F.fprintf frm "@[%s@]" s + | None -> F.fprintf frm "@[*%u@]" h + in + H.get_sort f h + | B.LRef i -> + let f = function + | Some (id, _) -> F.fprintf frm "@[%s@]" id + | None -> F.fprintf frm "@[#%u@]" i + in + if !indexes then f None else B.get f c i + | 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 (id, B.Abst w, t) -> + let f cc = + F.fprintf frm "@[[%s:%a].%a@]" id (pp_term c) w (pp_term cc) t + in + B.push f c id (B.Abst w) + | B.Bind (id, B.Abbr v, t) -> + let f cc = + F.fprintf frm "@[[%s=%a].%a@]" id (pp_term c) v (pp_term cc) t + in + B.push f c id (B.Abbr v) + | B.Bind (id, B.Void, t) -> + let f cc = F.fprintf frm "@[[%s].%a@]" id (pp_term cc) t in + B.push f c id B.Void + +let pp_context frm c = + let pp_entry frm = function + | id, B.Abst w -> + F.fprintf frm "@,@[%s : %a@]" id (pp_term c) w + | id, B.Abbr v -> + F.fprintf frm "@,@[%s = %a@]" id (pp_term c) v + | id, B.Void -> + F.fprintf frm "@,%s" id + in + let iter map frm l = List.iter (map frm) l in + let f _ es = F.fprintf frm "%a" (iter pp_entry) (List.rev es) in + B.contents f c + +let specs = { + L.pp_term = pp_term; L.pp_context = pp_context +}