Im trying to prove commutativity in Isabelle/HOL for a self-defined add
function. I managed to prove associativity but I'm stuck on this.
The definition of add
:
fun add :: "nat ⇒ nat ⇒ nat" where
"add 0 n = n" |
"add (Suc m) n = Suc(add m n)"
The proof of associativity:
lemma add_Associative: "add(add k m) z = add k (add m z)"
apply(induction k)
apply(auto)
done
The proof of commutativity:
theorem add_commutativity: "add k m = add m k"
apply(induction k)
apply(induction m)
apply(auto)
I get the following goals:
goal (3 subgoals):
1. add 0 0 = add 0 0
2. ⋀m. add 0 m = add m 0 ⟹
add 0 (Suc m) = add (Suc m) 0
3. ⋀k. add k m = add m k ⟹
add (Suc k) m = add m (Suc k)
After applying auto I'm left with just subgoal 3:
3. ⋀k. add k m = add m k ⟹
add (Suc k) m = add m (Suc k)
EDIT: Im not so much looking for an answer, as a push in the right direction. These are exercises from a book called Concrete Sementics.