【发布时间】:2023-07-09 21:46:01
【问题描述】:
上下文
我试图在 Coq 中用关系 le 定义偏序 A ≤ B ≤ C,并证明它是可判定的:forall x y, {le x y} + {~le x y}。
我通过等效的布尔函数leb 成功地做到了这一点,但找不到直接证明它的方法(或该母校的le_antisym)。我陷入了以下情况:
1 subgoal
H : le C A
______________________________________(1/1)
False
问题
- 我如何证明
le C A是一个错误的前提? - 还有其他我应该使用的证明策略吗?
- 我应该以不同的方式定义我的谓词
le吗?
最小的可执行示例
Require Import Setoid.
Ltac inv H := inversion H; clear H; subst.
Inductive t : Set := A | B | C.
Ltac destruct_ts :=
repeat match goal with
| [ x : t |- _ ] => destruct x
end.
Inductive le : t -> t -> Prop :=
| le_refl : forall x, le x x
| le_trans : forall x y z, le x y -> le y z -> le x z
| le_A_B : le A B
| le_B_C : le B C .
Definition leb (x y : t) : bool :=
match x, y with
| A, _ => true
| _, C => true
| B, B => true
| _, _ => false
end.
Theorem le_iff_leb : forall x y,
le x y <-> leb x y = true.
Proof.
intros x y. split; intro H.
- induction H; destruct_ts; simpl in *; congruence.
- destruct_ts; eauto using le; simpl in *; congruence.
Qed.
Theorem le_antisym : forall x y,
le x y -> le y x -> x = y.
Proof.
intros x y H1 H2.
rewrite le_iff_leb in *. (* How to prove that without using [leb]? *)
destruct x, y; simpl in *; congruence.
Qed.
Theorem le_dec : forall x y, { le x y } + { ~le x y }.
intros x y.
destruct x, y; eauto using le.
- apply right.
intros H. (* Stuck here *)
inv H.
rewrite le_iff_leb in *.
destruct y; simpl in *; congruence.
- apply right.
intros H; inv H. (* Same thing *)
rewrite le_iff_leb in *.
destruct y; simpl in *; congruence.
- apply right.
intros H; inv H. (* Same thing *)
rewrite le_iff_leb in *.
destruct y; simpl in *; congruence.
Qed.
【问题讨论】:
-
为什么称其为部分排序?有三个元素 A |乙| C,它们完全有序。
-
这是我能想到的最简单的例子,但我正在处理的关系不是总订单,所以我不希望有人根据订单是总计。
标签: coq proof deterministic formal-verification partial-ordering