12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970(***************************************************************************)(* This file is part of the third-party OCaml library `smtml`. *)(* Copyright (C) 2023-2024 formalsec *)(* *)(* This program is free software: you can redistribute it and/or modify *)(* it under the terms of the GNU General Public License as published by *)(* the Free Software Foundation, either version 3 of the License, or *)(* (at your option) any later version. *)(* *)(* This program 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 General Public License for more details. *)(* *)(* You should have received a copy of the GNU General Public License *)(* along with this program. If not, see <https://www.gnu.org/licenses/>. *)(***************************************************************************)includeOptimizer_intfletsolver_time=ref0.0let(let+)of=Option.mapfomoduleMake(M:Mappings_intf.S)=structmoduleO=M.Optimizertypet=M.optimizeletcreate():t=O.make()letpush(opt:t):unit=O.pushoptletpop(opt:t):unit=O.popoptletadd(opt:t)(es:Expr.tlist):unit=O.addoptesletprotect(opt:t)(f:unit->'a):'a=pushopt;letresult=f()inpopopt;resultletcheck(opt:t)=Utils.run_and_time_call~use:(funtime->solver_time:=!solver_time+.time)(fun()->O.checkopt)letmodelopt=let+model=O.modeloptinM.values_of_modelmodelletmaximize(opt:t)(e:Expr.t):Value.toption=ignore@@O.maximizeopte;matchcheckoptwith|`Sat->let+model=O.modeloptinM.valuemodele|_->Noneletminimize(opt:t)(e:Expr.t):Value.toption=ignore@@O.minimizeopte;matchcheckoptwith|`Sat->let+model=O.modeloptinM.valuemodele|_->NoneendmoduleZ3=Make(Z3_mappings)