如何证明Coq中的强排序列表cons?

时间:2018-06-20 02:12:24

标签: coq proof formal-verification

我正尝试在Coq中建立河内证明之塔,作为学习活动。经过数小时无果的尝试,我的第一个证明仍然停留在最后一个目标上。

能否请您解释为什么我的程序失败,以及如何纠正它?

编辑:回顾代码,看来我需要先证明StronglySorted le (l:list nat),然后才能证明ordered_stacking,对吗?

Require Import List.
Require Import Arith.
Require Import Coq.Sorting.Sorting.

Definition stack_disk :=
  fun (n:nat) (l:list nat) =>
    match l with
      | nil => n::nil
      | n'::l' =>
          if n' <? n
          then n::l
          else l
    end.

Eval compute in (stack_disk 2 (1::0::nil)).
Eval compute in (stack_disk 2 (2::1::0::nil)).

Lemma ordered_stacking: forall (n:nat) (l:list nat),
  StronglySorted le l -> StronglySorted le (stack_disk n l) -> StronglySorted le (n::l).
  Proof.
    intros n l H.
    induction l as [|hl tl];simpl;auto.
    destruct (hl <? n).
    auto.
    constructor.
    apply H.

输出:

1 subgoal
n, hl : nat
tl : list nat
H : StronglySorted le (hl :: tl)
IHtl : StronglySorted le tl ->
       StronglySorted le (stack_disk n tl) -> StronglySorted le (n :: tl)
H0 : StronglySorted le (hl :: tl)
______________________________________(1/1)
Forall (le n) (hl :: tl)

1 个答案:

答案 0 :(得分:2)

问题是您在破坏布尔值之后没有记录 $(".progress").attr('data-percent', 5); $(".progress").data('percent', 5); 的事实。这是一个解决方案:

n <= hl