123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140(************************************************************************)(* * 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) *)(************************************************************************)openUtilopenNamesletmake_dirl=DirPath.make(List.rev_mapId.of_stringl)(************************************************************************)(* Rocq reference API *)(************************************************************************)letrocq=Libnames.rocq_init_string(* "Corelib" *)letinit_dir=[rocq;"Init"]letjmeq_module_name=["Stdlib";"Logic";"JMeq"]lettable:GlobRef.tCString.Map.tref=Summary.ref~name:"rocqlib_registered"CString.Map.emptyletget_lib_refs()=CString.Map.bindings!tablelethas_refs=CString.Map.mems!tableletcheck_refsgr=matchCString.Map.finds!tablewith|r->GlobRef.UserOrd.equalrgr|exceptionNot_found->falseletcheck_ind_refsind=check_refs(GlobRef.IndRefind)exceptionNotFoundRefofstringlet()=CErrors.register_handler(function|NotFoundRefs->SomePp.(str"not found in table: "++strs)|_->None)letlib_refs=tryCString.Map.finds!tablewithNot_found->raise(NotFoundRefs)letlib_ref_opts=CString.Map.find_opts!tableletadd_refsc=table:=CString.Map.addsc!tableletcache_ref(s,c)=add_refsclet(inRocqlibRef:Libobject.locality*(string*GlobRef.t)->Libobject.obj)=letopenLibobjectindeclare_object@@object_with_locality"COQLIBREF"~cache:cache_ref~subst:(Someident_subst_function)~discharge:(funx->x)(** Replaces a binding ! *)letregister_reflocalsc=Lib.add_leaf@@inRocqlibRef(local,(s,c))(************************************************************************)(* Generic functions to find Rocq objects *)(* For tactics/commands requiring vernacular libraries *)letcheck_required_libraryd=letdir=make_dirdintrylet_:Declarations.module_body=Global.lookup_module(ModPath.MPfiledir)in()withNot_found->letin_current_dir=matchLib.current_mp()with|MPfiledp->DirPath.equaldirdp|_->falseinifnotin_current_dirthenCErrors.user_errPp.(str"Library "++DirPath.printdir++str" has to be required first.")(************************************************************************)(* Specific Rocq objects *)(************************************************************************)letlogic_module_name=init_dir@["Logic"]letdatatypes_module_name=init_dir@["Datatypes"](** Identity *)(* Sigma data *)typerocq_sigma_data={proj1:GlobRef.t;proj2:GlobRef.t;elim:GlobRef.t;intro:GlobRef.t;typ:GlobRef.t}letbuild_sigma_genstr={typ=lib_ref("core."^str^".type");elim=lib_ref("core."^str^".rect");intro=lib_ref("core."^str^".intro");proj1=lib_ref("core."^str^".proj1");proj2=lib_ref("core."^str^".proj2");}letbuild_prod()=build_sigma_gen"prod"letbuild_sigma()=build_sigma_gen"sig"letbuild_sigma_type()=build_sigma_gen"sigT"(* Equalities *)typerocq_eq_data={eq:GlobRef.t;ind:GlobRef.t;refl:GlobRef.t;sym:GlobRef.t;trans:GlobRef.t;congr:GlobRef.t}(* Leibniz equality on Type *)letbuild_eqdata_genstr={eq=lib_ref("core."^str^".type");ind=lib_ref("core."^str^".ind");refl=lib_ref("core."^str^".refl");sym=lib_ref("core."^str^".sym");trans=lib_ref("core."^str^".trans");congr=lib_ref("core."^str^".congr");}letbuild_rocq_eq_data()=build_eqdata_gen"eq"letbuild_rocq_jmeq_data()=build_eqdata_gen"JMeq"letbuild_rocq_identity_data()=build_eqdata_gen"identity"