123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603(************************************************************************)(* * 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) *)(************************************************************************)(** Abstract representations of values in a vo *)(** NB: This needs updating when the types in declarations.ml and
their dependencies are changed. *)(** We reify here the types of values present in a vo.
in order to validate its structure. Maybe this reification
could become automatically generated someday ?
See values.mli for the meaning of each constructor.
*)type'vkind=|Any|Failofstring|Tupleofstring*'varray|Sumofstring*int*'varrayarray|Arrayof'v|Listof'v|Optof'v|Int|String|Annotofstring*'v|Int64|Float64moduleVector=structtype('a,_)t=|[]:('a,[`O])t|(::):'a*('a,'s)t->('a,[`Sof's])ttype'nsize=(unit,'n)tletrecvmap:'n'a'b.('a->'b)->('a,'n)t->('b,'n)t=fun(typen)f(v:(_,n)t):(_,n)t->matchvwith|[]->[]|x::tl->letx=fxinx::vmapftlletrecviter2:'n'a'b.('a->'b->unit)->('a,'n)t->('b,'n)t->unit=fun(typen)f(v1:(_,n)t)(v2:(_,n)t)->matchv1,v2with|[],[]->()|x1::tl1,x2::tl2->let()=fx1x2inviter2ftl1tl2endmoduleInternal:sigtypevaluevalequal:value->value->boolvalkind:value->valuekindvalof_kind:valuekind->valuevalmfix:'nVector.size->((value,'n)Vector.t->(value,'n)Vector.t)->(value,'n)Vector.tend=structtypevalue=|Vofvaluekind|Proxyofvaluekindrefletkind=function|Vv->v|Proxyv->!v(* Proxy is equal to its contents *)letequalab=kinda==kindbletof_kindv=Vvletcheck_productive=function|Proxy_->assertfalse|Vv->vletmfix(typen)(n:nVector.size)(f:(value,n)Vector.t->(value,n)Vector.t):(value,n)Vector.t=letopenVectorinletself=vmap(fun()->Proxy(refAny))ninletans=fselfinlet()=viter2(funselfans->letans=check_productiveansinmatchselfwith|Proxyself->self:=ans|_->assertfalse)selfansinansendtypenonrecvalue=Internal.valueletequal=Internal.equalletkind=Internal.kindletof_kind=Internal.of_kindletmfix=Internal.mfixletfixf=let[v]:_Vector.t=mfix[()](fun[v]->[fv])inv(** Some pseudo-constructors *)letv_tuplenamev=of_kind@@Tuple(name,v)letv_sumnameccvv=of_kind@@Sum(name,cc,vv)letv_enumnamen=of_kind@@Sum(name,n,[||])letv_annotav=of_kind@@Annot(a,v)letv_failf=of_kind@@Failf(* uncurried forms *)letv_tuple_c(name,v)=v_tuplenamevletv_sum_c(name,cc,vv)=v_sumnameccvvletv_annot_c(a,v)=v_annotav(** Ocaml standard library *)letv_any=of_kindAnyletv_int=of_kindIntletv_int64=of_kindInt64letv_float64=of_kindFloat64letv_string=of_kindStringletv_optv=of_kind@@Optvletv_listv=of_kind@@Listvletv_arrayv=of_kind@@Arrayvletv_pairv1v2=v_tuple"*"[|v1;v2|]letv_bool=v_enum"bool"2letv_unit=v_enum"unit"1letv_setv=fix(funs->v_sum_c("Set.t",1,[|[|s;v_annot_c("elem",v);s;v_annot_c("bal",v_int)|]|]))letv_mapvkvd=fix(funm->v_sum_c("Map.t",1,[|[|m;v_annot_c("key",vk);v_annot_c("data",vd);m;v_annot_c("bal",v_int)|]|]))letv_hsetv=v_mapv_int(v_setv)letv_hmapvkvd=v_mapv_int(v_mapvkvd)letv_predv=v_pairv_bool(v_setv)(** kernel/names *)letv_id=v_stringletv_dp=v_annot_c("dirpath",v_listv_id)letv_name=v_sum"name"1[|[|v_id|]|]letv_uid=v_tuple"uniq_ident"[|v_int;v_string;v_dp|]letv_mp=fix(funv_mp->v_sum_c("module_path",0,[|[|v_dp|];[|v_uid|];[|v_mp;v_id|]|]))letv_kn=v_tuple"kernel_name"[|v_mp;v_id;v_int|]letv_cst=v_sum"cst|mind"0[|[|v_kn|];[|v_kn;v_kn|]|]letv_ind=v_tuple"inductive"[|v_cst;v_int|]letv_cons=v_tuple"constructor"[|v_ind;v_int|](** kernel/univ *)letv_level_global=v_tuple"Level.Global.t"[|v_dp;v_string;v_int|]letv_raw_level=v_sum"raw_level"1(* Set *)[|(*Level*)[|v_level_global|];(*Var*)[|v_int|]|]letv_level=v_tuple"level"[|v_int;v_raw_level|]letv_expr=v_tuple"levelexpr"[|v_level;v_int|]letv_univ=v_listv_exprletv_qvar=v_sum"qvar"0[|[|v_int|];[|v_string;v_int|]|]letv_constant_quality=v_enum"constant_quality"3letv_quality=v_sum"quality"0[|[|v_qvar|];[|v_constant_quality|]|]letv_cstrs=v_annot_c("Univ.constraints",v_set(v_tuple"univ_constraint"[|v_level;v_enum"order_request"3;v_level|]))letv_variance=v_enum"variance"3letv_instance=v_annot_c("instance",v_pair(v_arrayv_quality)(v_arrayv_level))letv_abs_context=v_tuple"abstract_universe_context"[|v_pair(v_arrayv_name)(v_arrayv_name);v_cstrs|]letv_context_set=v_tuple"universe_context_set"[|v_hsetv_level;v_cstrs|](** kernel/term *)letv_sort=v_sum"sort"3(*SProp, Prop, Set*)[|[|v_univ(*Type*)|];[|v_qvar;v_univ(*QSort*)|]|]letv_relevance=v_sum"relevance"2[|[|v_qvar|]|]letv_binder_annotx=v_tuple"binder_annot"[|x;v_relevance|]letv_puniversesv=v_tuple"punivs"[|v;v_instance|]letv_caseinfo=letv_cstyle=v_enum"case_style"5inletv_cprint=v_tuple"case_printing"[|v_cstyle|]inv_tuple"case_info"[|v_ind;v_int;v_arrayv_int;v_arrayv_int;v_cprint|]letv_cast=v_enum"cast_kind"3letv_proj_repr=v_tuple"projection_repr"[|v_ind;v_int;v_int;v_cst|]letv_proj=v_tuple"projection"[|v_proj_repr;v_bool|]letv_uint63=ifSys.word_size==64thenv_intelsev_int64letv_constr=fix(funv_constr->letv_prec=v_tuple_c("prec_declaration",[|v_array(v_binder_annotv_name);v_arrayv_constr;v_arrayv_constr|])inletv_fix=v_tuple_c("pfixpoint",[|v_tuple_c("fix2",[|v_arrayv_int;v_int|]);v_prec|])inletv_cofix=v_tuple_c("pcofixpoint",[|v_int;v_prec|])inletv_case_invert=v_sum_c("case_inversion",1,[|[|v_arrayv_constr|]|])inletv_case_branch=v_tuple_c("case_branch",[|v_array(v_binder_annotv_name);v_constr|])inletv_case_return=v_tuple_c("case_return",[|v_tuple_c("case_return'",[|v_array(v_binder_annotv_name);v_constr|]);v_relevance|])inv_sum_c("constr",0,[|[|v_int|];(* Rel *)[|v_id|];(* Var *)[|v_fail"Meta"|];(* Meta *)[|v_fail"Evar"|];(* Evar *)[|v_sort|];(* Sort *)[|v_constr;v_cast;v_constr|];(* Cast *)[|v_binder_annotv_name;v_constr;v_constr|];(* Prod *)[|v_binder_annotv_name;v_constr;v_constr|];(* Lambda *)[|v_binder_annotv_name;v_constr;v_constr;v_constr|];(* LetIn *)[|v_constr;v_arrayv_constr|];(* App *)[|v_puniversesv_cst|];(* Const *)[|v_puniversesv_ind|];(* Ind *)[|v_puniversesv_cons|];(* Construct *)[|v_caseinfo;v_instance;v_arrayv_constr;v_case_return;v_case_invert;v_constr;v_arrayv_case_branch|];(* Case *)[|v_fix|];(* Fix *)[|v_cofix|];(* CoFix *)[|v_proj;v_relevance;v_constr|];(* Proj *)[|v_uint63|];(* v_int *)[|v_float64|];(* Float *)[|v_string|];(* v_string *)[|v_instance;v_arrayv_constr;v_constr;v_constr|](* v_array *)|]))letv_rdecl=v_sum"rel_declaration"0[|[|v_binder_annotv_name;v_constr|];(* LocalAssum *)[|v_binder_annotv_name;v_constr;v_constr|]|](* LocalDef *)letv_rctxt=v_listv_rdeclletv_ndecl=v_sum"named_declaration"0[|[|v_binder_annotv_id;v_constr|];(* LocalAssum *)[|v_binder_annotv_id;v_constr;v_constr|]|](* LocalDef *)letv_nctxt=v_listv_ndeclletv_section_ctxt=v_enum"emptylist"1(** kernel/mod_subst *)letv_univ_abstractedv=v_tuple"univ_abstracted"[|v;v_abs_context|]letv_delta_hint=v_sum"delta_hint"0[|[|v_int;v_opt(v_univ_abstractedv_constr)|];[|v_kn|]|]letv_resolver=v_tuple"delta_resolver"[|v_mapv_mpv_mp;v_hmapv_knv_delta_hint|]letv_mp_resolver=v_tuple""[|v_mp;v_resolver|]letv_subst=v_annot_c("substitution",v_mapv_mpv_mp_resolver)(** kernel/lazyconstr *)letv_abstr_info=v_tuple_c("abstr_info",[|v_nctxt;v_abs_context;v_instance|])letv_abstr_inst_info=v_tuple_c("abstr_inst_info",[|v_listv_id;v_instance|])letv_expand_info=v_tuple_c("expand_info",[|v_hmapv_cstv_abstr_inst_info;v_hmapv_cstv_abstr_inst_info|])letv_cooking_info=v_tuple_c("cooking_info",[|v_expand_info;v_abstr_info|])letv_opaque=v_sum"opaque"0[|[|v_listv_subst;v_listv_cooking_info;v_dp;v_int|]|](** kernel/declarations *)letv_conv_level=v_sum"conv_level"2[|[|v_int|]|]letv_oracle=v_tuple"oracle"[|v_mapv_idv_conv_level;v_hmapv_cstv_conv_level;v_hmapv_proj_reprv_conv_level;v_predv_id;v_predv_cst;v_predv_proj_repr;|]letv_template_arity=v_tuple"template_arity"[|v_sort|]letv_template_universes=v_tuple"template_universes"[|v_listv_bool;v_context_set|]letv_primitive=v_enum"primitive"63(* Number of constructors of the CPrimitives.t type *)letv_cst_def=v_sum"constant_def"0[|[|v_optv_int|];[|v_constr|];[|v_opaque|];[|v_primitive|];[|v_bool|]|]letv_typing_flags=v_tuple"typing_flags"[|v_bool;v_bool;v_bool;v_oracle;v_bool;v_bool;v_bool;v_bool;v_bool;v_bool;v_bool|]letv_univs=v_sum"universes"1[|[|v_abs_context|]|]letv_vm_reloc_table=v_array(v_pairv_intv_int)letv_vm_annot_switch=v_tuple"vm_annot_switch"[|v_vm_reloc_table;v_bool;v_int|]letv_vm_caml_prim=v_enum"vm_caml_prim"6letv_non_subst_reloc=v_sum"vm_non_subst_reloc"0[|[|v_sort|];[|v_fail"Evar"|];[|v_int|];[|v_instance|];[|v_any|];(* contains a Vmvalues.value *)[|v_uint63|];[|v_float64|];[|v_string|];[|v_vm_annot_switch|];[|v_vm_caml_prim|];|]letv_reloc=v_sum"vm_reloc"0[|[|v_ind|];[|v_cst|];[|v_int|];|]letv_vm_patches=v_tuple"vm_patches"[|v_arrayv_reloc|]letv_vm_pbody_codeindex=v_sum"pbody_code"1[|[|v_arrayv_bool;index;v_vm_patches|];[|v_cst|];|]letv_vm_index=v_pairv_dpv_intletv_vm_indirect_code=v_vm_pbody_codev_vm_indexletv_vm_emitcodes=v_stringletv_vm_fv_elem=v_sum"vm_fv_elem"0[|[|v_id|];[|v_int|]|]letv_vm_fv=v_arrayv_vm_fv_elemletv_vm_positions=v_stringletv_vm_to_patch=v_tuple"vm_to_patch"[|v_vm_emitcodes;v_vm_fv;v_vm_positions;v_arrayv_non_subst_reloc|]letv_cb=v_tuple"constant_body"[|v_section_ctxt;v_instance;v_cst_def;v_constr;v_relevance;v_optv_vm_indirect_code;v_univs;v_bool;v_typing_flags|]letv_recarg_type=v_sum"recarg_type"0[|[|v_ind|](* Mrec *);[|v_cst|](* NestedPrimitive *)|]letv_recarg=v_sum"recarg"1(* Norec *)[|[|v_recarg_type|](* Mrec *)|]letv_wfp=fix(funv_wfp->v_sum_c("wf_paths",0,[|[|v_int;v_int|];(* Rtree.Param *)[|v_recarg;v_array(v_arrayv_wfp)|];(* Rtree.Node *)[|v_int;v_arrayv_wfp|](* Rtree.Rec *)|]))letv_mono_ind_arity=v_tuple"monomorphic_inductive_arity"[|v_constr;v_sort|]letv_ind_arity=v_sum"inductive_arity"0[|[|v_mono_ind_arity|];[|v_template_arity|]|]letv_squash_info=v_sum"squash_info"1[|[|v_setv_quality|]|]letv_one_ind=v_tuple"one_inductive_body"[|v_id;v_rctxt;v_ind_arity;v_arrayv_id;v_arrayv_constr;v_int;v_int;v_optv_squash_info;v_array(v_pairv_rctxtv_constr);v_arrayv_int;v_arrayv_int;v_wfp;v_relevance;v_int;v_int;v_vm_reloc_table|]letv_finite=v_enum"recursivity_kind"3letv_record_info=v_sum"record_info"2[|[|v_array(v_tuple"record"[|v_id;v_arrayv_id;v_arrayv_relevance;v_arrayv_constr|])|]|]letv_ind_pack=v_tuple"mutual_inductive_body"[|v_arrayv_one_ind;v_record_info;v_finite;v_int;v_section_ctxt;v_instance;v_int;v_int;v_rctxt;v_univs;(* universes *)v_optv_template_universes;v_opt(v_arrayv_variance);v_opt(v_arrayv_variance);v_optv_bool;v_typing_flags|]letv_prim_ind=v_enum"prim_ind"6(* Number of "Register ... as kernel.ind_..." in Primv_int63.v and PrimFloat.v *)letv_prim_type=v_enum"prim_type"4(* Number of constructors of prim_type in "kernel/cPrimitives.ml" *)letv_retro_action=v_sum"retro_action"0[|[|v_prim_ind;v_ind|];[|v_prim_type;v_cst|];|]letv_retroknowledge=v_sum"module_retroknowledge"0[|[|v_listv_retro_action|]|]letv_puniv=v_optv_intletv_pqvar=v_optv_intletv_quality_pattern=v_sum"quality_pattern"0[|[|v_pqvar|];[|v_constant_quality|]|]letv_instance_mask=v_pair(v_arrayv_quality_pattern)(v_arrayv_puniv)letv_sort_pattern=v_sum_c("sort_pattern",3,[|[|v_puniv|];(* PSType *)[|v_pqvar;v_puniv|](* PSQSort *)|])let[_v_hpattern;v_elimination;_v_head_elim;_v_patarg]:_Vector.t=mfix[();();();()](fun[v_hpattern;v_elimination;v_head_elim;v_patarg]->letv_hpattern=v_sum_c("head_pattern",0,[|[|v_int|];(* PHRel *)[|v_sort_pattern|];(* PHSort *)[|v_cst;v_instance_mask|];(* PHSymbol *)[|v_ind;v_instance_mask|];(* PHInd *)[|v_cons;v_instance_mask|];(* PHConstr *)[|v_uint63|];(* PHv_int *)[|v_float64|];(* PHFloat *)[|v_string|];(* PHv_string *)[|v_arrayv_patarg;v_patarg|];(* PHLambda *)[|v_arrayv_patarg;v_patarg|];(* PHProd *)|])andv_elimination=v_sum_c("pattern_elimination",0,[|[|v_arrayv_patarg|];(* PEApp *)[|v_ind;v_instance_mask;v_patarg;v_arrayv_patarg|];(* PECase *)[|v_proj|];(* PEProj *)|])andv_head_elim=v_tuple_c("head*elims",[|v_hpattern;v_listv_elimination|])andv_patarg=v_sum_c("pattern_argument",1,[|[|v_int|];(* EHole *)[|v_head_elim|];(* ERigid *)|])in[v_hpattern;v_elimination;v_head_elim;v_patarg])letv_rewrule=v_tuple"rewrite_rule"[|v_tuple"nvars"[|v_int;v_int;v_int|];v_pairv_instance_mask(v_listv_elimination);v_constr|]letv_rrb=v_tuple"rewrite_rules_body"[|v_list(v_pairv_cstv_rewrule)|]letv_module_with_decl=v_sum"with_declaration"0[|[|v_listv_id;v_mp|];[|v_listv_id;v_pairv_constr(v_optv_abs_context)|];|]letv_mae=fix(funv_mae->v_sum_c("module_alg_expr",0,[|[|v_mp|];(* SEBident *)[|v_mae;v_mp|];(* SEBapply *)[|v_mae;v_module_with_decl|](* SEBwith *)|]))let[_v_sfb;_v_struc;_v_sign;_v_mexpr;_v_impl;v_module;_v_modtype]:_Vector.t=mfix[();();();();();();()](fun[v_sfb;v_struc;v_sign;v_mexpr;v_impl;v_module;v_modtype]->letv_noimpl=v_unitinletv_sfb=v_sum_c("struct_field_body",0,[|[|v_cb|];(* SFBconst *)[|v_ind_pack|];(* SFBmind *)[|v_rrb|];(* SFBrules *)[|v_module|];(* SFBmodule *)[|v_modtype|](* SFBmodtype *)|])andv_struc=v_list(v_tuple_c("label*sfb",[|v_id;v_sfb|]))andv_sign=v_sum_c("module_sign",0,[|[|v_struc|];(* NoFunctor *)[|v_uid;v_modtype;v_sign|]|])(* MoreFunctor *)andv_mexpr=v_sum_c("module_expr",0,[|[|v_mae|];(* MENoFunctor *)[|v_mexpr|]|])(* MEMoreFunctor *)andv_impl=v_sum_c("module_impl",2,(* Abstract, FullStruct *)[|[|v_mexpr|];(* Algebraic *)[|v_struc|]|])(* Struct *)andv_module=v_tuple_c("module_body",[|v_mp;v_sum_c("when_mod_body",0,[|[|v_impl|]|]);v_sign;v_optv_mexpr;v_resolver;v_retroknowledge|])andv_modtype=v_tuple_c("module_type_body",[|v_mp;v_noimpl;v_sign;v_optv_mexpr;v_resolver;v_unit|])in[v_sfb;v_struc;v_sign;v_mexpr;v_impl;v_module;v_modtype])(** kernel/safe_typing *)letv_vodigest=v_sum_c("module_impl",0,[|[|v_string|];[|v_string;v_string|]|])letv_deps=v_array(v_tuple"dep"[|v_dp;v_vodigest|])letv_flags=v_tuple"flags"[|v_bool|](* Allow Rewrite Rules *)letv_compiled_lib=v_tuple"compiled"[|v_dp;v_module;v_context_set;v_deps;v_flags|](** Toplevel structures in a vo (see Cic.mli) *)letv_libsum=v_tuple_c("summary",[|v_dp;v_deps;v_string;v_any|])letv_lib=v_tuple_c("library",[|v_compiled_lib;v_any;v_any|])letv_delayed_universes=v_sum_c("delayed_universes",0,[|[|v_unit|];[|v_context_set|]|])letv_opaquetable=v_array(v_opt(v_pairv_constrv_delayed_universes))letv_vmlib=v_tuple"vmlibrary"[|v_dp;v_arrayv_vm_to_patch|]