我想证明在阿格达,我认为这是真正的一个简单的引理。

  

如果一个矢量具有两个以上的元件,考虑以下服用head相同立即服用其inithead

我已经配制,如下所示:

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))组件。我想我的问题是;是否有可能,怎么的,什么是这个词的意思。

非常感谢。

有帮助吗?

解决方案

  

我不完全了解如何   读取(init (x ∷ xs) | (initLast (x ∷ xs) | initLast xs))组件。一世   假设我的问题是;是吗   可能的话,怎么的,什么是这个词   的意思。

这告诉你的价值init (x ∷ xs)依赖于一切的|右边的值。当您在阿格达函数证明一下你的证明必须有原始定义的结构。

在此情况下,必须在壳体的initLast结果因为initLast的定义执行此产生任何结果之前。

init : ∀ {a n} {A : Set a} → Vec A (1 + n) → Vec A n
init xs         with initLast xs
                --  ⇧  The first thing this definition does is case on this value
init .(ys ∷ʳ y) | (ys , y , refl) = ys

因此,这里是我们如何写引理。

module inithead where

open import Data.Nat
open import Data.Product
open import Data.Vec
open import Relation.Binary.PropositionalEquality

lem-headInit : {A : Set} {n : ℕ} (xs : Vec A (2 + n))
             → head (init xs) ≡ head xs

lem-headInit (x ∷ xs) with initLast xs
lem-headInit (x ∷ .(ys ∷ʳ y)) | ys , y , refl = refl

我把你的推广定理,Vec A的自由,因为引理不依赖于载体上的内容。

其他提示

确定。我这有一个作弊,我希望有人有更好的解决方案。我扔掉了所有正在init来定义,并创建了自己的天真的版本,你从initLast获得额外的信息。

initLazy : ∀{A l} → Vec A (suc l) → Vec A l
initLazy (x ∷ []) = []
initLazy (x ∷ (y ∷ ys)) = x ∷ (initLazy (y ∷ ys))

现在的引理是微不足道的。

任何其他优惠?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top