emacsagdaagda-mode

How can I use agda2-mode to generate patterns when I expect to see an absurd pattern?


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.


Solution

  • 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:

    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.