首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Coq中证明10%Z < Int.max_unsigned和Compcert中的整型

如何在Coq中证明10%Z < Int.max_unsigned和Compcert中的整型
EN

Stack Overflow用户
提问于 2018-02-07 17:56:32
回答 2查看 89关注 0票数 0

我想证明一个小于Int.max_unsigned的Z类型值。

引理检验: 10%Z < Int.max_unsigned。证据。??如何证明上述测试引理?

EN

回答 2

Stack Overflow用户

发布于 2018-02-08 00:32:01

CompCert的Int.max_unsigned是根据许多其他概念定义的,如Int.modulusInt.wordsize和用于计算某些n的2次方的two_power_nat函数。通过逐个展开这些定义并观察发生了什么,了解事物是如何组织的是很有指导意义的:

代码语言:javascript
复制
unfold Int.max_unsigned.
(* 10 < Int.modulus - 1 *)
unfold Int.modulus.
(* 10 < two_power_nat Int.wordsize - 1 *)
unfold Int.wordsize.
(* 10 < two_power_nat Wordsize_32.wordsize - 1 *)

但这会变得很无聊。一个更简单的证明是使用compute策略来评估Int.max_unsigned,并与10进行比较:

代码语言:javascript
复制
Lemma test: 10%Z < Int.max_unsigned.
Proof.
  compute.
  (* The goal is now simply [Lt = Lt]. *)
  auto.
Qed.
票数 5
EN

Stack Overflow用户

发布于 2018-02-07 18:27:35

这些简单的定理可以用auto策略来证明。示例:

代码语言:javascript
复制
Require Import ZArith.

Open Scope Z_scope.

Lemma test: 10 < 111.
Proof.
  auto with zarith.
Qed.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48660767

复制
相关文章

相似问题

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