1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495(************************************************************************)(* * The Coq Proof Assistant / The Coq Development Team *)(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)(* <O___,, * (see CREDITS file for the list of authors) *)(* \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) *)(************************************************************************)(************************************************************************)(* Coq serialization API/Plugin *)(* Copyright 2016-2018 MINES ParisTech -- Dual License LGPL 2.1 / GPL3+ *)(* Written by: Emilio J. Gallego Arias *)(************************************************************************)(* Status: Very Experimental *)(************************************************************************)type'ahyp=(Names.Id.tlist*'aoption*'a)typeinfo={evar:Evar.t;name:Names.Id.toption}type'areified_goal={info:info;ty:'a;hyp:'ahyplist}type'aser_goals={goals:'alist;stack:('alist*'alist)list;bullet:Pp.toption;shelf:'alist;given_up:'alist}(** XXX: Do we need to perform evar normalization? *)moduleCDC=Context.Compacted.Declarationtypecdcl=Constr.compacted_declarationletto_tupleppx:cdcl->(Names.Id.tlist*'pcoption*'pc)=letopenCDCinfunction|LocalAssum(idl,tm)->(List.mapContext.binder_nameidl,None,ppxtm)|LocalDef(idl,tdef,tm)->(List.mapContext.binder_nameidl,Some(ppxtdef),ppxtm)(** gets a hypothesis *)letget_hyp(ppx:Constr.t->'pc)(_sigma:Evd.evar_map)(hdecl:cdcl):(Names.Id.tlist*'pcoption*'pc)=to_tupleppxhdecl(** gets the constr associated to the type of the current goal *)letget_goal_type(ppx:Constr.t->'pc)(sigma:Evd.evar_map)(g:Goal.goal)=ppx@@EConstr.to_constr~abort_on_undefined_evars:falsesigma(Goal.V82.conclsigmag)letbuild_infosigmag={evar=g;name=Evd.evar_identgsigma}(** Generic processor *)letprocess_goal_genppxsigmag:'areified_goal=letenv=Goal.V82.envsigmagin(* why is compaction neccesary... ? [eg for better display] *)letctx=Termops.compact_named_context(Environ.named_contextenv)inletppx=ppxenvsigmainlethyp=List.map(get_hypppxsigma)ctxinletinfo=build_infosigmagin{info;ty=get_goal_typeppxsigmag;hyp}letif_not_empty(pp:Pp.t)=ifPp.(reprpp=Ppcmd_empty)thenNoneelseSomeppletget_goals_gen(ppx:Environ.env->Evd.evar_map->Constr.t->'a)~docsid:'areified_goalser_goalsoption=matchStm.state_of_id~docsidwith|`Valid(Some{Vernacstate.lemmas=Somelemmas;_})->letproof=Vernacstate.LemmaStack.with_toplemmas~f:(funpstate->Declare.Proof.getpstate)inlet{Proof.goals;stack;sigma;_}=Proof.dataproofinletppx=List.map(process_goal_genppxsigma)inSome{goals=ppxgoals;stack=List.map(fun(g1,g2)->ppxg1,ppxg2)stack;bullet=if_not_empty@@Proof_bullet.suggestproof;shelf=Evd.shelfsigma|>ppx;given_up=Evd.given_upsigma|>Evar.Set.elements|>ppx}|`Expired|`Error_|`Valid_->Noneletget_goals=get_goals_gen(fun__x->x)letget_egoals=get_goals_gen(funenvevdec->Constrextern.extern_constr~inctx:trueenvevdEConstr.(of_constrec))