123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120(**************************************************************************)(* *)(* VSRocq *)(* *)(* Copyright INRIA and contributors *)(* (see version control and README file for authors & dates) *)(* *)(**************************************************************************)(* *)(* This file is distributed under the terms of the MIT License. *)(* See LICENSE file. *)(* *)(**************************************************************************)openPrintingopenLsp.TypesopenPpx_yojson_conv_lib.Yojson_conv.Primitivestypehypothesis={ids:stringlist;body:stringoption;_type:string;}[@@derivingyojson]typegoal={id:int;hypotheses:hypothesislist;goal:string;}[@@derivingyojson]typet={goals:goallist;shelvedGoals:goallist;givenUpGoals:goallist;unfocusedGoals:goallist;}[@@derivingyojson]openPrintermoduleCompactedDecl=Context.Compacted.Declarationletmk_pp_hypenvsigma(decl:EConstr.compacted_declaration)=letids,pbody,typ=matchdeclwith|CompactedDecl.LocalAssum(ids,typ)->ids,None,typ|CompactedDecl.LocalDef(ids,c,typ)->(* Force evaluation *)letpb=pr_leconstr_env~inctx:trueenvsigmacinletpb=ifEConstr.isCastsigmacthenPp.surroundpbelsepbinids,Somepb,typinletids=List.map(funid->Pp.string_of_ppcmds@@Ppconstr.pr_idid.Context.binder_name)idsinletbody=Option.mapPp.string_of_ppcmdspbodyinlettyp=pr_letype_envenvsigmatypinlet_type=Pp.string_of_ppcmdstypin{ids;body;_type}letmk_goalenvsigmag=letEvarInfoevi=Evd.findsigmaginletenv=Evd.evar_filtered_envenveviinletmin_env=Environ.reset_contextenvinletid=Evar.reprginletconcl=matchEvd.evar_bodyeviwith|Evar_empty->Evd.evar_conclevi|Evar_definedbody->Retyping.get_type_ofenvsigmabodyinletccl=pr_letype_env~goal_concl_style:trueenvsigmaconclinletmk_hypd(env,l)=letd'=CompactedDecl.to_named_contextdinletenv'=List.fold_rightEConstr.push_namedd'envinletRefl=EConstr.Unsafe.eqinlethyp=mk_pp_hypenvsigmadin(env',hyp::l)inlet(_env,hyps)=Context.Compacted.foldmk_hyp(Termops.compact_named_contextsigma(EConstr.named_contextenv))~init:(min_env,[])in{id;hypotheses=List.revhyps;goal=Pp.string_of_ppcmdsccl;}letproof_of_statest=matchst.Vernacstate.interp.lemmaswith|None->None|Somelemmas->Some(lemmas|>Vernacstate.LemmaStack.with_top~f:Declare.Proof.get)(* The Rocq diff API is so poorly designed that we have to imperatively set a
string option to control the behavior of `mk_goal_diff`. We do the required
plumbing here. *)letstring_of_diff_mode=function|Settings.Goals.Diff.Mode.Off->"off"|On->"on"|Removed->"removed"letset_diff_modediff_mode=Goptions.set_string_option_valueProof_diffs.opt_name@@string_of_diff_modediff_modeletget_proofst=Vernacstate.unfreeze_full_statest;matchproof_of_statestwith|None->None|Someproof->letenv=Global.env()inletproof_data=Proof.dataproofinletb_goals=Proof.background_subgoalsproofinletsigma=proof_data.sigmainletgoals=List.map(mk_goalenvsigma)proof_data.goalsinletunfocusedGoals=List.map(mk_goalenvsigma)b_goalsinletshelvedGoals=List.map(mk_goalenvsigma)(Evd.shelfsigma)inletgivenUpGoals=List.map(mk_goalenvsigma)(Evar.Set.elements@@Evd.given_upsigma)inSome{goals;shelvedGoals;givenUpGoals;unfocusedGoals;}