[英]How does one understand Data vs Record capabilities in agda?
Why doesn't a custom unit type allow us to prove this basic left unit law?为什么自定义单位类型不允许我们证明这个基本的左单位定律? I see the only difference between my implementation and that of the standard library is the use of Record
vs Data
inductive inductive type former.我看到我的实现与标准库的实现之间的唯一区别是使用Record
与Data
归纳归纳类型形成器。 I don't understand why the Data
won't allow me to prove this basic left identity lemma, which should be true definitionally.我不明白为什么Data
不允许我证明这个基本的左身份引理,这在定义上应该是正确的。 Does it have to do with Record
's automatic eta inheritance?它与Record
的自动 eta inheritance 有关吗? If so, why is this the case?如果是这样,为什么会这样? Is it possible to prove this without the builtin (eg Record
) Unit type?如果没有内置(例如Record
)单元类型,是否可以证明这一点? In general, is this a limitation of Data
, or is it possible to do everything in agda modulo records?一般来说,这是Data
的限制,还是可以在 agda 模记录中做所有事情?
data _≡_ {A : Set} : A → A → Set where
refl : (a : A) → a ≡ a
--from builtin
lunitm : (f : ⊤ → ⊤) → (λ x → f tt) ≡ f
lunitm f = refl (λ x → tt)
data ⊤2 : Set where
tt2 : ⊤2
lunitm2 : (f : ⊤2 → ⊤2) → (λ x → f tt2) ≡ f
lunitm2 f = ? --refl ? --can't instantiate
This is indeed due to ⊤2
being a data
rather than record
.这确实是因为⊤2
是data
而不是record
。
Agda implements eta-rules for negative types . Agda 为否定类型实现了 eta 规则。
Records are negative and so have eta-rules associated with them.记录是负面的,因此有与之相关的 eta 规则。 The eta-rule of的 eta 规则
record Unit : Set where
constructor unit
is是
_ : (u : Unit) -> u ≡ unit
_ = λ u -> refl
Supporting eta-equality for positive types is possible in theory , but Agda does not implement that.理论上支持正类型的 eta-equality 是可能的,但 Agda 没有实现这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.