corec test0 where "test0 x y = (case (x, y) of
(S a1 s1, S a2 s2) ==> S (a1 + a2) (test0 s1 s2))"
friend_of_corec test0 where "test0 x y = (case (x, y) of
(S a1 s1, S a2 s2) ==> 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) ==> C1 (a + b) (test05 t11 t21) (test05 t12 t22)
| (C1 a t11 _, C2 b t2) ==> C2 (a + b) (test05 t11 t2)
| (C2 a t1, C1 b _ t22) ==> C2 (a + b) (test05 t1 t22)
| (C2 a t1, C2 b t2) ==> C2 (a + b) (test05 t1 t2)
| (_, _) ==> C3 [])"
friend_of_corec test05 where "test05 x y = (case (x, y) of
(C1 a t11 t12, C1 b t21 t22) ==> C1 (a + b) (test05 t11 t21) (test05 t12 t22)
| (C1 a t11 _, C2 b t2) ==> C2 (a + b) (test05 t11 t2)
| (C2 a t1, C1 b _ t22) ==> C2 (a + b) (test05 t1 t22)
| (C2 a t1, C2 b t2) ==> C2 (a + b) (test05 t1 t2)
| (_, _) ==> C3 [])" apply (rule test05.code) apply transfer_prover done
corec test06 :: "T0 \ T0"where "test06 x =
(if¬ 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¬ 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 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 ==> (f20 r y) # (branches y)
| H1 (Some t) r ==> (f20 r t) # (branches y)
| H2 n t r ==> (f20 r (Node n [])) # (branches y)
| H3 ==> 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 ==> (f20 r y) # (branches y)
| H1 (Some t) r ==> (f20 r t) # (branches y)
| H2 n t r ==> (f20 r (Node n [])) # (branches y)
| H3 ==> branches y)" sorry
corec f21 where "f21 x xh =
Node (node x) (case xh of
H1 (Some a) yh ==> (f21 x (map_h (map_option (f20 yh)) id id yh)) # (branches a)
| H1 None yh ==> [f21 x yh]
| H2 b c yh ==> (f21 c (map_h id (%n. n + b) id yh)) # (branches x)
| H3 ==> branches x)"
friend_of_corec f21 where "f21 x xh =
Node (node x) (case xh of
H1 (Some a) yh ==> (f21 x (map_h (map_option (f20 yh)) (%t. t) (%t. t) yh)) # (branches a)
| H1 None yh ==> [f21 x yh]
| H2 b c yh ==> (f21 c (map_h (%t. t) (%n. n + b) (%t. t) yh)) # (branches x)
| H3 ==> 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 ==> Node 0 []
| H1 l r ==> Node 0 ((f28 r) # map the (filter (%opt. case opt of None ==> False | Some _ ==> True) l))
| H2 f t r ==> 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‹¬ P (head xs)› 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 und die Messung sind noch experimentell.