123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116(************************************************************************)(* * The Coq Proof Assistant / The Coq 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;var_trstate:Id.Pred.t;cst_trstate:Cpred.t;}letempty={var_opacity=Id.Map.empty;cst_opacity=Cmap.empty;var_trstate=Id.Pred.full;cst_trstate=Cpred.full;}letget_strategy{var_opacity;cst_opacity;_}f=function|VarKeyid->(tryId.Map.findidvar_opacitywithNot_found->default)|ConstKeyc->(tryCmap.find(fc)cst_opacitywithNot_found->default)|RelKey_->Expandletset_strategy({var_opacity;cst_opacity;_}asoracle)kl=matchkwith|VarKeyid->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;}|ConstKeyc->letcst_opacity=ifis_defaultlthenCmap.removeccst_opacityelseCmap.addclcst_opacityinletcst_trstate=matchlwith|Opaque->Cpred.removecoracle.cst_trstate|_->Cpred.addcoracle.cst_trstatein{oraclewithcst_opacity;cst_trstate;}|RelKey_->CErrors.user_errPp.(str"set_strategy: RelKey")letfold_strategyf{var_opacity;cst_opacity;_}accu=letfvaridlvlaccu=f(VarKeyid)lvlaccuinletfcstcstlvlaccu=f(ConstKeycst)lvlaccuinletaccu=Id.Map.foldfvarvar_opacityaccuinCmap.foldfcstcst_opacityacculetget_transp_state{var_trstate;cst_trstate;_}={TransparentState.tr_var=var_trstate;tr_cst=cst_trstate}letdep_orderl2rk1k2=matchk1,k2with|RelKey_,RelKey_->l2r|RelKey_,(VarKey_|ConstKey_)->true|VarKey_,RelKey_->false|VarKey_,VarKey_->l2r|VarKey_,ConstKey_->true|ConstKey_,(RelKey_|VarKey_)->false|ConstKey_,ConstKey_->l2r(* Unfold the first constant only if it is "more transparent" than the
second one. In case of tie, use the recommended default. *)letoracle_orderfol2rk1k2=matchget_strategyofk1,get_strategyofk2with|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<n2letget_strategyo=get_strategyo(funx->x)