From: acondolu Date: Tue, 11 Jul 2017 15:39:37 +0000 (+0200) Subject: Fix: nested `Lambda(false,_) were not handled correctly X-Git-Tag: weak-reduction-separation~55 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=415e18c6bfb1bbd125123ff9eb22b2caa7c42187;p=fireball-separation.git Fix: nested `Lambda(false,_) were not handled correctly (cherry picked from commit 0147bacbe2db4055ae6f991aaa64a9fb1047edc6) --- diff --git a/ocaml/num.ml b/ocaml/num.ml index 85a2bfa..eb37e4c 100644 --- a/ocaml/num.ml +++ b/ocaml/num.ml @@ -116,7 +116,7 @@ let rec string_of_term l = | `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 @@ -158,12 +158,12 @@ let cast_to_i_num_var = 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;; @@ -198,9 +198,10 @@ and mk_match t (n,ar) bs_lift bs args = | `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 =