首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Coq证明#Coq

Coq证明#Coq
EN

Stack Overflow用户
提问于 2022-01-01 03:53:55
回答 1查看 170关注 0票数 0

我试图解决这个证据,但我找不到它的方法。我有两个子目标,但我甚至不知道它是否正确。

这里是我试图解决的引理,但我被困住了:

2个次级目标

a,b: Nat

H: Equal (leB a,b) True

______________________________________(1/2)

等匹配b与

Z => False

S‘=> leB a m’

结束(leB A b) /相等(leB b (S a)) (leB A b)

______________________________________(2/2)

相等(leB (S ) b)真/等(leB b (S ))真

代码语言:javascript
运行
AI代码解释
复制
Inductive Bool : Type :=
          True : Bool | False : Bool.

Definition Not(b : Bool) : Bool :=
          Bool_rect (fun a => Bool)
                     False
                     True
                     b.



Lemma classic : forall b : Bool, Equal b (Not (Not b)).
Proof.
intro.
induction b.
simpl.
apply refl.
simpl.
apply refl.
Qed.

Definition Equal(T : Type)(x y : T) : Prop :=
           forall P : T -> Prop, (P x) -> (P y).

Arguments Equal[T].
(* Avec certaines versions Arguments Equal[T] *)

Lemma refl : forall T : Type, forall x : T, Equal x x.
Proof.
intros.
unfold Equal.
intros.
assumption.
Qed.

Fixpoint leB n m : Bool :=
  match n, m with
    | Z, _ => True
    | _, Z => False
    | S n', S m' => leB n' m'
  end.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-02 08:59:38

首先,不要在intros开头引入所有变量。你会得到一个太弱的归纳假说。只需介绍一下a

然后,在每个分支中,用b策略考虑不同的destruct情况。它将简化您的目标,您可以看到目标的左边或右侧是真的,并使用您的refl引理来完成目标。

最后一种情况要求您使用您的归纳假设,在这里,重要的是它适用于所有的b,而不仅仅是一个特定的b

另外,您没有为您的Nat类型提供定义,我想是这样的:

代码语言:javascript
运行
AI代码解释
复制
Inductive Nat := Z | S (n:Nat).

这是一个证据。

代码语言:javascript
运行
AI代码解释
复制
Lemma Linear : forall a b, (Equal (leB a b) True) \/ (Equal (leB b a) True). 
  Proof.
induction a. 
- intros b. destruct b; simpl.
    + left. apply refl. 
    + left. apply refl.
- intros b. destruct b; simpl.
  + right. apply refl.
  + destruct (IHa b) as [Hleft | Hright].
    ++ left. apply Hleft.
    ++ right. apply Hright.
Qed.

虽然它可能不那么有洞察力,但你也可以使用策略尝试这些步骤,以获得一个较短的证据。

代码语言:javascript
运行
AI代码解释
复制
induction a; destruct b; firstorder.

也会证明你的引理。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70548700

复制
相关文章
用了一段时间Agda的感想
最近闲下来的时候其实一直有在玩Agda。其实之前也知道Agda,但是由于Coq的相关资料更多,而且那时候我在Windows平台上无法安装Agda(old-times库的问题),于是拖到近来PLFA这本书的中文翻译动工才开始跟着看。
KAAAsS
2022/01/14
1.5K0
用了一段时间Agda的感想
用于数学的 10 个优秀编程语言
作为一个对数学和编程语言充满激情的人,谁也不能阻止我分享我总结的10个超棒的用于数学的编程语言。 正文共:2619 字 预计阅读时间:7 分钟 作为一个对数学和编程语言充满激情的人,谁也不能阻止我分
前朝楚水
2018/04/03
3.4K0
用于数学的 10 个优秀编程语言
「SF-LC」10 IndPrinciples
P only need to fullfill l : the_type but not n:nat since we are proving property of the_type.
零式的天空
2022/03/14
7420
「SF-LC」1 Basics
The .v code is a gorgeous example of literal programming and the compiled .html website is full-fledged. So this note is intended to be NOT self-contained and only focus on things I found essential or interesting. This note is intended to be very personal and potentially mix English with Chinese (You can Lol) So yeah. Don’t expect it to be well organized and well written. I posted it on blog mainly for my own references purpose. The quotes could either come from the book or saying from someone (even including me).
零式的天空
2022/03/14
3950
「SF-LC」5 Tactics
It also works with conditional hypotheses:
零式的天空
2022/03/14
5330
「SF-LC」4 Poly
Until today, We were living in the monomorphic world of Coq. So if we want a list, we have to define it for each type:
零式的天空
2022/03/14
1.3K0
「SF-LC」8 Maps
From now on, importing from std lib. (but should not notice much difference)
零式的天空
2022/03/14
3370
「SF-LC」9 ProofObjects
So the book material is designed to be gradually reveal the facts that
零式的天空
2022/03/14
5530
「SF-LC」3 List
Pair of Numbers Q: Why name inductive? A: Inductive means building things bottom-up, it doesn’t have
零式的天空
2022/03/14
4210
「SF-LC」6 Logic
The equality operator = is also a function that returns a Prop. (property: equality)
零式的天空
2022/03/14
5880
收藏贴 :2019年必备43种区块链开发工具 原
本文列出2019年最新整理的用于区块链开发的43种流行的开发库、开发工具与开发框架。
用户1408045
2019/05/14
1.7K0
收藏贴 :2019年必备43种区块链开发工具
                                                                            原
「SF-LC」7 Ind Prop
we can write an Inductive definition of the even property!
零式的天空
2022/03/14
6450
「SF-LC」11 Rel
I have been long confused with Unary Relations vs. Binary Relation on the Same Set (homogeneous relation) I thought they were same…but turns out they are totally different!
零式的天空
2022/03/14
3840
「SF-LC」12 Imp
A weird convention through out all IMP is:
零式的天空
2022/03/14
1.7K0
「SF-PLF」6 Types
The toy lang from SmallStep is too “safe” to demonstrate any runtime (or dynamic) type errors. — 运行时类型错误 So that’s add some operations (common church numeral ones), and bool type.
零式的天空
2022/03/02
4370
「SF-PLF」7 Stlc
“Base Types”, only Bool for now. — 基类型 …again, exactly following TAPL.
零式的天空
2022/03/02
3580
「SF-LC」15 Extraction
如果不做任何处理的话…生成的 ml 里的 nat 则都会是 Church Numeral…
零式的天空
2022/03/14
5140
007. 编辑器专家的 Emacs 世界
本期节目请来了一位使用 Emacs 15 年之久的编辑器专家领蜂,在高中竞赛时获奖后,父母送给他一台个人电脑,这打开了他的 Emacs 之旅。
飞驰的西瓜
2022/07/26
5550
007. 编辑器专家的 Emacs 世界
MCE | 铁死亡抑制机制
众所周知,谷胱甘肽过氧化物酶 4 (GPX4) 和铁死亡抑制蛋白 1 (FSP1) 构成了铁死亡的两大主要防御系统→
MedChemExpress
2023/03/09
7190
MCE | 铁死亡抑制机制
「SF-LC」13 ImpParser
basically, parser combinator (But 非常麻烦 in Coq)
零式的天空
2022/03/14
3660

相似问题

Coq证明用法

16

Coq证明策略

23

注释Coq证明

227

在Coq中证明

33

Coq simple隐含证明

111
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档