Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用Coq中的两个递归变量定义递归表示法_Coq - Fatal编程技术网

用Coq中的两个递归变量定义递归表示法

用Coq中的两个递归变量定义递归表示法,coq,Coq,我想为类型上下文定义如下所示的符号: { x1 : T1, x2 : T2, x3 : T3 } 然而,我无法找到一种递归定义这种符号的方法。我的猜测如下: Notation "{ x1 : T1 , .. , xn : Tn }" := (cons (x1, T1) .. (cons (xn, Tn)) ..). 我得到以下错误:“找不到递归模式的起始位置。” 这样的递归表示法可能吗?如果可能的话,怎么做呢?Coq似乎没有将x1:T1和xn:Tn识别为表达式,而是将表示法解析为{x1:(T

我想为类型上下文定义如下所示的符号:

{ x1 : T1, x2 : T2, x3 : T3 }
然而,我无法找到一种递归定义这种符号的方法。我的猜测如下:

Notation "{ x1 : T1 , .. , xn : Tn }" := (cons (x1, T1) .. (cons (xn, Tn)) ..).
我得到以下错误:“找不到递归模式的起始位置。”


这样的递归表示法可能吗?如果可能的话,怎么做呢?

Coq似乎没有将
x1:T1
xn:Tn
识别为表达式,而是将表示法解析为
{x1:(T1,…,xn):Tn}
。这建议在以下两个步骤中定义符号

Section T. (* To see the effect of the notation after closing this section. *)

(* recursive list notation *)
Notation "{ x1 , .. , xn }" :=
  (cons x1 .. (cons xn nil) ..).

(* pair notation *)
Notation "x : T" := ((x, T))
(at level 100).

Definition z := { 3 : 4, 5 : 6, 7 : 8 }.

Print z.
(* z = {3 : 4, 5 : 6, 7 : 8} *)

End T.

Print z.
(* z = ((3, 4) :: (5, 6) :: (7, 8) :: nil)%list *)

我在GitHub上打开了。让我们看看会发生什么。它以某种方式被解析为
{x1:(T1,…,xn):Tn}
..(欢迎使用修复程序来消除常见类型注释语法的歧义!我对级别系统不够熟悉。)这看起来应该行得通。我稍后将研究的另一个问题是,是否有一种方法可以设置作用域,以便第二种表示法只能在大括号内工作。谢谢