Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Coq 对子表上子集关系性质的证明_Coq - Fatal编程技术网

Coq 对子表上子集关系性质的证明

Coq 对子表上子集关系性质的证明,coq,Coq,我正在证明一个关于子集的简单数学性质,例如:子集B;这是关于向集合B添加成员不会影响这种关系的事实。在程序中,A和B是成对的列表列表对中的实体检查特定对是否在对列表中,listPairEqual检查两个对列表的相等性。我有点被困在引理的证明中引理addtolistPairSUB: Require Import List. Require Import Bool. Definition entity := nat. Definition entityID := nat. Definition l

我正在证明一个关于子集的简单数学性质,例如:子集B;这是关于向集合B添加成员不会影响这种关系的事实。在程序中,A和B是成对的列表<代码>列表对中的实体检查特定对是否在对列表中,
listPairEqual
检查两个对列表的相等性。我有点被困在引理的证明中
引理addtolistPairSUB

Require Import List.
Require Import Bool.

Definition entity := nat.
Definition entityID := nat.
Definition listPair : Set :=
   list  (entity * entityID).

(* Nat equality *)
Fixpoint Entity_eq (X:_) (a b:_) : bool :=
   match a with
  | O => match b with
         | O => true
         | S m' => false
         end
  | S n' => match b with
            | O => false
            | S m' => ( Entity_eq nat (n')( m'))
            end
    end.

(* checking if an  entity is in an listPair *)
Fixpoint  entity_IN_listPair
  (entit: entity ) (lispair: listPair) : bool :=
match lispair with 
  |first::body =>               match first with
                                        |(p_one,ptwo)=> (Entity_eq (nat)(entit)(p_one )) 
                                             ||  entity_IN_listPair entit body

                                       end
 |nil => false
 end.

(* checking the equality of two listPair *)
Fixpoint  listPairSUB
           (first second: listPair) : bool :=
   match first with 
  |head::tail => match head with
                                 |(part1,part2)=> if (entity_IN_listPair part1 second)
                                                 then  listPairSUB tail second
                                                 else false
                                 end
   |nil => true
       end. 

Definition listPairEqual (firstL secondL:listPair) :=
   (listPairSUB firstL secondL) && (listPairSUB secondL firstL).

 Lemma  addtolistPairSUB: 
 forall (a b: listPair ) (c:entity * entityID),
        listPairSUB a b = true->listPairSUB (a) (c::b) = true .
Proof.
induction a.
给你。(我冒昧地对代码进行了一点重构。)


这个说法是错误的:只需考虑l1=[(0,0)]、p=(0,0)和l2=[]即可。您最初的评论要求表明,如果l1不是l2的子集,那么它就不是p::l2的子集。我的例子满足前提,但不满足结论,因此该陈述是错误的。在不知道自己想要什么的情况下,很难知道如何修复它;你的建议也行不通,我明白你的意思。这个定理的基础是简单的数学子集关系。如果一个子集B为真,向B中添加任何成员都不会影响关系A的子集B。好吧,这正是答案中证明的定理所说的,不是吗?是的,但你指出了一个错误的例子(假=真,前提是不做任何事情使这个特定示例为假),我的意思是,也许它的Coq编码不正确。我很困惑。我应该如何更改它或它是正确的(
Require Import List.
Require Import Bool.

Definition entity := nat.
Definition entityID := nat.
Definition listPair : Set :=
  list (entity * entityID).

Fixpoint in_listpair e (l : listPair) :=
  match l with
  | nil          => false
  | (x, y) :: l' => Nat.eqb e x || in_listpair e l'
  end.

Fixpoint subset_listpair (l1 l2 : listPair) :=
  match l1 with
  | nil => true
  | (x1, _) :: l1 => in_listpair x1 l2 && subset_listpair l1 l2
  end.

Lemma subset_listpair_cons l1 l2 p :
  subset_listpair l1 l2 = true ->
  subset_listpair l1 (p :: l2) = true.
Proof.
induction l1 as [|[x1 y1] l1 IH]; simpl; trivial.
destruct p as [x2 y2]; simpl.
destruct (in_listpair x1 l2); simpl; try easy.
intros H; rewrite IH; trivial.
now rewrite orb_true_r.
Qed.