With-抽象和平等
With-abstraction and equality
在下面的例子中
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
postulate
f : Nat → Nat
g : ∀{x y} → f x ≡ suc y → Nat
h : Nat → Nat
h x with f x
h x | zero = zero
h x | suc y = g {x} {y} {!refl!}
Agda 不接受 refl
作为参数。
主要问题是,
- 我做错了什么?
- correct/optimal/established/preferred 证明这样的东西的方法是什么?
当然,我们非常感谢任何对 Agda 行为的见解。
≡-Reasoning and 'with' patterns and should answer your questions. The official docs描述如何做你想做的,但他们似乎不太beginner-friendly。
在下面的例子中
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
postulate
f : Nat → Nat
g : ∀{x y} → f x ≡ suc y → Nat
h : Nat → Nat
h x with f x
h x | zero = zero
h x | suc y = g {x} {y} {!refl!}
Agda 不接受 refl
作为参数。
主要问题是,
- 我做错了什么?
- correct/optimal/established/preferred 证明这样的东西的方法是什么?
当然,我们非常感谢任何对 Agda 行为的见解。
≡-Reasoning and 'with' patterns and