For example, we're proving 2 + 2 != 5
:
data _+_≡_ : ℕ → ℕ → ℕ → Set where
znn : ∀ {n} → zero + n ≡ n
sns : ∀ {m n k} → m + n ≡ k → suc m + n ≡ suc k
And I can manually prove it:
2+2≠5 : 2 + 2 ≡ 5 → ⊥
2+2≠5 (sns (sns ()))
But I want the pattern (sns (sns ()))
to be generated (just like filling a hole). Are there any ways to achieve that?
I am using Emacs 25 with agda2-mode.
Ok, so let's say you start from this configuration:
2+2≠5 : 2 + 2 ≡ 5 → ⊥
2+2≠5 h = {!!}
In this case you can use emacs' keyboard macros because the sub-term generated by matching on h
will also be named h
. So using:
<f3>
(start recording the macro)C-c C-f
(move to the hole)C-c C-c h RET
(match on h
)<f4>
(record the macro)you've recorded the action of "moving to the first goal an matching on h". You can now keep pressing <f4>
until you reach an absurd case.