]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/ng_kernel/nCicReduction.ml
Refinement of inductive type implemented.
[helm.git] / helm / software / components / ng_kernel / nCicReduction.ml
index 2b1d4119b51b4ec6d7b9206d289a704d2d4bc383..1815ceedfcf5c87e9d387068ffbfb039c76763ff 100644 (file)
@@ -15,6 +15,8 @@ module C = NCic
 module Ref = NReference
 module E = NCicEnvironment
 
+exception AssertFailure of string Lazy.t;;
+
 module type Strategy = sig
   type stack_term
   type env_term
@@ -404,7 +406,14 @@ let _ =
   NCicPp.set_head_beta_reduce (fun ~upto t -> head_beta_reduce ~upto t);
 ;;
 
-
-
+(* if n < 0, then splits all prods from an arity, returning a sort *)
+let rec split_prods ~subst context n te =
+  match (n, R.whd ~subst context te) with
+   | (0, _) -> context,te
+   | (n, C.Sort _) when n <= 0 -> context,te
+   | (n, C.Prod (name,so,ta)) ->
+       split_prods ~subst ((name,(C.Decl so))::context) (n - 1) ta
+   | (_, _) -> raise (AssertFailure (lazy "split_prods"))
+;;
 
 (* vim:set foldmethod=marker: *)