123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114(**************************************************************************)(* *)(* VSCoq *)(* *)(* 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. *)(* *)(**************************************************************************)openPrintingtypegoal={id:int;hypotheses:pplist;goal:pp;}[@@derivingyojson]typet={goals:goallist;shelvedGoals:goallist;givenUpGoals:goallist;}[@@derivingyojson]openPrintermoduleCompactedDecl=Context.Compacted.Declarationletmk_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'envinlethyp=pr_ecompacted_declenvsigmadin(env',hyp::l)inlet(_env,hyps)=Context.Compacted.foldmk_hyp(Termops.compact_named_contextsigma(EConstr.named_contextenv))~init:(min_env,[])in{id;hypotheses=List.rev_mappp_of_coqpphyps;goal=pp_of_coqppccl;}letmk_goal_diffdiff_goal_mapenvsigmag=letid=Evar.reprginletog_s=Proof_diffs.map_goalgdiff_goal_mapinlet(hyps,ccl)=Proof_diffs.diff_goal?og_s(Proof_diffs.make_goalenvsigmag)in{id;hypotheses=List.rev_mappp_of_coqpphyps;goal=pp_of_coqppccl;}letproof_of_statest=matchst.Vernacstate.interp.lemmaswith|None->None|Somelemmas->Some(lemmas|>Vernacstate.LemmaStack.with_top~f:Declare.Proof.get)(* The Coq 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_proof~previousdiff_modest=Vernacstate.unfreeze_full_statest;matchproof_of_statestwith|None->None|Someproof->letmk_goalenvsigmag=matchdiff_modewith|Settings.Goals.Diff.Mode.Off->mk_goalenvsigmag|_->beginset_diff_modediff_mode;matchOption.bindpreviousproof_of_statewith|None->mk_goalenvsigmag|Someold_proof->letdiff_goal_map=Proof_diffs.make_goal_mapold_proofproofinmk_goal_diffdiff_goal_mapenvsigmagendinletenv=Global.env()inletproof_data=Proof.dataproofinletsigma=proof_data.sigmainletgoals=List.map(mk_goalenvsigma)proof_data.goalsinletshelvedGoals=List.map(mk_goalenvsigma)(Evd.shelfsigma)inletgivenUpGoals=List.map(mk_goalenvsigma)(Evar.Set.elements@@Evd.given_upsigma)inSome{goals;shelvedGoals;givenUpGoals;}