From 9d606c93b36796bb2fd0412745da367a1f8a6084 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Mon, 19 May 2008 23:31:44 +0000 Subject: [PATCH] Bug fixed in computation of leftnos: variables were not considered. --- .../components/ng_kernel/oCic2NCic.ml | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/helm/software/components/ng_kernel/oCic2NCic.ml b/helm/software/components/ng_kernel/oCic2NCic.ml index 0e9ff4831..ee259877d 100644 --- a/helm/software/components/ng_kernel/oCic2NCic.ml +++ b/helm/software/components/ng_kernel/oCic2NCic.ml @@ -42,6 +42,16 @@ let strictify = | Fix l -> `Fix (Lazy.force l) ;; +let count_vars vars = + List.length + (List.filter (fun v -> + match fst (CicEnvironment.get_obj CicUniv.oblivion_ugraph v) with + Cic.Variable (_,Some _,_,_,_) -> false + | Cic.Variable (_,None,_,_,_) -> true + | _ -> assert false) vars) +;; + + (***** A function to restrict the context of a term getting rid of unsed variables *******) @@ -650,8 +660,8 @@ let convert_term uri t = | Cic.MutInd (curi, tyno, ens) -> let is_inductive, lno = match fst (CicEnvironment.get_obj CicUniv.oblivion_ugraph curi) with - Cic.InductiveDefinition ([],_,lno,_) -> true, lno - | Cic.InductiveDefinition ((_,b,_,_)::_,_,lno,_) -> b, lno + Cic.InductiveDefinition ([],vars,lno,_) -> true, lno + count_vars vars + | Cic.InductiveDefinition ((_,b,_,_)::_,vars,lno,_) -> b, lno + count_vars vars | _ -> assert false in aux_ens k curi octx ctx n_fix uri ens @@ -659,7 +669,7 @@ let convert_term uri t = | Cic.MutConstruct (curi, tyno, consno, ens) -> let lno = match fst (CicEnvironment.get_obj CicUniv.oblivion_ugraph curi) with - Cic.InductiveDefinition (_,_,lno,_) -> lno + Cic.InductiveDefinition (_,vars,lno,_) -> lno + count_vars vars | _ -> assert false in aux_ens k curi octx ctx n_fix uri ens @@ -672,8 +682,8 @@ let convert_term uri t = | Cic.MutCase (curi, tyno, outty, t, branches) -> let is_inductive,lno = match fst (CicEnvironment.get_obj CicUniv.oblivion_ugraph curi) with - Cic.InductiveDefinition ([],_,lno,_) -> true, lno - | Cic.InductiveDefinition ((_,b,_,_)::_,_,lno,_) -> b, lno + Cic.InductiveDefinition ([],vars,lno,_) -> true, lno + count_vars vars + | Cic.InductiveDefinition ((_,b,_,_)::_,vars,lno,_) -> b, lno + count_vars vars | _ -> assert false in let r = reference_of_ouri curi (Ref.Ind (is_inductive,tyno,lno)) in let outty, fixpoints_outty = aux k octx ctx n_fix uri outty in @@ -801,14 +811,7 @@ let convert_obj_aux uri = function (get_relevance ty, name, nty, cl)::itl, fix_ty @ fix_cl @ acc) itl ([],[]) in - NCic.Inductive(ind, leftno + List.length - (List.filter (fun v -> - match fst (CicEnvironment.get_obj CicUniv.oblivion_ugraph v) with - Cic.Variable (_,Some _,_,_,_) -> false - | Cic.Variable (_,None,_,_,_) -> true - | _ -> assert false) - vars) - , itl, (`Provided, `Regular)), + NCic.Inductive(ind, leftno + count_vars vars, itl, (`Provided, `Regular)), fix_itl | Cic.Variable _ | Cic.CurrentProof _ -> assert false -- 2.39.2