通过相互corecursion定义一对共固定点

时间:2018-07-30 20:10:15

标签: coq

是否有一种简便的方法来定义两个共固定点,使您可以同时输出它们?理想情况下,我想要以下内容:

Require Import Streams.

Definition alts : Stream bool * Stream bool :=
  cofix a := Cons false b with
        b := Cons true a for (a,b).

但是,似乎Coq只允许您从互斥的块中返回标识符之一。我现在能做的最好的事情如下:

Definition alts2 : Stream bool * Stream bool :=
  let a := cofix a := Cons false b with
                 b := Cons true a for a in (a,Cons true a).

当然,这不是理想的选择,因为我需要重复b的定义。有更好的方法吗?

1 个答案:

答案 0 :(得分:0)

一种解决方法是使用CoFixpoint来相互定义ab,然后重用它们来定义alts

CoFixpoint a : Stream bool := Cons false b
with b : Stream bool := Cons true a.

Definition alts : Stream bool * Stream bool := (a, b).

此方法的缺点是我们用新名称ab污染名称空间。

相关问题