agda - Agda:重写子表达式
问题描述
我试图证明:
AddTodoSetsNewCompletedToFalse :
∀ {n : ℕ} (todos : Vec Todo (1 + n)) (text : String) →
Todo.completed (last (AddTodo todos text)) ≡ false
AddTodoSetsNewCompletedToFalse todos text = ?
在哪里
AddTodoLastAddedElementIsTodo :
∀ {a} {A : Set a} {n} (todos : Vec Todo n) (text : String) →
last (AddTodo todos text) ≡
record
{ id = 1
; completed = false
; text = text
}
AddTodoLastAddedElementIsTodo todos text = vecLast todos
和
vecLast : ∀ {a} {A : Set a} {l n} (xs : Vec A n) → last (xs ∷ʳ l) ≡ l
vecLast [] = refl
vecLast (_ ∷ xs) = P.trans (prop (xs ∷ʳ _)) (vecLast xs)
where
prop : ∀ {a} {A : Set a} {n x} (xs : Vec A (suc n)) → last (x ∷ xs) ≡ last xs
prop xs with initLast xs
... | _ , _ , refl = refl
我尝试使用rewrite
并得到:
AddTodoSetsNewCompletedToFalse :
∀ {a} {A : Set a} {n} (todos : Vec Todo n) (text : String) →
Todo.completed (last (AddTodo todos text)) ≡ false
AddTodoSetsNewCompletedToFalse todos text rewrite AddTodoLastAddedElementIsTodo todos text = refl
但错误:
_a_100 : Agda.Primitive.Level
出现了。
我不确定如何解决这个问题。从这里我明白这与隐含的论点有关。但不确定如何解决
这种错误表示未解决的元变量,这意味着 Agda 无法推断出隐式参数
谢谢!
解决方案
您不A
使用AddTodoSetsNewCompletedToFalse
. 此外,这不是错误,而是未解决的元数据。
所以发生的情况是,无论您在哪里使用AddTodoSetsNewCompletedToFalse
,参数或结果类型中的任何内容都不会限制A
(以及随后a
)的选择,因此统一器无法解决这些元变量。AddTodoSetsNewCompletedToFalse {a = _} {A = _}
您可以通过编写并观察这两个元数据未解决来明确发生了什么。
您应该简单地从 的类型中删除前两个参数 (a
和A
) AddTodoSetsNewCompletedToFalse
。
推荐阅读
- javascript - webpackChunkName 的动态导入
- sql-server - SSRS 参数 - 来自查询的值(并行性)
- mysql - 使用 VB.NET 使用 BLOB 将 PDF 文件插入 MYSQL
- ruby-on-rails - 连接被拒绝 - “localhost”端口 1025 的连接(2)
- python - python楼层除法算子是如何实现的?
- r - 如何删除 R 中的行,该行在一列中包含相同的数据“集”
- sql-server - 如何在 SQL 表中选择索引
- google-maps - Google 地理编码 API 为邮政编码返回 ZERO_RESULTS
- python - OSError: [Errno 121] Remote IO error running donkey calibrate
- c++ - 快速选择算法的最小 kth