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 @{thm[display] gcd_mult}
108 @{thm[display] gcd_self0}
113 Rules handy with THEN
115 @{thm[display] iffD1}
118 @{thm[display] iffD2}
124 again: more legible, and variables properly generalized
127 lemma gcd_self [simp]: "gcd k k = k"
128 by (rule gcd_mult [of k 1, simplified])
132 NEXT SECTION: Methods for Forward Proof
136 theorem arg_cong, useful in forward steps
137 @{thm[display] arg_cong[no_vars]}
141 lemma "2 \<le> u \<Longrightarrow> u*m \<noteq> Suc(u*n)"
144 before using arg_cong
145 @{subgoals[display,indent=0,margin=65]}
147 apply (drule_tac f="\<lambda>x. x mod u" in arg_cong)
150 @{subgoals[display,indent=0,margin=65]}
152 apply (simp add: mod_Suc)
156 have just used this rule:
157 @{thm[display] mod_Suc[no_vars]}
160 @{thm[display] mult_le_mono1[no_vars]}
161 \rulename{mult_le_mono1}
169 lemma relprime_dvd_mult:
170 "\<lbrakk> gcd k n = 1; k dvd m*n \<rbrakk> \<Longrightarrow> k dvd m"
171 apply (insert gcd_mult_distrib2 [of m k n])
172 txt{*@{subgoals[display,indent=0,margin=65]}*}
174 txt{*@{subgoals[display,indent=0,margin=65]}*}
175 apply (erule_tac t="m" in ssubst);
181 @{thm[display] relprime_dvd_mult}
182 \rulename{relprime_dvd_mult}
184 Another example of "insert"
186 @{thm[display] mod_div_equality}
187 \rulename{mod_div_equality}
190 (*MOVED to Force.thy, which now depends only on Divides.thy
191 lemma div_mult_self_is_m: "0<n \<Longrightarrow> (m*n) div n = (m::nat)"
194 lemma relprime_dvd_mult_iff: "gcd k n = 1 \<Longrightarrow> (k dvd m*n) = (k dvd m)";
195 by (blast intro: relprime_dvd_mult dvd_trans)
198 lemma relprime_20_81: "gcd 20 81 = 1";
199 by (simp add: gcd.simps)
204 @{thm[display] relprime_dvd_mult}
205 \rulename{relprime_dvd_mult}
207 @{thm[display] relprime_dvd_mult [OF relprime_20_81]}
209 @{thm[display] dvd_refl}
212 @{thm[display] dvd_add}
215 @{thm[display] dvd_add [OF dvd_refl dvd_refl]}
217 @{thm[display] dvd_add [OF _ dvd_refl]}
220 lemma "\<lbrakk>(z::int) < 37; 66 < 2*z; z*z \<noteq> 1225; Q(34); Q(36)\<rbrakk> \<Longrightarrow> Q(z)";
221 apply (subgoal_tac "z = 34 \<or> z = 36")
223 the tactic leaves two subgoals:
224 @{subgoals[display,indent=0,margin=65]}
227 apply (subgoal_tac "z \<noteq> 35")
229 the tactic leaves two subgoals:
230 @{subgoals[display,indent=0,margin=65]}