coq - 通过相互共游定义一对共定点
问题描述
有没有一种简单的方法可以定义两个 cofixpoints,让您同时输出它们?理想情况下,我想要以下内容:
Require Import Streams.
Definition alts : Stream bool * Stream bool :=
cofix a := Cons false b with
b := Cons true a for (a,b).
但是,似乎 Coq 只允许您从相互的 cofixes 块中返回其中一个标识符。我现在能做的最好的事情是:
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
. 有没有更好的办法?
解决方案
一种解决方法是使用CoFixpoint
相互定义a
,b
然后重用它们来定义alts
。
CoFixpoint a : Stream bool := Cons false b
with b : Stream bool := Cons true a.
Definition alts : Stream bool * Stream bool := (a, b).
这种方法的缺点是我们用新名称a
和b
.
推荐阅读
- python - 如何使用波士顿住房数据集进行预测?
- sql - SQL Server中基于ID的Concat 2列
- java - 如何按 HomeButton 并关闭应用程序,然后我想注销客户端,所以如果他再次按应用程序图标
- ubuntu - 无法通过 SSH、面板和浏览器的 SSH 访问我的 Google Cloud 实例
- php - XCRUD:如何插入 html?
- java - 括号匹配算法java
- java - 使用 Java 13 的 Liquibase:org.hibernate.boot.registry.classloading.spi.ClassLoadingException
- java - 如何使用 JSP 检索整数 URL 参数?
- javascript - 获取角度延迟加载的浏览器模块错误
- javascript - 根据选择的多个选项重定向到不同的页面