X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=blobdiff_plain;f=helm%2Fsoftware%2Fhelena%2Fsrc%2Fautomath%2FautCrg.ml;h=d1a72518b2d053636bbc639eb30d434854322950;hp=5ed896306dfcf0558d6858ad499f57398b3f94f0;hb=88977b2d546e547e23b046792fe2ad8f6ff192a4;hpb=fdb80b08af83b86759833142456ce3c4f84cd80e diff --git a/helm/software/helena/src/automath/autCrg.ml b/helm/software/helena/src/automath/autCrg.ml index 5ed896306..d1a72518b 100644 --- a/helm/software/helena/src/automath/autCrg.ml +++ b/helm/software/helena/src/automath/autCrg.ml @@ -24,7 +24,7 @@ type qid = D.uri * D.id * D.id list type context_node = qid option (* context node: None = root *) type status = { - path: D.id list; (* current section path *) + path: D.id list; (* current section path *) node: context_node; (* current context node *) nodes: context_node list; (* context node list *) line: int; (* line number *) @@ -44,28 +44,29 @@ let empty_cnt = D.empty_lenv let alpha id = if id.[0] >= '0' && id.[0] <= '9' then !G.alpha ^ id else id -let attrs_for_abst id aw = +let attrs_for_appl yv yt = + E.appl_attrs ~side:yv ~main:yt !G.restricted + +let attrs_for_abst id yw = let id = if !G.alpha <> "" then alpha id else id in - let main = E.succ aw.E.b_main in - E.bind_attrs ~name:(id, true) ~side:aw.E.b_main ~main () + E.bind_attrs ~name:(id, true) ~side:yw ~main:(E.succ yw) () -let attrs_for_decl aw = - let main = E.succ aw.E.b_main in - E.bind_attrs ~side:aw.E.b_main ~main () +let attrs_for_env y = + E.env_attrs ~side:y () -let add_abst cnt id aw w = - let y = attrs_for_abst id aw in +let add_abst cnt id yw w = + let a = attrs_for_abst id yw in let l = if !G.infinity then N.infinity else N.two in - D.EBind (cnt, E.empty_node, y, D.Abst (false, l, w)) + D.EBind (cnt, E.empty_node, a, D.Abst (false, l, w)) -let mk_lref f _ y i = f y (D.TLRef (E.empty_node, i)) +let mk_lref f _ a i = f a.E.b_main (D.TLRef (E.empty_node, i)) let id_of_name (id, _, _) = if !G.alpha <> "" then alpha id else id let mk_qid f lst id path = let str = String.concat "/" path in - let str = Filename.concat str id in + let str = Filename.concat str id in let str = lst.mk_uri str in f (U.uri_of_string str, id, path) @@ -96,7 +97,7 @@ let resolve_gref err f lst qid = with Not_found -> err qid let resolve_gref_relaxed f lst qid = -(* this is not tail recursive *) +(* this is not tail recursive *) let rec err qid = relax_qid (resolve_gref err f lst) lst qid in resolve_gref err f lst qid @@ -107,23 +108,23 @@ let get_cnt err f lst = function with Not_found -> err node let get_cnt_relaxed f lst = -(* this is not tail recursive *) +(* this is not tail recursive *) let rec err node = relax_opt_qid (get_cnt err f lst) lst node in get_cnt err f lst lst.node -let push_abst f y w lenv = +let push_abst f a w lenv = let bw = D.Abst (false, N.infinity, w) in - D.push_bind f E.empty_node y bw lenv + D.push_bind f E.empty_node a bw lenv (* let rec set_name_y f = function | D.ESort -> f D.ESort | D.EBind (e, a, y, b) -> set_name_y (D.push_bind f a {y with E.b_name = Some ("Y", true)} b) e - | D.EAppl (e, x, v) -> set_name_y (D.push_appl f x v) e + | D.EAppl (e, a, v) -> set_name_y (D.push_appl f a v) e | D.EProj (e, d) -> let f d = set_name_y (D.push_proj f d) e in set_name_y f d *) let add_proj yt e t = match e with | D.ESort -> t - | D.EBind (D.ESort, _, y, b) -> D.TBind (E.compose y yt, b, t) + | D.EBind (D.ESort, _, a, b) -> D.TBind (E.compose a yt, b, t) | e -> D.TProj (D.set_attrs C.start yt e, t) @@ -131,21 +132,19 @@ let add_proj yt e t = match e with let rec xlate_term f st lst z lenv = function | A.Sort s -> let k = if s then 0 else 1 in - let y = E.bind_attrs ~main:(k, 0) () in - f y (D.TSort k) + f (k, 0) (D.TSort k) | A.Appl (v, t) -> - let f vv yt tt = - f yt (D.TAppl (!G.extended, vv, tt)) + let f yv vv yt tt = + f yt (D.TAppl (attrs_for_appl yv yt, vv, tt)) in - let f _ vv = xlate_term (f vv) st lst z lenv t in + let f yv vv = xlate_term (f yv vv) st lst z lenv t in xlate_term f st lst false lenv v | A.Abst (name, w, t) -> let f yw ww = - let yw = attrs_for_abst name yw in + let a = attrs_for_abst name yw in let f yt tt = - let yt = E.compose yw yt in - let l = - if !G.cc then match z, snd yt.E.b_main with + let l = + if !G.cc then match z, snd yt with | true, _ -> N.one | _ , 0 -> N.one | _ , 1 -> N.unknown st @@ -155,26 +154,26 @@ let rec xlate_term f st lst z lenv = function in let b = D.Abst (false, l, ww) in (* let yt = {yt with E.b_name = Some ("P", true)} in *) - f yt (D.TBind (yt, b, tt)) + f yt (D.TBind (E.compose a yt, b, tt)) in let f lenv = xlate_term f st lst z lenv t in - push_abst f yw ww lenv + push_abst f a ww lenv in xlate_term f st lst true lenv w | A.GRef (name, args) -> let map1 args (id, _) = A.GRef ((id, true, []), []) :: args in - let map2 f arg args = - let f _ v = f (D.EAppl (args, !G.extended, v)) in + let map2 y f arg args = + let f yv v = f (D.EAppl (args, attrs_for_appl yv y, v)) in xlate_term f st lst false lenv arg in let g qid y cnt = let gref = D.TGRef (E.empty_node, uri_of_qid qid) in if cnt = D.ESort then f y gref else - let f = function - | D.EAppl (D.ESort, x, v) -> f y (D.TAppl (x, v, gref)) + let f = function + | D.EAppl (D.ESort, a, v) -> f y (D.TAppl (a, v, gref)) | args -> f y (D.TProj (args, gref)) in - let f args = C.list_fold_right f map2 args D.ESort in + let f args = C.list_fold_right f (map2 y) args D.ESort in D.sub_list_strict (D.fold_names f map1 args) cnt args in let g qid = resolve_gref_relaxed g lst qid in @@ -186,7 +185,7 @@ let xlate_entity err f st lst = function err {lst with path = name :: lst.path; nodes = lst.node :: lst.nodes} | A.Section None -> begin match lst.path, lst.nodes with - | _ :: ptl, nhd :: ntl -> + | _ :: ptl, nhd :: ntl -> err {lst with path = ptl; node = nhd; nodes = ntl} | _ -> assert false end @@ -194,12 +193,12 @@ let xlate_entity err f st lst = function err {lst with node = None} | A.Context (Some name) -> let f name = err {lst with node = Some name} in - complete_qid f lst name + complete_qid f lst name | A.Block (name, w) -> - let f qid = + let f qid = let f cnt = - let f aw ww = - UH.add hcnt (uri_of_qid qid) (add_abst cnt name aw ww); + let f yw ww = + UH.add hcnt (uri_of_qid qid) (add_abst cnt name yw ww); err {lst with node = Some qid} in xlate_term f st lst true cnt w @@ -209,13 +208,14 @@ let xlate_entity err f st lst = function complete_qid f lst (name, true, []) | A.Decl (name, w) -> let f lenv = - let f qid = + let f qid = let f yw ww = - let y = attrs_for_decl yw in - UH.add henv (uri_of_qid qid) (y, lenv); + let yv = E.succ yw in + let a = attrs_for_env yv in + UH.add henv (uri_of_qid qid) (yv, lenv); let t = add_proj yw lenv ww in let na = E.node_attrs ~apix:lst.line () in - let entity = E.empty_root, na, uri_of_qid qid, E.Abst t in + let entity = E.empty_root, na, uri_of_qid qid, E.abst a t in IFDEF TRACE THEN G.set_current_trace lst.line ELSE () END; @@ -225,22 +225,24 @@ ELSE () END; in complete_qid f lst (name, true, []) in - let f = if !G.infinity then f else D.set_layer f N.one in + let f = if !G.infinity then f else D.set_layer f N.one in get_cnt_relaxed f lst | A.Def (name, w, trans, v) -> let f lenv = - let f qid = + let f qid = let f yw ww = let f yv vv = + let a = attrs_for_env yv in UH.add henv (uri_of_qid qid) (yv, lenv); - let t = add_proj yv lenv (D.TCast (ww, vv)) in -(* - let lenv0 = D.set_layer C.start N.one lenv in - let t = D.TCast (add_proj yw lenv0 ww, add_proj yv lenv vv) in -*) + let t = if !G.cast then + let f e = D.TCast (add_proj yw e ww, add_proj yv lenv vv) in + if !G.infinity then f lenv else D.set_layer f N.one lenv + else + add_proj yv lenv (D.TCast (ww, vv)) + in let na = E.node_attrs ~apix:lst.line () in let ra = if trans then E.empty_root else E.root_attrs ~meta:[E.Private] () in - let entity = ra, na, uri_of_qid qid, E.Abbr t in + let entity = ra, na, uri_of_qid qid, E.abbr a t in IFDEF TRACE THEN G.set_current_trace lst.line ELSE () END;