coq - Coq:如何证明 forall nm, n <= m \/ m <= n
问题描述
如何证明
定理 le_total:对于所有 nm,n <= m \ / m <= n。
以下是我可能有帮助的定理:
Inductive le : nat -> nat -> Prop :=
| le_n (n : nat) : le n n
| le_S (n m : nat) (H : le n m) : le n (S m).
Notation "n <= m" := (le n m).
Theorem le_le_S : forall n m,
n <= m -> S n <= S m.
Proof.
intros n m H. induction H.
- (* le_n *)
apply le_n.
- (* le_S *)
apply le_S. apply IHle. Qed.
(** **** Exercise: 1 star, standard (le_trans) *)
Lemma le_trans : forall m n o, m <= n -> n <= o -> m <= o.
Proof.
intros m n o Lmn Lno.
generalize dependent Lmn.
generalize dependent m.
induction Lno.
-intros. apply Lmn.
-intros. apply le_S. apply IHLno. apply Lmn.
Qed.
(** [] *)
(** **** Exercise: 1 star, standard (O_le_n) *)
Theorem O_le_n : forall n,
0 <= n.
Proof.
intros. induction n.
apply le_n.
apply le_S. apply IHn.
Qed.
我能够达到一个点,即在 n 上使用归纳可以让我到达一个好位置,但我不知道在那之后该去哪里。
解决方案
我的猜测是你的归纳假设不够普遍。关于两个变量(在这种情况下)的一些结果n
需要m
归纳在n
上m
。所以一开始,而不是
Proof.
intros n m.
induction n.
做:
Proof.
intros n.
induction n.
推荐阅读
- sql-server - 尝试使用 sql_server_socket 将我的应用程序与 SQL Server 连接起来。在 SqlConnection.dart 中,未正确指定 guinness 包的版本
- azure-devops - Azure YAML Pipelines:如何在 Azure DevOps 的另一个项目中引用一个项目和 repo
- for-loop - FOR循环/向量化数列
- lua - 如何在 ROBLOX 中制作杀手机器人
- python - 在 Python 中录制时检测并分割静音
- mongodb - $ 查找 mongodb 对象数组
- python - Flask、Asyncio、BS4、Requests-html ValueError:信号仅在主解释器的主线程中有效
- android - 使用 replace() 时片段未替换
- blockchain - 使用 web3.js 调用以太坊合约时出现意外错误
- spring - Spring Boot REST API - 字段 ID 的类型不匹配