证明关于有序列表的定理

时间:2016-02-12 17:31:32

标签: coq proof

这应该是一个直截了当的事情要证明,但我一直陷入困境。非常感谢帮助...

Require Import Arith.

Fixpoint At n (l:list nat) :=
  match n with
    | 0    => match l with nil => None | cons x _  => Some x   end
    | S n' => match l with nil => None | cons _ l' => At n' l' end
  end.

Definition ordered l :=
  forall i j, i < j -> j < length l ->
              exists x y, At i l = Some x /\ At j l = Some y /\ x <= y.

Lemma ordered_cons:
  forall l a b, ordered (cons b l) -> a <= b ->  ordered (cons a (cons b l)).

  intros l a b H H0 i j Hij Hj.
  destruct i,j;
    (* solve three of the four cases, and leave one untouched *)
    try (inversion Hij; fail);
    try (apply H; simpl in *; omega).

编辑:这是完成证明的解决方案。我需要考虑j的下两个案例。

  destruct j;
    try (exists a,b; auto; fail).

  destruct (H 0 (S j)) as [x [y [Ha [Hb Hc]]]]; auto with arith;
  simpl in *; inversion Ha; exists a, y;
  repeat split; try tauto; omega.
Qed.

0 个答案:

没有答案