123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131(**************************************************************************)(* *)(* This file is part of WP plug-in of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* CEA (Commissariat a l'energie atomique et aux energies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)openLangopenConditionsopenTactical(* -------------------------------------------------------------------------- *)(* --- Choice Tactical --- *)(* -------------------------------------------------------------------------- *)classchoice=objectinheritTactical.make~id:"Wp.choice"~title:"Choice"~descr:"Select a Goal Alternative"~params:[]methodselect_feedback(s:Tactical.selection)=matchswith|Inside(Goalp,q)->beginmatchF.e_exprpwith|Qed.Logic.OrqswhenList.memqqqs->Applicable(fun(hs,_)->["Choice",(hs,F.p_boolq)])|_->Not_applicableend|Empty|Compose_|Clause_|Inside(Step_,_)|Multi_->Not_applicableendclassabsurd=objectinheritTactical.make~id:"Wp.absurd"~title:"Absurd"~descr:"Contradict the Goal or an Hypothesis"~params:[]methodselect_feedback(s:Tactical.selection)=matchswith|Empty|Compose_|Inside_|Multi_->Not_applicable|Clause(Goal_)->letabsurd(seq,goal)=letgoal=F.p_notgoalinletstep=Conditions.step~descr:"Absurd"(Whengoal)inlethyps=Conditions.listseqinlethyps=Conditions.sequence(hyps@[step])in["Absurd",(hyps,F.p_false)]inApplicableabsurd|Clause(Steps)->beginmatchs.conditionwith|Havep|Whenp|Corep|Initp|Typep->letabsurdseq=letemp=Conditions.(step(HaveF.p_true))inletseq=Conditions.replace~at:s.idempseqin["Absurd",(fstseq,F.p_notp)]inApplicableabsurd|Branch_|Either_|State_->Not_applicableendendclasscontrapose=objectinheritTactical.make~id:"Wp.contrapose"~title:"Contrapose"~descr:"Swap and Negate Hypothesis with Conclusion"~params:[]methodselect_feedback(s:Tactical.selection)=matchswith|Empty|Compose_|Inside_|Clause(Goal_)|Multi_->Not_applicable|Clause(Steps)->beginmatchs.conditionwith|Havep|Whenp|Corep|Initp|Typep->letcontrapose(hs,goal)=letdescr="Contrapose"inletgoal=F.p_notgoalinletgoal=Conditions.(step~descr(Havegoal))inleths=Conditions.replace~at:s.idgoal(hs,F.p_false)in["Contrapose",(fsths,F.p_notp)]inApplicablecontrapose|Branch_|Either_|State_->Not_applicableendendmoduleChoice=structlettactical=Tactical.export(newchoice)letstrategy=Strategy.maketactical~arguments:[]endmoduleAbsurd=structlettactical=Tactical.export(newabsurd)letstrategy=Strategy.maketactical~arguments:[]endmoduleContrapose=structlettactical=Tactical.export(newcontrapose)letstrategy=Strategy.maketactical~arguments:[]end