equal
deleted
inserted
replaced
438 then have h': "\<And>x. h' x = |
438 then have h': "\<And>x. h' x = |
439 (case f x of None \<Rightarrow> NIL | Some (z, w) \<Rightarrow> CONS z (h' w))" |
439 (case f x of None \<Rightarrow> NIL | Some (z, w) \<Rightarrow> CONS z (h' w))" |
440 unfolding h'_def by (simp add: LList_corec) |
440 unfolding h'_def by (simp add: LList_corec) |
441 have "(h x, h' x) \<in> {(h u, h' u) | u. True}" by blast |
441 have "(h x, h' x) \<in> {(h u, h' u) | u. True}" by blast |
442 then show "h x = h' x" |
442 then show "h x = h' x" |
443 proof (coinduct rule: LList_equalityI [where A = UNIV]) |
443 proof (coinduct taking: UNIV rule: LList_equalityI) |
444 case (EqLList M N) |
444 case (EqLList M N) |
445 then obtain x where MN: "M = h x" "N = h' x" by blast |
445 then obtain x where MN: "M = h x" "N = h' x" by blast |
446 show ?case |
446 show ?case |
447 proof (cases "f x") |
447 proof (cases "f x") |
448 case None |
448 case None |
473 proof - |
473 proof - |
474 def M \<equiv> "Rep_llist l1" and N \<equiv> "Rep_llist l2" |
474 def M \<equiv> "Rep_llist l1" and N \<equiv> "Rep_llist l2" |
475 with r have "(M, N) \<in> {(Rep_llist l1, Rep_llist l2) | l1 l2. (l1, l2) \<in> r}" |
475 with r have "(M, N) \<in> {(Rep_llist l1, Rep_llist l2) | l1 l2. (l1, l2) \<in> r}" |
476 by blast |
476 by blast |
477 then have "M = N" |
477 then have "M = N" |
478 proof (coinduct rule: LList_equalityI [where A = UNIV]) |
478 proof (coinduct taking: UNIV rule: LList_equalityI) |
479 case (EqLList M N) |
479 case (EqLList M N) |
480 then obtain l1 l2 where |
480 then obtain l1 l2 where |
481 MN: "M = Rep_llist l1" "N = Rep_llist l2" and r: "(l1, l2) \<in> r" |
481 MN: "M = Rep_llist l1" "N = Rep_llist l2" and r: "(l1, l2) \<in> r" |
482 by auto |
482 by auto |
483 from step [OF r] show ?case |
483 from step [OF r] show ?case |
607 shows "Lmap (f o g) M = Lmap f (Lmap g M)" (is "?lhs M = ?rhs M") |
607 shows "Lmap (f o g) M = Lmap f (Lmap g M)" (is "?lhs M = ?rhs M") |
608 proof - |
608 proof - |
609 have "(?lhs M, ?rhs M) \<in> {(?lhs N, ?rhs N) | N. N \<in> LList A}" |
609 have "(?lhs M, ?rhs M) \<in> {(?lhs N, ?rhs N) | N. N \<in> LList A}" |
610 using M by blast |
610 using M by blast |
611 then show ?thesis |
611 then show ?thesis |
612 proof (coinduct taking: "range (\<lambda>N :: 'a Datatype.item. N)" |
612 proof (coinduct taking: "range (\<lambda>N. N)" rule: LList_equalityI) |
613 rule: LList_equalityI) |
|
614 case (EqLList L M) |
613 case (EqLList L M) |
615 then obtain N where LM: "L = ?lhs N" "M = ?rhs N" and N: "N \<in> LList A" by blast |
614 then obtain N where LM: "L = ?lhs N" "M = ?rhs N" and N: "N \<in> LList A" by blast |
616 from N show ?case |
615 from N show ?case |
617 proof cases |
616 proof cases |
618 case NIL |
617 case NIL |
630 assumes M: "M \<in> LList A" |
629 assumes M: "M \<in> LList A" |
631 shows "Lmap (\<lambda>x. x) M = M" (is "?lmap M = _") |
630 shows "Lmap (\<lambda>x. x) M = M" (is "?lmap M = _") |
632 proof - |
631 proof - |
633 have "(?lmap M, M) \<in> {(?lmap N, N) | N. N \<in> LList A}" using M by blast |
632 have "(?lmap M, M) \<in> {(?lmap N, N) | N. N \<in> LList A}" using M by blast |
634 then show ?thesis |
633 then show ?thesis |
635 proof (coinduct taking: "range (\<lambda>N :: 'a Datatype.item. N)" |
634 proof (coinduct taking: "range (\<lambda>N. N)" rule: LList_equalityI) |
636 rule: LList_equalityI) |
|
637 case (EqLList L M) |
635 case (EqLList L M) |
638 then obtain N where LM: "L = ?lmap N" "M = N" and N: "N \<in> LList A" by blast |
636 then obtain N where LM: "L = ?lmap N" "M = N" and N: "N \<in> LList A" by blast |
639 from N show ?case |
637 from N show ?case |
640 proof cases |
638 proof cases |
641 case NIL |
639 case NIL |