我目前正在使用 Coq 中的红黑树,并希望为列表配备一个订单,以便可以使用该模块nat
将它们存储在红黑树中。MSetRBT
出于这个原因,我定义seq_lt
如下:
Fixpoint seq_lt (p q : seq nat) := match p, q with
| _, [::] => false
| [::], _ => true
| h :: p', h' :: q' =>
if h == h' then seq_lt p' q'
else (h < h')
end.
到目前为止,我已经成功展示了:
Lemma lt_not_refl p : seq_lt p p = false.
Proof.
elim: p => //= ? ?; by rewrite eq_refl.
Qed.
也
Lemma lt_not_eqseq : forall p q, seq_lt p q -> ~(eqseq p q).
Proof.
rewrite /not. move => p q.
case: p; case: q => //= a A a' A'.
case: (boolP (a' == a)); last first.
- move => ? ?; by rewrite andFb.
- move => a'_eq_a A'_lt_A; rewrite andTb eqseqE; move/eqP => Heq.
move: A'_lt_A; by rewrite Heq lt_not_refl.
Qed.
但是,我正在努力证明以下内容:
Lemma seq_lt_not_gt p q : ~~(seq_lt q p) -> (seq_lt p q) || (eqseq p q).
Proof.
case: p; case: q => // a A a' A'.
case: (boolP (a' < a)) => Haa'.
- rewrite {1}/seq_lt.
suff -> : (a' == a) = false by move/negP => ?.
by apply: ltn_eqF.
- rewrite -leqNgt leq_eqVlt in Haa'.
move/orP: Haa'; case; last first.
+ move => a_lt_a' _; apply/orP; left; rewrite /seq_lt.
have -> : (a == a') = false by apply: ltn_eqF. done.
+ (* What now? *)
Admitted.
我什至不确定最后一个引理是否可以使用归纳法,但我已经研究了几个小时,不知道从这一点开始。定义有seq_lt
问题吗?