Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file enum.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198(******************************************************************************)(* *)(* 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 *)(* *)(******************************************************************************)openOptionsopenFormatopenSigmoduleSy=SymbolsmoduleE=ExprmoduleHs=Hstringtype'aabstract=ConsofHs.t*Ty.t|Alienof'amoduletypeALIEN=sigincludeSig.Xvalembed:rabstract->rvalextract:r->(rabstract)optionendmoduleShostak(X:ALIEN)=structtypet=X.rabstracttyper=X.rletname="Sum"letis_mine_symbsyty=matchsy,tywith|Sy.Op(Sy.Constr_),Ty.Tsum_->true|_->falseletfully_interpreted_=truelettype_info=function|Cons(_,ty)->ty|Alienx->X.type_infoxletcolor_=assertfalse(*BISECT-IGNORE-BEGIN*)moduleDebug=structletprintfmt=function|Cons(hs,_)->fprintffmt"%s"(Hs.viewhs)|Alienx->fprintffmt"%a"X.printxletsolve_bisab=ifdebug_sum()thenfprintffmt"[Sum] we solve %a = %a@."X.printaX.printbletsolve_bis_resultres=ifdebug_sum()thenmatchreswith|[p,v]->fprintffmt"\twe get: %a |-> %a@."X.printpX.printv|[]->fprintffmt"\tthe equation is trivial@."|_->assertfalseletsolve_bis_unsolvable()=ifdebug_sum()thenfprintffmt"\tthe equation is unsolvable@."end(*BISECT-IGNORE-END*)letprint=Debug.printletembedr=matchX.extractrwith|Somec->c|None->Alienrletis_mine=function|Alienr->r|Cons_asc->X.embedcletcompare_minec1c2=matchc1,c2with|Cons(h1,ty1),Cons(h2,ty2)->letn=Hs.compareh1h2inifn<>0thennelseTy.comparety1ty2|Alienr1,Alienr2->X.str_cmpr1r2|Alien_,Cons_->1|Cons_,Alien_->-1letcomparexy=compare_mine(embedx)(embedy)letequals1s2=matchs1,s2with|Cons(h1,ty1),Cons(h2,ty2)->Hs.equalh1h2&&Ty.equalty1ty2|Alienr1,Alienr2->X.equalr1r2|Alien_,Cons_|Cons_,Alien_->falselethash=function|Cons(h,ty)->Hstring.hashh+19*Ty.hashty|Alienr->X.hashrletleaves_=[]letsubstpvc=letcr=is_minecinifX.equalpcrthenvelsematchcwith|Cons_->cr|Alienr->X.substpvrletmaket=matchE.term_viewtwith|E.Term{E.f=Sy.Op(Sy.Constrhs);xs=[];ty;_}->is_mine(Cons(hs,ty)),[]|_->assertfalseletsolveab=matchembeda,embedbwith|Cons(c1,_),Cons(c2,_)whenHs.equalc1c2->[]|Cons(_,_),Cons(_,_)->raiseUtil.Unsolvable|Cons_,Alienr2->[r2,a]|Alienr1,Cons_->[r1,b]|Alien_,Alien_->ifX.str_cmpab>0then[a,b]else[b,a]letsolve_bisab=Debug.solve_bisab;tryletres=solveabinDebug.solve_bis_resultres;reswithUtil.Unsolvable->Debug.solve_bis_unsolvable();raiseUtil.Unsolvableletabstract_selectorsvacc=is_minev,accletterm_extract_=None,falseletsolver1r2pb={pbwithsbt=List.rev_append(solve_bisr1r2)pb.sbt}letsolver1r2pb=ifOptions.timers()thentryTimers.exec_timer_startTimers.M_SumTimers.F_solve;letres=solver1r2pbinTimers.exec_timer_pauseTimers.M_SumTimers.F_solve;reswithe->Timers.exec_timer_pauseTimers.M_SumTimers.F_solve;raiseeelsesolver1r2pbletassign_value___=(* values of theory sum should be assigned by case_split *)Noneletchoose_adequate_model_rl=letl=List.filter(fun(_,r)->matchembedrwithCons_->true|_->false)linletr=matchlwith|(_,r)::l->List.iter(fun(_,x)->assert(X.equalxr))l;r|[]->(* We do this, because terms of some semantic values created
by CS are not created and added to UF *)matchembedrwithCons_->r|_->assertfalseinignore(flush_str_formatter());fprintfstr_formatter"%a"print(embedr);r,flush_str_formatter()end