首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Coq中的列表构造函数冲突

Coq中的列表构造函数冲突
EN

Stack Overflow用户
提问于 2021-01-11 07:42:49
回答 1查看 47关注 0票数 0

我在Coq中有以下定义:

代码语言:javascript
复制
Inductive list_variable : Type :=
| nil
| cons (s : string) (l : list_variable).

Fixpoint getElement (l : list_variable) (s : Variabile) (v : Address) {struct l} : Address :=
match l with
| nil => v
| str :: nil => (updateValues v ((updateState (updateState s "memPointer" (s("memPointer")+1)) str (s("memPointer"))) "memPointer") undef)
| str :: l => getElement l s v
end.

由于某些原因,最后一行和第二行返回Found a constructor of inductive type list while a constructor of list_variable is expected.

作为参考,str::nil的长期回报在另一个地方可以很好地工作。这是为了一个类似记忆的模拟。

你知道为什么会发生这种情况吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-11 08:10:15

符号::被设计成List.cons,而你想要的是构造函数MyModule.cons。如果你想使用::,你必须为它定义一个新的符号:

代码语言:javascript
复制
Inductive list_variable : Type :=
| nil
| cons : ...
.

(* Redefine "::" for new list type *)
Infix "::" := cons.

如果您打算对listlist_variable使用相同的符号,则有必要管理符号作用域。请参阅the Coq manual, the section on notations

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65659686

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档