123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102(******************************************************************************)(* This file is part of Waterproof-lib. *)(* *)(* Waterproof-lib 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. *)(* *)(* Waterproof-lib 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 Waterproof-lib. If not, see <https://www.gnu.org/licenses/>. *)(* *)(******************************************************************************)openHintsopenSummaryopenExceptionsopenHint_dataset_declarationsopenProofutils(**
Contains the hint dataset that is currently loaded
*)letloaded_hint_dataset:stringlistref=ref~name:"loaded_hint_dataset"[](**
Dictionary with dataset names as keys and datasets as values
*)letexisting_datasets:hint_datasetStringMap.tref=ref~name:"existing_datasets"@@List.fold_left(fundict(name,dataset)->StringMap.addnamedatasetdict)StringMap.empty[("Empty",empty);("Core",core);("Algebra",algebra);("Integers",integers);("RealsAndIntegers",reals_and_integers);("Sets",sets);("Intuition",intuition);("ClassicalEpsilon",classical_epsilon)](**
Adds a dataset to the currently loaded hint datasets
*)letload_dataset(hint_dataset_name:string):unit=ifStringMap.memhint_dataset_name!existing_datasetsthenbeginifnot@@List.memhint_dataset_name!loaded_hint_datasetthenloaded_hint_dataset:=hint_dataset_name::!loaded_hint_datasetendelsethrow(NonExistingDatasethint_dataset_name)(**
Removes a dataset to the currently loaded hint datasets
*)letremove_dataset(hint_dataset_name:string):unit=loaded_hint_dataset:=List.filter(fundataset->dataset<>hint_dataset_name)!loaded_hint_dataset(**
Clears all the currently loaded datasets
*)letclear_dataset():unit=loaded_hint_dataset:=["Empty"](**
Creates a new empty dataset from a given name
*)letcreate_new_dataset(dataset_name:string):unit=ifStringMap.memdataset_name!existing_datasetsthenthrow(NonExistingDatasetdataset_name)(* TODO *)elsebeginexisting_datasets:=StringMap.adddataset_name(new_datasetdataset_name)!existing_datasetsend(**
Sets the databases of a given {! database_type} in a given dataset
*)letpopulate_dataset(dataset_name:string)(database_type:database_type)(databases:stringlist):unit=existing_datasets:=StringMap.updatedataset_name(function|None->throw(NonExistingDatasetdataset_name)|Somedataset->Some(set_databasesdatasetdatabase_typedatabases))!existing_datasets(**
Converts a name into the corresponding hint dataset
*)letdataset_of_name(name:string):hint_dataset=tryStringMap.findname!existing_datasetswithNot_found->throw(NonExistingDatasetname)(**
Merges two lists without duplicates
*)letrecmerge(list1:'alist)(list2:'alist):'alist=matchlist1with|[]->list2|x::pwhenList.memxlist2->mergeplist2|x::p->mergep(x::list2)(**
Returns the list of databases of the current loaded dataset for the given {! Hint_dataset_declarations.database_type}
*)letget_current_databases(database_type:database_type):hint_db_namelist=letdatasets=List.mapdataset_of_name!loaded_hint_datasetinList.fold_left(funaccdataset->mergeacc(get_databasesdatasetdatabase_type))[]datasets