- let hd, n_args = get_inert p.div in\r
- match hd with\r
- | C | L _ | A _ -> assert false\r
- | V hd_var ->\r
- let tms = get_subterms_with_head hd_var p.conv in\r
- if List.exists (fun t -> snd (get_inert t) >= n_args) tms\r
- then (\r
- (* let tms = List.sort (fun t1 t2 -> - compare (snd (get_inert t1)) (snd (get_inert t2))) tms in *)\r
- List.iter (fun t -> try\r
- let js = find_eta_difference p t in\r
- (* print_endline (String.concat ", " (List.map string_of_int js)); *)\r
- if js = [] then problem_fail p "no eta difference found (div subterm of conv?)";\r
- let js = List.rev js in\r
- List.iter\r
- (fun j ->\r
- try\r
- let k = 1 + max\r
- (compute_max_lambdas_at hd_var j p.div)\r
- (compute_max_lambdas_at hd_var j p.conv) in\r
- ignore (aux (step j k p))\r
- with Fail(_, s) ->\r
- print_endline ("Backtracking (eta_diff) because: " ^ s)) js;\r
- raise (Fail(-1, "no eta difference"))\r
- with Fail(_, s) ->\r
- print_endline ("Backtracking (get_subterms) because: " ^ s)) tms;\r
- raise (Fail(-1, "no similar terms"))\r
- )\r
- else\r
- problem_fail (finish p) "Finish did not complete the problem"\r
- in\r
- try\r
- aux p\r
- with Done sigma -> sigma\r
+ if eta_subterm p.div p.conv\r
+ then raise (Backtrack "div is subterm of conv");\r
+ match p.div with\r
+ | L _ as t -> (* case p.div is an abstraction *)\r
+ print_endline "\nSOTTO UN LAMBDA";\r
+ let t, g = mk_app t C in\r
+ aux ({p with div=mk_apps C (t::g)})\r
+ | V _ | C -> raise (Backtrack "V | C")\r
+ | A _ -> (\r
+ if is_constant p.div (* case p.div is rigid inert *)\r
+ then (print_endline "\nSOTTO UN C"; try_all "auto.C"\r
+ (fun div -> aux (sanity {p with div})) (args_of_inert p.div))\r
+ else (* case p.div is flexible inert *)\r
+ let hd, n_args = get_inert p.div in\r
+ match hd with\r
+ | C | L _ | A _ -> assert false\r
+ | V hd_var ->\r
+ let tms = get_subterms_with_head hd_var p.conv in\r
+ let arity = List.fold_right (max ++ (snd ++ get_inert)) tms 0 in\r
+ try_both "???" (finish p) arity\r
+ (fun _ ->\r
+ let jss = List.concat (List.map (find_eta_difference p) tms) in\r
+ let jss = List.sort_uniq compare jss in\r
+ let f = try_all "no differences"\r
+ (fun j ->\r
+ let k = 1 + max\r
+ (compute_max_lambdas_at hd_var j p.div)\r
+ (compute_max_lambdas_at hd_var j p.conv) in\r
+ let divs, p = step j k p in\r
+ try_all "p.div" (fun div -> aux (sanity {p with div})) divs\r
+ ) in\r
+ try_both "step, then diverge arguments"\r
+ f jss\r
+ (try_all "tried p.div arguments" (fun div -> aux {p with div})) (args_of_inert p.div)\r
+ ) ()\r
+ ) in try\r
+ aux p\r
+ with Done sigma -> sigma\r