*)
let num_more_args = 2;;
+let convergent_dummy = `N(-1);;
+
type discriminating_set = (int * nf) list;;
type problem =
if i > bound then
raise (Backtrack ("no more alternatives for " ^ string_of_var var))
else
- try(try
+ try
f p i
- with Pacman | Bottom -> raise (Backtrack "Pacman/Bottom"))
with Backtrack s ->
prerr_endline ("!!BACKTRACK!! " ^ s);
List.iter (fun (r,l) -> r := l) (List.combine p.deltas (List.hd p.trail)) ;
^"(* DIVERGENT *)" ^ nl
^" "^ (match div with None -> "None" | Some div -> "(Some\""^ print ~l (div :> nf) ^"\")") ^ nl
^" (* CONVERGENT *) [" ^ nl ^ " "
- ^ String.concat "\n " (List.map (fun t -> "(* _ *) " ^ (if t = `N (-1) then "" else "\""^ print ~l (t :> nf) ^"\";")) conv) ^
+ ^ String.concat "\n " (List.map (fun t -> "(* _ *) " ^ (if t = convergent_dummy then "" else "\""^ print ~l (t :> nf) ^"\";")) conv) ^
(if conv = [] then "" else nl)
^ "] (* NUMERIC *) [" ^ nl ^ " "
^ String.concat "\n " (List.mapi (fun i t -> " (* "^ string_of_int i ^" *) \"" ^ print ~l (t :> nf) ^ "\";") ps)
let t = subst false false x inst (t :> nf) in
(*prerr_endline ("SUBSTITUTED t:" ^ print (t :> nf));*)
let freshno,new_t,acc_new_ps =
- expand_match (freshno,acc_ps@`Var(max_int/3,-666)::todo_ps,acc_new_ps) t
+ try
+ expand_match (freshno,acc_ps@`Var(max_int/3,-666)::todo_ps,acc_new_ps) t
+ with Pacman | Bottom -> raise (Backtrack "Pacman/Bottom in ps")
in
aux_ps (freshno,acc_ps@[new_t],acc_new_ps) todo_ps
| [] -> acc
| t::todo_conv ->
(*prerr_endline ("EXPAND t:" ^ print (t :> nf));*)
- let t = try
- subst false false x inst (t :> nf)
- with Pacman -> `N(-1) in (* DUMMY CONVERGENT *)
+ let t = subst false false x inst (t :> nf) in
(*prerr_endline ("SUBSTITUTED t:" ^ print (t :> nf));*)
- let freshno,new_t,acc_new_ps = expand_match (freshno,ps,acc_new_ps) t in
+ let freshno,new_t,acc_new_ps =
+ try
+ expand_match (freshno,ps,acc_new_ps) t
+ with Pacman -> freshno,convergent_dummy,acc_new_ps
+ | Bottom -> raise (Backtrack "Bottom in conv") in
aux_conv ps (freshno,acc_conv@[new_t],acc_new_ps) todo_conv
(* cut&paste from aux' above *)
let freshno,new_t,acc_new_ps = expand_match (freshno,ps,acc_new_ps) t in
freshno,Some(cast_to_i_var new_t),acc_new_ps
with Bottom -> freshno, None, acc_new_ps
+ | Pacman -> raise (Backtrack "Pacman in div")
and expand_match ((freshno,acc_ps,acc_new_ps) as acc) t =
match t with
let _ = List.find (fun h -> hd_of t = Some h) showstoppers in
t)
with Not_found -> match hd_of t with
- | None -> assert (t = `N ~-1); t
+ | None -> assert (t = convergent_dummy); t
| Some h ->
prerr_endline ("FREEZING " ^ string_of_var h);
- `N ~-1 (* convergent dummy*)
+ convergent_dummy
) (List.combine showstoppers_conv p.conv) in
List.iter
(fun bs ->
List.iter (fun n ->
prerr_endline ("_::: " ^ (Pure.print n));
let t = Pure.mwhd (e',n,[]) in
- prerr_endline ("_:: " ^ (Pure.print t))
+ prerr_endline ("_:: " ^ (Pure.print t));
+ assert (t <> Pure.B)
) conv ;
List.iteri (fun i n ->
prerr_endline ((string_of_int i) ^ "::: " ^ (Pure.print n));