123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115(************************************************************************)(* * 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 SERAPI *)(* Copyright 2016-2019 MINES ParisTech -- LGPL 2.1+ *)(* Copyright 2019-2022 Inria -- LGPL 2.1+ *)(* Written by: Emilio J. Gallego Arias *)(************************************************************************)type'ahyp={names:Names.Id.tlist;def:'aoption;ty:'a}typeinfo={evar:Evar.t;name:Names.Id.toption}type'areified_goal={info:info;ty:'a;hyps:'ahyplist}type'agoals={goals:'alist;stack:('alist*'alist)list;bullet:Pp.toption;shelf:'alist;given_up:'alist}typereified_pp=Pp.treified_goalgoals(** XXX: Do we need to perform evar normalization? *)moduleCDC=Context.Compacted.Declarationtypecdcl=Constr.compacted_declarationletto_tupleppx:cdcl->'pchyp=letopenCDCinfunction|LocalAssum(idl,tm)->{names=List.mapContext.binder_nameidl;def=None;ty=ppxtm}|LocalDef(idl,tdef,tm)->{names=List.mapContext.binder_nameidl;def=Some(ppxtdef);ty=ppxtm}(** gets a hypothesis *)letget_hyp(ppx:Constr.t->'pc)(_sigma:Evd.evar_map)(hdecl:cdcl):'pchyp=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:Evar.t):_=ppx@@EConstr.to_constr~abort_on_undefined_evars:falsesigmaEvd.(evar_concl(findsigmag))letbuild_infosigmag={evar=g;name=Evd.evar_identgsigma}(** Generic processor *)letprocess_goal_genppxsigmag:'areified_goal=(* XXX This looks cumbersome *)letenv=Global.env()inletevi=Evd.findsigmaginletenv=Evd.evar_filtered_envenveviin(* why is compaction neccesary... ? [eg for better display] *)letctx=Termops.compact_named_context(Environ.named_contextenv)inletppx=ppxenvsigmainlethyps=List.map(get_hypppxsigma)ctx|>List.revinletinfo=build_infosigmagin{info;ty=get_goal_typeppxsigmag;hyps}(* let if_not_empty (pp : Pp.t) = if Pp.(repr pp = Ppcmd_empty) then None else
Some pp *)letpr_hyp(h:_hyp)=let{names;ty;def=_}=hinPp.(prlistNames.Id.printnames++str" : "++ty)letpr_hypshyps=Pp.(pr_vertical_listpr_hyphyps++fnl()++str"============================================"++fnl())letpr_goal~hyps(g:_reified_goal)=lethyps=ifhypsthenpr_hypsg.hypselsePp.mt()inPp.(hyps++g.ty)letpp_goals(g:_goals)=let{goals;stack=_;bullet=_;shelf=_;given_up=_}=ginmatchgoalswith|[]->Pp.str"No goals left"|g::gs->Pp.(v0(pr_goal~hyps:trueg)++cut()++prlist_with_sepcut(pr_goal~hyps:false)gs)