简体   繁体   English

当我期望看到荒谬的模式时,如何使用agda2模式生成模式?

[英]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 : 例如,我们证明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). 但是我希望生成图案(sns (sns ())) (就像填充孔一样)。 Are there any ways to achieve that? 有什么方法可以实现?

I am using Emacs 25 with agda2-mode. 我正在使用带有agda2模式的Emacs 25。

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 . 在这种情况下,您可以使用emacs的键盘宏,因为通过匹配h生成的子项也将被命名为h So using: 因此使用:

  • <f3> (start recording the macro) <f3> (开始记录宏)
  • Cc Cf (move to the hole) Cc Cf (移至孔)
  • Cc Cc h RET (match on h ) Cc Cc h RET (与h匹配)
  • <f4> (record the macro) <f4> (记录宏)

you've recorded the action of "moving to the first goal an matching on h". 您已经记录了“将与h的匹配移到第一个目标”的操作。 You can now keep pressing <f4> until you reach an absurd case. 现在,您可以一直按<f4>直到出现荒谬的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM