123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146(************************************************************************)(* * 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) *)(************************************************************************)(* Created by Bruno Barras as part of the rewriting of the conversion
algorithm, Nov 2001 *)openNames(* Priority for the expansion of constant in the conversion test.
* Higher levels means that the expansion is less prioritary.
* (And Expand stands for -oo, and Opaque +oo.)
* The default value is [Level 100].
*)typelevel=Expand|Levelofint|Opaqueletpr_level=function|Expand->Pp.str"expand"|Level0->Pp.str"transparent"|Leveln->Pp.intn|Opaque->Pp.str"opaque"letdefault=Level0letis_default=function|Level0->true|_->falselettransparent=defaultletis_transparent=function|Level0->true|_->falsetypeoracle={var_opacity:levelId.Map.t;cst_opacity:levelCmap.t;prj_opacity:levelPRmap.t;var_trstate:Id.Pred.t;cst_trstate:Cpred.t;prj_trstate:PRpred.t;}letempty={var_opacity=Id.Map.empty;cst_opacity=Cmap.empty;prj_opacity=PRmap.empty;var_trstate=Id.Pred.full;cst_trstate=Cpred.full;prj_trstate=PRpred.full;}typeevaluable=|EvalVarRefofId.t|EvalConstRefofConstant.t|EvalProjectionRefofProjection.Repr.tletget_strategy{var_opacity;cst_opacity;prj_opacity;_}=function|EvalVarRefid->(tryId.Map.findidvar_opacitywithNot_found->default)|EvalConstRefc->(tryCmap.findccst_opacitywithNot_found->default)|EvalProjectionRefp->(tryPRmap.findpprj_opacitywithNot_found->default)letset_strategy({var_opacity;cst_opacity;prj_opacity;_}asoracle)kl=matchkwith|EvalVarRefid->letvar_opacity=ifis_defaultlthenId.Map.removeidvar_opacityelseId.Map.addidlvar_opacityinletvar_trstate=matchlwith|Opaque->Id.Pred.removeidoracle.var_trstate|_->Id.Pred.addidoracle.var_trstatein{oraclewithvar_opacity;var_trstate;}|EvalConstRefc->letcst_opacity=ifis_defaultlthenCmap.removeccst_opacityelseCmap.addclcst_opacityinletcst_trstate=matchlwith|Opaque->Cpred.removecoracle.cst_trstate|_->Cpred.addcoracle.cst_trstatein{oraclewithcst_opacity;cst_trstate;}|EvalProjectionRefp->letprj_opacity=ifis_defaultlthenPRmap.removepprj_opacityelsePRmap.addplprj_opacityinletprj_trstate=matchlwith|Opaque->PRpred.removeporacle.prj_trstate|_->PRpred.addporacle.prj_trstatein{oraclewithprj_opacity;prj_trstate}letfold_strategyf{var_opacity;cst_opacity;prj_opacity;_}accu=letfvaridlvlaccu=f(EvalVarRefid)lvlaccuinletfcstcstlvlaccu=f(EvalConstRefcst)lvlaccuinletfprjplvlaccu=f(EvalProjectionRefp)lvlaccuinletaccu=Id.Map.foldfvarvar_opacityaccuinletaccu=Cmap.foldfcstcst_opacityaccuinPRmap.foldfprjprj_opacityacculetget_transp_state{var_trstate;cst_trstate;prj_trstate;_}=letopenTransparentStatein{tr_var=var_trstate;tr_cst=cst_trstate;tr_prj=prj_trstate}letdep_orderl2rk1k2=matchk1,k2with|None,None->l2r|None,_->true|Some_,None->false|Somek1,Somek2->matchk1,k2with|EvalVarRef_,EvalVarRef_->l2r|EvalVarRef_,(EvalConstRef_|EvalProjectionRef_)->true|EvalConstRef_,EvalVarRef_->false|EvalConstRef_,EvalProjectionRef_->l2r|EvalConstRef_,EvalConstRef_->l2r|EvalProjectionRef_,EvalVarRef_->false|EvalProjectionRef_,EvalConstRef_->l2r|EvalProjectionRef_,EvalProjectionRef_->l2r(* Unfold the first constant only if it is "more transparent" than the
second one. In case of tie, use the recommended default. *)letoracle_orderol2rk1k2=lets1=matchk1withNone->Expand|Somek1->get_strategyok1inlets2=matchk2withNone->Expand|Somek2->get_strategyok2inmatchs1,s2with|Expand,Expand->dep_orderl2rk1k2|Expand,(Opaque|Level_)->true|(Opaque|Level_),Expand->false|Opaque,Opaque->dep_orderl2rk1k2|Level_,Opaque->true|Opaque,Level_->false|Leveln1,Leveln2->ifInt.equaln1n2thendep_orderl2rk1k2elsen1<n2