src/HOL/ex/Coercion_Examples.thy
changeset 51320 c1cb872ccb2b
parent 51247 064683ba110c
child 51335 6bac04a6a197
--- a/src/HOL/ex/Coercion_Examples.thy	Fri Mar 01 22:15:31 2013 +0100
+++ b/src/HOL/ex/Coercion_Examples.thy	Fri Mar 01 22:15:31 2013 +0100
@@ -178,4 +178,22 @@
 
 term "ys=[[[[[1::nat]]]]]"
 
+consts
+  case_nil :: "'a \<Rightarrow> 'b"
+  case_cons :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
+  case_abs :: "('c \<Rightarrow> 'b) \<Rightarrow> 'b"
+  case_elem :: "'a \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> 'b"
+
+declare [[coercion_args case_cons - -]]
+declare [[coercion_args case_abs -]]
+declare [[coercion_args case_elem - +]]
+
+term "case_cons (case_abs (\<lambda>n. case_abs (\<lambda>is. case_elem (((n::nat),(is::int list))) (n#is)))) case_nil"
+
+consts n :: nat m :: nat
+term "- (n + m)"
+declare [[coercion_args uminus -]]
+declare [[coercion_args plus + +]]
+term "- (n + m)"
+ 
 end