【发布时间】:2021-11-12 14:05:42
【问题描述】:
由于 Coq 具有强大的类型推断算法,我想知道我们是否可以根据 Notation 的变量为不同的重写“重载”表示法。
作为一个例子,我将借用我的一篇关于在 Coq 中形式化类型语言语义的工作。在这个形式化中,我有类型对和表达式对,我想为它们各自的构造函数使用相同的符号:{ _ , _ }。
Inductive type: Type := ... | tpair: type -> type -> type | ...
Inductive expr: Type := ... | epair: expr -> expr -> expr | ...
Notation "{ t1 , t2 }" := tpair t1 t2
Notation "{ e1 , e2 }" := epair e1 e2
我知道最后一条语句会引发错误,因为符号已经定义;如果有人考虑过它的诡计,或者如果有另一种“官方”的方式来做到这一点,我将不胜感激。
【问题讨论】:
标签: overloading coq notation