summaryrefslogtreecommitdiff
path: root/checker/indtypes.ml
diff options
context:
space:
mode:
Diffstat (limited to 'checker/indtypes.ml')
-rw-r--r--checker/indtypes.ml16
1 files changed, 14 insertions, 2 deletions
diff --git a/checker/indtypes.ml b/checker/indtypes.ml
index de57c50a..2431f14e 100644
--- a/checker/indtypes.ml
+++ b/checker/indtypes.ml
@@ -1,6 +1,6 @@
(************************************************************************)
(* v * The Coq Proof Assistant / The Coq Development Team *)
-(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
+(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010 *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
@@ -383,6 +383,15 @@ let ienv_push_inductive (env, n, ntypes, ra_env) (mi,lpar) =
let newidx = n + auxntyp in
(env', newidx, ntypes, ra_env')
+let rec ienv_decompose_prod (env,_,_,_ as ienv) n c =
+ if n=0 then (ienv,c) else
+ let c' = whd_betadeltaiota env c in
+ match c' with
+ Prod(na,a,b) ->
+ let ienv' = ienv_push_var ienv (na,a,mk_norec) in
+ ienv_decompose_prod ienv' (n-1) b
+ | _ -> assert false
+
(* The recursive function that checks positivity and builds the list
of recursive arguments *)
let check_positivity_one (env, _,ntypes,_ as ienv) hyps nrecp i indlc =
@@ -422,6 +431,7 @@ let check_positivity_one (env, _,ntypes,_ as ienv) hyps nrecp i indlc =
and check_positive_imbr (env,n,ntypes,ra_env as ienv) (mi, largs) =
let (mib,mip) = lookup_mind_specif env mi in
let auxnpar = mib.mind_nparams_rec in
+ let nonrecpar = mib.mind_nparams - auxnpar in
let (lpar,auxlargs) =
try list_chop auxnpar largs
with Failure _ -> raise (IllFormedInd (LocalNonPos n)) in
@@ -441,10 +451,12 @@ let check_positivity_one (env, _,ntypes,_ as ienv) hyps nrecp i indlc =
let lpar' = List.map (lift auxntyp) lpar in
let irecargs =
(* fails if the inductive type occurs non positively *)
- (* when substituted *)
+ (* with recursive parameters substituted *)
Array.map
(function c ->
let c' = hnf_prod_applist env' c lpar' in
+ (* skip non-recursive parameters *)
+ let (ienv',c') = ienv_decompose_prod ienv' nonrecpar c' in
check_constructors ienv' false c')
auxlcvect in
(Rtree.mk_rec [|mk_paths (Imbr mi) irecargs|]).(0)