I decided to prove the following theorem:
theory Scratch
imports Main
begin
lemma "(3::int)^k mod 4 = 1 ⟷ even k"
proof (cases "even k")
case True
then obtain l where "2*l = k" by auto
then show ?thesis
using power_mult [of "(3::int)" 2 l]
and power_mod [of "(9::int)" 4 l] by auto
next
case False
then obtain l where "2*l + 1 = k" using odd_two_times_div_two_succ by blast
then have "(3::int)^k mod 4 = 3"
using power_mult [of "(3::int)" 2 l ]
and mod_mult_right_eq [of "(3::int)" "9^l" 4]
and power_mod [of "(9::int)" 4 l]
by auto
then show ?thesis using `odd k` by auto
qed
end
The proof is accepted by Isabelle, but to my taste, there is way too much trivial detail as to how calculations mod 4
are performed:
then have "(3::int)^k mod 4 = 3"
using power_mult [of "(3::int)" 2 l ]
and mod_mult_right_eq [of "(3::int)" "9^l" 4]
and power_mod [of "(9::int)" 4 l]
by auto
Apart from the application of power_mult
, this is only application of various rules on what
parts of expressions may be safely reduced. Is there a proof method that can infer detail like this automatically?
(I'm also open to any other comments about my proof style - one thing that bothers me is the repetitive ::int
)