more robust multiset simproc
authorfleury <Mathias.Fleury@mpi-inf.mpg.de>
Mon, 12 Sep 2016 09:29:25 +0200
changeset 63850 32690ddf614f
parent 63849 0dd6731060d7
child 63851 1a1fd3f3a24c
more robust multiset simproc
src/HOL/Library/multiset_simprocs_util.ML
--- a/src/HOL/Library/multiset_simprocs_util.ML	Mon Sep 12 08:23:59 2016 +0200
+++ b/src/HOL/Library/multiset_simprocs_util.ML	Mon Sep 12 09:29:25 2016 +0200
@@ -27,11 +27,16 @@
 
 (*** Utilities ***)
 
+(*repeat_mset is not symmetric, unlike multiplication over natural numbers.*)
 fun mk_repeat_mset (t, u) =
   let
     val T = fastype_of t;
     val U = fastype_of u;
-  in Const (@{const_name "repeat_mset"}, T --> U --> U) $ t $ u end;
+  in
+    if T = @{typ nat}
+    then Const (@{const_name "repeat_mset"}, T --> U --> U) $ t $ u
+    else Const (@{const_name "repeat_mset"}, U --> T --> T) $ u $ t
+  end;
 
 (*Maps n to #n for n = 1, 2*)
 val numeral_syms = [@{thm numeral_One} RS sym, @{thm numeral_2_eq_2} RS sym,