显示 (head . init ) = Agda 中的 head
我试图证明 Agda 中的一个简单引理,我认为这是正确的。
如果向量具有两个以上元素,则在获取
init
后获取其head
与立即获取其head
相同。< /p>
我将其表述如下:
lem-headInit : ∀{l} (xs : Vec ℕ (suc (suc l)))
-> head (init xs) ≡ head xs
lem-headInit (x ∷ xs) = ?
这给了我;
.l : ℕ
x : ℕ
xs : Vec ℕ (suc .l)
------------------------------
Goal: head (init (x ∷ xs) | (initLast (x ∷ xs) | initLast xs)) ≡ x
作为回应。
我不完全理解如何读取 (init (x ∷ xs) | (initLast (x ∷ xs) | initLast xs))
组件。我想我的问题是;是否可能,如何以及该术语的含义是什么。
非常感谢。
I'm trying to prove a simple lemma in Agda, which I think is true.
If a vector has more than two elements, taking its
head
following taking theinit
is the same as taking itshead
immediately.
I have formulated it as follows:
lem-headInit : ∀{l} (xs : Vec ℕ (suc (suc l)))
-> head (init xs) ≡ head xs
lem-headInit (x ∷ xs) = ?
Which gives me;
.l : ℕ
x : ℕ
xs : Vec ℕ (suc .l)
------------------------------
Goal: head (init (x ∷ xs) | (initLast (x ∷ xs) | initLast xs)) ≡ x
as a response.
I do not entirely understand how to read the (init (x ∷ xs) | (initLast (x ∷ xs) | initLast xs))
component. I suppose my questions are; is it possible, how and what does that term mean.
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这告诉您,值
init (x ∷ xs)
取决于|
右侧所有内容的值。当您在 Agda 中的函数中证明某些内容时,您的证明必须具有原始定义的结构。在这种情况下,您必须对
initLast
的结果进行区分,因为initLast
的定义会在生成任何结果之前执行此操作。这就是我们如何编写引理。
我冒昧地将你的引理推广到 Vec A ,因为引理不依赖于向量的内容。
This tells you that the value
init (x ∷ xs)
depends on the value of everything to the right of the|
. When you prove something about in a function in Agda your proof will have to have the structure of the original definition.In this case you have to case on the result of
initLast
because the definition ofinitLast
does this before producing any results.So here is how we write the lemma.
I took the liberty of generalizing your lemma to
Vec A
since the lemma doesn't depend on the contents of the vector.好的。我通过作弊得到了这个,我希望有人有更好的解决方案。我抛弃了从
init
中获得的所有额外信息,这些信息是根据initLast
定义的,并创建了我自己的简单版本。现在引理是微不足道的。
还有其他优惠吗?
Ok. I've got this one by cheating and I'm hoping somebody has a better solution. I threw away all the extra information you get from
init
being defined in terms ofinitLast
and created my own naive version.Now the lemma is trivial.
Any other offers?