123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687(************************************************************************)(* * The Rocq Prover / The Rocq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)openUtilopenNamesopenEConstrtypetemplate_arity=|NonTemplateArgofName.tbinder_annot*types*template_arity|TemplateArgofName.tbinder_annot*rel_context*Univ.Level.t*template_arity|DefParamofName.tbinder_annot*constr*types*template_arity|CtorTypeofDeclarations.template_universes*types|IndTypeofDeclarations.template_universes*rel_context*Sorts.t(* be Prop if all these levels are Prop *)typetemplate_can_be_prop={template_can_be_prop:Univ.Level.Set.toption}letget_template_arityenvind~ctoropt=letmib,mip=Inductive.lookup_mind_specifenvindinlettemplate=matchmib.mind_templatewith|None->assertfalse|Somet->tinletcan_be_prop,type_after_params=matchctoroptwith|None->lets=matchmip.mind_aritywith|RegularArity_->assertfalse|TemplateArity{template_level=s}->sinletctx=List.rev@@List.skipn(List.lengthmib.mind_params_ctxt)@@List.revmip.mind_arity_ctxtinlettemplate_can_be_prop=matchswith|SProp|Prop|Set->None|QSort_->assertfalse|Typeu->(* if all template levels are instantiated to Prop, do we get Prop? *)lettemplate_levels=Univ.ContextSet.levelstemplate.template_contextinifList.exists(fun(u,n)->n>0||not(Univ.Level.Set.memutemplate_levels))(Univ.Universe.repru)thenNoneelse(* don't use the qvar for non used univs
eg with "Ind (A:Type@{u}) (B:Type@{v}) : Type@{u}"
"Ind True nat" should be Prop *)letused_template_levels=Univ.Level.Set.intertemplate_levels(Univ.Universe.levelsu)inSomeused_template_levelsin{template_can_be_prop},IndType(template,EConstr.of_rel_contextctx,s)|Somector->letctyp=mip.mind_user_lc.(ctor-1)inlet_,ctyp=Term.decompose_prod_n_decls(List.lengthmib.mind_params_ctxt)ctypin(* don't bother with Prop for constructors *){template_can_be_prop=None},CtorType(template,EConstr.of_constrctyp)inletrecauxis_template(params:Constr.rel_context)=matchis_template,paramswith|_,LocalDef(na,v,t)::params->letcodom=auxis_templateparamsinDefParam(EConstr.of_binder_annotna,EConstr.of_constrv,EConstr.of_constrt,codom)|[],[]->type_after_params|_::_,[]|[],LocalAssum_::_->assertfalse|false::is_template,LocalAssum(na,t)::params->letcodom=auxis_templateparamsinNonTemplateArg(EConstr.of_binder_annotna,EConstr.of_constrt,codom)|true::is_template,LocalAssum(na,t)::params->letctx,c=Term.decompose_prod_declstinletu=matchConstr.kindcwith|Sort(Typeu)->beginmatchUniv.Universe.leveluwith|Someu->u|None->assertfalseend|_->assertfalseinletcodom=auxis_templateparamsinTemplateArg(EConstr.of_binder_annotna,EConstr.of_rel_contextctx,u,codom)inletres=auxtemplate.template_param_arguments(List.revmib.mind_params_ctxt)incan_be_prop,res