123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122(**************************************************************************)(* *)(* 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). *)(* *)(**************************************************************************)(* -------------------------------------------------------------------------- *)(* --- Why3 Config & Provers --- *)(* -------------------------------------------------------------------------- *)letcfg=lazybeginletextra_config=Wp_parameters.Why3ExtraConfig.get()intryWhy3.Whyconf.init_config~extra_configNonewithexn->Wp_parameters.abort"%a"Why3.Exn_printer.exn_printerexnendletversion=Why3.Config.versionletconfig()=Lazy.forcecfgletset_procs=Why3.Controller_itp.set_session_max_tasksletconfigure=lettodo=reftrueinbeginfun()->if!todothenbeginletcommands="why3"::Wp_parameters.Why3Flags.get()inletargs=Array.of_listcommandsinbegintry(* Ensure that an error message generating directly by why3 is
reported as coming from Why3, not from Frama-C. *)Why3.Getopt.commands:=commands;Why3.Getopt.parse_all(Why3.Debug.Args.[desc_debug;desc_debug_all;desc_debug_list])(funopt->raise(Arg.Bad("unknown option: "^opt)))argswithArg.Bads|Arg.Helps->Wp_parameters.abort"%s"send;ignore(Why3.Debug.Args.option_list());Why3.Debug.Args.set_flags_selected();todo:=falseendendtypet=Why3.Whyconf.proverletfind_opts=tryletconfig=Lazy.forcecfginletfilter=Why3.Whyconf.parse_filter_proversinSome((Why3.Whyconf.filter_one_proverconfigfilter).Why3.Whyconf.prover)with|Why3.Whyconf.ProverNotFound_|Why3.Whyconf.ParseFilterProver_|Why3.Whyconf.ProverAmbiguity_->Nonetypefallback=Exactoft|Fallbackoft|NotFoundletfind_fallbackname=matchfind_optnamewith|Someprv->Exactprv|None->(* Why3 should deal with this intermediate case *)matchfind_opt(String.lowercase_asciiname)with|Someprv->Exactprv|None->matchString.split_on_char','namewith|shortname::_::_->beginmatchfind_opt(String.lowercase_asciishortname)with|Someprv->Fallbackprv|None->NotFoundend|_->NotFoundletident_why3=Why3.Whyconf.prover_parseable_formatletident_wps=letname=Why3.Whyconf.prover_parseable_formatsinletprv=String.split_on_char','nameinString.concat":"prvlettitle?(version=true)p=ifversionthenPretty_utils.to_stringWhy3.Whyconf.print_proverpelsep.Why3.Whyconf.prover_nameletcompare=Why3.Whyconf.Prover.compareletis_mainstreamp=p.Why3.Whyconf.prover_altern=""letprovers()=Why3.Whyconf.Mprover.keys(Why3.Whyconf.get_provers(config()))letprovers_set():Why3.Whyconf.Sprover.t=Why3.Whyconf.Mprover.domain(Why3.Whyconf.get_provers(config()))letis_availablep=Why3.Whyconf.Mprover.memp(Why3.Whyconf.get_provers(config()))lethas_shortcutps=matchWhy3.Wstdlib.Mstr.find_opts(Why3.Whyconf.get_prover_shortcuts(config()))with|None->false|Somep'->Why3.Whyconf.Prover.equalpp'(* -------------------------------------------------------------------------- *)