]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/helena/src/automath/autCrg.ml
- bug fix in the static analyzer allows better Pi/forall separation (exportation...
[helm.git] / helm / software / helena / src / automath / autCrg.ml
index 667b18cc1bfaea0c77f68dca895ed06d38a871d2..22b3e799c2474bda8996b46f40b905e58ec15014 100644 (file)
@@ -44,10 +44,19 @@ let empty_cnt = D.empty_lenv
 let alpha id =
    if id.[0] >= '0' && id.[0] <= '9' then !G.alpha ^ id else id
 
-let add_abst cnt id aw w =
+let attrs_for_abst id aw =
    let id = if !G.alpha <> "" then alpha id else id in
-   let aw = {aw with E.n_name = Some (id, true); E.n_degr = succ aw.E.n_degr} in 
-   D.EBind (cnt, aw, D.Abst (false, N.two, w))
+   let main = E.succ aw.E.n_main in
+   E.node_attrs ~name:(id, true) ~side:aw.E.n_main ~main ()
+
+let attrs_for_decl aw =
+   let main = E.succ aw.E.n_main in
+   E.node_attrs ~side:aw.E.n_main ~main ()
+
+let add_abst cnt id aw w =
+   let a = attrs_for_abst id aw in
+   let l = if !G.infinity then N.infinity else N.two in
+   D.EBind (cnt, a, D.Abst (false, l, w))
 
 let mk_lref f a i = f a (D.TLRef (a, i))
 
@@ -103,58 +112,66 @@ let get_cnt_relaxed f lst =
    get_cnt err f lst lst.node
 
 let push_abst f a w lenv =
-   let bw = D.Abst (false, N.infinite, w) in
+   let bw = D.Abst (false, N.infinity, w) in
    D.push_bind f a bw lenv
 
-let add_proj e t = match e with
+let add_proj at e t = match e with
    | D.ESort                 -> t
-   | D.EBind (D.ESort, a, b) -> D.TBind (a, b, t) 
-   | _                       -> D.TProj (E.empty_node, e, t)
+   | D.EBind (D.ESort, a, b) -> D.TBind (E.compose a at, b, t) 
+   | _                       ->
+      let e = if !G.export || !G.manager <> G.Quiet then D.set_attrs C.start at e else e in
+      D.TProj (at, e, t)
 
 (* this is not tail recursive in the GRef branch *)
 let rec xlate_term f st lst y lenv = function
    | A.Sort s            ->
       let h = if s then 0 else 1 in
-      let a = E.node_attrs ~sort:h () in
+      let a = E.node_attrs ~main:(h, 0) () in
       f a (D.TSort (a, h))
    | A.Appl (v, t)       ->
-      let f vv at tt = f at (D.TAppl (at, !G.extended, vv, tt)) in
-      let f _ vv = xlate_term (f vv) st lst y lenv t in
+      let f av vv at tt =
+         let at = E.compose av at in
+         f at (D.TAppl (at, !G.extended, vv, tt))
+      in
+      let f av vv = xlate_term (f av vv) st lst y lenv t in
       xlate_term f st lst false lenv v
    | A.Abst (name, w, t) ->
-      let name = if !G.alpha <> "" then alpha name else name in
-      let name = Some (name, true) in
-      let f aw ww = 
+      let f aw ww =
+         let aw = attrs_for_abst name aw in
          let f at tt =
+           let at = E.compose aw at in
             let l = 
-               if !G.cc then match y, at.E.n_degr with
+               if !G.cc then match y, snd at.E.n_main with
                   | true, _ -> N.one
                   | _   , 0 -> N.one
                   | _   , 1 -> N.unknown st
                   | _   , 2 -> N.two
                   | _       -> assert false
-               else N.infinite
+               else N.infinity
             in
            let b = D.Abst (false, l, ww) in
-           let at = {at with E.n_name = name} in
            f at (D.TBind (at, b, tt))
         in
          let f lenv = xlate_term f st lst y lenv t in
-        push_abst f {aw with E.n_name = name; E.n_degr = succ aw.E.n_degr} ww lenv
+        push_abst f aw 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 _ arg = f (D.EAppl (args, E.empty_node, !G.extended, arg)) in 
+         let f av v = f (D.EAppl (args, E.shift av, !G.extended, v)) in 
          xlate_term f st lst false lenv arg
       in
       let g qid a cnt =
          let gref = D.TGRef (a, uri_of_qid qid) in
         if cnt = D.ESort then f a gref else
         let f = function 
-            | D.EAppl (D.ESort, _, x, v) -> f a (D.TAppl (a, x, v, gref))
-            | args                       -> f a (D.TProj (a, args, gref))
+            | D.EAppl (D.ESort, av, x, v) ->
+               let a = E.compose av a in
+               f a (D.TAppl (a, x, v, gref))
+            | args                        ->
+               let args = if !G.export || !G.manager <> G.Quiet then D.set_attrs C.start a args else args in
+               f a (D.TProj (a, args, gref))
          in
         let f args = C.list_fold_right f map2 args D.ESort in
         D.sub_list_strict (D.fold_names f map1 args) cnt args
@@ -193,14 +210,14 @@ let xlate_entity err f st lst = function
       let f lenv =
         let f qid = 
             let f aw ww =
-               let aw = {aw with E.n_apix = lst.line; E.n_degr = succ aw.E.n_degr} in
-               UH.add henv (uri_of_qid qid) (aw, lenv);
-              let t = add_proj lenv ww in
+               let a = attrs_for_decl aw in
+               UH.add henv (uri_of_qid qid) (a, lenv);
+              let t = add_proj aw lenv ww in
 (*
            print_newline (); CrgOutput.pp_term print_string t;
 *)
-              let b = E.Abst t in
-              let entity = E.empty_root, aw, uri_of_qid qid, b in
+               let na = {aw with E.n_apix = lst.line} in
+              let entity = E.empty_root, na, uri_of_qid qid, E.Abst t in
                G.set_current_trace lst.line;
               f {lst with line = succ lst.line} entity
            in
@@ -208,21 +225,21 @@ let xlate_entity err f st lst = function
         in
          complete_qid f lst (name, true, [])
       in
-      get_cnt_relaxed (D.replace f N.one) lst
+      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 _ ww =
               let f av vv =
-                  let na = {av with E.n_apix = lst.line} in
-                  UH.add henv (uri_of_qid qid) (na, lenv);
-                  let t = add_proj lenv (D.TCast (na, ww, vv)) in
+                  UH.add henv (uri_of_qid qid) (av, lenv);
+                  let t = add_proj av lenv (D.TCast (av, ww, vv)) in
 (*
            print_newline (); CrgOutput.pp_term print_string t;
 *)
-                 let b = E.Abbr t in
+                  let na = {av with E.n_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, b in
+                 let entity = ra, na, uri_of_qid qid, E.Abbr t in
                   G.set_current_trace lst.line;
                  f {lst with line = succ lst.line} entity
               in