X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fng_kernel%2FnCicReduction.ml;h=717644ac558d170a6b31d999e85a75cb3cd61e84;hb=7d9753115cb26bf27a739e9e1d753fd60b185c17;hp=a88a1aaf388ce9f1dfd69261709ba08d5a6a1c0c;hpb=8b1a49bbee9eea86eb74c040defe701370ca5893;p=helm.git diff --git a/helm/software/components/ng_kernel/nCicReduction.ml b/helm/software/components/ng_kernel/nCicReduction.ml index a88a1aaf3..717644ac5 100644 --- a/helm/software/components/ng_kernel/nCicReduction.ml +++ b/helm/software/components/ng_kernel/nCicReduction.ml @@ -17,6 +17,9 @@ module E = NCicEnvironment exception AssertFailure of string Lazy.t;; +let debug = ref false;; +let pp m = if !debug then prerr_endline (Lazy.force m) else ();; + module type Strategy = sig type stack_term type env_term @@ -141,31 +144,32 @@ module Reduction(RS : Strategy) = struct (Ref.Decl|Ref.Ind _|Ref.Con _|Ref.CoFix _))), _) as config -> config, true | (_, _, (C.Const (Ref.Ref - (_,Ref.Fix (fixno,recindex,height)) as refer) as head),s) as config -> -(* if delta >= height then config else *) - (match - try Some (RS.from_stack ~delta (List.nth s recindex)) - with Failure _ -> None - with - | None -> config, true - | Some recparam -> - let fixes,_,_ = NCicEnvironment.get_checked_fixes_or_cofixes refer in - match reduce ~delta:0 ~subst context recparam with - | (_,_,C.Const (Ref.Ref (_,Ref.Con _)), _) as c, _ - when delta >= height -> - let new_s = - replace recindex s (RS.compute_to_stack ~reduce:(reduce ~subst - context) ~unwind c) - in - (0, [], head, new_s), false - | (_,_,C.Const (Ref.Ref (_,Ref.Con _)), _) as c, _ -> - let new_s = - replace recindex s (RS.compute_to_stack ~reduce:(reduce ~subst - context) ~unwind c) - in - let _,_,_,_,body = List.nth fixes fixno in - aux (0, [], body, new_s) - | _ -> config, true) + (_,Ref.Fix (fixno,recindex,height)) as refer)),s) as config -> + (let arg = try Some (List.nth s recindex) with Failure _ -> None in + match arg with + None -> config, true + | Some arg -> + let fixes,(_,_,pragma),_ = + NCicEnvironment.get_checked_fixes_or_cofixes refer in + if delta >= height then + match pragma with + | `Projection -> + (match RS.from_stack ~delta:max_int arg with + | _,_,C.Const(Ref.Ref(_,Ref.Con _)),_::_ -> + let _,_,_,_,body = List.nth fixes fixno in + aux (0, [], body, s) + | _ -> config,false) + | _ -> config,false + else + match RS.from_stack ~delta:0 arg with + | (_,_,C.Const (Ref.Ref (_,Ref.Con _)), _) as c -> + let new_s = + replace recindex s + (RS.compute_to_stack ~reduce:(reduce ~subst context) + ~unwind c) in + let _,_,_,_,body = List.nth fixes fixno in + aux (0, [], body, new_s) + | _ -> config, true) | (k, e, C.Match (_,_,term,pl),s) as config -> let decofix = function | (_,_,C.Const(Ref.Ref(_,Ref.CoFix c)as refer),s)->