123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315(******************************************************************************)(* *)(* 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 *)(* *)(******************************************************************************)openFormattypety_module=|M_None|M_Typing|M_Sat|M_Match|M_CC|M_UF|M_Arith|M_Arrays|M_Sum|M_Records|M_AC|M_Expr|M_Triggers|M_Simplexletmtagk=matchkwith|M_None->0|M_Typing->1|M_Sat->2|M_Match->3|M_CC->4|M_UF->5|M_Arith->6|M_Arrays->7|M_Sum->8|M_Records->9|M_AC->10|M_Expr->11|M_Triggers->12|M_Simplex->13letnb_mtag=14typety_function=|F_add|F_add_lemma|F_add_predicate|F_add_terms|F_are_equal|F_assume|F_class_of|F_leaves|F_make|F_m_lemmas|F_m_predicates|F_query|F_solve|F_subst|F_union|F_unsat|F_none|F_new_facts|F_apply_subst|F_instantiateletftagf=matchfwith|F_add->0|F_add_lemma->1|F_assume->2|F_class_of->3|F_leaves->4|F_make->5|F_m_lemmas->6|F_m_predicates->7|F_query->8|F_solve->9|F_subst->10|F_union->11|F_unsat->12|F_add_predicate->13|F_add_terms->14|F_are_equal->15|F_none->16|F_new_facts->17|F_apply_subst->18|F_instantiate->19letnb_ftag=20letstring_of_ty_modulek=matchkwith|M_None->"None"|M_Typing->"Typing"|M_Sat->"Sat"|M_Match->"Match"|M_CC->"CC"|M_UF->"UF"|M_Arith->"Arith"|M_Arrays->"Arrays"|M_Sum->"Sum"|M_Records->"Records"|M_AC->"AC"|M_Expr->"Expr"|M_Triggers->"Triggers"|M_Simplex->"Simplex"letstring_of_ty_functionf=matchfwith|F_add->"add"|F_add_lemma->"add_lemma"|F_assume->"assume"|F_class_of->"class_of"|F_leaves->"leaves"|F_make->"make"|F_m_lemmas->"m_lemmas"|F_m_predicates->"m_predicates"|F_query->"query"|F_solve->"solve"|F_subst->"subst"|F_union->"union"|F_unsat->"unsat"|F_add_predicate->"add_predicate"|F_add_terms->"add_terms"|F_are_equal->"are_equal"|F_none->"none"|F_new_facts->"new_facts"|F_apply_subst->"apply_subst"|F_instantiate->"instantiate"typet={(* current time *)mutablecur_u:float;(* current activated (module x function) for time profiling *)mutablecur_t:(ty_module*ty_function*int);(* stack of suspended (module x function)s callers *)mutablestack:(ty_module*ty_function*int)list;(* table of timers for each combination "" *)z:(floatarray)array;(*h:(ty_module, float ref) Hashtbl.t;*)}letcpt_id=ref0letfresh_id()=incrcpt_id;!cpt_id(** return a new empty env **)letempty()={cur_t=(M_None,F_none,0);cur_u=0.0;stack=[];z=Array.initnb_mtag(fun_->Array.makenb_ftag0.);}(** reset the references of the given env to empty **)letresetenv=fori=0tonb_mtag-1doleta=env.z.(i)inforj=0tonb_ftag-1doa.(j)<-0.donedone;env.cur_t<-(M_None,F_none,0);env.cur_u<-0.0;env.stack<-[];cpt_id:=0letaccumulateenvcurmf=letmt=mtagminletft=ftagfinenv.z.(mt).(ft)<-env.z.(mt).(ft)+.(cur-.env.cur_u)letaccumulate_cumulative_modenameenvmfcur=ifOptions.cumulative_time_profiling()thenbeginifOptions.debug()theneprintf"@.%s time of %s , %s@."name(string_of_ty_modulem)(string_of_ty_functionf);List.iter(fun(m,f,_)->ifOptions.debug()theneprintf" also update time of %s , %s@."(string_of_ty_modulem)(string_of_ty_functionf);accumulateenvcurmf)env.stackend(** save the current timer and start the timer m x f **)letstartenvmf=letcur=MyUnix.cur_time()inaccumulate_cumulative_mode"start"envmfcur;beginmatchenv.cur_twith|(M_None,_,_)->()|kd->accumulateenvcurmf;env.stack<-kd::env.stackend;env.cur_t<-(m,f,fresh_id());env.cur_u<-cur(** pause the timer "m x f" and restore the former timer **)letpauseenvmf=letcur=MyUnix.cur_time()inaccumulate_cumulative_mode"pause"envmfcur;accumulateenvcurmf;env.cur_u<-cur;matchenv.stackwith|[]->env.cur_t<-(M_None,F_none,0)|kd::st->env.cur_t<-kd;env.stack<-st(** update the value of the current timer **)letupdateenv=letcur=MyUnix.cur_time()inletm,f,_=env.cur_tinaccumulate_cumulative_mode"update"envmfcur;accumulateenvcurmf;env.cur_u<-cur(** get the value of the timer "m x f" **)letget_valueenvmf=env.z.(mtagm).(ftagf)(** get the sum of the "ty_function" timers for the given "ty_module" **)letget_sumenvm=letcpt=ref0.inArray.iter(funv->cpt:=!cpt+.v)env.z.(mtagm);!cptletcurrent_timerenv=env.cur_tletget_stackenv=env.stackletget_timers_arrayenv=env.zletall_functions=letl=[F_add;F_add_lemma;F_add_predicate;F_add_terms;F_are_equal;F_assume;F_class_of;F_leaves;F_make;F_m_lemmas;F_m_predicates;F_query;F_solve;F_subst;F_union;F_unsat;F_none;F_new_facts;F_apply_subst;F_instantiate;]inassert(List.lengthl=nb_ftag);lletall_modules=letl=[M_None;M_Typing;M_Sat;M_Match;M_CC;M_UF;M_Arith;M_Arrays;M_Sum;M_Records;M_AC;M_Expr;M_Triggers;M_Simplex;]inassert(List.lengthl=nb_mtag);llet(timer_start:(ty_module->ty_function->unit)ref)=ref(fun__->())let(timer_pause:(ty_module->ty_function->unit)ref)=ref(fun__->())letset_timer_startf=assert(Options.timers());timer_start:=fletset_timer_pausef=assert(Options.timers());timer_pause:=fletexec_timer_startkdmsg=!timer_startkdmsgletexec_timer_pausekd=!timer_pausekd