511 lemma not_bn: "bound0 p \<Longrightarrow> bound0 (not p)" |
523 lemma not_bn: "bound0 p \<Longrightarrow> bound0 (not p)" |
512 by (cases p) auto |
524 by (cases p) auto |
513 |
525 |
514 definition conj :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
526 definition conj :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
515 where |
527 where |
516 "conj p q = (if (p = F \<or> q=F) then F else if p=T then q else if q=T then p else And p q)" |
528 "conj p q = |
|
529 (if p = F \<or> q = F then F |
|
530 else if p = T then q |
|
531 else if q = T then p |
|
532 else And p q)" |
517 |
533 |
518 lemma conj: "Ifm bbs bs (conj p q) = Ifm bbs bs (And p q)" |
534 lemma conj: "Ifm bbs bs (conj p q) = Ifm bbs bs (And p q)" |
519 by (cases "p=F \<or> q=F", simp_all add: conj_def) (cases p, simp_all) |
535 by (cases "p = F \<or> q = F", simp_all add: conj_def) (cases p, simp_all) |
520 |
536 |
521 lemma conj_qf: "qfree p \<Longrightarrow> qfree q \<Longrightarrow> qfree (conj p q)" |
537 lemma conj_qf: "qfree p \<Longrightarrow> qfree q \<Longrightarrow> qfree (conj p q)" |
522 using conj_def by auto |
538 using conj_def by auto |
523 |
539 |
524 lemma conj_nb: "bound0 p \<Longrightarrow> bound0 q \<Longrightarrow> bound0 (conj p q)" |
540 lemma conj_nb: "bound0 p \<Longrightarrow> bound0 q \<Longrightarrow> bound0 (conj p q)" |
525 using conj_def by auto |
541 using conj_def by auto |
526 |
542 |
527 definition disj :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
543 definition disj :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
528 where |
544 where |
529 "disj p q = |
545 "disj p q = |
530 (if (p = T \<or> q=T) then T else if p=F then q else if q=F then p else Or p q)" |
546 (if p = T \<or> q = T then T |
|
547 else if p = F then q |
|
548 else if q = F then p |
|
549 else Or p q)" |
531 |
550 |
532 lemma disj: "Ifm bbs bs (disj p q) = Ifm bbs bs (Or p q)" |
551 lemma disj: "Ifm bbs bs (disj p q) = Ifm bbs bs (Or p q)" |
533 by (cases "p=T \<or> q=T", simp_all add: disj_def) (cases p, simp_all) |
552 by (cases "p=T \<or> q=T", simp_all add: disj_def) (cases p, simp_all) |
534 |
553 |
535 lemma disj_qf: "\<lbrakk>qfree p ; qfree q\<rbrakk> \<Longrightarrow> qfree (disj p q)" |
554 lemma disj_qf: "qfree p \<Longrightarrow> qfree q \<Longrightarrow> qfree (disj p q)" |
536 using disj_def by auto |
555 using disj_def by auto |
537 |
556 |
538 lemma disj_nb: "\<lbrakk>bound0 p ; bound0 q\<rbrakk> \<Longrightarrow> bound0 (disj p q)" |
557 lemma disj_nb: "bound0 p \<Longrightarrow> bound0 q \<Longrightarrow> bound0 (disj p q)" |
539 using disj_def by auto |
558 using disj_def by auto |
540 |
559 |
541 definition imp :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
560 definition imp :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
542 where |
561 where |
543 "imp p q = (if (p = F \<or> q=T) then T else if p=T then q else if q=F then not p else Imp p q)" |
562 "imp p q = |
|
563 (if p = F \<or> q = T then T |
|
564 else if p = T then q |
|
565 else if q = F then not p |
|
566 else Imp p q)" |
544 |
567 |
545 lemma imp: "Ifm bbs bs (imp p q) = Ifm bbs bs (Imp p q)" |
568 lemma imp: "Ifm bbs bs (imp p q) = Ifm bbs bs (Imp p q)" |
546 by (cases "p=F \<or> q=T", simp_all add: imp_def, cases p) (simp_all add: not) |
569 by (cases "p = F \<or> q = T", simp_all add: imp_def, cases p) (simp_all add: not) |
547 |
570 |
548 lemma imp_qf: "qfree p \<Longrightarrow> qfree q \<Longrightarrow> qfree (imp p q)" |
571 lemma imp_qf: "qfree p \<Longrightarrow> qfree q \<Longrightarrow> qfree (imp p q)" |
549 using imp_def by (cases "p=F \<or> q=T",simp_all add: imp_def,cases p) (simp_all add: not_qf) |
572 using imp_def by (cases "p = F \<or> q = T", simp_all add: imp_def, cases p) (simp_all add: not_qf) |
550 |
573 |
551 lemma imp_nb: "bound0 p \<Longrightarrow> bound0 q \<Longrightarrow> bound0 (imp p q)" |
574 lemma imp_nb: "bound0 p \<Longrightarrow> bound0 q \<Longrightarrow> bound0 (imp p q)" |
552 using imp_def by (cases "p=F \<or> q=T",simp_all add: imp_def,cases p) simp_all |
575 using imp_def by (cases "p = F \<or> q = T", simp_all add: imp_def, cases p) simp_all |
553 |
576 |
554 definition iff :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
577 definition iff :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
555 where |
578 where |
556 "iff p q = |
579 "iff p q = |
557 (if (p = q) then T |
580 (if p = q then T |
558 else if (p = not q \<or> not p = q) then F |
581 else if p = not q \<or> not p = q then F |
559 else if p = F then not q |
582 else if p = F then not q |
560 else if q = F then not p |
583 else if q = F then not p |
561 else if p = T then q |
584 else if p = T then q |
562 else if q = T then p |
585 else if q = T then p |
563 else Iff p q)" |
586 else Iff p q)" |
791 |
814 |
792 lemma zsplit0_I: |
815 lemma zsplit0_I: |
793 shows "\<And>n a. zsplit0 t = (n,a) \<Longrightarrow> (Inum ((x::int) #bs) (CN 0 n a) = Inum (x #bs) t) \<and> numbound0 a" |
816 shows "\<And>n a. zsplit0 t = (n,a) \<Longrightarrow> (Inum ((x::int) #bs) (CN 0 n a) = Inum (x #bs) t) \<and> numbound0 a" |
794 (is "\<And>n a. ?S t = (n,a) \<Longrightarrow> (?I x (CN 0 n a) = ?I x t) \<and> ?N a") |
817 (is "\<And>n a. ?S t = (n,a) \<Longrightarrow> (?I x (CN 0 n a) = ?I x t) \<and> ?N a") |
795 proof (induct t rule: zsplit0.induct) |
818 proof (induct t rule: zsplit0.induct) |
796 case (1 c n a) thus ?case by auto |
819 case (1 c n a) |
797 next |
820 then show ?case by auto |
798 case (2 m n a) thus ?case by (cases "m=0") auto |
821 next |
|
822 case (2 m n a) |
|
823 then show ?case by (cases "m = 0") auto |
799 next |
824 next |
800 case (3 m i a n a') |
825 case (3 m i a n a') |
801 let ?j = "fst (zsplit0 a)" |
826 let ?j = "fst (zsplit0 a)" |
802 let ?b = "snd (zsplit0 a)" |
827 let ?b = "snd (zsplit0 a)" |
803 have abj: "zsplit0 a = (?j,?b)" by simp |
828 have abj: "zsplit0 a = (?j, ?b)" by simp |
804 {assume "m\<noteq>0" |
829 { |
805 with 3(1)[OF abj] 3(2) have ?case by (auto simp add: Let_def split_def)} |
830 assume "m \<noteq> 0" |
|
831 with 3(1)[OF abj] 3(2) have ?case |
|
832 by (auto simp add: Let_def split_def) |
|
833 } |
806 moreover |
834 moreover |
807 {assume m0: "m =0" |
835 { |
|
836 assume m0: "m = 0" |
808 with abj have th: "a'=?b \<and> n=i+?j" using 3 |
837 with abj have th: "a'=?b \<and> n=i+?j" using 3 |
809 by (simp add: Let_def split_def) |
838 by (simp add: Let_def split_def) |
810 from abj 3 m0 have th2: "(?I x (CN 0 ?j ?b) = ?I x a) \<and> ?N ?b" by blast |
839 from abj 3 m0 have th2: "(?I x (CN 0 ?j ?b) = ?I x a) \<and> ?N ?b" |
811 from th have "?I x (CN 0 n a') = ?I x (CN 0 (i+?j) ?b)" by simp |
840 by blast |
812 also from th2 have "\<dots> = ?I x (CN 0 i (CN 0 ?j ?b))" by (simp add: distrib_right) |
841 from th have "?I x (CN 0 n a') = ?I x (CN 0 (i+?j) ?b)" |
813 finally have "?I x (CN 0 n a') = ?I x (CN 0 i a)" using th2 by simp |
842 by simp |
814 with th2 th have ?case using m0 by blast} |
843 also from th2 have "\<dots> = ?I x (CN 0 i (CN 0 ?j ?b))" |
815 ultimately show ?case by blast |
844 by (simp add: distrib_right) |
|
845 finally have "?I x (CN 0 n a') = ?I x (CN 0 i a)" |
|
846 using th2 by simp |
|
847 with th2 th have ?case using m0 |
|
848 by blast |
|
849 } |
|
850 ultimately show ?case by blast |
816 next |
851 next |
817 case (4 t n a) |
852 case (4 t n a) |
818 let ?nt = "fst (zsplit0 t)" |
853 let ?nt = "fst (zsplit0 t)" |
819 let ?at = "snd (zsplit0 t)" |
854 let ?at = "snd (zsplit0 t)" |
820 have abj: "zsplit0 t = (?nt,?at)" by simp hence th: "a=Neg ?at \<and> n=-?nt" using 4 |
855 have abj: "zsplit0 t = (?nt,?at)" by simp |
821 by (simp add: Let_def split_def) |
856 then have th: "a=Neg ?at \<and> n=-?nt" |
822 from abj 4 have th2: "(?I x (CN 0 ?nt ?at) = ?I x t) \<and> ?N ?at" by blast |
857 using 4 by (simp add: Let_def split_def) |
823 from th2[simplified] th[simplified] show ?case by simp |
858 from abj 4 have th2: "(?I x (CN 0 ?nt ?at) = ?I x t) \<and> ?N ?at" |
|
859 by blast |
|
860 from th2[simplified] th[simplified] show ?case |
|
861 by simp |
824 next |
862 next |
825 case (5 s t n a) |
863 case (5 s t n a) |
826 let ?ns = "fst (zsplit0 s)" |
864 let ?ns = "fst (zsplit0 s)" |
827 let ?as = "snd (zsplit0 s)" |
865 let ?as = "snd (zsplit0 s)" |
828 let ?nt = "fst (zsplit0 t)" |
866 let ?nt = "fst (zsplit0 t)" |
829 let ?at = "snd (zsplit0 t)" |
867 let ?at = "snd (zsplit0 t)" |
830 have abjs: "zsplit0 s = (?ns,?as)" by simp |
868 have abjs: "zsplit0 s = (?ns, ?as)" |
831 moreover have abjt: "zsplit0 t = (?nt,?at)" by simp |
869 by simp |
832 ultimately have th: "a=Add ?as ?at \<and> n=?ns + ?nt" using 5 |
870 moreover have abjt: "zsplit0 t = (?nt, ?at)" |
833 by (simp add: Let_def split_def) |
871 by simp |
834 from abjs[symmetric] have bluddy: "\<exists>x y. (x,y) = zsplit0 s" by blast |
872 ultimately have th: "a=Add ?as ?at \<and> n=?ns + ?nt" |
835 from 5 have "(\<exists>x y. (x,y) = zsplit0 s) \<longrightarrow> (\<forall>xa xb. zsplit0 t = (xa, xb) \<longrightarrow> Inum (x # bs) (CN 0 xa xb) = Inum (x # bs) t \<and> numbound0 xb)" by auto |
873 using 5 by (simp add: Let_def split_def) |
836 with bluddy abjt have th3: "(?I x (CN 0 ?nt ?at) = ?I x t) \<and> ?N ?at" by blast |
874 from abjs[symmetric] have bluddy: "\<exists>x y. (x,y) = zsplit0 s" |
837 from abjs 5 have th2: "(?I x (CN 0 ?ns ?as) = ?I x s) \<and> ?N ?as" by blast |
875 by blast |
|
876 from 5 have "(\<exists>x y. (x, y) = zsplit0 s) \<longrightarrow> |
|
877 (\<forall>xa xb. zsplit0 t = (xa, xb) \<longrightarrow> Inum (x # bs) (CN 0 xa xb) = Inum (x # bs) t \<and> numbound0 xb)" |
|
878 by auto |
|
879 with bluddy abjt have th3: "(?I x (CN 0 ?nt ?at) = ?I x t) \<and> ?N ?at" |
|
880 by blast |
|
881 from abjs 5 have th2: "(?I x (CN 0 ?ns ?as) = ?I x s) \<and> ?N ?as" |
|
882 by blast |
838 from th3[simplified] th2[simplified] th[simplified] show ?case |
883 from th3[simplified] th2[simplified] th[simplified] show ?case |
839 by (simp add: distrib_right) |
884 by (simp add: distrib_right) |
840 next |
885 next |
841 case (6 s t n a) |
886 case (6 s t n a) |
842 let ?ns = "fst (zsplit0 s)" |
887 let ?ns = "fst (zsplit0 s)" |
843 let ?as = "snd (zsplit0 s)" |
888 let ?as = "snd (zsplit0 s)" |
844 let ?nt = "fst (zsplit0 t)" |
889 let ?nt = "fst (zsplit0 t)" |
845 let ?at = "snd (zsplit0 t)" |
890 let ?at = "snd (zsplit0 t)" |
846 have abjs: "zsplit0 s = (?ns,?as)" by simp |
891 have abjs: "zsplit0 s = (?ns, ?as)" |
847 moreover have abjt: "zsplit0 t = (?nt,?at)" by simp |
892 by simp |
848 ultimately have th: "a=Sub ?as ?at \<and> n=?ns - ?nt" using 6 |
893 moreover have abjt: "zsplit0 t = (?nt, ?at)" |
849 by (simp add: Let_def split_def) |
894 by simp |
850 from abjs[symmetric] have bluddy: "\<exists>x y. (x,y) = zsplit0 s" by blast |
895 ultimately have th: "a=Sub ?as ?at \<and> n=?ns - ?nt" |
|
896 using 6 by (simp add: Let_def split_def) |
|
897 from abjs[symmetric] have bluddy: "\<exists>x y. (x,y) = zsplit0 s" |
|
898 by blast |
851 from 6 have "(\<exists>x y. (x,y) = zsplit0 s) \<longrightarrow> |
899 from 6 have "(\<exists>x y. (x,y) = zsplit0 s) \<longrightarrow> |
852 (\<forall>xa xb. zsplit0 t = (xa, xb) \<longrightarrow> Inum (x # bs) (CN 0 xa xb) = Inum (x # bs) t \<and> numbound0 xb)" |
900 (\<forall>xa xb. zsplit0 t = (xa, xb) \<longrightarrow> Inum (x # bs) (CN 0 xa xb) = Inum (x # bs) t \<and> numbound0 xb)" |
853 by auto |
901 by auto |
854 with bluddy abjt have th3: "(?I x (CN 0 ?nt ?at) = ?I x t) \<and> ?N ?at" by blast |
902 with bluddy abjt have th3: "(?I x (CN 0 ?nt ?at) = ?I x t) \<and> ?N ?at" |
855 from abjs 6 have th2: "(?I x (CN 0 ?ns ?as) = ?I x s) \<and> ?N ?as" by blast |
903 by blast |
|
904 from abjs 6 have th2: "(?I x (CN 0 ?ns ?as) = ?I x s) \<and> ?N ?as" |
|
905 by blast |
856 from th3[simplified] th2[simplified] th[simplified] show ?case |
906 from th3[simplified] th2[simplified] th[simplified] show ?case |
857 by (simp add: left_diff_distrib) |
907 by (simp add: left_diff_distrib) |
858 next |
908 next |
859 case (7 i t n a) |
909 case (7 i t n a) |
860 let ?nt = "fst (zsplit0 t)" |
910 let ?nt = "fst (zsplit0 t)" |
861 let ?at = "snd (zsplit0 t)" |
911 let ?at = "snd (zsplit0 t)" |
862 have abj: "zsplit0 t = (?nt,?at)" by simp |
912 have abj: "zsplit0 t = (?nt,?at)" |
863 hence th: "a=Mul i ?at \<and> n=i*?nt" using 7 |
913 by simp |
864 by (simp add: Let_def split_def) |
914 then have th: "a=Mul i ?at \<and> n=i*?nt" |
865 from abj 7 have th2: "(?I x (CN 0 ?nt ?at) = ?I x t) \<and> ?N ?at" by blast |
915 using 7 by (simp add: Let_def split_def) |
866 hence "?I x (Mul i t) = i * ?I x (CN 0 ?nt ?at)" by simp |
916 from abj 7 have th2: "(?I x (CN 0 ?nt ?at) = ?I x t) \<and> ?N ?at" |
867 also have "\<dots> = ?I x (CN 0 (i*?nt) (Mul i ?at))" by (simp add: distrib_left) |
917 by blast |
868 finally show ?case using th th2 by simp |
918 then have "?I x (Mul i t) = i * ?I x (CN 0 ?nt ?at)" |
|
919 by simp |
|
920 also have "\<dots> = ?I x (CN 0 (i*?nt) (Mul i ?at))" |
|
921 by (simp add: distrib_left) |
|
922 finally show ?case using th th2 |
|
923 by simp |
869 qed |
924 qed |
870 |
925 |
871 consts iszlfm :: "fm \<Rightarrow> bool" -- {* Linearity test for fm *} |
926 consts iszlfm :: "fm \<Rightarrow> bool" -- {* Linearity test for fm *} |
872 recdef iszlfm "measure size" |
927 recdef iszlfm "measure size" |
873 "iszlfm (And p q) = (iszlfm p \<and> iszlfm q)" |
928 "iszlfm (And p q) = (iszlfm p \<and> iszlfm q)" |
947 using qfp |
1002 using qfp |
948 proof (induct p rule: zlfm.induct) |
1003 proof (induct p rule: zlfm.induct) |
949 case (5 a) |
1004 case (5 a) |
950 let ?c = "fst (zsplit0 a)" |
1005 let ?c = "fst (zsplit0 a)" |
951 let ?r = "snd (zsplit0 a)" |
1006 let ?r = "snd (zsplit0 a)" |
952 have spl: "zsplit0 a = (?c,?r)" by simp |
1007 have spl: "zsplit0 a = (?c, ?r)" |
|
1008 by simp |
953 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1009 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
954 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" by auto |
1010 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" |
|
1011 by auto |
955 let ?N = "\<lambda>t. Inum (i#bs) t" |
1012 let ?N = "\<lambda>t. Inum (i#bs) t" |
956 from 5 Ia nb show ?case |
1013 from 5 Ia nb show ?case |
957 apply (auto simp add: Let_def split_def algebra_simps) |
1014 apply (auto simp add: Let_def split_def algebra_simps) |
958 apply (cases "?r", auto) |
1015 apply (cases "?r") |
959 apply (case_tac nat, auto) |
1016 apply auto |
|
1017 apply (case_tac nat) |
|
1018 apply auto |
960 done |
1019 done |
961 next |
1020 next |
962 case (6 a) |
1021 case (6 a) |
963 let ?c = "fst (zsplit0 a)" |
1022 let ?c = "fst (zsplit0 a)" |
964 let ?r = "snd (zsplit0 a)" |
1023 let ?r = "snd (zsplit0 a)" |
965 have spl: "zsplit0 a = (?c,?r)" by simp |
1024 have spl: "zsplit0 a = (?c, ?r)" |
|
1025 by simp |
966 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1026 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
967 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" by auto |
1027 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" |
|
1028 by auto |
968 let ?N = "\<lambda>t. Inum (i#bs) t" |
1029 let ?N = "\<lambda>t. Inum (i#bs) t" |
969 from 6 Ia nb show ?case |
1030 from 6 Ia nb show ?case |
970 apply (auto simp add: Let_def split_def algebra_simps) |
1031 apply (auto simp add: Let_def split_def algebra_simps) |
971 apply (cases "?r", auto) |
1032 apply (cases "?r") |
972 apply (case_tac nat, auto) |
1033 apply auto |
|
1034 apply (case_tac nat) |
|
1035 apply auto |
973 done |
1036 done |
974 next |
1037 next |
975 case (7 a) |
1038 case (7 a) |
976 let ?c = "fst (zsplit0 a)" |
1039 let ?c = "fst (zsplit0 a)" |
977 let ?r = "snd (zsplit0 a)" |
1040 let ?r = "snd (zsplit0 a)" |
978 have spl: "zsplit0 a = (?c,?r)" by simp |
1041 have spl: "zsplit0 a = (?c, ?r)" |
|
1042 by simp |
979 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1043 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
980 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" by auto |
1044 have Ia: "Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" |
|
1045 by auto |
981 let ?N = "\<lambda>t. Inum (i#bs) t" |
1046 let ?N = "\<lambda>t. Inum (i#bs) t" |
982 from 7 Ia nb show ?case |
1047 from 7 Ia nb show ?case |
983 apply (auto simp add: Let_def split_def algebra_simps) |
1048 apply (auto simp add: Let_def split_def algebra_simps) |
984 apply (cases "?r", auto) |
1049 apply (cases "?r") |
985 apply (case_tac nat, auto) |
1050 apply auto |
|
1051 apply (case_tac nat) |
|
1052 apply auto |
986 done |
1053 done |
987 next |
1054 next |
988 case (8 a) |
1055 case (8 a) |
989 let ?c = "fst (zsplit0 a)" |
1056 let ?c = "fst (zsplit0 a)" |
990 let ?r = "snd (zsplit0 a)" |
1057 let ?r = "snd (zsplit0 a)" |
991 have spl: "zsplit0 a = (?c,?r)" by simp |
1058 have spl: "zsplit0 a = (?c, ?r)" |
|
1059 by simp |
992 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1060 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
993 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" by auto |
1061 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" |
|
1062 by auto |
994 let ?N = "\<lambda>t. Inum (i#bs) t" |
1063 let ?N = "\<lambda>t. Inum (i#bs) t" |
995 from 8 Ia nb show ?case |
1064 from 8 Ia nb show ?case |
996 apply (auto simp add: Let_def split_def algebra_simps) |
1065 apply (auto simp add: Let_def split_def algebra_simps) |
997 apply (cases "?r", auto) |
1066 apply (cases "?r") |
998 apply (case_tac nat, auto) |
1067 apply auto |
|
1068 apply (case_tac nat) |
|
1069 apply auto |
999 done |
1070 done |
1000 next |
1071 next |
1001 case (9 a) |
1072 case (9 a) |
1002 let ?c = "fst (zsplit0 a)" |
1073 let ?c = "fst (zsplit0 a)" |
1003 let ?r = "snd (zsplit0 a)" |
1074 let ?r = "snd (zsplit0 a)" |
1004 have spl: "zsplit0 a = (?c,?r)" by simp |
1075 have spl: "zsplit0 a = (?c, ?r)" |
|
1076 by simp |
1005 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1077 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1006 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" by auto |
1078 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" |
|
1079 by auto |
1007 let ?N = "\<lambda>t. Inum (i#bs) t" |
1080 let ?N = "\<lambda>t. Inum (i#bs) t" |
1008 from 9 Ia nb show ?case |
1081 from 9 Ia nb show ?case |
1009 apply (auto simp add: Let_def split_def algebra_simps) |
1082 apply (auto simp add: Let_def split_def algebra_simps) |
1010 apply (cases "?r", auto) |
1083 apply (cases "?r") |
1011 apply (case_tac nat, auto) |
1084 apply auto |
|
1085 apply (case_tac nat) |
|
1086 apply auto |
1012 done |
1087 done |
1013 next |
1088 next |
1014 case (10 a) |
1089 case (10 a) |
1015 let ?c = "fst (zsplit0 a)" |
1090 let ?c = "fst (zsplit0 a)" |
1016 let ?r = "snd (zsplit0 a)" |
1091 let ?r = "snd (zsplit0 a)" |
1017 have spl: "zsplit0 a = (?c,?r)" by simp |
1092 have spl: "zsplit0 a = (?c, ?r)" |
|
1093 by simp |
1018 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1094 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1019 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" by auto |
1095 have Ia: "Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" |
|
1096 by auto |
1020 let ?N = "\<lambda>t. Inum (i#bs) t" |
1097 let ?N = "\<lambda>t. Inum (i#bs) t" |
1021 from 10 Ia nb show ?case |
1098 from 10 Ia nb show ?case |
1022 apply (auto simp add: Let_def split_def algebra_simps) |
1099 apply (auto simp add: Let_def split_def algebra_simps) |
1023 apply (cases "?r",auto) |
1100 apply (cases "?r") |
1024 apply (case_tac nat, auto) |
1101 apply auto |
|
1102 apply (case_tac nat) |
|
1103 apply auto |
1025 done |
1104 done |
1026 next |
1105 next |
1027 case (11 j a) |
1106 case (11 j a) |
1028 let ?c = "fst (zsplit0 a)" |
1107 let ?c = "fst (zsplit0 a)" |
1029 let ?r = "snd (zsplit0 a)" |
1108 let ?r = "snd (zsplit0 a)" |
1030 have spl: "zsplit0 a = (?c,?r)" by simp |
1109 have spl: "zsplit0 a = (?c,?r)" |
|
1110 by simp |
1031 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1111 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1032 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" by auto |
1112 have Ia: "Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" |
|
1113 by auto |
1033 let ?N = "\<lambda>t. Inum (i#bs) t" |
1114 let ?N = "\<lambda>t. Inum (i#bs) t" |
1034 have "j=0 \<or> (j\<noteq>0 \<and> ?c = 0) \<or> (j\<noteq>0 \<and> ?c >0) \<or> (j\<noteq> 0 \<and> ?c<0)" by arith |
1115 have "j = 0 \<or> (j \<noteq> 0 \<and> ?c = 0) \<or> (j \<noteq> 0 \<and> ?c > 0) \<or> (j \<noteq> 0 \<and> ?c < 0)" |
|
1116 by arith |
1035 moreover |
1117 moreover |
1036 {assume "j=0" hence z: "zlfm (Dvd j a) = (zlfm (Eq a))" by (simp add: Let_def) |
1118 { |
1037 hence ?case using 11 `j = 0` by (simp del: zlfm.simps) } |
1119 assume "j = 0" |
|
1120 then have z: "zlfm (Dvd j a) = (zlfm (Eq a))" |
|
1121 by (simp add: Let_def) |
|
1122 then have ?case using 11 `j = 0` |
|
1123 by (simp del: zlfm.simps) |
|
1124 } |
1038 moreover |
1125 moreover |
1039 {assume "?c=0" and "j\<noteq>0" hence ?case |
1126 { |
|
1127 assume "?c = 0" and "j \<noteq> 0" |
|
1128 then have ?case |
1040 using zsplit0_I[OF spl, where x="i" and bs="bs"] |
1129 using zsplit0_I[OF spl, where x="i" and bs="bs"] |
1041 apply (auto simp add: Let_def split_def algebra_simps) |
1130 apply (auto simp add: Let_def split_def algebra_simps) |
1042 apply (cases "?r",auto) |
1131 apply (cases "?r") |
1043 apply (case_tac nat, auto) |
1132 apply auto |
1044 done} |
1133 apply (case_tac nat) |
|
1134 apply auto |
|
1135 done |
|
1136 } |
1045 moreover |
1137 moreover |
1046 {assume cp: "?c > 0" and jnz: "j\<noteq>0" hence l: "?L (?l (Dvd j a))" |
1138 { |
|
1139 assume cp: "?c > 0" and jnz: "j \<noteq> 0" |
|
1140 then have l: "?L (?l (Dvd j a))" |
1047 by (simp add: nb Let_def split_def) |
1141 by (simp add: nb Let_def split_def) |
1048 hence ?case using Ia cp jnz by (simp add: Let_def split_def)} |
1142 then have ?case |
|
1143 using Ia cp jnz by (simp add: Let_def split_def) |
|
1144 } |
1049 moreover |
1145 moreover |
1050 {assume cn: "?c < 0" and jnz: "j\<noteq>0" hence l: "?L (?l (Dvd j a))" |
1146 { |
|
1147 assume cn: "?c < 0" and jnz: "j \<noteq> 0" |
|
1148 then have l: "?L (?l (Dvd j a))" |
1051 by (simp add: nb Let_def split_def) |
1149 by (simp add: nb Let_def split_def) |
1052 hence ?case using Ia cn jnz dvd_minus_iff[of "abs j" "?c*i + ?N ?r" ] |
1150 then have ?case |
1053 by (simp add: Let_def split_def) } |
1151 using Ia cn jnz dvd_minus_iff[of "abs j" "?c*i + ?N ?r"] |
|
1152 by (simp add: Let_def split_def) |
|
1153 } |
1054 ultimately show ?case by blast |
1154 ultimately show ?case by blast |
1055 next |
1155 next |
1056 case (12 j a) |
1156 case (12 j a) |
1057 let ?c = "fst (zsplit0 a)" |
1157 let ?c = "fst (zsplit0 a)" |
1058 let ?r = "snd (zsplit0 a)" |
1158 let ?r = "snd (zsplit0 a)" |
1059 have spl: "zsplit0 a = (?c,?r)" by simp |
1159 have spl: "zsplit0 a = (?c, ?r)" |
|
1160 by simp |
1060 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1161 from zsplit0_I[OF spl, where x="i" and bs="bs"] |
1061 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" by auto |
1162 have Ia:"Inum (i # bs) a = Inum (i #bs) (CN 0 ?c ?r)" and nb: "numbound0 ?r" |
|
1163 by auto |
1062 let ?N = "\<lambda>t. Inum (i#bs) t" |
1164 let ?N = "\<lambda>t. Inum (i#bs) t" |
1063 have "j=0 \<or> (j\<noteq>0 \<and> ?c = 0) \<or> (j\<noteq>0 \<and> ?c >0) \<or> (j\<noteq> 0 \<and> ?c<0)" by arith |
1165 have "j = 0 \<or> (j \<noteq> 0 \<and> ?c = 0) \<or> (j \<noteq> 0 \<and> ?c > 0) \<or> (j \<noteq> 0 \<and> ?c < 0)" |
|
1166 by arith |
1064 moreover |
1167 moreover |
1065 {assume "j=0" hence z: "zlfm (NDvd j a) = (zlfm (NEq a))" by (simp add: Let_def) |
1168 { |
1066 hence ?case using assms 12 `j = 0` by (simp del: zlfm.simps)} |
1169 assume "j = 0" |
|
1170 then have z: "zlfm (NDvd j a) = (zlfm (NEq a))" |
|
1171 by (simp add: Let_def) |
|
1172 then have ?case |
|
1173 using assms 12 `j = 0` by (simp del: zlfm.simps) |
|
1174 } |
1067 moreover |
1175 moreover |
1068 {assume "?c=0" and "j\<noteq>0" hence ?case |
1176 { |
|
1177 assume "?c = 0" and "j \<noteq> 0" |
|
1178 then have ?case |
1069 using zsplit0_I[OF spl, where x="i" and bs="bs"] |
1179 using zsplit0_I[OF spl, where x="i" and bs="bs"] |
1070 apply (auto simp add: Let_def split_def algebra_simps) |
1180 apply (auto simp add: Let_def split_def algebra_simps) |
1071 apply (cases "?r",auto) |
1181 apply (cases "?r") |
1072 apply (case_tac nat, auto) |
1182 apply auto |
1073 done} |
1183 apply (case_tac nat) |
|
1184 apply auto |
|
1185 done |
|
1186 } |
1074 moreover |
1187 moreover |
1075 {assume cp: "?c > 0" and jnz: "j\<noteq>0" hence l: "?L (?l (Dvd j a))" |
1188 { |
|
1189 assume cp: "?c > 0" and jnz: "j \<noteq> 0" |
|
1190 then have l: "?L (?l (Dvd j a))" |
1076 by (simp add: nb Let_def split_def) |
1191 by (simp add: nb Let_def split_def) |
1077 hence ?case using Ia cp jnz by (simp add: Let_def split_def) } |
1192 then have ?case using Ia cp jnz |
|
1193 by (simp add: Let_def split_def) |
|
1194 } |
1078 moreover |
1195 moreover |
1079 {assume cn: "?c < 0" and jnz: "j\<noteq>0" hence l: "?L (?l (Dvd j a))" |
1196 { |
|
1197 assume cn: "?c < 0" and jnz: "j \<noteq> 0" |
|
1198 then have l: "?L (?l (Dvd j a))" |
1080 by (simp add: nb Let_def split_def) |
1199 by (simp add: nb Let_def split_def) |
1081 hence ?case using Ia cn jnz dvd_minus_iff[of "abs j" "?c*i + ?N ?r"] |
1200 then have ?case |
1082 by (simp add: Let_def split_def)} |
1201 using Ia cn jnz dvd_minus_iff[of "abs j" "?c*i + ?N ?r"] |
|
1202 by (simp add: Let_def split_def) |
|
1203 } |
1083 ultimately show ?case by blast |
1204 ultimately show ?case by blast |
1084 qed auto |
1205 qed auto |
1085 |
1206 |
1086 consts minusinf :: "fm \<Rightarrow> fm" -- {* Virtual substitution of @{text "-\<infinity>"} *} |
1207 consts minusinf :: "fm \<Rightarrow> fm" -- {* Virtual substitution of @{text "-\<infinity>"} *} |
1087 recdef minusinf "measure size" |
1208 recdef minusinf "measure size" |
1131 and d: "d dvd d'" |
1252 and d: "d dvd d'" |
1132 and ad: "d_\<delta> p d" |
1253 and ad: "d_\<delta> p d" |
1133 shows "d_\<delta> p d'" |
1254 shows "d_\<delta> p d'" |
1134 using lin ad d |
1255 using lin ad d |
1135 proof (induct p rule: iszlfm.induct) |
1256 proof (induct p rule: iszlfm.induct) |
1136 case (9 i c e) thus ?case using d |
1257 case (9 i c e) |
|
1258 then show ?case using d |
1137 by (simp add: dvd_trans[of "i" "d" "d'"]) |
1259 by (simp add: dvd_trans[of "i" "d" "d'"]) |
1138 next |
1260 next |
1139 case (10 i c e) thus ?case using d |
1261 case (10 i c e) |
|
1262 then show ?case using d |
1140 by (simp add: dvd_trans[of "i" "d" "d'"]) |
1263 by (simp add: dvd_trans[of "i" "d" "d'"]) |
1141 qed simp_all |
1264 qed simp_all |
1142 |
1265 |
1143 lemma \<delta>: |
1266 lemma \<delta>: |
1144 assumes lin:"iszlfm p" |
1267 assumes lin:"iszlfm p" |
1145 shows "d_\<delta> p (\<delta> p) \<and> \<delta> p >0" |
1268 shows "d_\<delta> p (\<delta> p) \<and> \<delta> p >0" |
1146 using lin |
1269 using lin |
1147 proof (induct p rule: iszlfm.induct) |
1270 proof (induct p rule: iszlfm.induct) |
1148 case (1 p q) |
1271 case (1 p q) |
1149 let ?d = "\<delta> (And p q)" |
1272 let ?d = "\<delta> (And p q)" |
1150 from 1 lcm_pos_int have dp: "?d >0" by simp |
1273 from 1 lcm_pos_int have dp: "?d > 0" |
1151 have d1: "\<delta> p dvd \<delta> (And p q)" using 1 by simp |
1274 by simp |
1152 hence th: "d_\<delta> p ?d" using delta_mono 1(2,3) by(simp only: iszlfm.simps) |
1275 have d1: "\<delta> p dvd \<delta> (And p q)" |
1153 have "\<delta> q dvd \<delta> (And p q)" using 1 by simp |
1276 using 1 by simp |
1154 hence th': "d_\<delta> q ?d" using delta_mono 1 by(simp only: iszlfm.simps) |
1277 then have th: "d_\<delta> p ?d" |
1155 from th th' dp show ?case by simp |
1278 using delta_mono 1(2,3) by (simp only: iszlfm.simps) |
|
1279 have "\<delta> q dvd \<delta> (And p q)" |
|
1280 using 1 by simp |
|
1281 then have th': "d_\<delta> q ?d" |
|
1282 using delta_mono 1 by (simp only: iszlfm.simps) |
|
1283 from th th' dp show ?case |
|
1284 by simp |
1156 next |
1285 next |
1157 case (2 p q) |
1286 case (2 p q) |
1158 let ?d = "\<delta> (And p q)" |
1287 let ?d = "\<delta> (And p q)" |
1159 from 2 lcm_pos_int have dp: "?d >0" by simp |
1288 from 2 lcm_pos_int have dp: "?d > 0" |
1160 have "\<delta> p dvd \<delta> (And p q)" using 2 by simp |
1289 by simp |
1161 hence th: "d_\<delta> p ?d" using delta_mono 2 by(simp only: iszlfm.simps) |
1290 have "\<delta> p dvd \<delta> (And p q)" |
1162 have "\<delta> q dvd \<delta> (And p q)" using 2 by simp |
1291 using 2 by simp |
1163 hence th': "d_\<delta> q ?d" using delta_mono 2 by(simp only: iszlfm.simps) |
1292 then have th: "d_\<delta> p ?d" |
1164 from th th' dp show ?case by simp |
1293 using delta_mono 2 by (simp only: iszlfm.simps) |
|
1294 have "\<delta> q dvd \<delta> (And p q)" |
|
1295 using 2 by simp |
|
1296 then have th': "d_\<delta> q ?d" |
|
1297 using delta_mono 2 by (simp only: iszlfm.simps) |
|
1298 from th th' dp show ?case |
|
1299 by simp |
1165 qed simp_all |
1300 qed simp_all |
1166 |
1301 |
1167 |
1302 |
1168 consts a_\<beta> :: "fm \<Rightarrow> int \<Rightarrow> fm" -- {* adjust the coeffitients of a formula *} |
1303 consts a_\<beta> :: "fm \<Rightarrow> int \<Rightarrow> fm" -- {* adjust the coeffitients of a formula *} |
1169 recdef a_\<beta> "measure size" |
1304 recdef a_\<beta> "measure size" |