1 theory Forward = Primes:
4 Forward proof material: of, OF, THEN, simplify, rule_format.
8 SKIP most developments...
13 lemma is_gcd_commute: "is_gcd k m n = is_gcd k n m"
14 apply (auto simp add: is_gcd_def);
17 lemma gcd_commute: "gcd(m,n) = gcd(n,m)"
18 apply (rule is_gcd_unique)
20 apply (subst is_gcd_commute)
21 apply (simp add: is_gcd)
24 lemma gcd_1 [simp]: "gcd(m,1) = 1"
28 lemma gcd_1_left [simp]: "gcd(1,m) = 1"
29 apply (simp add: gcd_commute [of 1])
41 @{thm[display] gcd_1_left}
49 lemma gcd_mult_distrib2: "k * gcd(m,n) = gcd(k*m, k*n)"
50 apply (induct_tac m n rule: gcd.induct)
51 apply (case_tac "n=0")
53 apply (case_tac "k=0")
54 apply (simp_all add: mod_geq gcd_non_0 mod_mult_distrib2)
58 @{thm[display] gcd_mult_distrib2}
59 \rulename{gcd_mult_distrib2}
67 lemmas gcd_mult_0 = gcd_mult_distrib2 [of k 1];
68 lemmas gcd_mult_1 = gcd_mult_0 [simplified];
71 @{thm[display] gcd_mult_distrib2 [of _ 1]}
73 @{thm[display] gcd_mult_0}
76 @{thm[display] gcd_mult_1}
83 lemmas gcd_mult = gcd_mult_1 [THEN sym];
85 lemmas gcd_mult = gcd_mult_distrib2 [of k 1, simplified, THEN sym];
86 (*better in one step!*)
92 lemma gcd_mult [simp]: "gcd(k, k*n) = k"
93 by (rule gcd_mult_distrib2 [of k 1, simplified, THEN sym])
96 lemmas gcd_self = gcd_mult [of k 1, simplified];
100 Rules handy with THEN
102 @{thm[display] iffD1}
105 @{thm[display] iffD2}
114 lemma gcd_self [simp]: "gcd(k,k) = k"
115 by (rule gcd_mult [of k 1, simplified])
119 NEXT SECTION: Methods for Forward Proof
123 theorem arg_cong, useful in forward steps
124 @{thm[display] arg_cong[no_vars]}
128 lemma "#2 \<le> u \<Longrightarrow> u*m \<noteq> Suc(u*n)"
131 before using arg_cong
132 @{subgoals[display,indent=0,margin=65]}
134 apply (drule_tac f="\<lambda>x. x mod u" in arg_cong)
137 @{subgoals[display,indent=0,margin=65]}
139 apply (simp add: mod_Suc)
143 have just used this rule:
144 @{thm[display] mod_Suc[no_vars]}
147 @{thm[display] mult_le_mono1[no_vars]}
148 \rulename{mult_le_mono1}
156 lemma relprime_dvd_mult:
157 "\<lbrakk> gcd(k,n)=1; k dvd m*n \<rbrakk> \<Longrightarrow> k dvd m"
158 apply (insert gcd_mult_distrib2 [of m k n])
160 apply (erule_tac t="m" in ssubst);
166 Another example of "insert"
168 @{thm[display] mod_div_equality}
169 \rulename{mod_div_equality}
172 (*MOVED to Force.thy, which now depends only on Divides.thy
173 lemma div_mult_self_is_m: "0<n \<Longrightarrow> (m*n) div n = (m::nat)"
176 lemma relprime_dvd_mult_iff: "gcd(k,n)=1 \<Longrightarrow> (k dvd m*n) = (k dvd m)";
177 by (blast intro: relprime_dvd_mult dvd_trans)
180 lemma relprime_20_81: "gcd(#20,#81) = 1";
181 by (simp add: gcd.simps)
186 @{thm[display] relprime_dvd_mult}
187 \rulename{relprime_dvd_mult}
189 @{thm[display] relprime_dvd_mult [OF relprime_20_81]}
191 @{thm[display] dvd_refl}
194 @{thm[display] dvd_add}
197 @{thm[display] dvd_add [OF dvd_refl dvd_refl]}
199 @{thm[display] dvd_add [OF _ dvd_refl]}
202 lemma "\<lbrakk>(z::int) < #37; #66 < #2*z; z*z \<noteq> #1225; Q(#34); Q(#36)\<rbrakk> \<Longrightarrow> Q(z)";
203 apply (subgoal_tac "z = #34 \<or> z = #36")
205 the tactic leaves two subgoals:
206 @{subgoals[display,indent=0,margin=65]}
209 apply (subgoal_tac "z \<noteq> #35")
211 the tactic leaves two subgoals:
212 @{subgoals[display,indent=0,margin=65]}