如何使用包含Coq中通用量词的假设?

时间:2017-06-16 09:43:03

标签: coq coq-tactic

我是Coq的新手。我对以下证据感到困惑:

 const uuidV1 = require('uuid/v1');
 ...
 function saveThread(req,res){
      const threadId=uuidV1(); // -> 6c84fb90-12c4-11e1-840d-7b25c5ee775a
      let thread=req.body;
      thread.id=threadId;
      saveThread();
      //return response (res.status(200).json(newThreadObject))
      saveThreadId();
 } 

结果显示:

Lemma nth_eq : forall {A} (l1 l2 : list A),
length l1 = length l2 ->
(forall d k, nth k l1 d = nth k l2 d) ->l1 = l2.
Proof.
  intros.

通过使用H0和H可以明显推断,但我不知道如何使用H0来完成证明。非常感谢你的帮助!

1 个答案:

答案 0 :(得分:1)

由于已经有一段时间了并且OP没有对gallais的评论做出回应,我在这里提出了一个解决方案,希望能够很容易地在IDE中逐步完成证明

Require Import List.

Lemma nth_eq : forall {A} (l1 l2 : list A),
length l1 = length l2 ->
(forall d k, nth k l1 d = nth k l2 d) ->l1 = l2.
Proof.
(* shortcut to the below:
   induction l1; destruct l2; try discriminate 1.
   will eliminate two of the cases for you *)
induction l1; destruct l2.
+ reflexivity.
+ discriminate 1.
+ discriminate 1.
+ intros. f_equal.
  - specialize H0 with (d := a) (k := 0). simpl in H0. assumption.
  - apply IHl1.
    * simpl in H. injection H. trivial.
    * intros. specialize H0 with (d := d) (k := S k). simpl in H0.
      assumption.
Qed.