123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115(******************************************************************************)(* *)(* The Alt-Ergo theorem prover *)(* Copyright (C) 2006-2013 *)(* *)(* Sylvain Conchon *)(* Evelyne Contejean *)(* *)(* Francois Bobot *)(* Mohamed Iguernelala *)(* Stephane Lescuyer *)(* Alain Mebsout *)(* *)(* CNRS - INRIA - Universite Paris Sud *)(* *)(* This file is distributed under the terms of the Apache Software *)(* License version 2.0 *)(* *)(* ------------------------------------------------------------------------ *)(* *)(* Alt-Ergo: The SMT Solver For Software Verification *)(* Copyright (C) 2013-2018 --- OCamlPro SAS *)(* *)(* This file is distributed under the terms of the Apache Software *)(* License version 2.0 *)(* *)(******************************************************************************)openOptionsopenFormatmoduleE=ExprmoduleSE=E.SetmoduleSA=Set.Make(structtypet=E.t*Explanation.tletcompare(s1,_)(s2,_)=E.compares1s2end)moduleX=Shostak.CombinemoduleMX=Map.Make(structtypet=X.rletcompare=X.hash_cmpend)typet=(SE.t*SA.t)MX.ttyper=X.rletinter_tpl(x1,y1)(x2,y2)=Options.exec_thread_yield();SE.interx1x2,SA.intery1y2letunion_tpl(x1,y1)(x2,y2)=Options.exec_thread_yield();SE.unionx1x2,SA.uniony1y2letone,_=X.make(E.mk_term(Symbols.name"@bottom")[]Ty.Tint)letleavesr=matchX.leavesrwith[]->[one]|l->lletfindkm=tryMX.findkmwithNot_found->(SE.empty,SA.empty)letadd_termktmp=letg_t,g_a=findkmpinMX.addk(SE.addtg_t,g_a)mpletup_addgtrtlvs=letg=ifMX.memrtgthengelseMX.addrt(SE.empty,SA.empty)ginmatchE.term_viewtwith|E.Term{E.xs=[];_}->g|E.Term_->List.fold_left(fungx->add_termxtg)glvs|_->assertfalseletcongr_addglvs=matchlvswith[]->SE.empty|x::ls->List.fold_left(funaccy->SE.inter(fst(findyg))acc)(fst(findxg))lsletup_close_upgpv=letlvs=leavesvinletg_p=findpginList.fold_left(funggl->MX.addl(union_tplg_p(findlg))gg)glvsletcongr_close_upgptouched=letinter=function[]->(SE.empty,SA.empty)|rx::l->List.fold_left(funaccx->inter_tplacc(findxg))(findrxg)linList.fold_left(fun(st,sa)tch->union_tpl(st,sa)(inter(leavestch)))(findpg)touchedletprintg=ifdebug_use()thenbeginletstermsfmt=SE.iter(fprintffmt"%a "E.print)inletsatomsfmt=SA.iter(fun(a,e)->fprintffmt"%a %a"E.printaExplanation.printe)infprintffmt"@{<C.Bold>[use]@} gamma :\n";MX.iter(funt(st,sa)->fprintffmt"%a is used by {%a} and {%a}\n"X.printtstermsstsatomssa)gendletmem=MX.memletadd=MX.addletempty=MX.empty