| `I _ as t -> "(" ^ string_of_term_no_pars_app l (t :> nf) ^ ")"
| `Lam _ as t -> "(" ^ string_of_term_no_pars_lam l t ^ ")"
| `Match(t,(v,ar),bs_lift,bs,args) ->
- "[match("^print_name l v ^ ":" ^ string_of_int ar^") " ^ string_of_term_no_pars l (t :> nf) ^
+ "[match("^ string_of_var v ^":"^ string_of_int ar ^") " ^ string_of_term_no_pars l (t :> nf) ^
" with " ^ String.concat " | " (List.map (fun (n,t) -> string_of_int n ^ " => " ^ string_of_term l (lift bs_lift t)) !bs) ^ "] " ^
String.concat " " (List.map (string_of_term l) args) ^ ")"
and string_of_term_no_pars_app l = function
prerr_endline (print (t :> nf));
assert false (* algorithm failed *)
-let set_arity arity = function
+let rec set_arity arity = function
| `Var(n,_) -> `Var(n,arity)
-| `Lam(false, `N _)
-| `Lam(false, `Lam _) as t -> t
-| `Lam(false, `Match(t,(n,_),bs_lift,bs,args)) -> `Lam(false, `Match(t,(n,arity),bs_lift,bs,args))
-| _ -> assert false
+| `N _ as t -> t
+| `Lam(false, t) -> `Lam(false, set_arity arity t)
+| `Match(t,(n,_),bs_lift,bs,args) -> `Match(t,(n,arity),bs_lift,bs,args)
+| `I _ | `Lam _ -> assert false
let minus1 n = if n = min_int then n else n - 1;;
| `I _ | `Var _ | `Match _ -> `Match(t,(n,ar),bs_lift,bs,args)
and subst truelam delift_by_one what (with_what : nf) (where : nf) =
- let aux_propagate_arity ar = function
- | `Lam(false,`Match(`I(v,args),(x,_),liftno,bs,args')) when not delift_by_one ->
- `Lam(false,`Match(`I(v,args),(x,ar),liftno,bs,args'))
+ let rec aux_propagate_arity ar = function
+ | `Lam(false, t) when not delift_by_one -> `Lam(false, aux_propagate_arity ar t)
+ | `Match(`I(v,args),(x,_),liftno,bs,args') when not delift_by_one ->
+ `Match(`I(v,args),(x,ar),liftno,bs,args')
| `Var(i,oldar) -> `Var(i, if truelam then (assert (oldar = min_int); ar) else oldar)
| _ as t -> t in
let rec aux_i_num_var l =