29 |
29 |
30 |
30 |
31 lemma Pos_stars: |
31 lemma Pos_stars: |
32 "Pos (Stars vs) = {[]} \<union> (\<Union>n < length vs. {n#ps | ps. ps \<in> Pos (vs ! n)})" |
32 "Pos (Stars vs) = {[]} \<union> (\<Union>n < length vs. {n#ps | ps. ps \<in> Pos (vs ! n)})" |
33 apply(induct vs) |
33 apply(induct vs) |
34 apply(simp) |
34 apply(auto simp add: insert_ident less_Suc_eq_0_disj) |
35 apply(simp add: insert_ident) |
35 done |
36 apply(rule subset_antisym) |
|
37 using less_Suc_eq_0_disj by auto |
|
38 |
36 |
39 lemma Pos_empty: |
37 lemma Pos_empty: |
40 shows "[] \<in> Pos v" |
38 shows "[] \<in> Pos v" |
41 by (induct v rule: Pos.induct)(auto) |
39 by (induct v rule: Pos.induct)(auto) |
42 |
40 |
43 fun intlen :: "'a list \<Rightarrow> int" |
41 fun intlen :: "'a list \<Rightarrow> int" |
44 where |
42 where |
45 "intlen [] = 0" |
43 "intlen [] = 0" |
46 | "intlen (x # xs) = 1 + intlen xs" |
44 | "intlen (x # xs) = 1 + intlen xs" |
47 |
45 |
|
46 lemma intlen_int: |
|
47 shows "intlen xs = int (length xs)" |
|
48 by (induct xs)(simp_all) |
|
49 |
48 lemma intlen_bigger: |
50 lemma intlen_bigger: |
49 shows "0 \<le> intlen xs" |
51 shows "0 \<le> intlen xs" |
50 by (induct xs)(auto) |
52 by (induct xs)(auto) |
51 |
53 |
52 lemma intlen_append: |
54 lemma intlen_append: |
53 shows "intlen (xs @ ys) = intlen xs + intlen ys" |
55 shows "intlen (xs @ ys) = intlen xs + intlen ys" |
54 by (induct xs arbitrary: ys) (auto) |
56 by (simp add: intlen_int) |
55 |
57 |
56 lemma intlen_length: |
58 lemma intlen_length: |
57 shows "intlen xs < intlen ys \<longleftrightarrow> length xs < length ys" |
59 shows "intlen xs < intlen ys \<longleftrightarrow> length xs < length ys" |
58 apply(induct xs arbitrary: ys) |
60 by (simp add: intlen_int) |
59 apply (auto simp add: intlen_bigger not_less) |
|
60 apply (metis intlen.elims intlen_bigger le_imp_0_less) |
|
61 apply (smt Suc_lessI intlen.simps(2) length_Suc_conv nat_neq_iff) |
|
62 by (smt Suc_lessE intlen.simps(2) length_Suc_conv) |
|
63 |
61 |
64 lemma intlen_length_eq: |
62 lemma intlen_length_eq: |
65 shows "intlen xs = intlen ys \<longleftrightarrow> length xs = length ys" |
63 shows "intlen xs = intlen ys \<longleftrightarrow> length xs = length ys" |
66 apply(induct xs arbitrary: ys) |
64 by (simp add: intlen_int) |
67 apply (auto simp add: intlen_bigger not_less) |
|
68 apply(case_tac ys) |
|
69 apply(simp_all) |
|
70 apply (smt intlen_bigger) |
|
71 apply (smt intlen.elims intlen_bigger length_Suc_conv) |
|
72 by (metis intlen.simps(2) length_Suc_conv) |
|
73 |
65 |
74 definition pflat_len :: "val \<Rightarrow> nat list => int" |
66 definition pflat_len :: "val \<Rightarrow> nat list => int" |
75 where |
67 where |
76 "pflat_len v p \<equiv> (if p \<in> Pos v then intlen (flat (at v p)) else -1)" |
68 "pflat_len v p \<equiv> (if p \<in> Pos v then intlen (flat (at v p)) else -1)" |
77 |
69 |
545 apply(case_tac "length (flat v1') < length (flat v1)") |
532 apply(case_tac "length (flat v1') < length (flat v1)") |
546 using PosOrd_shorterI apply blast |
533 using PosOrd_shorterI apply blast |
547 by (metis PosOrd_SeqI1 PosOrd_shorterI WW1 antisym_conv3 append_eq_append_conv assms(2)) |
534 by (metis PosOrd_SeqI1 PosOrd_shorterI WW1 antisym_conv3 append_eq_append_conv assms(2)) |
548 |
535 |
549 |
536 |
|
537 |
550 section {* The Posix Value is smaller than any other Value *} |
538 section {* The Posix Value is smaller than any other Value *} |
551 |
539 |
552 |
540 |
553 lemma Posix_PosOrd: |
541 lemma Posix_PosOrd: |
554 assumes "s \<in> r \<rightarrow> v1" "v2 \<in> CPT r s" |
542 assumes "s \<in> r \<rightarrow> v1" "v2 \<in> CV r s" |
555 shows "v1 :\<sqsubseteq>val v2" |
543 shows "v1 :\<sqsubseteq>val v2" |
556 using assms |
544 using assms |
557 proof (induct arbitrary: v2 rule: Posix.induct) |
545 proof (induct arbitrary: v2 rule: Posix.induct) |
558 case (Posix_ONE v) |
546 case (Posix_ONE v) |
559 have "v \<in> CPT ONE []" by fact |
547 have "v \<in> CV ONE []" by fact |
560 then have "v = Void" |
548 then have "v = Void" |
561 by (simp add: CPT_simps) |
549 by (simp add: CV_simps) |
562 then show "Void :\<sqsubseteq>val v" |
550 then show "Void :\<sqsubseteq>val v" |
563 by (simp add: PosOrd_ex_eq_def) |
551 by (simp add: PosOrd_ex_eq_def) |
564 next |
552 next |
565 case (Posix_CHAR c v) |
553 case (Posix_CHAR c v) |
566 have "v \<in> CPT (CHAR c) [c]" by fact |
554 have "v \<in> CV (CHAR c) [c]" by fact |
567 then have "v = Char c" |
555 then have "v = Char c" |
568 by (simp add: CPT_simps) |
556 by (simp add: CV_simps) |
569 then show "Char c :\<sqsubseteq>val v" |
557 then show "Char c :\<sqsubseteq>val v" |
570 by (simp add: PosOrd_ex_eq_def) |
558 by (simp add: PosOrd_ex_eq_def) |
571 next |
559 next |
572 case (Posix_ALT1 s r1 v r2 v2) |
560 case (Posix_ALT1 s r1 v r2 v2) |
573 have as1: "s \<in> r1 \<rightarrow> v" by fact |
561 have as1: "s \<in> r1 \<rightarrow> v" by fact |
574 have IH: "\<And>v2. v2 \<in> CPT r1 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact |
562 have IH: "\<And>v2. v2 \<in> CV r1 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact |
575 have "v2 \<in> CPT (ALT r1 r2) s" by fact |
563 have "v2 \<in> CV (ALT r1 r2) s" by fact |
576 then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s" |
564 then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s" |
577 by(auto simp add: CPT_def prefix_list_def) |
565 by(auto simp add: CV_def prefix_list_def) |
578 then consider |
566 then consider |
579 (Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" |
567 (Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" |
580 | (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s" |
568 | (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s" |
581 by (auto elim: CPrf.cases) |
569 by (auto elim: CPrf.cases) |
582 then show "Left v :\<sqsubseteq>val v2" |
570 then show "Left v :\<sqsubseteq>val v2" |
583 proof(cases) |
571 proof(cases) |
584 case (Left v3) |
572 case (Left v3) |
585 have "v3 \<in> CPT r1 s" using Left(2,3) |
573 have "v3 \<in> CV r1 s" using Left(2,3) |
586 by (auto simp add: CPT_def prefix_list_def) |
574 by (auto simp add: CV_def prefix_list_def) |
587 with IH have "v :\<sqsubseteq>val v3" by simp |
575 with IH have "v :\<sqsubseteq>val v3" by simp |
588 moreover |
576 moreover |
589 have "flat v3 = flat v" using as1 Left(3) |
577 have "flat v3 = flat v" using as1 Left(3) |
590 by (simp add: Posix1(2)) |
578 by (simp add: Posix1(2)) |
591 ultimately have "Left v :\<sqsubseteq>val Left v3" |
579 ultimately have "Left v :\<sqsubseteq>val Left v3" |
601 qed |
589 qed |
602 next |
590 next |
603 case (Posix_ALT2 s r2 v r1 v2) |
591 case (Posix_ALT2 s r2 v r1 v2) |
604 have as1: "s \<in> r2 \<rightarrow> v" by fact |
592 have as1: "s \<in> r2 \<rightarrow> v" by fact |
605 have as2: "s \<notin> L r1" by fact |
593 have as2: "s \<notin> L r1" by fact |
606 have IH: "\<And>v2. v2 \<in> CPT r2 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact |
594 have IH: "\<And>v2. v2 \<in> CV r2 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact |
607 have "v2 \<in> CPT (ALT r1 r2) s" by fact |
595 have "v2 \<in> CV (ALT r1 r2) s" by fact |
608 then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s" |
596 then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s" |
609 by(auto simp add: CPT_def prefix_list_def) |
597 by(auto simp add: CV_def prefix_list_def) |
610 then consider |
598 then consider |
611 (Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" |
599 (Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" |
612 | (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s" |
600 | (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s" |
613 by (auto elim: CPrf.cases) |
601 by (auto elim: CPrf.cases) |
614 then show "Right v :\<sqsubseteq>val v2" |
602 then show "Right v :\<sqsubseteq>val v2" |
615 proof (cases) |
603 proof (cases) |
616 case (Right v3) |
604 case (Right v3) |
617 have "v3 \<in> CPT r2 s" using Right(2,3) |
605 have "v3 \<in> CV r2 s" using Right(2,3) |
618 by (auto simp add: CPT_def prefix_list_def) |
606 by (auto simp add: CV_def prefix_list_def) |
619 with IH have "v :\<sqsubseteq>val v3" by simp |
607 with IH have "v :\<sqsubseteq>val v3" by simp |
620 moreover |
608 moreover |
621 have "flat v3 = flat v" using as1 Right(3) |
609 have "flat v3 = flat v" using as1 Right(3) |
622 by (simp add: Posix1(2)) |
610 by (simp add: Posix1(2)) |
623 ultimately have "Right v :\<sqsubseteq>val Right v3" |
611 ultimately have "Right v :\<sqsubseteq>val Right v3" |
624 by (auto simp add: PosOrd_ex_eq_def PosOrd_RightI) |
612 by (auto simp add: PosOrd_ex_eq_def PosOrd_RightI) |
625 then show "Right v :\<sqsubseteq>val v2" unfolding Right . |
613 then show "Right v :\<sqsubseteq>val v2" unfolding Right . |
626 next |
614 next |
627 case (Left v3) |
615 case (Left v3) |
628 have "v3 \<in> CPT r1 s" using Left(2,3) as2 |
616 have "v3 \<in> CV r1 s" using Left(2,3) as2 |
629 by (auto simp add: CPT_def prefix_list_def) |
617 by (auto simp add: CV_def prefix_list_def) |
630 then have "flat v3 = flat v \<and> \<Turnstile> v3 : r1" using as1 Left(3) |
618 then have "flat v3 = flat v \<and> \<Turnstile> v3 : r1" using as1 Left(3) |
631 by (simp add: Posix1(2) CPT_def) |
619 by (simp add: Posix1(2) CV_def) |
632 then have "False" using as1 as2 Left |
620 then have "False" using as1 as2 Left |
633 by (auto simp add: Posix1(2) L_flat_Prf1 Prf_CPrf) |
621 by (auto simp add: Posix1(2) L_flat_Prf1 Prf_CPrf) |
634 then show "Right v :\<sqsubseteq>val v2" by simp |
622 then show "Right v :\<sqsubseteq>val v2" by simp |
635 qed |
623 qed |
636 next |
624 next |
637 case (Posix_SEQ s1 r1 v1 s2 r2 v2 v3) |
625 case (Posix_SEQ s1 r1 v1 s2 r2 v2 v3) |
638 have "s1 \<in> r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" by fact+ |
626 have "s1 \<in> r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" by fact+ |
639 then have as1: "s1 = flat v1" "s2 = flat v2" by (simp_all add: Posix1(2)) |
627 then have as1: "s1 = flat v1" "s2 = flat v2" by (simp_all add: Posix1(2)) |
640 have IH1: "\<And>v3. v3 \<in> CPT r1 s1 \<Longrightarrow> v1 :\<sqsubseteq>val v3" by fact |
628 have IH1: "\<And>v3. v3 \<in> CV r1 s1 \<Longrightarrow> v1 :\<sqsubseteq>val v3" by fact |
641 have IH2: "\<And>v3. v3 \<in> CPT r2 s2 \<Longrightarrow> v2 :\<sqsubseteq>val v3" by fact |
629 have IH2: "\<And>v3. v3 \<in> CV r2 s2 \<Longrightarrow> v2 :\<sqsubseteq>val v3" by fact |
642 have cond: "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by fact |
630 have cond: "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by fact |
643 have "v3 \<in> CPT (SEQ r1 r2) (s1 @ s2)" by fact |
631 have "v3 \<in> CV (SEQ r1 r2) (s1 @ s2)" by fact |
644 then obtain v3a v3b where eqs: |
632 then obtain v3a v3b where eqs: |
645 "v3 = Seq v3a v3b" "\<Turnstile> v3a : r1" "\<Turnstile> v3b : r2" |
633 "v3 = Seq v3a v3b" "\<Turnstile> v3a : r1" "\<Turnstile> v3b : r2" |
646 "flat v3a @ flat v3b = s1 @ s2" |
634 "flat v3a @ flat v3b = s1 @ s2" |
647 by (force simp add: prefix_list_def CPT_def elim: CPrf.cases) |
635 by (force simp add: prefix_list_def CV_def elim: CPrf.cases) |
648 with cond have "flat v3a \<sqsubseteq>pre s1" unfolding prefix_list_def |
636 with cond have "flat v3a \<sqsubseteq>pre s1" unfolding prefix_list_def |
649 by (smt L_flat_Prf1 Prf_CPrf append_eq_append_conv2 append_self_conv) |
637 by (smt L_flat_Prf1 Prf_CPrf append_eq_append_conv2 append_self_conv) |
650 then have "flat v3a \<sqsubset>spre s1 \<or> (flat v3a = s1 \<and> flat v3b = s2)" using eqs |
638 then have "flat v3a \<sqsubset>spre s1 \<or> (flat v3a = s1 \<and> flat v3b = s2)" using eqs |
651 by (simp add: sprefix_list_def append_eq_conv_conj) |
639 by (simp add: sprefix_list_def append_eq_conv_conj) |
652 then have q2: "v1 :\<sqsubset>val v3a \<or> (flat v3a = s1 \<and> flat v3b = s2)" |
640 then have q2: "v1 :\<sqsubset>val v3a \<or> (flat v3a = s1 \<and> flat v3b = s2)" |
653 using PosOrd_spreI as1(1) eqs by blast |
641 using PosOrd_spreI as1(1) eqs by blast |
654 then have "v1 :\<sqsubset>val v3a \<or> (v3a \<in> CPT r1 s1 \<and> v3b \<in> CPT r2 s2)" using eqs(2,3) |
642 then have "v1 :\<sqsubset>val v3a \<or> (v3a \<in> CV r1 s1 \<and> v3b \<in> CV r2 s2)" using eqs(2,3) |
655 by (auto simp add: CPT_def) |
643 by (auto simp add: CV_def) |
656 then have "v1 :\<sqsubset>val v3a \<or> (v1 :\<sqsubseteq>val v3a \<and> v2 :\<sqsubseteq>val v3b)" using IH1 IH2 by blast |
644 then have "v1 :\<sqsubset>val v3a \<or> (v1 :\<sqsubseteq>val v3a \<and> v2 :\<sqsubseteq>val v3b)" using IH1 IH2 by blast |
657 then have "Seq v1 v2 :\<sqsubseteq>val Seq v3a v3b" using eqs q2 as1 |
645 then have "Seq v1 v2 :\<sqsubseteq>val Seq v3a v3b" using eqs q2 as1 |
658 unfolding PosOrd_ex_eq_def by (auto simp add: PosOrd_SeqI1 PosOrd_SeqI2) |
646 unfolding PosOrd_ex_eq_def by (auto simp add: PosOrd_SeqI1 PosOrd_SeqI2) |
659 then show "Seq v1 v2 :\<sqsubseteq>val v3" unfolding eqs by blast |
647 then show "Seq v1 v2 :\<sqsubseteq>val v3" unfolding eqs by blast |
660 next |
648 next |
661 case (Posix_STAR1 s1 r v s2 vs v3) |
649 case (Posix_STAR1 s1 r v s2 vs v3) |
662 have "s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" by fact+ |
650 have "s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" by fact+ |
663 then have as1: "s1 = flat v" "s2 = flat (Stars vs)" by (auto dest: Posix1(2)) |
651 then have as1: "s1 = flat v" "s2 = flat (Stars vs)" by (auto dest: Posix1(2)) |
664 have IH1: "\<And>v3. v3 \<in> CPT r s1 \<Longrightarrow> v :\<sqsubseteq>val v3" by fact |
652 have IH1: "\<And>v3. v3 \<in> CV r s1 \<Longrightarrow> v :\<sqsubseteq>val v3" by fact |
665 have IH2: "\<And>v3. v3 \<in> CPT (STAR r) s2 \<Longrightarrow> Stars vs :\<sqsubseteq>val v3" by fact |
653 have IH2: "\<And>v3. v3 \<in> CV (STAR r) s2 \<Longrightarrow> Stars vs :\<sqsubseteq>val v3" by fact |
666 have cond: "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" by fact |
654 have cond: "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" by fact |
667 have cond2: "flat v \<noteq> []" by fact |
655 have cond2: "flat v \<noteq> []" by fact |
668 have "v3 \<in> CPT (STAR r) (s1 @ s2)" by fact |
656 have "v3 \<in> CV (STAR r) (s1 @ s2)" by fact |
669 then consider |
657 then consider |
670 (NonEmpty) v3a vs3 where "v3 = Stars (v3a # vs3)" |
658 (NonEmpty) v3a vs3 where "v3 = Stars (v3a # vs3)" |
671 "\<Turnstile> v3a : r" "\<Turnstile> Stars vs3 : STAR r" |
659 "\<Turnstile> v3a : r" "\<Turnstile> Stars vs3 : STAR r" |
672 "flat (Stars (v3a # vs3)) = s1 @ s2" |
660 "flat (Stars (v3a # vs3)) = s1 @ s2" |
673 | (Empty) "v3 = Stars []" |
661 | (Empty) "v3 = Stars []" |
674 unfolding CPT_def |
662 unfolding CV_def |
675 apply(auto) |
663 apply(auto) |
676 apply(erule CPrf.cases) |
664 apply(erule CPrf.cases) |
677 apply(simp_all) |
665 apply(simp_all) |
678 apply(auto)[1] |
666 apply(auto)[1] |
679 apply(case_tac vs) |
667 apply(case_tac vs) |
706 unfolding PosOrd_ex_eq_def using cond2 |
694 unfolding PosOrd_ex_eq_def using cond2 |
707 by (simp add: PosOrd_shorterI) |
695 by (simp add: PosOrd_shorterI) |
708 qed |
696 qed |
709 next |
697 next |
710 case (Posix_STAR2 r v2) |
698 case (Posix_STAR2 r v2) |
711 have "v2 \<in> CPT (STAR r) []" by fact |
699 have "v2 \<in> CV (STAR r) []" by fact |
712 then have "v2 = Stars []" |
700 then have "v2 = Stars []" |
713 unfolding CPT_def by (auto elim: CPrf.cases) |
701 unfolding CV_def by (auto elim: CPrf.cases) |
714 then show "Stars [] :\<sqsubseteq>val v2" |
702 then show "Stars [] :\<sqsubseteq>val v2" |
715 by (simp add: PosOrd_ex_eq_def) |
703 by (simp add: PosOrd_ex_eq_def) |
716 qed |
704 qed |
717 |
705 |
718 lemma Posix_PosOrd_stronger: |
|
719 assumes "s \<in> r \<rightarrow> v1" "v2 \<in> CPTpre r s" |
|
720 shows "v1 :\<sqsubseteq>val v2" |
|
721 proof - |
|
722 from assms(2) have "v2 \<in> CPT r s \<or> flat v2 \<sqsubset>spre s" |
|
723 unfolding CPTpre_def CPT_def sprefix_list_def prefix_list_def by auto |
|
724 moreover |
|
725 { assume "v2 \<in> CPT r s" |
|
726 with assms(1) |
|
727 have "v1 :\<sqsubseteq>val v2" by (rule Posix_PosOrd) |
|
728 } |
|
729 moreover |
|
730 { assume "flat v2 \<sqsubset>spre s" |
|
731 then have "flat v2 \<sqsubset>spre flat v1" using assms(1) |
|
732 using Posix1(2) by blast |
|
733 then have "v1 :\<sqsubseteq>val v2" |
|
734 by (simp add: PosOrd_ex_eq_def PosOrd_spreI) |
|
735 } |
|
736 ultimately show "v1 :\<sqsubseteq>val v2" by blast |
|
737 qed |
|
738 |
706 |
739 lemma Posix_PosOrd_reverse: |
707 lemma Posix_PosOrd_reverse: |
740 assumes "s \<in> r \<rightarrow> v1" |
708 assumes "s \<in> r \<rightarrow> v1" |
741 shows "\<not>(\<exists>v2 \<in> CPTpre r s. v2 :\<sqsubset>val v1)" |
709 shows "\<not>(\<exists>v2 \<in> CV r s. v2 :\<sqsubset>val v1)" |
742 using assms |
710 using assms |
743 by (metis Posix_PosOrd_stronger less_irrefl PosOrd_def |
711 by (metis Posix_PosOrd less_irrefl PosOrd_def |
744 PosOrd_ex_eq_def PosOrd_ex_def PosOrd_trans) |
712 PosOrd_ex_eq_def PosOrd_ex_def PosOrd_trans) |
745 |
713 |
746 |
|
747 lemma test2: |
|
748 assumes "\<forall>v \<in> set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" |
|
749 shows "(Stars vs) \<in> CPT (STAR r) (flat (Stars vs))" |
|
750 using assms |
|
751 apply(induct vs) |
|
752 apply(auto simp add: CPT_def) |
|
753 apply(rule CPrf.intros) |
|
754 apply(simp) |
|
755 apply(rule CPrf.intros) |
|
756 apply(simp_all) |
|
757 by (metis (no_types, lifting) CPT_def Posix_CPT mem_Collect_eq) |
|
758 |
714 |
759 |
715 |
760 lemma PosOrd_Posix_Stars: |
716 lemma PosOrd_Posix_Stars: |
761 assumes "\<forall>v \<in> set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" |
717 assumes "\<forall>v \<in> set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" |
762 and "\<not>(\<exists>vs2 \<in> PT (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val (Stars vs))" |
718 and "\<not>(\<exists>vs2 \<in> LV (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val (Stars vs))" |
763 shows "(flat (Stars vs)) \<in> (STAR r) \<rightarrow> Stars vs" |
719 shows "(flat (Stars vs)) \<in> (STAR r) \<rightarrow> Stars vs" |
764 using assms |
720 using assms |
765 proof(induct vs) |
721 proof(induct vs) |
766 case Nil |
722 case Nil |
767 show "flat (Stars []) \<in> STAR r \<rightarrow> Stars []" |
723 show "flat (Stars []) \<in> STAR r \<rightarrow> Stars []" |
768 by(simp add: Posix.intros) |
724 by(simp add: Posix.intros) |
769 next |
725 next |
770 case (Cons v vs) |
726 case (Cons v vs) |
771 have IH: "\<lbrakk>\<forall>v\<in>set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []; |
727 have IH: "\<lbrakk>\<forall>v\<in>set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []; |
772 \<not> (\<exists>vs2\<in>PT (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs)\<rbrakk> |
728 \<not> (\<exists>vs2\<in>LV (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs)\<rbrakk> |
773 \<Longrightarrow> flat (Stars vs) \<in> STAR r \<rightarrow> Stars vs" by fact |
729 \<Longrightarrow> flat (Stars vs) \<in> STAR r \<rightarrow> Stars vs" by fact |
774 have as2: "\<forall>v\<in>set (v # vs). flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" by fact |
730 have as2: "\<forall>v\<in>set (v # vs). flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" by fact |
775 have as3: "\<not> (\<exists>vs2\<in>PT (STAR r) (flat (Stars (v # vs))). vs2 :\<sqsubset>val Stars (v # vs))" by fact |
731 have as3: "\<not> (\<exists>vs2\<in>LV (STAR r) (flat (Stars (v # vs))). vs2 :\<sqsubset>val Stars (v # vs))" by fact |
776 have "flat v \<in> r \<rightarrow> v" using as2 by simp |
732 have "flat v \<in> r \<rightarrow> v" using as2 by simp |
777 moreover |
733 moreover |
778 have "flat (Stars vs) \<in> STAR r \<rightarrow> Stars vs" |
734 have "flat (Stars vs) \<in> STAR r \<rightarrow> Stars vs" |
779 proof (rule IH) |
735 proof (rule IH) |
780 show "\<forall>v\<in>set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" using as2 by simp |
736 show "\<forall>v\<in>set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" using as2 by simp |
781 next |
737 next |
782 show "\<not> (\<exists>vs2\<in>PT (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs)" using as3 |
738 show "\<not> (\<exists>vs2\<in>LV (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs)" using as3 |
783 apply(auto) |
739 apply(auto) |
784 apply(subst (asm) (2) PT_def) |
740 apply(subst (asm) (2) LV_def) |
785 apply(auto) |
741 apply(auto) |
786 apply(erule Prf.cases) |
742 apply(erule Prf.cases) |
787 apply(simp_all) |
743 apply(simp_all) |
788 apply(drule_tac x="Stars (v # vs)" in bspec) |
744 apply(drule_tac x="Stars (v # vs)" in bspec) |
789 apply(simp add: PT_def CPT_def) |
745 apply(simp add: LV_def CV_def) |
790 using Posix_Prf Prf.intros(6) calculation |
746 using Posix_Prf Prf.intros(6) calculation |
791 apply(rule_tac Prf.intros) |
747 apply(rule_tac Prf.intros) |
792 apply(simp add:) |
748 apply(simp add:) |
793 apply (simp add: PosOrd_StarsI2) |
749 apply (simp add: PosOrd_StarsI2) |
794 done |
750 done |
821 |
777 |
822 |
778 |
823 section {* The Smallest Value is indeed the Posix Value *} |
779 section {* The Smallest Value is indeed the Posix Value *} |
824 |
780 |
825 text {* |
781 text {* |
826 The next lemma seems to require PT instead of CPT in the Star-case. |
782 The next lemma seems to require LV instead of CV in the Star-case. |
827 *} |
783 *} |
828 |
784 |
829 lemma PosOrd_Posix: |
785 lemma PosOrd_Posix: |
830 assumes "v1 \<in> CPT r s" "\<forall>v\<^sub>2 \<in> PT r s. \<not> v\<^sub>2 :\<sqsubset>val v1" |
786 assumes "v1 \<in> CV r s" "\<forall>v\<^sub>2 \<in> LV r s. \<not> v\<^sub>2 :\<sqsubset>val v1" |
831 shows "s \<in> r \<rightarrow> v1" |
787 shows "s \<in> r \<rightarrow> v1" |
832 using assms |
788 using assms |
833 proof(induct r arbitrary: s v1) |
789 proof(induct r arbitrary: s v1) |
834 case (ZERO s v1) |
790 case (ZERO s v1) |
835 have "v1 \<in> CPT ZERO s" by fact |
791 have "v1 \<in> CV ZERO s" by fact |
836 then show "s \<in> ZERO \<rightarrow> v1" unfolding CPT_def |
792 then show "s \<in> ZERO \<rightarrow> v1" unfolding CV_def |
837 by (auto elim: CPrf.cases) |
793 by (auto elim: CPrf.cases) |
838 next |
794 next |
839 case (ONE s v1) |
795 case (ONE s v1) |
840 have "v1 \<in> CPT ONE s" by fact |
796 have "v1 \<in> CV ONE s" by fact |
841 then show "s \<in> ONE \<rightarrow> v1" unfolding CPT_def |
797 then show "s \<in> ONE \<rightarrow> v1" unfolding CV_def |
842 by(auto elim!: CPrf.cases intro: Posix.intros) |
798 by(auto elim!: CPrf.cases intro: Posix.intros) |
843 next |
799 next |
844 case (CHAR c s v1) |
800 case (CHAR c s v1) |
845 have "v1 \<in> CPT (CHAR c) s" by fact |
801 have "v1 \<in> CV (CHAR c) s" by fact |
846 then show "s \<in> CHAR c \<rightarrow> v1" unfolding CPT_def |
802 then show "s \<in> CHAR c \<rightarrow> v1" unfolding CV_def |
847 by (auto elim!: CPrf.cases intro: Posix.intros) |
803 by (auto elim!: CPrf.cases intro: Posix.intros) |
848 next |
804 next |
849 case (ALT r1 r2 s v1) |
805 case (ALT r1 r2 s v1) |
850 have IH1: "\<And>s v1. \<lbrakk>v1 \<in> CPT r1 s; \<forall>v2 \<in> PT r1 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r1 \<rightarrow> v1" by fact |
806 have IH1: "\<And>s v1. \<lbrakk>v1 \<in> CV r1 s; \<forall>v2 \<in> LV r1 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r1 \<rightarrow> v1" by fact |
851 have IH2: "\<And>s v1. \<lbrakk>v1 \<in> CPT r2 s; \<forall>v2 \<in> PT r2 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r2 \<rightarrow> v1" by fact |
807 have IH2: "\<And>s v1. \<lbrakk>v1 \<in> CV r2 s; \<forall>v2 \<in> LV r2 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r2 \<rightarrow> v1" by fact |
852 have as1: "\<forall>v2\<in>PT (ALT r1 r2) s. \<not> v2 :\<sqsubset>val v1" by fact |
808 have as1: "\<forall>v2\<in>LV (ALT r1 r2) s. \<not> v2 :\<sqsubset>val v1" by fact |
853 have as2: "v1 \<in> CPT (ALT r1 r2) s" by fact |
809 have as2: "v1 \<in> CV (ALT r1 r2) s" by fact |
854 then consider |
810 then consider |
855 (Left) v1' where |
811 (Left) v1' where |
856 "v1 = Left v1'" "s = flat v1'" |
812 "v1 = Left v1'" "s = flat v1'" |
857 "v1' \<in> CPT r1 s" |
813 "v1' \<in> CV r1 s" |
858 | (Right) v1' where |
814 | (Right) v1' where |
859 "v1 = Right v1'" "s = flat v1'" |
815 "v1 = Right v1'" "s = flat v1'" |
860 "v1' \<in> CPT r2 s" |
816 "v1' \<in> CV r2 s" |
861 unfolding CPT_def by (auto elim: CPrf.cases) |
817 unfolding CV_def by (auto elim: CPrf.cases) |
862 then show "s \<in> ALT r1 r2 \<rightarrow> v1" |
818 then show "s \<in> ALT r1 r2 \<rightarrow> v1" |
863 proof (cases) |
819 proof (cases) |
864 case (Left v1') |
820 case (Left v1') |
865 have "v1' \<in> CPT r1 s" using as2 |
821 have "v1' \<in> CV r1 s" using as2 |
866 unfolding CPT_def Left by (auto elim: CPrf.cases) |
822 unfolding CV_def Left by (auto elim: CPrf.cases) |
867 moreover |
823 moreover |
868 have "\<forall>v2 \<in> PT r1 s. \<not> v2 :\<sqsubset>val v1'" using as1 |
824 have "\<forall>v2 \<in> LV r1 s. \<not> v2 :\<sqsubset>val v1'" using as1 |
869 unfolding PT_def Left using Prf.intros(2) PosOrd_Left_eq by force |
825 unfolding LV_def Left using Prf.intros(2) PosOrd_Left_eq by force |
870 ultimately have "s \<in> r1 \<rightarrow> v1'" using IH1 by simp |
826 ultimately have "s \<in> r1 \<rightarrow> v1'" using IH1 by simp |
871 then have "s \<in> ALT r1 r2 \<rightarrow> Left v1'" by (rule Posix.intros) |
827 then have "s \<in> ALT r1 r2 \<rightarrow> Left v1'" by (rule Posix.intros) |
872 then show "s \<in> ALT r1 r2 \<rightarrow> v1" using Left by simp |
828 then show "s \<in> ALT r1 r2 \<rightarrow> v1" using Left by simp |
873 next |
829 next |
874 case (Right v1') |
830 case (Right v1') |
875 have "v1' \<in> CPT r2 s" using as2 |
831 have "v1' \<in> CV r2 s" using as2 |
876 unfolding CPT_def Right by (auto elim: CPrf.cases) |
832 unfolding CV_def Right by (auto elim: CPrf.cases) |
877 moreover |
833 moreover |
878 have "\<forall>v2 \<in> PT r2 s. \<not> v2 :\<sqsubset>val v1'" using as1 |
834 have "\<forall>v2 \<in> LV r2 s. \<not> v2 :\<sqsubset>val v1'" using as1 |
879 unfolding PT_def Right using Prf.intros(3) PosOrd_RightI by force |
835 unfolding LV_def Right using Prf.intros(3) PosOrd_RightI by force |
880 ultimately have "s \<in> r2 \<rightarrow> v1'" using IH2 by simp |
836 ultimately have "s \<in> r2 \<rightarrow> v1'" using IH2 by simp |
881 moreover |
837 moreover |
882 { assume "s \<in> L r1" |
838 { assume "s \<in> L r1" |
883 then obtain v' where "v' \<in> PT r1 s" |
839 then obtain v' where "v' \<in> LV r1 s" |
884 unfolding PT_def using L_flat_Prf2 by blast |
840 unfolding LV_def using L_flat_Prf2 by blast |
885 then have "Left v' \<in> PT (ALT r1 r2) s" |
841 then have "Left v' \<in> LV (ALT r1 r2) s" |
886 unfolding PT_def by (auto intro: Prf.intros) |
842 unfolding LV_def by (auto intro: Prf.intros) |
887 with as1 have "\<not> (Left v' :\<sqsubset>val Right v1') \<and> (flat v' = s)" |
843 with as1 have "\<not> (Left v' :\<sqsubset>val Right v1') \<and> (flat v' = s)" |
888 unfolding PT_def Right by (auto) |
844 unfolding LV_def Right by (auto) |
889 then have False using PosOrd_Left_Right Right by blast |
845 then have False using PosOrd_Left_Right Right by blast |
890 } |
846 } |
891 then have "s \<notin> L r1" by rule |
847 then have "s \<notin> L r1" by rule |
892 ultimately have "s \<in> ALT r1 r2 \<rightarrow> Right v1'" by (rule Posix.intros) |
848 ultimately have "s \<in> ALT r1 r2 \<rightarrow> Right v1'" by (rule Posix.intros) |
893 then show "s \<in> ALT r1 r2 \<rightarrow> v1" using Right by simp |
849 then show "s \<in> ALT r1 r2 \<rightarrow> v1" using Right by simp |
894 qed |
850 qed |
895 next |
851 next |
896 case (SEQ r1 r2 s v1) |
852 case (SEQ r1 r2 s v1) |
897 have IH1: "\<And>s v1. \<lbrakk>v1 \<in> CPT r1 s; \<forall>v2 \<in> PT r1 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r1 \<rightarrow> v1" by fact |
853 have IH1: "\<And>s v1. \<lbrakk>v1 \<in> CV r1 s; \<forall>v2 \<in> LV r1 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r1 \<rightarrow> v1" by fact |
898 have IH2: "\<And>s v1. \<lbrakk>v1 \<in> CPT r2 s; \<forall>v2 \<in> PT r2 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r2 \<rightarrow> v1" by fact |
854 have IH2: "\<And>s v1. \<lbrakk>v1 \<in> CV r2 s; \<forall>v2 \<in> LV r2 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r2 \<rightarrow> v1" by fact |
899 have as1: "\<forall>v2\<in>PT (SEQ r1 r2) s. \<not> v2 :\<sqsubset>val v1" by fact |
855 have as1: "\<forall>v2\<in>LV (SEQ r1 r2) s. \<not> v2 :\<sqsubset>val v1" by fact |
900 have as2: "v1 \<in> CPT (SEQ r1 r2) s" by fact |
856 have as2: "v1 \<in> CV (SEQ r1 r2) s" by fact |
901 then obtain |
857 then obtain |
902 v1a v1b where eqs: |
858 v1a v1b where eqs: |
903 "v1 = Seq v1a v1b" "s = flat v1a @ flat v1b" |
859 "v1 = Seq v1a v1b" "s = flat v1a @ flat v1b" |
904 "v1a \<in> CPT r1 (flat v1a)" "v1b \<in> CPT r2 (flat v1b)" |
860 "v1a \<in> CV r1 (flat v1a)" "v1b \<in> CV r2 (flat v1b)" |
905 unfolding CPT_def by(auto elim: CPrf.cases) |
861 unfolding CV_def by(auto elim: CPrf.cases) |
906 have "\<forall>v2 \<in> PT r1 (flat v1a). \<not> v2 :\<sqsubset>val v1a" |
862 have "\<forall>v2 \<in> LV r1 (flat v1a). \<not> v2 :\<sqsubset>val v1a" |
907 proof |
863 proof |
908 fix v2 |
864 fix v2 |
909 assume "v2 \<in> PT r1 (flat v1a)" |
865 assume "v2 \<in> LV r1 (flat v1a)" |
910 with eqs(2,4) have "Seq v2 v1b \<in> PT (SEQ r1 r2) s" |
866 with eqs(2,4) have "Seq v2 v1b \<in> LV (SEQ r1 r2) s" |
911 by (simp add: CPT_def PT_def Prf.intros(1) Prf_CPrf) |
867 by (simp add: CV_def LV_def Prf.intros(1) Prf_CPrf) |
912 with as1 have "\<not> Seq v2 v1b :\<sqsubset>val Seq v1a v1b \<and> flat (Seq v2 v1b) = flat (Seq v1a v1b)" |
868 with as1 have "\<not> Seq v2 v1b :\<sqsubset>val Seq v1a v1b \<and> flat (Seq v2 v1b) = flat (Seq v1a v1b)" |
913 using eqs by (simp add: PT_def) |
869 using eqs by (simp add: LV_def) |
914 then show "\<not> v2 :\<sqsubset>val v1a" |
870 then show "\<not> v2 :\<sqsubset>val v1a" |
915 using PosOrd_SeqI1 by blast |
871 using PosOrd_SeqI1 by blast |
916 qed |
872 qed |
917 then have "flat v1a \<in> r1 \<rightarrow> v1a" using IH1 eqs by simp |
873 then have "flat v1a \<in> r1 \<rightarrow> v1a" using IH1 eqs by simp |
918 moreover |
874 moreover |
919 have "\<forall>v2 \<in> PT r2 (flat v1b). \<not> v2 :\<sqsubset>val v1b" |
875 have "\<forall>v2 \<in> LV r2 (flat v1b). \<not> v2 :\<sqsubset>val v1b" |
920 proof |
876 proof |
921 fix v2 |
877 fix v2 |
922 assume "v2 \<in> PT r2 (flat v1b)" |
878 assume "v2 \<in> LV r2 (flat v1b)" |
923 with eqs(2,3,4) have "Seq v1a v2 \<in> PT (SEQ r1 r2) s" |
879 with eqs(2,3,4) have "Seq v1a v2 \<in> LV (SEQ r1 r2) s" |
924 by (simp add: CPT_def PT_def Prf.intros Prf_CPrf) |
880 by (simp add: CV_def LV_def Prf.intros Prf_CPrf) |
925 with as1 have "\<not> Seq v1a v2 :\<sqsubset>val Seq v1a v1b \<and> flat v2 = flat v1b" |
881 with as1 have "\<not> Seq v1a v2 :\<sqsubset>val Seq v1a v1b \<and> flat v2 = flat v1b" |
926 using eqs by (simp add: PT_def) |
882 using eqs by (simp add: LV_def) |
927 then show "\<not> v2 :\<sqsubset>val v1b" |
883 then show "\<not> v2 :\<sqsubset>val v1b" |
928 using PosOrd_SeqI2 by auto |
884 using PosOrd_SeqI2 by auto |
929 qed |
885 qed |
930 then have "flat v1b \<in> r2 \<rightarrow> v1b" using IH2 eqs by simp |
886 then have "flat v1b \<in> r2 \<rightarrow> v1b" using IH2 eqs by simp |
931 moreover |
887 moreover |
933 proof |
889 proof |
934 assume "\<exists>s3 s4. s3 \<noteq> [] \<and> s3 @ s4 = flat v1b \<and> flat v1a @ s3 \<in> L r1 \<and> s4 \<in> L r2" |
890 assume "\<exists>s3 s4. s3 \<noteq> [] \<and> s3 @ s4 = flat v1b \<and> flat v1a @ s3 \<in> L r1 \<and> s4 \<in> L r2" |
935 then obtain s3 s4 where q1: "s3 \<noteq> [] \<and> s3 @ s4 = flat v1b \<and> flat v1a @ s3 \<in> L r1 \<and> s4 \<in> L r2" by blast |
891 then obtain s3 s4 where q1: "s3 \<noteq> [] \<and> s3 @ s4 = flat v1b \<and> flat v1a @ s3 \<in> L r1 \<and> s4 \<in> L r2" by blast |
936 then obtain vA vB where q2: "flat vA = flat v1a @ s3" "\<turnstile> vA : r1" "flat vB = s4" "\<turnstile> vB : r2" |
892 then obtain vA vB where q2: "flat vA = flat v1a @ s3" "\<turnstile> vA : r1" "flat vB = s4" "\<turnstile> vB : r2" |
937 using L_flat_Prf2 by blast |
893 using L_flat_Prf2 by blast |
938 then have "Seq vA vB \<in> PT (SEQ r1 r2) s" unfolding eqs using q1 |
894 then have "Seq vA vB \<in> LV (SEQ r1 r2) s" unfolding eqs using q1 |
939 by (auto simp add: PT_def intro: Prf.intros) |
895 by (auto simp add: LV_def intro: Prf.intros) |
940 with as1 have "\<not> Seq vA vB :\<sqsubset>val Seq v1a v1b" unfolding eqs by auto |
896 with as1 have "\<not> Seq vA vB :\<sqsubset>val Seq v1a v1b" unfolding eqs by auto |
941 then have "\<not> vA :\<sqsubset>val v1a \<and> length (flat vA) > length (flat v1a)" using q1 q2 PosOrd_SeqI1 by auto |
897 then have "\<not> vA :\<sqsubset>val v1a \<and> length (flat vA) > length (flat v1a)" using q1 q2 PosOrd_SeqI1 by auto |
942 then show "False" |
898 then show "False" |
943 using PosOrd_shorterI by blast |
899 using PosOrd_shorterI by blast |
944 qed |
900 qed |
945 ultimately |
901 ultimately |
946 show "s \<in> SEQ r1 r2 \<rightarrow> v1" unfolding eqs |
902 show "s \<in> SEQ r1 r2 \<rightarrow> v1" unfolding eqs |
947 by (rule Posix.intros) |
903 by (rule Posix.intros) |
948 next |
904 next |
949 case (STAR r s v1) |
905 case (STAR r s v1) |
950 have IH: "\<And>s v1. \<lbrakk>v1 \<in> CPT r s; \<forall>v2\<in>PT r s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r \<rightarrow> v1" by fact |
906 have IH: "\<And>s v1. \<lbrakk>v1 \<in> CV r s; \<forall>v2\<in>LV r s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r \<rightarrow> v1" by fact |
951 have as1: "\<forall>v2\<in>PT (STAR r) s. \<not> v2 :\<sqsubset>val v1" by fact |
907 have as1: "\<forall>v2\<in>LV (STAR r) s. \<not> v2 :\<sqsubset>val v1" by fact |
952 have as2: "v1 \<in> CPT (STAR r) s" by fact |
908 have as2: "v1 \<in> CV (STAR r) s" by fact |
953 then obtain |
909 then obtain |
954 vs where eqs: |
910 vs where eqs: |
955 "v1 = Stars vs" "s = flat (Stars vs)" |
911 "v1 = Stars vs" "s = flat (Stars vs)" |
956 "\<forall>v \<in> set vs. v \<in> CPT r (flat v)" |
912 "\<forall>v \<in> set vs. v \<in> CV r (flat v)" |
957 unfolding CPT_def by (auto elim: CPrf.cases dest!: CPrf_stars) |
913 unfolding CV_def by (auto elim: CPrf.cases) |
958 have "\<forall>v\<in>set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" |
914 have "\<forall>v\<in>set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" |
959 proof |
915 proof |
960 fix v |
916 fix v |
961 assume a: "v \<in> set vs" |
917 assume a: "v \<in> set vs" |
962 then obtain pre post where e: "vs = pre @ [v] @ post" |
918 then obtain pre post where e: "vs = pre @ [v] @ post" |
963 by (metis append_Cons append_Nil in_set_conv_decomp_first) |
919 by (metis append_Cons append_Nil in_set_conv_decomp_first) |
964 then have q: "\<forall>v2\<in>PT (STAR r) s. \<not> v2 :\<sqsubset>val Stars (pre @ [v] @ post)" |
920 then have q: "\<forall>v2\<in>LV (STAR r) s. \<not> v2 :\<sqsubset>val Stars (pre @ [v] @ post)" |
965 using as1 unfolding eqs by simp |
921 using as1 unfolding eqs by simp |
966 have "\<forall>v2\<in>PT r (flat v). \<not> v2 :\<sqsubset>val v" unfolding eqs |
922 have "\<forall>v2\<in>LV r (flat v). \<not> v2 :\<sqsubset>val v" unfolding eqs |
967 proof (rule ballI, rule notI) |
923 proof (rule ballI, rule notI) |
968 fix v2 |
924 fix v2 |
969 assume w: "v2 :\<sqsubset>val v" |
925 assume w: "v2 :\<sqsubset>val v" |
970 assume "v2 \<in> PT r (flat v)" |
926 assume "v2 \<in> LV r (flat v)" |
971 then have "Stars (pre @ [v2] @ post) \<in> PT (STAR r) s" |
927 then have "Stars (pre @ [v2] @ post) \<in> LV (STAR r) s" |
972 using as2 unfolding e eqs |
928 using as2 unfolding e eqs |
973 apply(auto simp add: CPT_def PT_def intro!: Prf.intros)[1] |
929 apply(auto simp add: CV_def LV_def intro!: Prf.intros)[1] |
974 using CPrf_Stars_appendE CPrf_stars Prf_CPrf apply blast |
930 using CPrf_Stars_appendE Prf_CPrf Prf_elims(6) list.set_intros apply blast |
975 by (meson CPrf_Stars_appendE CPrf_stars Prf_CPrf list.set_intros(2)) |
931 by (metis CPrf_Stars_appendE Prf_CPrf Prf_elims(6) list.set_intros(2) val.inject(5)) |
976 then have "\<not> Stars (pre @ [v2] @ post) :\<sqsubset>val Stars (pre @ [v] @ post)" |
932 then have "\<not> Stars (pre @ [v2] @ post) :\<sqsubset>val Stars (pre @ [v] @ post)" |
977 using q by simp |
933 using q by simp |
978 with w show "False" |
934 with w show "False" |
979 using PT_def \<open>v2 \<in> PT r (flat v)\<close> append_Cons flat.simps(7) mem_Collect_eq |
935 using LV_def \<open>v2 \<in> LV r (flat v)\<close> append_Cons flat.simps(7) mem_Collect_eq |
980 PosOrd_StarsI PosOrd_Stars_appendI by auto |
936 PosOrd_StarsI PosOrd_Stars_appendI by auto |
981 qed |
937 qed |
982 with IH |
938 with IH |
983 show "flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" using a as2 unfolding eqs |
939 show "flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" using a as2 unfolding eqs CV_def |
984 using eqs(3) by (smt CPT_def CPrf_stars mem_Collect_eq) |
940 by (auto elim: CPrf.cases) |
985 qed |
941 qed |
986 moreover |
942 moreover |
987 have "\<not> (\<exists>vs2\<in>PT (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs)" |
943 have "\<not> (\<exists>vs2\<in>LV (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs)" |
988 proof |
944 proof |
989 assume "\<exists>vs2 \<in> PT (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs" |
945 assume "\<exists>vs2 \<in> LV (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs" |
990 then obtain vs2 where "\<turnstile> Stars vs2 : STAR r" "flat (Stars vs2) = flat (Stars vs)" |
946 then obtain vs2 where "\<turnstile> Stars vs2 : STAR r" "flat (Stars vs2) = flat (Stars vs)" |
991 "Stars vs2 :\<sqsubset>val Stars vs" |
947 "Stars vs2 :\<sqsubset>val Stars vs" |
992 unfolding PT_def |
948 unfolding LV_def |
993 apply(auto elim: Prf.cases) |
949 apply(auto) |
994 apply(erule Prf.cases) |
950 apply(erule Prf.cases) |
995 apply(auto intro: Prf.intros) |
951 apply(auto intro: Prf.intros) |
996 done |
952 done |
997 then show "False" using as1 unfolding eqs |
953 then show "False" using as1 unfolding eqs |
998 apply - |
954 apply - |
999 apply(drule_tac x="Stars vs2" in bspec) |
955 apply(drule_tac x="Stars vs2" in bspec) |
1000 apply(auto simp add: PT_def) |
956 apply(auto simp add: LV_def) |
1001 done |
957 done |
1002 qed |
958 qed |
1003 ultimately have "flat (Stars vs) \<in> STAR r \<rightarrow> Stars vs" |
959 ultimately have "flat (Stars vs) \<in> STAR r \<rightarrow> Stars vs" |
1004 thm PosOrd_Posix_Stars |
960 thm PosOrd_Posix_Stars |
1005 by (rule PosOrd_Posix_Stars) |
961 by (rule PosOrd_Posix_Stars) |