如何找到Coq中两个列表之间的差异

时间:2019-01-14 17:13:25

标签: coq

我在coq中有两个列表。我想找出这两个列表之间的区别。请plz指导我在coq中编写代码

2 个答案:

答案 0 :(得分:0)

正如亚瑟(Arthur)所说,差异有很多版本。如果您想减法,这里有两种方法:

Variable (T: eqType).

Definition dlist1 (l1 l2 : seq T) :=
  foldr (fun x l => if x \in l2 then l else [:: x & l]) [::] l1.

Definition dlist2 (l1 l2 : seq T) :=
  foldl (fun l x => filter (predC1 x) l) l1 l2.

YMMV。证明:

Lemma dlist2_nil l2 : dlist2 [::] l2 = [::].
Proof. by elim: l2. Qed.

Lemma dlist2_cons x1 l1 l2 :
  dlist2 (x1 :: l1) l2 =
  if x1 \in l2 then dlist2 l1 l2 else [:: x1 & dlist2 l1 l2].
Proof. by elim: l2 l1 => //= x2 l2 ih2 l1; rewrite inE; case: eqP => /=. Qed.

Lemma dlistP l1 l2 : dlist1 l1 l2 = dlist2 l1 l2.
Proof.
by elim: l1 l2 => [|x1 l1 ih1] /= l2; rewrite ?dlist2_nil // dlist2_cons ih1.
Qed.

答案 1 :(得分:0)

您要寻找的不是两个列表之间的区别,而是它们的交集。您可以通过重用标准库的某些部分来对该函数进行编程。

manualDateEntryFromInputHandler(e) {
    let inputValue = e.target.value
    let dateValue = inputValue
    let date = moment(inputValue) 
    this.setState({date, dateValue})
}