src/Pure/drule.ML
changeset 11163 14732e3eaa6e
parent 11120 5254d35e4f7c
child 11512 da3a96ab5630
--- a/src/Pure/drule.ML	Tue Feb 20 18:47:06 2001 +0100
+++ b/src/Pure/drule.ML	Tue Feb 20 18:47:22 2001 +0100
@@ -40,6 +40,7 @@
   val zero_var_indexes  : thm -> thm
   val standard          : thm -> thm
   val rotate_prems      : int -> thm -> thm
+  val rearrange_prems   : int list -> thm -> thm
   val assume_ax         : theory -> string -> thm
   val RSN               : thm * (int * thm) -> thm
   val RS                : thm * thm -> thm
@@ -367,6 +368,15 @@
 (*Rotates a rule's premises to the left by k*)
 val rotate_prems = permute_prems 0;
 
+(* permute prems, where the i-th position in the argument list (counting from 0)
+   gives the position within the original thm to be transferred to position i.
+   Any remaining trailing positions are left unchanged. *)
+val rearrange_prems = let
+  fun rearr new []      thm = thm
+  |   rearr new (p::ps) thm = rearr (new+1) 
+     (map (fn q => if new<=q andalso q<p then q+1 else q) ps)
+     (permute_prems (new+1) (new-p) (permute_prems new (p-new) thm))
+  in rearr 0 end;
 
 (*Assume a new formula, read following the same conventions as axioms.
   Generalizes over Free variables,