1 theory Forward imports Primes begin
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 (Suc 0) = Suc 0"
28 lemma gcd_1_left [simp]: "gcd (Suc 0) m = Suc 0"
29 apply (simp add: gcd_commute [of "Suc 0"])
40 lemma gcd_mult_distrib2: "k * gcd m n = gcd (k*m) (k*n)"
41 apply (induct_tac m n rule: gcd.induct)
42 apply (case_tac "n=0")
44 apply (case_tac "k=0")
45 apply (simp_all add: mod_geq gcd_non_0 mod_mult_distrib2)
49 @{thm[display] gcd_mult_distrib2}
50 \rulename{gcd_mult_distrib2}
58 lemmas gcd_mult_0 = gcd_mult_distrib2 [of k 1];
59 lemmas gcd_mult_1 = gcd_mult_0 [simplified];
61 lemmas where1 = gcd_mult_distrib2 [where m=1]
63 lemmas where2 = gcd_mult_distrib2 [where m=1 and k=1]
65 lemmas where3 = gcd_mult_distrib2 [where m=1 and k="j+k"]
69 @{thm[display] gcd_mult_distrib2 [of _ 1]}
71 example using ``where'':
72 @{thm[display] gcd_mult_distrib2 [where m=1]}
74 example using ``where'', ``and'':
75 @{thm[display] gcd_mult_distrib2 [where m=1 and k="j+k"]}
77 @{thm[display] gcd_mult_0}
80 @{thm[display] gcd_mult_1}
87 lemmas gcd_mult0 = gcd_mult_1 [THEN sym];
88 (*not quite right: we need ?k but this gives k*)
90 lemmas gcd_mult0' = gcd_mult_distrib2 [of k 1, simplified, THEN sym];
91 (*better in one step!*)
94 more legible, and variables properly generalized
97 lemma gcd_mult [simp]: "gcd k (k*n) = k"
98 by (rule gcd_mult_distrib2 [of k 1, simplified, THEN sym])
101 lemmas gcd_self0 = gcd_mult [of k 1, simplified];
105 Rules handy with THEN
107 @{thm[display] iffD1}
110 @{thm[display] iffD2}
116 again: more legible, and variables properly generalized
119 lemma gcd_self [simp]: "gcd k k = k"
120 by (rule gcd_mult [of k 1, simplified])
124 NEXT SECTION: Methods for Forward Proof
128 theorem arg_cong, useful in forward steps
129 @{thm[display] arg_cong[no_vars]}
133 lemma "2 \<le> u \<Longrightarrow> u*m \<noteq> Suc(u*n)"
136 before using arg_cong
137 @{subgoals[display,indent=0,margin=65]}
139 apply (drule_tac f="\<lambda>x. x mod u" in arg_cong)
142 @{subgoals[display,indent=0,margin=65]}
144 apply (simp add: mod_Suc)
148 have just used this rule:
149 @{thm[display] mod_Suc[no_vars]}
152 @{thm[display] mult_le_mono1[no_vars]}
153 \rulename{mult_le_mono1}
161 lemma relprime_dvd_mult:
162 "\<lbrakk> gcd k n = 1; k dvd m*n \<rbrakk> \<Longrightarrow> k dvd m"
163 apply (insert gcd_mult_distrib2 [of m k n])
165 apply (erule_tac t="m" in ssubst);
171 Another example of "insert"
173 @{thm[display] mod_div_equality}
174 \rulename{mod_div_equality}
177 (*MOVED to Force.thy, which now depends only on Divides.thy
178 lemma div_mult_self_is_m: "0<n \<Longrightarrow> (m*n) div n = (m::nat)"
181 lemma relprime_dvd_mult_iff: "gcd k n = 1 \<Longrightarrow> (k dvd m*n) = (k dvd m)";
182 by (blast intro: relprime_dvd_mult dvd_trans)
185 lemma relprime_20_81: "gcd 20 81 = 1";
186 by (simp add: gcd.simps)
191 @{thm[display] relprime_dvd_mult}
192 \rulename{relprime_dvd_mult}
194 @{thm[display] relprime_dvd_mult [OF relprime_20_81]}
196 @{thm[display] dvd_refl}
199 @{thm[display] dvd_add}
202 @{thm[display] dvd_add [OF dvd_refl dvd_refl]}
204 @{thm[display] dvd_add [OF _ dvd_refl]}
207 lemma "\<lbrakk>(z::int) < 37; 66 < 2*z; z*z \<noteq> 1225; Q(34); Q(36)\<rbrakk> \<Longrightarrow> Q(z)";
208 apply (subgoal_tac "z = 34 \<or> z = 36")
210 the tactic leaves two subgoals:
211 @{subgoals[display,indent=0,margin=65]}
214 apply (subgoal_tac "z \<noteq> 35")
216 the tactic leaves two subgoals:
217 @{subgoals[display,indent=0,margin=65]}