@ p.ps
;;
-let sum_arities p =
+let measure_of_term, measure_of_terms =
let rec aux = function
| `N _ | `Bottom | `Pacman -> 0
| `Var(_,ar) -> if ar = min_int then 0 else max 0 ar (*assert (ar >= 0); ar*)
| `Lam(_,t) -> aux t
| `I(v,args) -> aux (`Var v) + aux_many (Listx.to_list args :> nf list)
- | `Match(u,(_,ar),_,_,args) -> aux (u :> nf) + (if ar = min_int then 0 else ar - 1) + aux_many (args :> nf list)
+ | `Match(u,(_,ar),_,_,args) -> aux (u :> nf) + (if ar <= 0 then 0 else ar - 1) + aux_many (args :> nf list)
and aux_many tms = List.fold_right ((+) ++ aux) tms 0 in
- aux_many (all_terms p :> nf list)
- ;;
+ (fun t -> aux (t :> nf)), (fun l -> aux_many (l :> nf list))
+;;
+
+let sum_arities p = measure_of_terms (all_terms p)
let problem_measure p = sum_arities p;;
let string_of_measure = string_of_int;;
) else "# ";
"#";
"$" ^ p.label;
- (match div with None -> "# no D" | Some div -> "D " ^ print ~l (div :> nf));
+ (match div with None -> "# no D" | Some div -> "D ("^string_of_int (measure_of_term div)^")"^ print ~l (div :> nf));
]
- @ List.map (fun t -> if t = convergent_dummy then "#C" else "C " ^ print ~l (t :> nf)) conv
- @ List.mapi (fun i t -> string_of_int i ^ " " ^ print ~l (t :> nf)) ps
+ @ List.map (fun t -> if t = convergent_dummy then "#C" else "C ("^string_of_int (measure_of_term t)^") " ^ print ~l (t :> nf)) conv
+ @ List.mapi (fun i t -> string_of_int i ^ " ("^string_of_int (measure_of_term t)^") " ^ print ~l (t :> nf)) ps
@ [""])
;;
| #nf_nob as t -> t\r
| `Bottom -> raise (ParsingError "Input term not in normal form") in\r
let rec aux_nob lev : nf_nob -> nf = function\r
- | `I((n,_), args) -> `I((n,1 + Listx.length args), Listx.map (fun t -> exclude_bottom (aux_nob lev t)) args)\r
+ | `I((n,_), args) -> `I((n,(if lev = 0 then 0 else 1) + Listx.length args), Listx.map (fun t -> exclude_bottom (aux_nob lev t)) args)\r
| `Var(n,_) -> fix lev n\r
| `Lam(_,t) -> `Lam (true, aux (lev+1) t)\r
| `Match _ | `N _ -> assert false\r