From cca5f6b7431b846b7bdcbf813632cb79580d5874 Mon Sep 17 00:00:00 2001 From: Ferruccio Guidi Date: Tue, 1 Sep 2009 09:51:00 +0000 Subject: [PATCH] basic_rg: bugfix in AST to allow attributes in global entries xml: the exported XML data now comply a DTD icons: crux icon for the browser's address line Makefile: "lint" entry added for XML validation --- helm/software/lambda-delta/Makefile | 8 + helm/software/lambda-delta/automath/omega.aut | 8 +- helm/software/lambda-delta/basic_rg/brg.ml | 50 ++--- .../lambda-delta/basic_rg/brgOutput.ml | 178 ++++++++++++------ .../lambda-delta/basic_rg/brgReduction.ml | 84 ++++----- .../lambda-delta/basic_rg/brgReduction.mli | 4 +- .../lambda-delta/basic_rg/brgSubstitution.ml | 14 +- .../software/lambda-delta/basic_rg/brgType.ml | 42 ++--- .../lambda-delta/basic_rg/brgUntrusted.ml | 14 +- helm/software/lambda-delta/common/library.ml | 14 +- helm/software/lambda-delta/icons/crux-16.ico | Bin 0 -> 318 bytes helm/software/lambda-delta/performance.txt | 4 - .../software/lambda-delta/toplevel/metaAut.ml | 2 +- .../software/lambda-delta/toplevel/metaBrg.ml | 12 +- helm/software/lambda-delta/xml/ld.dtd | 84 +++++++++ 15 files changed, 334 insertions(+), 184 deletions(-) create mode 100644 helm/software/lambda-delta/icons/crux-16.ico create mode 100644 helm/software/lambda-delta/xml/ld.dtd diff --git a/helm/software/lambda-delta/Makefile b/helm/software/lambda-delta/Makefile index dcdb7eeb3..e33ec50e3 100644 --- a/helm/software/lambda-delta/Makefile +++ b/helm/software/lambda-delta/Makefile @@ -14,6 +14,10 @@ INPUT = automath/grundlagen.aut INPUT-ORIG = automath/grundlagen-orig.aut +XMLDIR = xml + +XMLLINT = xmllint --noout --stream --valid + test: $(MAIN).opt @echo " HELENA -a -c $(INPUT)" $(H)./$(MAIN).opt -a -c -S 3 $(O) $(INPUT) > log.txt @@ -33,3 +37,7 @@ hal: $(MAIN).opt xml-si: $(MAIN).opt @echo " HELENA -u -x $(INPUT)" $(H)./$(MAIN).opt -u -x -s 2 -S 1 $(INPUT) > log.txt + +lint: $(XMLS) + @echo XMLLINT --valid $(XMLDIR)/*.ld.xml + $(XMLLINT) --path $(XMLDIR) `find -name *.ld.xml` diff --git a/helm/software/lambda-delta/automath/omega.aut b/helm/software/lambda-delta/automath/omega.aut index 9a41532ce..661154db9 100644 --- a/helm/software/lambda-delta/automath/omega.aut +++ b/helm/software/lambda-delta/automath/omega.aut @@ -1,10 +1,10 @@ -# The lambda-term \omega +# The lambda-term \Omega # This book is not accepted in AUT-QE because [y:'type'] is not allowed -# This book is accepted in lambda-delta with sort inclusion but omega is not +# This book is accepted in lambda-delta with sort inclusion but Omega is not # valid if sort inclusion is allowed on the term backbone only # This book is valid in lambda-delta with sort inclusion allowed everywhere +l -@ delta := [x:[y:'type']'type']x : [x:[y:'type']'type']'type' - omega := delta : 'type' +@ Delta := [x:[y:'type']'type']x : [x:[y:'type']'type']'type' + Omega := Delta : 'type' -l diff --git a/helm/software/lambda-delta/basic_rg/brg.ml b/helm/software/lambda-delta/basic_rg/brg.ml index 5ad05a72f..779a121e6 100644 --- a/helm/software/lambda-delta/basic_rg/brg.ml +++ b/helm/software/lambda-delta/basic_rg/brg.ml @@ -20,32 +20,32 @@ type attr = Name of bool * id (* real?, name *) type attrs = attr list -type bind = Void (* exclusion *) - | Abst of term (* abstraction *) - | Abbr of term (* abbreviation *) +type bind = Void of attrs (* attrs *) + | Abst of attrs * term (* attrs, type *) + | Abbr of attrs * term (* attrs, body *) and term = Sort of attrs * int (* attrs, hierarchy index *) | LRef of attrs * int (* attrs, position index *) | GRef of attrs * uri (* attrs, reference *) | Cast of attrs * term * term (* attrs, type, term *) | Appl of attrs * term * term (* attrs, argument, function *) - | Bind of attrs * bind * term (* attrs, binder, scope *) + | Bind of bind * term (* binder, scope *) type obj = bind Item.obj (* age, uri, binder *) type item = bind Item.item type context = Null -(* Cons: tail, relative context, attrs, binder *) - | Cons of context * context option * attrs * bind +(* Cons: tail, relative context, binder *) + | Cons of context * context option * bind type message = (context, term) Log.item list (* Currified constructors ***************************************************) -let abst w = Abst w +let abst a w = Abst (a, w) -let abbr v = Abbr v +let abbr a v = Abbr (a, v) let lref a i = LRef (a, i) @@ -53,40 +53,40 @@ let cast a u t = Cast (a, u, t) let appl a u t = Appl (a, u, t) -let bind a b t = Bind (a, b, t) +let bind b t = Bind (b, t) -let bind_abst a u t = Bind (a, Abst u, t) +let bind_abst a u t = Bind (Abst (a, u), t) -let bind_abbr a v t = Bind (a, Abbr v, t) +let bind_abbr a v t = Bind (Abbr (a, v), t) (* context handling functions ***********************************************) let empty_context = Null -let push f es ?c a b = - let es = Cons (es, c, a, b) in f es +let push f es ?c b = + let es = Cons (es, c, b) in f es let get err f es i = let rec aux j = function - | Null -> err i - | Cons (tl, None, a, b) when j = 0 -> f tl a b - | Cons (_, Some c, a, b) when j = 0 -> f c a b - | Cons (tl, _, _, _) -> aux (pred j) tl + | Null -> err i + | Cons (tl, None, b) when j = 0 -> f tl b + | Cons (_, Some c, b) when j = 0 -> f c b + | Cons (tl, _, _) -> aux (pred j) tl in aux i es let rec rev_iter f map = function - | Null -> f () - | Cons (tl, None, a, b) -> - let f () = map f tl a b in rev_iter f map tl - | Cons (tl, Some c, a, b) -> - let f () = map f c a b in rev_iter f map tl + | Null -> f () + | Cons (tl, None, b) -> + let f () = map f tl b in rev_iter f map tl + | Cons (tl, Some c, b) -> + let f () = map f c b in rev_iter f map tl let rec fold_left f map x = function - | Null -> f x - | Cons (tl, _, a, b) -> + | Null -> f x + | Cons (tl, _, b) -> let f x = fold_left f map x tl in - map f x a b + map f x b let rec name err f = function | [] -> err () diff --git a/helm/software/lambda-delta/basic_rg/brgOutput.ml b/helm/software/lambda-delta/basic_rg/brgOutput.ml index 5dc3887c5..fe496e25d 100644 --- a/helm/software/lambda-delta/basic_rg/brgOutput.ml +++ b/helm/software/lambda-delta/basic_rg/brgOutput.ml @@ -45,13 +45,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 @@ -60,9 +60,9 @@ and count_term f c e = function 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 + let f _ = function | B.Abst _ - | B.Void -> + | B.Void _ -> f {c with tlrefs = succ c.tlrefs; nodes = succ c.nodes} | B.Abbr _ -> f {c with tlrefs = succ c.tlrefs; xnodes = succ c.xnodes} @@ -83,21 +83,21 @@ 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 (a, b, t) -> + | B.Bind (b, t) -> let f c e = count_term f c e t in - let f c = B.push (f c) e a b in + let f c = B.push (f c) e b in count_term_binder f c e b let count_obj f c = function - | (_, u, B.Abst w) -> + | (_, u, B.Abst (_, w)) -> let c = {c with eabsts = succ c.eabsts; nodes = succ c.nodes; uris = u :: c.uris } in count_term f c B.empty_context w - | (_, _, B.Abbr v) -> + | (_, _, B.Abbr (_, v)) -> let c = {c with eabbrs = succ c.eabbrs; xnodes = succ c.xnodes} in count_term f c B.empty_context v - | (_, u, B.Void) -> + | (_, u, B.Void _) -> let c = {c with evoids = succ c.evoids; nodes = succ c.nodes; uris = u :: c.uris } in @@ -130,6 +130,40 @@ let print_counters f c = L.warn (P.sprintf " + Abbreviation nodes: %7u" nodes); f () +(* 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) -> + let f n1 r1 = + if n1 = n && r1 = r then f false else does_not_occur f n r c + in + attrs_of_binder (B.name C.err f) b + +let rename f c a = + let rec aux f c n r = + let f = function + | true -> f n r + | false -> aux f c (n ^ "'") r + in + does_not_occur f n r c + in + let f n0 r0 = + let f n r = if n = n0 && r = r0 then f a else f (B.Name (r, n) :: a) in + aux f c n0 r0 + in + B.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 + (* context/term pretty printing *********************************************) let id frm a = @@ -140,41 +174,52 @@ let id frm a = B.name C.err f a let rec pp_term c frm = function - | B.Sort (_, h) -> + | 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) -> + | B.LRef (_, i) -> let err i = F.fprintf frm "@[#%u@]" i in - let f _ a _ = F.fprintf frm "@[%a@]" id a in + let f _ = function + | B.Abst (a, _) + | B.Abbr (a, _) + | B.Void a -> F.fprintf frm "@[%a@]" id a + in if !O.indexes then err i else B.get err f c i - | B.GRef (_, s) -> F.fprintf frm "@[$%s@]" (U.string_of_uri s) - | B.Cast (_, u, t) -> + | 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) -> + | B.Appl (_, v, t) -> F.fprintf frm "@[(%a).%a@]" (pp_term c) v (pp_term c) t - | B.Bind (a, B.Abst w, t) -> - let f cc = + | B.Bind (B.Abst (a, w), t) -> + let f a cc = F.fprintf frm "@[[%a:%a].%a@]" id a (pp_term c) w (pp_term cc) t in - B.push f c a (B.Abst w) - | B.Bind (a, B.Abbr v, t) -> - let f cc = + let f a = B.push (f a) c (B.abst a w) in + rename f c a + | B.Bind (B.Abbr (a, v), t) -> + let f a cc = F.fprintf frm "@[[%a=%a].%a@]" id a (pp_term c) v (pp_term cc) t in - B.push f c a (B.Abbr v) - | B.Bind (a, B.Void, t) -> - let f cc = F.fprintf frm "@[[%a].%a@]" id a (pp_term cc) t in - B.push f c a B.Void + let f a = B.push (f a) c (B.abbr a v) in + rename f c a + | B.Bind (B.Void a, t) -> + let f a cc = F.fprintf frm "@[[%a].%a@]" id a (pp_term cc) t in + let f a = B.push (f a) c (B.Void a) in + rename f c a let pp_context frm c = - let pp_entry f c a = function - | B.Abst w -> - F.fprintf frm "@,@[%a : %a@]" id a (pp_term c) w; f () - | B.Abbr v -> - F.fprintf frm "@,@[%a = %a@]" id a (pp_term c) v; f () - | B.Void -> - F.fprintf frm "@,%a" id a; f () + let pp_entry f c = function + | B.Abst (a, w) -> + let f a = F.fprintf frm "@,@[%a : %a@]" id a (pp_term c) w; f () in + rename f c a + | B.Abbr (a, v) -> + let f a = F.fprintf frm "@,@[%a = %a@]" id a (pp_term c) v; f () in + rename f c a + | B.Void a -> + let f a = F.fprintf frm "@,%a" id a; f () in + rename f c a in B.rev_iter C.start pp_entry c @@ -191,41 +236,58 @@ let id frm a = in B.name C.start f a -let rec exp_term frm = function +let rec exp_term c frm = function | B.Sort (a, l) -> + let a = + let err _ = a in + let f s = B.Name (true, s) :: a in + H.get_sort err f l + in F.fprintf frm "" (string_of_int l) id a | B.LRef (a, i) -> + let a = + let err _ = a in + let f n r = B.Name (r, n) :: a in + let f _ b = attrs_of_binder (B.name err f) b in + B.get err f c i + in F.fprintf frm "" (string_of_int i) id a | B.GRef (a, u) -> + let a = B.Name (true, U.name_of_uri u) :: a in F.fprintf frm "" (U.string_of_uri u) id a | B.Cast (a, w, t) -> - F.fprintf frm "%a%a" id a exp_boxed w exp_term t + F.fprintf frm "%a@,%a" id a (exp_boxed c) w (exp_term c) t | B.Appl (a, v, t) -> - F.fprintf frm "%a%a" id a exp_boxed v exp_term t - | B.Bind (a, b, t) -> - F.fprintf frm "%a%a" (exp_bind a) b exp_term t - -and exp_boxed frm t = - F.fprintf frm "@,@[ %a@]@," exp_term t - -and exp_bind a frm = function - | B.Abst w -> - F.fprintf frm "%a" id a exp_boxed w - | B.Abbr v -> - F.fprintf frm "%a" id a exp_boxed v - | B.Void -> + F.fprintf frm "%a@,%a" id a (exp_boxed c) v (exp_term c) t + | B.Bind (b, t) -> + let f b cc = F.fprintf frm "%a@,%a" (exp_bind c) b (exp_term cc) t in + let f b = B.push (f b) c b in + rename_bind f c b + +and exp_boxed c frm t = + F.fprintf frm "@,@[ %a@]@," (exp_term c) t + +and exp_bind c frm = function + | B.Abst (a, w) -> + F.fprintf frm "%a" id a (exp_boxed c) w + | B.Abbr (a, v) -> + F.fprintf frm "%a" id a (exp_boxed c) v + | B.Void a -> F.fprintf frm "" id a -let exp_obj frm = function - | _, uri, B.Abst w -> - let str = U.string_of_uri uri in - F.fprintf frm "@,%a" str exp_term w - | _, uri, B.Abbr v -> - let str = U.string_of_uri uri in - F.fprintf frm "@,%a" str exp_term v - | _, uri, B.Void -> - let str = U.string_of_uri uri in - F.fprintf frm "" str +let exp_obj c frm = function + | _, u, B.Abst (a, w) -> + let str = U.string_of_uri u in + let a = B.Name (true, U.name_of_uri u) :: a in + F.fprintf frm "%a" str id a (exp_boxed c) w + | _, u, B.Abbr (a, v) -> + let str = U.string_of_uri u in + let a = B.Name (true, U.name_of_uri u) :: a in + F.fprintf frm "%a" str id a (exp_boxed c) v + | _, u, B.Void a -> + let str = U.string_of_uri u in + let a = B.Name (true, U.name_of_uri u) :: a in + F.fprintf frm "" str id a let export_obj frm obj = - F.fprintf frm "@,@[ %a@]@," exp_obj obj + F.fprintf frm "@,@[ %a@]@," (exp_obj B.empty_context) obj diff --git a/helm/software/lambda-delta/basic_rg/brgReduction.ml b/helm/software/lambda-delta/basic_rg/brgReduction.ml index 4b1d287d9..f59d84226 100644 --- a/helm/software/lambda-delta/basic_rg/brgReduction.ml +++ b/helm/software/lambda-delta/basic_rg/brgReduction.ml @@ -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 a = function - | B.Abbr v -> + | 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 a 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 a 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 a 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 a b in - push f m1 a 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 diff --git a/helm/software/lambda-delta/basic_rg/brgReduction.mli b/helm/software/lambda-delta/basic_rg/brgReduction.mli index bf7c7f5d0..dd97b0d4d 100644 --- a/helm/software/lambda-delta/basic_rg/brgReduction.mli +++ b/helm/software/lambda-delta/basic_rg/brgReduction.mli @@ -15,9 +15,9 @@ type machine val empty_machine: machine -val get: (Brg.attrs -> Brg.bind -> 'a) -> machine -> int -> 'a +val get: (Brg.bind -> 'a) -> machine -> int -> 'a -val push: (machine -> 'a) -> machine -> Brg.attrs -> Brg.bind -> 'a +val push: (machine -> 'a) -> machine -> Brg.bind -> 'a (* arguments: expected type, inferred type, typed term *) val assert_conversion: diff --git a/helm/software/lambda-delta/basic_rg/brgSubstitution.ml b/helm/software/lambda-delta/basic_rg/brgSubstitution.ml index 5adc12631..e482b66c0 100644 --- a/helm/software/lambda-delta/basic_rg/brgSubstitution.ml +++ b/helm/software/lambda-delta/basic_rg/brgSubstitution.ml @@ -13,16 +13,16 @@ module B = Brg let iter map d = let rec iter_bind d = function - | B.Void as b -> b - | B.Abst w -> B.Abst (iter_term d w) - | B.Abbr v -> B.Abbr (iter_term d v) + | B.Void _ as b -> b + | B.Abst (a, w) -> B.Abst (a, iter_term d w) + | B.Abbr (a, v) -> B.Abbr (a, iter_term d v) and iter_term d = function | B.Sort _ as t -> t | B.GRef _ as t -> t | B.LRef (a, i) as t -> if i < d then t else map d a i | B.Cast (a, w, v) -> B.Cast (a, iter_term d w, iter_term d v) | B.Appl (a, w, u) -> B.Appl (a, iter_term d w, iter_term d u) - | B.Bind (a, b, u) -> B.Bind (a, iter_bind d b, iter_term (succ d) u) + | B.Bind (b, u) -> B.Bind (iter_bind d b, iter_term (succ d) u) in iter_term d @@ -33,6 +33,6 @@ let lift g h d t = if h = 0 then g t else g (iter (lift_map h) d t) let lift_bind g h d = function - | B.Void -> g B.Void - | B.Abst w -> let g w = g (B.Abst w) in lift g h d w - | B.Abbr v -> let g v = g (B.Abbr v) in lift g h d v + | B.Void _ as b -> g b + | B.Abst (a, w) -> let g w = g (B.abst a w) in lift g h d w + | B.Abbr (a, v) -> let g v = g (B.abbr a v) in lift g h d v diff --git a/helm/software/lambda-delta/basic_rg/brgType.ml b/helm/software/lambda-delta/basic_rg/brgType.ml index bf0678647..97872734b 100644 --- a/helm/software/lambda-delta/basic_rg/brgType.ml +++ b/helm/software/lambda-delta/basic_rg/brgType.ml @@ -36,60 +36,60 @@ let error1 s m t = let rec b_type_of f ~si g m x = log1 "Now checking" m x; match x with - | B.Sort (a, h) -> + | B.Sort (a, h) -> let f h = f x (B.Sort (a, h)) in H.apply f g h - | B.LRef (_, i) -> - let f _ = function - | B.Abst w -> + | B.LRef (_, i) -> + let f = function + | B.Abst (_, w) -> S.lift (f x) (succ i) (0) w - | B.Abbr (B.Cast (_, w, _)) -> + | B.Abbr (_, B.Cast (_, w, _)) -> S.lift (f x) (succ i) (0) w - | B.Abbr _ -> assert false - | B.Void -> + | B.Abbr _ -> assert false + | B.Void _ -> error1 "reference to excluded variable" m x in R.get f m i - | B.GRef (_, uri) -> + | B.GRef (_, uri) -> let f = function - | _, _, B.Abst w -> f x w - | _, _, B.Abbr (B.Cast (_, w, _)) -> f x w - | _, _, B.Abbr _ -> assert false - | _, _, B.Void -> + | _, _, B.Abst (_, w) -> f x w + | _, _, B.Abbr (_, B.Cast (_, w, _)) -> f x w + | _, _, B.Abbr _ -> assert false + | _, _, B.Void _ -> error1 "reference to excluded object" m x in E.get_obj f uri - | B.Bind (a, B.Abbr v, t) -> + | B.Bind (B.Abbr (a, v), t) -> let f xv xt tt = f (A.sh2 v xv t xt x (B.bind_abbr a)) (B.bind_abbr a xv tt) in let f xv m = b_type_of (f xv) ~si g m t in - let f xv = R.push (f xv) m a (B.Abbr xv) in + let f xv = R.push (f xv) m (B.abbr a xv) in let f xv vv = match xv with | B.Cast _ -> f xv | _ -> f (B.Cast ([], vv, xv)) in type_of f ~si g m v - | B.Bind (a, B.Abst u, t) -> + | B.Bind (B.Abst (a, u), t) -> let f xu xt tt = f (A.sh2 u xu t xt x (B.bind_abst a)) (B.bind_abst a xu tt) in let f xu m = b_type_of (f xu) ~si g m t in - let f xu _ = R.push (f xu) m a (B.Abst xu) in + let f xu _ = R.push (f xu) m (B.abst a xu) in type_of f ~si g m u - | B.Bind (a, B.Void, t) -> + | B.Bind (B.Void a as b, t) -> let f xt tt = - f (A.sh1 t xt x (B.bind a B.Void)) (B.bind a B.Void tt) + f (A.sh1 t xt x (B.bind b)) (B.bind b tt) in let f m = b_type_of f ~si g m t in - R.push f m a B.Void - | B.Appl (a, v, t) -> + R.push f m b + | B.Appl (a, v, t) -> let f xv vv xt tt = let f () = f (A.sh2 v xv t xt x (B.appl a)) (B.appl a xv tt) in R.assert_conversion f ~si ~rt:true m tt vv xv in let f xv vv = b_type_of (f xv vv) ~si g m t in type_of f ~si g m v - | B.Cast (a, u, t) -> + | B.Cast (a, u, t) -> let f xu xt tt = let f () = f (A.sh2 u xu t xt x (B.cast a)) xu in R.assert_conversion f ~si m xu tt xt diff --git a/helm/software/lambda-delta/basic_rg/brgUntrusted.ml b/helm/software/lambda-delta/basic_rg/brgUntrusted.ml index f9c23d73f..67c756b46 100644 --- a/helm/software/lambda-delta/basic_rg/brgUntrusted.ml +++ b/helm/software/lambda-delta/basic_rg/brgUntrusted.ml @@ -19,15 +19,15 @@ module T = BrgType (* to share *) let type_check f ?(si=false) g = function - | None -> f None None - | Some (e, uri, B.Abst t) -> + | None -> f None None + | Some (e, uri, B.Abst (a, t)) -> let f tt obj = f (Some tt) (Some obj) in - let f xt tt = E.set_obj (f tt) (e, uri, B.Abst xt) in + let f xt tt = E.set_obj (f tt) (e, uri, B.abst a xt) in L.loc := e; T.type_of f ~si g R.empty_machine t - | Some (e, uri, B.Abbr t) -> + | Some (e, uri, B.Abbr (a, t)) -> let f tt obj = f (Some tt) (Some obj) in - let f xt tt = E.set_obj (f tt) (e, uri, B.Abbr xt) in + let f xt tt = E.set_obj (f tt) (e, uri, B.abbr a xt) in L.loc := e; T.type_of f ~si g R.empty_machine t - | Some (e, uri, B.Void) -> + | Some (e, uri, (B.Void _ as b)) -> let f obj = f None (Some obj) in - L.loc := e; E.set_obj f (e, uri, B.Void) + L.loc := e; E.set_obj f (e, uri, b) diff --git a/helm/software/lambda-delta/common/library.ml b/helm/software/lambda-delta/common/library.ml index 23f156123..8dec0dd5d 100644 --- a/helm/software/lambda-delta/common/library.ml +++ b/helm/software/lambda-delta/common/library.ml @@ -17,7 +17,7 @@ module H = Hierarchy let base = "xml" -let obj_ext = ".ld.xml" +let obj_ext = ".xml" let system = "http://helm.cs.unibo.it/lambda-delta/" ^ base ^ "/ld.dtd" @@ -28,17 +28,17 @@ let pp_head frm = Format.fprintf frm "@,@," "1.0" "UTF-8" let pp_doctype frm = - Format.fprintf frm "@,@," system + Format.fprintf frm "@,@," system -let open_kernel si g frm = +let open_entry si g frm = let opts = if si then "si" else "" in let f shp = - Format.fprintf frm "" shp opts + Format.fprintf frm "" shp opts in H.string_of_graph f g -let close_kernel frm = - Format.fprintf frm "" +let close_entry frm = + Format.fprintf frm "" (* interface functions ******************************************************) @@ -51,6 +51,6 @@ let export_item export_obj si g = function let frm = Format.formatter_of_out_channel och in Format.pp_set_margin frm max_int; Format.fprintf frm "@[%t%t%t%a%t@]@." - pp_head pp_doctype (open_kernel si g) export_obj obj close_kernel; + pp_head pp_doctype (open_entry si g) export_obj obj close_entry; close_out och | None -> () diff --git a/helm/software/lambda-delta/icons/crux-16.ico b/helm/software/lambda-delta/icons/crux-16.ico new file mode 100644 index 0000000000000000000000000000000000000000..6c3a2a1184bfcec33ddca10176498671c4839640 GIT binary patch literal 318 zcmZQzU<5(|0RbS%!l1#(z#zuJz@P!d0zj+)#2|58;6DQp9stVz2jT-j_J0tAc%Y=D cq~dIBY)mTcf(8Ty1w|Zy){;sS?^5h40o6ks2LJ#7 literal 0 HcmV?d00001 diff --git a/helm/software/lambda-delta/performance.txt b/helm/software/lambda-delta/performance.txt index 01009680e..5d674bd66 100644 --- a/helm/software/lambda-delta/performance.txt +++ b/helm/software/lambda-delta/performance.txt @@ -4,7 +4,3 @@ untrusted : 0.4 trusted : 6.5 + 3 with upsilon relocations ------------------ total : 9.2 - - 107123 alpha conversions (107021 without si) - 298902 proper conversions - diff --git a/helm/software/lambda-delta/toplevel/metaAut.ml b/helm/software/lambda-delta/toplevel/metaAut.ml index 48628b2bb..2ef3ec737 100644 --- a/helm/software/lambda-delta/toplevel/metaAut.ml +++ b/helm/software/lambda-delta/toplevel/metaAut.ml @@ -49,7 +49,7 @@ let mk_qid st id path = let uripath = if st.cover = "" then path else st.cover :: path in let str = String.concat "/" uripath in let str = Filename.concat str id in - U.uri_of_string ("ld:/" ^ str), id, path + U.uri_of_string ("ld:/" ^ str ^ ".ld"), id, path let uri_of_qid (uri, _, _) = uri diff --git a/helm/software/lambda-delta/toplevel/metaBrg.ml b/helm/software/lambda-delta/toplevel/metaBrg.ml index 9fe774b81..4c5696cea 100644 --- a/helm/software/lambda-delta/toplevel/metaBrg.ml +++ b/helm/software/lambda-delta/toplevel/metaBrg.ml @@ -32,32 +32,32 @@ let rec xlate_term c f = function | M.Abst (id, w, t) -> let f w = let a = [B.Name (true, id)] in - let f t = f (B.Bind (a, B.Abst w, t)) in + let f t = f (B.Bind (B.abst a w, t)) in let f c = xlate_term c f t in - B.push f c a (B.Abst w) + B.push f c (B.abst a w) in xlate_term c f w let xlate_pars f pars = let map f (id, w) c = let a = [B.Name (true, id)] in - let f w = B.push f c a (B.Abst w) in + let f w = B.push f c (B.abst a w) in xlate_term c f w in C.list_fold_right f map pars B.empty_context let unwind_to_xlate_term f c t = - let map f t a b = f (B.bind a b t) in + let map f t b = f (B.bind b t) in let f t = B.fold_left f map t c in xlate_term c f t let xlate_entry f = function | e, pars, uri, u, None -> - let f u = f (e, uri, B.Abst u) in + let f u = f (e, uri, B.abst [] u) in let f c = unwind_to_xlate_term f c u in xlate_pars f pars | e, pars, uri, u, Some (_, t) -> - let f u t = f (e, uri, B.Abbr (B.Cast ([], u, t))) in + let f u t = f (e, uri, B.abbr [] (B.Cast ([], u, t))) in let f c u = unwind_to_xlate_term (f u) c t in let f c = unwind_to_xlate_term (f c) c u in xlate_pars f pars diff --git a/helm/software/lambda-delta/xml/ld.dtd b/helm/software/lambda-delta/xml/ld.dtd new file mode 100644 index 000000000..00ea55239 --- /dev/null +++ b/helm/software/lambda-delta/xml/ld.dtd @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.39.2