corec test0 where "test0 x y = (case (x, y) of
(S a1 s1, S a2 s2) \<Rightarrow> S (a1 + a2) (test0 s1 s2))"
friend_of_corec test0 where "test0 x y = (case (x, y) of
(S a1 s1, S a2 s2) \<Rightarrow> S (a1 + a2) (test0 s1 s2))" apply (rule test0.code) apply transfer_prover done
corec test01 where "test01 x y = C2 (lab x + lab y) (test01 (tl2 x) (tl2 y))"
friend_of_corec test01 where "test01 x y = C2 (lab x + lab y) (test01 (tl2 x) (tl2 y))" apply (rule test01.code) sorry(* not parametric *)
corec test02 where "test02 x y = C2 (lab x * lab y) (test01 (test02 x (tl2 y)) (test02 (tl2 x) y))"
friend_of_corec test02 where "test02 x y = C2 (lab x * lab y) (test01 (test02 x (tl2 y)) (test02 (tl2 x) y))" apply (rule test02.code) sorry(* not parametric *)
corec test03 where "test03 x = C2 (lab x) (C2 (lab x) (test02 (test03 (tl2 x)) (test03 (tl2 x))))"
friend_of_corec test03 where "test03 x = C2 (lab x) (C2 (lab x) (test02 (test03 (tl2 x)) (test03 (tl2 x))))" apply (rule test03.code) sorry(* not parametric *)
corec (friend) test04a where "test04a x = (case x of C1 a t1 t2 \ C1 (a * a) (test04a t1) (test04a t2) | C2 a t \ C2 (a * a) (test04a t) | C3 l \ C3 l)"
corec test04 where "test04 x = (case x of C1 a t1 t2 \ C1 (a * a) (test04 t1) (test04 t2) | C2 a t \ C2 (a * a) (test04 t) | C3 l \ C3 l)"
friend_of_corec test04 where "test04 x = (case x of C1 a t1 t2 \ C1 (a * a) (test04 t1) (test04 t2) | C2 a t \ C2 (a * a) (test04 t) | C3 l \ C3 l)" apply (rule test04.code) apply transfer_prover done
corec test05 where "test05 x y = (case (x, y) of
(C1 a t11 t12, C1 b t21 t22) \<Rightarrow> C1 (a + b) (test05 t11 t21) (test05 t12 t22)
| (C1 a t11 _, C2 b t2) \<Rightarrow> C2 (a + b) (test05 t11 t2)
| (C2 a t1, C1 b _ t22) \<Rightarrow> C2 (a + b) (test05 t1 t22)
| (C2 a t1, C2 b t2) \<Rightarrow> C2 (a + b) (test05 t1 t2)
| (_, _) \<Rightarrow> C3 [])"
friend_of_corec test05 where "test05 x y = (case (x, y) of
(C1 a t11 t12, C1 b t21 t22) \<Rightarrow> C1 (a + b) (test05 t11 t21) (test05 t12 t22)
| (C1 a t11 _, C2 b t2) \<Rightarrow> C2 (a + b) (test05 t11 t2)
| (C2 a t1, C1 b _ t22) \<Rightarrow> C2 (a + b) (test05 t1 t22)
| (C2 a t1, C2 b t2) \<Rightarrow> C2 (a + b) (test05 t1 t2)
| (_, _) \<Rightarrow> C3 [])" apply (rule test05.code) apply transfer_prover done
corec test06 :: "T0 \ T0" where "test06 x =
(if\<not> is_C1 x then let tail = tl2 x in
C1 (lab x) (test06 tail) tail
else
C2 (lab x) (test06 (tl12 x)))"
friend_of_corec test06 :: "T0 \ T0" where "test06 x =
(if\<not> is_C1 x then let tail = tl2 x in
C1 (lab x) (test06 tail) tail
else
C2 (lab x) (test06 (tl12 x)))" apply (rule test06.code) sorry(* not parametric *)
corec (friend) f10a where "f10a x y = Node
(integerize_tree_list (branches x) + integerize_tree_list (branches y))
(map (\<lambda>(x, y). f10a x y) (zip (branches x) (branches y)))"
corec f10 where "f10 x y = Node
(integerize_tree_list (branches x) + integerize_tree_list (branches y))
(map (\<lambda>(x, y). f10 x y) (zip (branches x) (branches y)))"
friend_of_corec f10 where "f10 x y = Node
(integerize_tree_list (branches x) + integerize_tree_list (branches y))
(map (\<lambda>(x, y). f10 x y) (zip (branches x) (branches y)))" apply (rule f10.code) by transfer_prover+
corec f12 where "f12 t = Node (node t) (map f12 (branches t))"
friend_of_corec f12 where "f12 t = Node (node t) (map f12 (branches t))" sorry
corec f13 where "f13 n ts = Node n (map (%t. f13 (node t) (branches t)) ts)"
friend_of_corec f13 where "f13 n ts = Node n (map (%t. f13 (node t) (branches t)) ts)" sorry
corec f14 :: "tree option \ tree" where "f14 t_opt = Node 0
(case map_option branches t_opt of
None \<Rightarrow> []
| Some ts \<Rightarrow> map (f14 o Some) ts)"
friend_of_corec f14 where "f14 t_opt = Node 0
(case map_option branches t_opt of
None \<Rightarrow> []
| Some ts \<Rightarrow> map (f14 o Some) ts)" sorry
corec f15 :: "tree list option \ tree" where "f15 ts_opt = Node 0
(case map_option (map branches) ts_opt of
None \<Rightarrow> []
| Some tss \<Rightarrow> map (f15 o Some) tss)"
friend_of_corec f15 where "f15 ts_opt = Node 0
(case map_option (map branches) ts_opt of
None \<Rightarrow> []
| Some tss \<Rightarrow> map (f15 o Some) tss)" sorry
corec f16 :: "tree list option \ tree" where "f16 ts_opt = Node 0
(case ts_opt of
None \<Rightarrow> []
| Some ts \<Rightarrow> map (f16 o Some o branches) ts)"
friend_of_corec f16 where "f16 ts_opt = Node 0
(case ts_opt of
None \<Rightarrow> []
| Some ts \<Rightarrow> map (f16 o Some o branches) ts)" sorry
corec f17 :: "tree list option \ tree" where "f17 ts_opt = Node 0 (case ts_opt of
None \<Rightarrow> []
| Some ts \<Rightarrow> [f17 (Some (map (List.hd o branches) ts))])"
(* not parametric friend_of_corec f17 where "f17 ts_opt = Node 0 (case ts_opt of None \<Rightarrow> [] | Some ts \<Rightarrow> [f17 (Some (map (List.hd o branches) ts))])" sorry
*)
corec f18 :: "tree \ tree" where "f18 t = Node (node t) (map (f18 o f12) (branches t))"
friend_of_corec f18 :: "tree \ tree" where "f18 t = Node (node t) (map (f18 o f12) (branches t))" sorry
corec f19 :: "tree \ tree" where "f19 t = Node (node t) (map (%f. f [t]) (map f13 [1, 2, 3]))"
friend_of_corec f19 :: "tree \ tree" where "f19 t = Node (node t) (map (%f. f [t]) (map f13 [1, 2, 3]))" sorry
corec f20 :: "(tree option, int, tree) h \ tree \ tree" where "f20 x y = Node (node y) (case (map_h (map_option f12) (%n. n) f12 x) of
H1 None r \<Rightarrow> (f20 r y) # (branches y)
| H1 (Some t) r \<Rightarrow> (f20 r t) # (branches y)
| H2 n t r \<Rightarrow> (f20 r (Node n [])) # (branches y)
| H3 \<Rightarrow> branches y)"
friend_of_corec f20 where "f20 x y = Node (node y) (case (map_h (map_option f12) (%n. n) f12 x) of
H1 None r \<Rightarrow> (f20 r y) # (branches y)
| H1 (Some t) r \<Rightarrow> (f20 r t) # (branches y)
| H2 n t r \<Rightarrow> (f20 r (Node n [])) # (branches y)
| H3 \<Rightarrow> branches y)" sorry
corec f21 where "f21 x xh =
Node (node x) (case xh of
H1 (Some a) yh \<Rightarrow> (f21 x (map_h (map_option (f20 yh)) id id yh)) # (branches a)
| H1 None yh \<Rightarrow> [f21 x yh]
| H2 b c yh \<Rightarrow> (f21 c (map_h id (%n. n + b) id yh)) # (branches x)
| H3 \<Rightarrow> branches x)"
friend_of_corec f21 where "f21 x xh =
Node (node x) (case xh of
H1 (Some a) yh \<Rightarrow> (f21 x (map_h (map_option (f20 yh)) (%t. t) (%t. t) yh)) # (branches a)
| H1 None yh \<Rightarrow> [f21 x yh]
| H2 b c yh \<Rightarrow> (f21 c (map_h (%t. t) (%n. n + b) (%t. t) yh)) # (branches x)
| H3 \<Rightarrow> branches x)" sorry
corec f22 :: "('a \ tree) \ 'a list \ tree" where "f22 f x = Node 0 (map f x)"
friend_of_corec f22:: "(nat \ tree) \ nat list \ tree" where "f22 f x = Node 0 (map f x)" sorry
corec f23 where "f23 xh = Node 0
(if is_H1 xh then
(f23 (h_tail xh)) # (branches (h_a xh))
else if is_H1 xh then
(f23 (h_tail xh)) # (h_c xh) # (branches (h_b xh))
else
[])"
friend_of_corec f23 where "f23 xh = Node 0
(if is_H1 xh then
(f23 (h_tail xh)) # (branches (h_a xh))
else if is_H1 xh then
(f23 (h_tail xh)) # (h_c xh) # (branches (h_b xh))
else
[])" sorry
corec f24 where "f24 xh =
(if is_H1 xh then
Node 0 ((f24 (h_tail xh)) # (h_a xh 0))
else if is_H2 xh then
Node (h_b xh) ((f24 (h_tail xh)) # (h_c xh 0))
else
Node 0 [])"
friend_of_corec f24 :: "(nat \ tree list, int, int \ tree list) h \ tree" where "f24 xh =
(if is_H1 xh then
Node 0 ((f24 (h_tail xh)) # (h_a xh 0))
else if is_H2 xh then
Node (h_b xh) ((f24 (h_tail xh)) # (h_c xh 0))
else
Node 0 [])" sorry
corec f25 where "f25 x = Node (node x) (map f25 ((id branches) x))"
corec f26 :: "(int, tree) y_type \ tree \ tree" where "f26 y x = (case map_y_type f12 y of
Y f y' \ Node (node x) ((f (node x)) # (map (f26 y') (branches x))))"
friend_of_corec f26 where "f26 y x = (case map_y_type f12 y of
Y f y' \ Node (node x) ((f (node x)) # (map (f26 y') (branches x))))" sorry
consts int_of_list :: "'a list \ int"
corec f27 :: "(int, tree) y_type \ tree \ tree" where "f27 y x = Node (int_of_list (map (f26 (y_tail y)) (branches x))) [lab y (node x)]"
friend_of_corec f27 :: "(int, tree) y_type \ tree \ tree" where "f27 y x = Node (int_of_list (map (f26 (y_tail y)) (branches x))) [lab y (node x)]" sorry
corec f28 :: "(tree option list, (int \ int) \ int list \ tree, tree) h \ tree" where "f28 xh = (case xh of
H3 \<Rightarrow> Node 0 []
| H1 l r \<Rightarrow> Node 0 ((f28 r) # map the (filter (%opt. case opt of None \<Rightarrow> False | Some _ \<Rightarrow> True) l))
| H2 f t r \<Rightarrow> Node (node t) (map (%t. f id [node t]) (branches t)))"
inductive llist_in where "llist_in (LCons x xs) x"
| "llist_in xs y \ llist_in (LCons x xs) y"
abbreviation"lset xs \ {x. llist_in xs x}"
corecursive lfilter where "lfilter P xs = (if \ x \ lset xs. \ P x then
LNil
else if P (head xs) then
LCons (head xs) (lfilter P (tail xs))
else
lfilter P (tail xs))" proof (relation "measure (\(P, xs). LEAST n. P (head ((tail ^^ n) xs)))", rule wf_measure, clarsimp) fix P xs x assume"llist_in xs x""P x""\ P (head xs)" from this(1,2) obtain a where"P (head ((tail ^^ a) xs))" by (atomize_elim, induct xs x rule: llist_in.induct) (auto simp: funpow_Suc_right
simp del: funpow.simps(2) intro: exI[of _ 0] exI[of _ "Suc i"for i]) with\<open>\<not> P (head xs)\<close> have"(LEAST n. P (head ((tail ^^ n) xs))) = Suc (LEAST n. P (head ((tail ^^ Suc n) xs)))" by (intro Least_Suc) auto thenshow"(LEAST n. P (head ((tail ^^ n) (tail xs)))) < (LEAST n. P (head ((tail ^^ n) xs)))" by (simp add: funpow_swap1[of tail]) qed
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.