Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************)
(* * The Coq Proof Assistant / The Coq Development Team *)
(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
(* <O___,, * (see CREDITS file for the list of authors) *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(* * (see LICENSE file for the text of the license) *)
(************************************************************************)
A library for finite sets, implemented as lists
This is a light implementation of finite sets as lists; for a more
extensive library, you might rather consider MSetWeakList.v. In
addition, if your domain is totally ordered, you might also
consider implementations of finite sets with access in logarithmic
time (e.g. MSetRBT.v which is based on red-black trees).
Require Import List. Set Implicit Arguments. Section first_definitions. Variable A : Type. Hypothesis Aeq_dec : forall x y:A, {x = y} + {x <> y}. Definition set := list A. Definition empty_set : set := nil. Fixpoint set_add (a:A) (x:set) : set := match x with | nil => a :: nil | a1 :: x1 => match Aeq_dec a a1 with | left _ => a1 :: x1 | right _ => a1 :: set_add a x1 end end. Fixpoint set_mem (a:A) (x:set) : bool := match x with | nil => false | a1 :: x1 => match Aeq_dec a a1 with | left _ => true | right _ => set_mem a x1 end end.
If a belongs to x, removes a from x. If not, does nothing.
Invariant: any element should occur at most once in x, see for
instance set_add. We hence remove here only the first occurrence
of a in x.
Fixpoint set_remove (a:A) (x:set) : set := match x with | nil => empty_set | a1 :: x1 => match Aeq_dec a a1 with | left _ => x1 | right _ => a1 :: set_remove a x1 end end. Fixpoint set_inter (x:set) : set -> set := match x with | nil => fun y => nil | a1 :: x1 => fun y => if set_mem a1 y then a1 :: set_inter x1 y else set_inter x1 y end. Fixpoint set_union (x y:set) : set := match y with | nil => x | a1 :: y1 => set_add a1 (set_union x y1) end.
returns the set of all els of x that does not belong to y
Fixpoint set_diff (x y:set) : set := match x with | nil => nil | a1 :: x1 => if set_mem a1 y then set_diff x1 y else set_add a1 (set_diff x1 y) end. Definition set_In : A -> set -> Prop := In (A:=A).A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), {set_In a x} + {~ set_In a x}A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), {set_In a x} + {~ set_In a x}(*** Realizer set_mem. Program_all. ***)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), {In a x} + {~ In a x}A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:set{In a nil} + {~ In a nil}A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), {In a l} + {~ In a l} -> {In a (a0 :: l)} + {~ In a (a0 :: l)}A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), {In a l} + {~ In a l} -> {In a (a0 :: l)} + {~ In a (a0 :: l)}A:TypeAeq_dec:forall x1 y : A, {x1 = y} + {x1 <> y}a:Ax:seta0:Ax0:list AHa0:{In a x0} + {~ In a x0}{In a (a0 :: x0)} + {~ In a (a0 :: x0)}A:TypeAeq_dec:forall x1 y : A, {x1 = y} + {x1 <> y}a:Ax:seta0:Ax0:list AHa0:{In a x0} + {~ In a x0}eq:a = a0{In a (a0 :: x0)} + {~ In a (a0 :: x0)}A:TypeAeq_dec:forall x1 y : A, {x1 = y} + {x1 <> y}a:Ax:seta0:Ax0:list AHa0:{In a x0} + {~ In a x0}eq:a <> a0{In a (a0 :: x0)} + {~ In a (a0 :: x0)}A:TypeAeq_dec:forall x1 y : A, {x1 = y} + {x1 <> y}a:Ax:seta0:Ax0:list AHa0:{In a x0} + {~ In a x0}eq:a <> a0{In a (a0 :: x0)} + {~ In a (a0 :: x0)}A:TypeAeq_dec:forall x1 y : A, {x1 = y} + {x1 <> y}a:Ax:seta0:Ax0:list AHa0:{In a x0} + {~ In a x0}eq:a <> a0In a x0 -> {In a (a0 :: x0)} + {~ In a (a0 :: x0)}A:TypeAeq_dec:forall x1 y : A, {x1 = y} + {x1 <> y}a:Ax:seta0:Ax0:list AHa0:{In a x0} + {~ In a x0}eq:a <> a0~ In a x0 -> {In a (a0 :: x0)} + {~ In a (a0 :: x0)}right; simpl; unfold not; intros [Hc1| Hc2]; auto with datatypes. Qed.A:TypeAeq_dec:forall x1 y : A, {x1 = y} + {x1 <> y}a:Ax:seta0:Ax0:list AHa0:{In a x0} + {~ In a x0}eq:a <> a0~ In a x0 -> {In a (a0 :: x0)} + {~ In a (a0 :: x0)}A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (B : Type) (P : B -> Prop) (y z : B) (a : A) (x : set), (set_In a x -> P y) -> P z -> P (if set_mem a x then y else z)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (B : Type) (P : B -> Prop) (y z : B) (a : A) (x : set), (set_In a x -> P y) -> P z -> P (if set_mem a x then y else z)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}B:TypeP:B -> Propy, z:Ba:Ax:setH:False -> P yH0:P zP zA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}B:TypeP:B -> Propy, z:Ba:Ax:seta0:Al:list AH:(set_In a l -> P y) -> P z -> P (if set_mem a l then y else z)H0:a0 = a \/ set_In a l -> P yH1:P zP (if if Aeq_dec a a0 then true else set_mem a l then y else z)elim (Aeq_dec a a0); auto with datatypes. Qed.A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}B:TypeP:B -> Propy, z:Ba:Ax:seta0:Al:list AH:(set_In a l -> P y) -> P z -> P (if set_mem a l then y else z)H0:a0 = a \/ set_In a l -> P yH1:P zP (if if Aeq_dec a a0 then true else set_mem a l then y else z)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (B : Type) (P : B -> Prop) (y z : B) (a : A) (x : set), (set_In a x -> P y) -> (~ set_In a x -> P z) -> P (if set_mem a x then y else z)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (B : Type) (P : B -> Prop) (y z : B) (a : A) (x : set), (set_In a x -> P y) -> (~ set_In a x -> P z) -> P (if set_mem a x then y else z)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}B:TypeP:B -> Propy, z:Ba:Ax:setH:False -> P yH0:~ False -> P zP zA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}B:TypeP:B -> Propy, z:Ba:Ax:seta0:Al:list AH:(set_In a l -> P y) -> (~ set_In a l -> P z) -> P (if set_mem a l then y else z)H0:a0 = a \/ set_In a l -> P yH1:~ (a0 = a \/ set_In a l) -> P zP (if if Aeq_dec a a0 then true else set_mem a l then y else z)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}B:TypeP:B -> Propy, z:Ba:Ax:seta0:Al:list AH:(set_In a l -> P y) -> (~ set_In a l -> P z) -> P (if set_mem a l then y else z)H0:a0 = a \/ set_In a l -> P yH1:~ (a0 = a \/ set_In a l) -> P zP (if if Aeq_dec a a0 then true else set_mem a l then y else z)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}B:TypeP:B -> Propy, z:Ba:Ax:seta0:Al:list AH:(set_In a l -> P y) -> (~ set_In a l -> P z) -> P (if set_mem a l then y else z)H0:a0 = a \/ set_In a l -> P yH1:~ (a0 = a \/ set_In a l) -> P za <> a0 -> P (if set_mem a l then y else z)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}B:TypeP:B -> Propy, z:Ba:Ax:seta0:Al:list AH:(set_In a l -> P y) -> (~ set_In a l -> P z) -> P (if set_mem a l then y else z)H0:a0 = a \/ set_In a l -> P yH1:~ (a0 = a \/ set_In a l) -> P zHneg:a <> a0H2:~ set_In a lP zcase H3; auto. Qed.A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}B:TypeP:B -> Propy, z:Ba:Ax:seta0:Al:list AH:(set_In a l -> P y) -> (~ set_In a l -> P z) -> P (if set_mem a l then y else z)H0:a0 = a \/ set_In a l -> P yH1:~ (a0 = a \/ set_In a l) -> P zHneg:a <> a0H2:~ set_In a lH3:a0 = a \/ set_In a lFalseA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), set_mem a x = true -> set_In a xA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), set_mem a x = true -> set_In a xA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setfalse = true -> FalseA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (set_mem a l = true -> set_In a l) -> (if Aeq_dec a a0 then true else set_mem a l) = true -> a0 = a \/ set_In a lintros a0 l; elim (Aeq_dec a a0); auto with datatypes. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (set_mem a l = true -> set_In a l) -> (if Aeq_dec a a0 then true else set_mem a l) = true -> a0 = a \/ set_In a lA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), set_In a x -> set_mem a x = trueA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), set_In a x -> set_mem a x = trueA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setFalse -> false = trueA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (set_In a l -> set_mem a l = true) -> a0 = a \/ set_In a l -> (if Aeq_dec a a0 then true else set_mem a l) = trueA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (set_In a l -> set_mem a l = true) -> a0 = a \/ set_In a l -> (if Aeq_dec a a0 then true else set_mem a l) = trueA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:seta0:Al:list Aa <> a0 -> (set_In a l -> set_mem a l = true) -> a0 = a \/ set_In a l -> set_mem a l = trueA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:seta0:Al:list AH1:a <> a0H2:set_In a l -> set_mem a l = trueH3:a0 = aset_mem a l = trueA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:seta0:Al:list AH1:a <> a0H2:set_In a l -> set_mem a l = trueH4:set_In a lset_mem a l = trueauto with datatypes. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:seta0:Al:list AH1:a <> a0H2:set_In a l -> set_mem a l = trueH4:set_In a lset_mem a l = trueA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), set_mem a x = false -> ~ set_In a xA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), set_mem a x = false -> ~ set_In a xA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setfalse = false -> ~ FalseA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (set_mem a l = false -> ~ set_In a l) -> (if Aeq_dec a a0 then true else set_mem a l) = false -> ~ (a0 = a \/ set_In a l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (set_mem a l = false -> ~ set_In a l) -> (if Aeq_dec a a0 then true else set_mem a l) = false -> ~ (a0 = a \/ set_In a l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:seta0:Al:list Aa = a0 -> (set_mem a l = false -> ~ set_In a l) -> true = false -> ~ (a0 = a \/ set_In a l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:seta0:Al:list Aa <> a0 -> (set_mem a l = false -> ~ set_In a l) -> set_mem a l = false -> ~ (a0 = a \/ set_In a l)unfold not; intros H H0 H1 [|]; auto with datatypes. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:seta0:Al:list Aa <> a0 -> (set_mem a l = false -> ~ set_In a l) -> set_mem a l = false -> ~ (a0 = a \/ set_In a l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), ~ set_In a x -> set_mem a x = falseA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), ~ set_In a x -> set_mem a x = falseA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:set~ False -> false = falseA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (~ set_In a l -> set_mem a l = false) -> ~ (a0 = a \/ set_In a l) -> (if Aeq_dec a a0 then true else set_mem a l) = falseA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (~ set_In a l -> set_mem a l = false) -> ~ (a0 = a \/ set_In a l) -> (if Aeq_dec a a0 then true else set_mem a l) = falseA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:seta0:Al:list Aa = a0 -> (~ set_In a l -> set_mem a l = false) -> ~ (a0 = a \/ set_In a l) -> true = falseA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:seta0:Al:list Aa <> a0 -> (~ set_In a l -> set_mem a l = false) -> ~ (a0 = a \/ set_In a l) -> set_mem a l = falsetauto. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:seta0:Al:list Aa <> a0 -> (~ set_In a l -> set_mem a l = false) -> ~ (a0 = a \/ set_In a l) -> set_mem a l = falseA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a b : A) (x : set), set_In a x -> set_In a (set_add b x)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a b : A) (x : set), set_In a x -> set_In a (set_add b x)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:setFalse -> b = a \/ FalseA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:setforall (a0 : A) (l : list A), (In a l -> In a (set_add b l)) -> a0 = a \/ In a l -> In a (if Aeq_dec b a0 then a0 :: l else a0 :: set_add b l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:setforall (a0 : A) (l : list A), (In a l -> In a (set_add b l)) -> a0 = a \/ In a l -> In a (if Aeq_dec b a0 then a0 :: l else a0 :: set_add b l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a l -> In a (set_add b l)Ha0a:a0 = aIn a (if Aeq_dec b a0 then a0 :: l else a0 :: set_add b l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a l -> In a (set_add b l)Hal:In a lIn a (if Aeq_dec b a0 then a0 :: l else a0 :: set_add b l)elim (Aeq_dec b a0); right; [ assumption | auto with datatypes ]. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a l -> In a (set_add b l)Hal:In a lIn a (if Aeq_dec b a0 then a0 :: l else a0 :: set_add b l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a b : A) (x : set), a = b -> set_In a (set_add b x)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a b : A) (x : set), a = b -> set_In a (set_add b x)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta = b -> b = a \/ FalseA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:setforall (a0 : A) (l : list A), (a = b -> In a (set_add b l)) -> a = b -> In a (if Aeq_dec b a0 then a0 :: l else a0 :: set_add b l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:setforall (a0 : A) (l : list A), (a = b -> In a (set_add b l)) -> a = b -> In a (if Aeq_dec b a0 then a0 :: l else a0 :: set_add b l)elim (Aeq_dec b a0); [ rewrite Hab; intro Hba0; rewrite Hba0; simpl; auto with datatypes | auto with datatypes ]. Qed. Hint Resolve set_add_intro1 set_add_intro2 : core.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:a = b -> In a (set_add b l)Hab:a = bIn a (if Aeq_dec b a0 then a0 :: l else a0 :: set_add b l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a b : A) (x : set), a = b \/ set_In a x -> set_In a (set_add b x)intros a b x [H1| H2]; auto with datatypes. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a b : A) (x : set), a = b \/ set_In a x -> set_In a (set_add b x)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a b : A) (x : set), set_In a (set_add b x) -> a = b \/ set_In a xA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a b : A) (x : set), set_In a (set_add b x) -> a = b \/ set_In a xA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a b : A) (x : set), In a (set_add b x) -> a = b \/ In a xA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:setIn a (set_add b nil) -> a = b \/ In a nilA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:setforall (a0 : A) (l : list A), (In a (set_add b l) -> a = b \/ In a l) -> In a (set_add b (a0 :: l)) -> a = b \/ In a (a0 :: l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:setforall (a0 : A) (l : list A), (In a (set_add b l) -> a = b \/ In a l) -> In a (set_add b (a0 :: l)) -> a = b \/ In a (a0 :: l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a (set_add b l) -> a = b \/ In a lIn a (if Aeq_dec b a0 then a0 :: l else a0 :: set_add b l) -> a = b \/ a0 = a \/ In a lA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a (set_add b l) -> a = b \/ In a lb = a0 -> In a (a0 :: l) -> a = b \/ a0 = a \/ In a lA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a (set_add b l) -> a = b \/ In a lb <> a0 -> In a (a0 :: set_add b l) -> a = b \/ a0 = a \/ In a lA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a (set_add b l) -> a = b \/ In a lb <> a0 -> In a (a0 :: set_add b l) -> a = b \/ a0 = a \/ In a lA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a (set_add b l) -> a = b \/ In a lH0:b <> a0H1:a0 = aa = b \/ a0 = a \/ In a lA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a (set_add b l) -> a = b \/ In a lH0:b <> a0H1:In a (set_add b l)a = b \/ a0 = a \/ In a lA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a (set_add b l) -> a = b \/ In a lH0:b <> a0H1:a0 = aa = b \/ a0 = a \/ In a lA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a (set_add b l) -> a = b \/ In a lH0:b <> a0H1:In a (set_add b l)a = b \/ a0 = a \/ In a ltauto. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:seta0:Al:list AH:In a (set_add b l) -> a = b \/ In a lH0:b <> a0H1:In a (set_add b l)a = b \/ a0 = a \/ In a lA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a b : A) (x : set), set_In a (set_add b x) -> a <> b -> set_In a xcase H1; trivial. Qed. Hint Resolve set_add_intro set_add_elim set_add_elim2 : core.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b:Ax:setH:set_In a (set_add b x)H0:a = bH1:a <> bset_In a xA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), set_add a x <> empty_setA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), set_add a x <> empty_setA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:seta :: nil <> empty_setA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), set_add a l <> empty_set -> (if Aeq_dec a a0 then a0 :: l else a0 :: set_add a l) <> empty_setintros; elim (Aeq_dec a a0); intros; discriminate. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), set_add a l <> empty_set -> (if Aeq_dec a a0 then a0 :: l else a0 :: set_add a l) <> empty_setA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setIn a (set_add b l) <-> a = b \/ In a lA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setIn a (set_add b l) <-> a = b \/ In a lA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setIn a (set_add b l) -> a = b \/ In a lA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:seta = b \/ In a l -> In a (set_add b l)apply set_add_intro. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:seta = b \/ In a l -> In a (set_add b l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al:list ANoDup l -> NoDup (set_add a l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al:list ANoDup l -> NoDup (set_add a l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:ANoDup (a :: nil)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, x:Al:list AH:~ In x lH':NoDup lIH:NoDup (set_add a l)NoDup (if Aeq_dec a x then x :: l else x :: set_add a l)constructor; [ tauto | constructor ].A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:ANoDup (a :: nil)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, x:Al:list AH:~ In x lH':NoDup lIH:NoDup (set_add a l)NoDup (if Aeq_dec a x then x :: l else x :: set_add a l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, x:Al:list AH:~ In x lH':NoDup lIH:NoDup (set_add a l)Hax:a <> x~ In x (set_add a l)intuition. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, x:Al:list AH:~ In x lH':NoDup lIH:NoDup (set_add a l)Hax:a <> x~ (x = a \/ In x l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setIn a (set_remove b l) -> In a lA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setIn a (set_remove b l) -> In a lA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:AIn a (set_remove b nil) -> In a nilA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsIn a (set_remove b (x :: xs)) -> In a (x :: xs)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:AIn a (set_remove b nil) -> In a nilauto.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:AH:In a (set_remove b nil)In a nilA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsIn a (set_remove b (x :: xs)) -> In a (x :: xs)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsIn a (if Aeq_dec b x then xs else x :: set_remove b xs) -> x = a \/ In a xsA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xse:b = xIn a xs -> x = a \/ In a xsA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsn:b <> xIn a (x :: set_remove b xs) -> x = a \/ In a xstauto.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xse:b = xIn a xs -> x = a \/ In a xsA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsn:b <> xIn a (x :: set_remove b xs) -> x = a \/ In a xsA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsn:b <> xH:In a (x :: set_remove b xs)x = a \/ In a xsA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsn:b <> xH:x = ax = a \/ In a xsA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsn:b <> xH:In a (set_remove b xs)x = a \/ In a xsA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsn:b <> xH:x = ax = a \/ In a xsapply in_eq.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsn:b <> xH:x = aa = a \/ In a xsA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsn:b <> xH:In a (set_remove b xs)x = a \/ In a xsA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsn:b <> xH:In a (set_remove b xs)In a xsassumption. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a (set_remove b xs) -> In a xsn:b <> xH:In a (set_remove b xs)In a (set_remove b xs)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setNoDup l -> In a (set_remove b l) -> a <> bA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setNoDup l -> In a (set_remove b l) -> a <> bA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:AND:NoDup nilFalse -> a <> bA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Al:list AIH:NoDup l -> In a (set_remove b l) -> a <> bND:NoDup (x :: l)In a (if Aeq_dec b x then l else x :: set_remove b l) -> a <> btauto.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:AND:NoDup nilFalse -> a <> bA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Al:list AIH:NoDup l -> In a (set_remove b l) -> a <> bND:NoDup (x :: l)In a (if Aeq_dec b x then l else x :: set_remove b l) -> a <> bA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Al:list AIH:NoDup l -> In a (set_remove b l) -> a <> bH:~ In x lH0:NoDup lIn a (if Aeq_dec b x then l else x :: set_remove b l) -> a <> bA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:list AIH:NoDup l -> In a (set_remove b l) -> a <> bH:~ In b lH0:NoDup lIn a l -> a <> bA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Al:list AIH:NoDup l -> In a (set_remove b l) -> a <> bH:~ In x lH0:NoDup lHbx:b <> xIn a (x :: set_remove b l) -> a <> bcongruence.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:list AIH:NoDup l -> In a (set_remove b l) -> a <> bH:~ In b lH0:NoDup lIn a l -> a <> bdestruct 1; subst; auto. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Al:list AIH:NoDup l -> In a (set_remove b l) -> a <> bH:~ In x lH0:NoDup lHbx:b <> xIn a (x :: set_remove b l) -> a <> bA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setIn a l -> a <> b -> In a (set_remove b l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setIn a l -> a <> b -> In a (set_remove b l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:AIn a nil -> a <> b -> In a (set_remove b nil)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a xs -> a <> b -> In a (set_remove b xs)In a (x :: xs) -> a <> b -> In a (set_remove b (x :: xs))now simpl.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:AIn a nil -> a <> b -> In a (set_remove b nil)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a xs -> a <> b -> In a (set_remove b xs)In a (x :: xs) -> a <> b -> In a (set_remove b (x :: xs))A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, b, x:Axs:list AHrec:In a xs -> a <> b -> In a (set_remove b xs)x = a \/ In a xs -> a <> b -> In a (if Aeq_dec b x then xs else x :: set_remove b xs)congruence. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x = y -> False}a, b:Axs:list AHrec:In a xs -> (a = b -> False) -> In a (set_remove b xs)H0:a = b -> FalseH1:b = aIn a xsA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setNoDup l -> In a (set_remove b l) <-> In a l /\ a <> bA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setNoDup l -> In a (set_remove b l) <-> In a l /\ a <> bA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setH:NoDup lH0:In a (set_remove b l)In a lA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setH:NoDup lH0:In a (set_remove b l)a <> bA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setH:NoDup lIn a l /\ a <> b -> In a (set_remove b l)eapply set_remove_1; eauto.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setH:NoDup lH0:In a (set_remove b l)In a leapply set_remove_2; eauto.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setH:NoDup lH0:In a (set_remove b l)a <> bdestruct 1; apply set_remove_3; auto. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a, b:Al:setH:NoDup lIn a l /\ a <> b -> In a (set_remove b l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al:list ANoDup l -> NoDup (set_remove a l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al:list ANoDup l -> NoDup (set_remove a l)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:ANoDup empty_setA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, x:Al:list AH:~ In x lH':NoDup lIH:NoDup (set_remove a l)NoDup (if Aeq_dec a x then l else x :: set_remove a l)constructor.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:ANoDup empty_setA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, x:Al:list AH:~ In x lH':NoDup lIH:NoDup (set_remove a l)NoDup (if Aeq_dec a x then l else x :: set_remove a l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, x:Al:list AH:~ In x lH':NoDup lIH:NoDup (set_remove a l)Hax:a <> xNoDup (x :: set_remove a l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, x:Al:list AH:~ In x lH':NoDup lIH:NoDup (set_remove a l)Hax:a <> x~ In x (set_remove a l)intuition. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a, x:Al:list AH:~ In x lH':NoDup lIH:NoDup (set_remove a l)Hax:a <> x~ (In x l /\ x <> a)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a x -> set_In a (set_union x y)simple induction y; simpl; auto with datatypes. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a x -> set_In a (set_union x y)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a y -> set_In a (set_union x y)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a y -> set_In a (set_union x y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:setFalse -> set_In a xA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:setforall (a0 : A) (l : list A), (set_In a l -> set_In a (set_union x l)) -> a0 = a \/ set_In a l -> set_In a (set_add a0 (set_union x l))intros; elim H0; auto with datatypes. Qed. Hint Resolve set_union_intro2 set_union_intro1 : core.A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:setforall (a0 : A) (l : list A), (set_In a l -> set_In a (set_union x l)) -> a0 = a \/ set_In a l -> set_In a (set_add a0 (set_union x l))A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a x \/ set_In a y -> set_In a (set_union x y)intros; elim H; auto with datatypes. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a x \/ set_In a y -> set_In a (set_union x y)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a (set_union x y) -> set_In a x \/ set_In a yA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a (set_union x y) -> set_In a x \/ set_In a yA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:setset_In a x -> set_In a x \/ FalseA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:setforall (a0 : A) (l : list A), (set_In a (set_union x l) -> set_In a x \/ set_In a l) -> set_In a (set_add a0 (set_union x l)) -> set_In a x \/ a0 = a \/ set_In a lA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:setforall (a0 : A) (l : list A), (set_In a (set_union x l) -> set_In a x \/ set_In a l) -> set_In a (set_add a0 (set_union x l)) -> set_In a x \/ a0 = a \/ set_In a lA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:seta0:Al:list AH:set_In a (set_union x l) -> set_In a x \/ set_In a lH0:set_In a (set_add a0 (set_union x l))set_In a x \/ a0 = a \/ set_In a lA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:seta0:Al:list AH:set_In a (set_union x l) -> set_In a x \/ set_In a lH0:set_In a (set_add a0 (set_union x l))a = a0 \/ set_In a (set_union x l) -> set_In a x \/ a0 = a \/ set_In a lA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:seta0:Al:list AH:set_In a (set_union x l) -> set_In a x \/ set_In a lH0:set_In a (set_add a0 (set_union x l))H1:a = a0set_In a x \/ a0 = a \/ set_In a lA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:seta0:Al:list AH:set_In a (set_union x l) -> set_In a x \/ set_In a lH0:set_In a (set_add a0 (set_union x l))H1:set_In a (set_union x l)set_In a x \/ a0 = a \/ set_In a ltauto. Qed.A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:seta0:Al:list AH:set_In a (set_union x l) -> set_In a x \/ set_In a lH0:set_In a (set_add a0 (set_union x l))H1:set_In a (set_union x l)set_In a x \/ a0 = a \/ set_In a lA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a (set_union l l') <-> In a l \/ In a l'A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a (set_union l l') <-> In a l \/ In a l'A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a (set_union l l') -> In a l \/ In a l'A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a l \/ In a l' -> In a (set_union l l')apply set_union_intro. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a l \/ In a l' -> In a (set_union l l')A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}l, l':list ANoDup l -> NoDup l' -> NoDup (set_union l l')A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}l, l':list ANoDup l -> NoDup l' -> NoDup (set_union l l')now apply set_add_nodup. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}l:list AH:NoDup lx':Al':list AH0:~ In x' l'H1:NoDup l'IH:NoDup (set_union l l')NoDup (set_add x' (set_union l l'))intros a x H; case (set_union_elim _ _ _ H); auto || contradiction. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), set_In a (set_union empty_set x) -> set_In a xintros a x H; case (set_union_elim _ _ _ H); auto || contradiction. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), set_In a (set_union x empty_set) -> set_In a xA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a x -> set_In a y -> set_In a (set_inter x y)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a x -> set_In a y -> set_In a (set_inter x y)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall y : set, set_In a nil -> set_In a y -> set_In a (set_inter nil y)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (forall y : set, set_In a l -> set_In a y -> set_In a (set_inter l y)) -> forall y : set, set_In a (a0 :: l) -> set_In a y -> set_In a (set_inter (a0 :: l) y)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (forall y : set, set_In a l -> set_In a y -> set_In a (set_inter l y)) -> forall y : set, set_In a (a0 :: l) -> set_In a y -> set_In a (set_inter (a0 :: l) y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHa0a:a0 = aHy:set_In a yset_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHal:set_In a lHy:set_In a yset_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHa0a:a0 = aHy:set_In a yset_In a (if set_mem a y then a :: set_inter l y else set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHal:set_In a lHy:set_In a yset_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHa0a:a0 = aHy:set_In a y(set_mem a y = true -> set_In a y) -> set_In a (if set_mem a y then a :: set_inter l y else set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHal:set_In a lHy:set_In a yset_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHa0a:a0 = aHy:set_In a y(set_mem a y = false -> ~ set_In a y) -> (set_mem a y = true -> set_In a y) -> set_In a (if set_mem a y then a :: set_inter l y else set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHal:set_In a lHy:set_In a yset_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHa0a:a0 = aHy:set_In a yH:true = false -> ~ set_In a yH0:true = true -> set_In a ya = a \/ set_In a (set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHa0a:a0 = aHy:set_In a yH:false = false -> ~ set_In a yH0:false = true -> set_In a yset_In a (set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHal:set_In a lHy:set_In a yset_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHa0a:a0 = aHy:set_In a yH:false = false -> ~ set_In a yH0:false = true -> set_In a yset_In a (set_inter l y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHal:set_In a lHy:set_In a yset_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y)elim (set_mem a0 y); [ right; auto with datatypes | auto with datatypes ]. Qed.A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> set_In a y0 -> set_In a (set_inter l y0)y:setHal:set_In a lHy:set_In a yset_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a (set_inter x y) -> set_In a xA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a (set_inter x y) -> set_In a xA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall y : set, set_In a (set_inter nil y) -> set_In a nilA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (forall y : set, set_In a (set_inter l y) -> set_In a l) -> forall y : set, set_In a (set_inter (a0 :: l) y) -> set_In a (a0 :: l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (forall y : set, set_In a (set_inter l y) -> set_In a l) -> forall y : set, set_In a (set_inter (a0 :: l) y) -> set_In a (a0 :: l)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_inter l y0) -> set_In a ly:setset_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y) -> a0 = a \/ set_In a lA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_inter l y0) -> set_In a ly:set(set_mem a0 y = true -> set_In a0 y) -> set_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y) -> a0 = a \/ set_In a lA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_inter l y0) -> set_In a ly:setH:true = true -> set_In a0 yH0:a0 = a \/ set_In a (set_inter l y)a0 = a \/ set_In a lA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_inter l y0) -> set_In a ly:setH:false = true -> set_In a0 yH0:set_In a (set_inter l y)a0 = a \/ set_In a leauto with datatypes. Qed.A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_inter l y0) -> set_In a ly:setH:false = true -> set_In a0 yH0:set_In a (set_inter l y)a0 = a \/ set_In a lA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a (set_inter x y) -> set_In a yA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a (set_inter x y) -> set_In a yA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall y : set, set_In a (set_inter nil y) -> set_In a yA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (forall y : set, set_In a (set_inter l y) -> set_In a y) -> forall y : set, set_In a (set_inter (a0 :: l) y) -> set_In a yA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (forall y : set, set_In a (set_inter l y) -> set_In a y) -> forall y : set, set_In a (set_inter (a0 :: l) y) -> set_In a yA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_inter l y0) -> set_In a y0y:setset_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y) -> set_In a yA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_inter l y0) -> set_In a y0y:set(set_mem a0 y = true -> set_In a0 y) -> set_In a (if set_mem a0 y then a0 :: set_inter l y else set_inter l y) -> set_In a yA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_inter l y0) -> set_In a y0y:setH:true = true -> set_In a0 yH0:a0 = a \/ set_In a (set_inter l y)set_In a yA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_inter l y0) -> set_In a y0y:setH:false = true -> set_In a0 yH0:set_In a (set_inter l y)set_In a yeauto with datatypes. Qed. Hint Resolve set_inter_elim1 set_inter_elim2 : core.A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_inter l y0) -> set_In a y0y:setH:false = true -> set_In a0 yH0:set_In a (set_inter l y)set_In a yA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a (set_inter x y) -> set_In a x /\ set_In a yeauto with datatypes. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a (set_inter x y) -> set_In a x /\ set_In a yA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a (set_inter l l') <-> In a l /\ In a l'A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a (set_inter l l') <-> In a l /\ In a l'A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a (set_inter l l') -> In a l /\ In a l'A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a l /\ In a l' -> In a (set_inter l l')apply set_inter_elim.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a (set_inter l l') -> In a l /\ In a l'A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a l /\ In a l' -> In a (set_inter l l')now apply set_inter_intro. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setH:In a lH0:In a l'In a (set_inter l l')A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}l, l':list ANoDup l -> NoDup l' -> NoDup (set_inter l l')A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}l, l':list ANoDup l -> NoDup l' -> NoDup (set_inter l l')A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}l':list AHl':NoDup l'NoDup nilA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}l':list Ax:Al:list AH:~ In x lH':NoDup lIH:NoDup l' -> NoDup (set_inter l l')Hl':NoDup l'NoDup (if set_mem x l' then x :: set_inter l l' else set_inter l l')constructor.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}l':list AHl':NoDup l'NoDup nilA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}l':list Ax:Al:list AH:~ In x lH':NoDup lIH:NoDup l' -> NoDup (set_inter l l')Hl':NoDup l'NoDup (if set_mem x l' then x :: set_inter l l' else set_inter l l')A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}l':list Ax:Al:list AH:~ In x lH':NoDup lIH:NoDup l' -> NoDup (set_inter l l')Hl':NoDup l'NoDup (x :: set_inter l l')rewrite set_inter_iff; tauto. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}l':list Ax:Al:list AH:~ In x lH':NoDup lIH:NoDup l' -> NoDup (set_inter l l')Hl':NoDup l'~ In x (set_inter l l')A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a x -> ~ set_In a y -> set_In a (set_diff x y)A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a x -> ~ set_In a y -> set_In a (set_diff x y)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall y : set, set_In a nil -> ~ set_In a y -> set_In a (set_diff nil y)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (forall y : set, set_In a l -> ~ set_In a y -> set_In a (set_diff l y)) -> forall y : set, set_In a (a0 :: l) -> ~ set_In a y -> set_In a (set_diff (a0 :: l) y)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (forall y : set, set_In a l -> ~ set_In a y -> set_In a (set_diff l y)) -> forall y : set, set_In a (a0 :: l) -> ~ set_In a y -> set_In a (set_diff (a0 :: l) y)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> ~ set_In a y0 -> set_In a (set_diff l y0)y:setHa0a:a0 = aHay:~ set_In a yset_In a (if set_mem a0 y then set_diff l y else set_add a0 (set_diff l y))A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> ~ set_In a y0 -> set_In a (set_diff l y0)y:setHal:set_In a lHay:~ set_In a yset_In a (if set_mem a0 y then set_diff l y else set_add a0 (set_diff l y))A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> ~ set_In a y0 -> set_In a (set_diff l y0)y:setHa0a:a0 = aHay:~ set_In a yset_mem a y = false -> set_In a (if set_mem a y then set_diff l y else set_add a (set_diff l y))A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> ~ set_In a y0 -> set_In a (set_diff l y0)y:setHal:set_In a lHay:~ set_In a yset_In a (if set_mem a0 y then set_diff l y else set_add a0 (set_diff l y))elim (set_mem a0 y); auto with datatypes. Qed.A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a l -> ~ set_In a y0 -> set_In a (set_diff l y0)y:setHal:set_In a lHay:~ set_In a yset_In a (if set_mem a0 y then set_diff l y else set_add a0 (set_diff l y))A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a (set_diff x y) -> set_In a xA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a (set_diff x y) -> set_In a xA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall y : set, set_In a (set_diff nil y) -> set_In a nilA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (forall y : set, set_In a (set_diff l y) -> set_In a l) -> forall y : set, set_In a (set_diff (a0 :: l) y) -> set_In a (a0 :: l)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setforall (a0 : A) (l : list A), (forall y : set, set_In a (set_diff l y) -> set_In a l) -> forall y : set, set_In a (set_diff (a0 :: l) y) -> set_In a (a0 :: l)A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_diff l y0) -> set_In a ly:setset_In a (set_diff l y) -> a0 = a \/ set_In a lA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_diff l y0) -> set_In a ly:setset_In a (set_add a0 (set_diff l y)) -> a0 = a \/ set_In a lA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_diff l y0) -> set_In a ly:setset_In a (set_add a0 (set_diff l y)) -> a0 = a \/ set_In a lintros [H1| H2]; eauto with datatypes. Qed.A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax:seta0:Al:list AHrec:forall y0 : set, set_In a (set_diff l y0) -> set_In a ly:setH:set_In a (set_add a0 (set_diff l y))a = a0 \/ set_In a (set_diff l y) -> a0 = a \/ set_In a lA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x y : set), set_In a (set_diff x y) -> ~ set_In a yA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:setFalse -> ~ set_In a yA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:setforall (a0 : A) (l : list A), (set_In a (set_diff l y) -> ~ set_In a y) -> set_In a (if set_mem a0 y then set_diff l y else set_add a0 (set_diff l y)) -> ~ set_In a yA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:setforall (a0 : A) (l : list A), (set_In a (set_diff l y) -> ~ set_In a y) -> set_In a (if set_mem a0 y then set_diff l y else set_add a0 (set_diff l y)) -> ~ set_In a yA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:seta0:Al:list AHrec:set_In a (set_diff l y) -> ~ set_In a yset_In a (if set_mem a0 y then set_diff l y else set_add a0 (set_diff l y)) -> ~ set_In a yA:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:seta0:Al:list AHrec:set_In a (set_diff l y) -> ~ set_In a y~ set_In a0 y -> set_In a (set_add a0 (set_diff l y)) -> ~ set_In a yrewrite H; trivial. Qed.A:TypeAeq_dec:forall x0 y0 : A, {x0 = y0} + {x0 <> y0}a:Ax, y:seta0:Al:list AHrec:set_In a (set_diff l y) -> ~ set_In a yH1:~ set_In a0 yH2:set_In a (set_add a0 (set_diff l y))H:a = a0~ set_In a yA:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a (set_diff l l') <-> In a l /\ ~ In a l'A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a (set_diff l l') <-> In a l /\ ~ In a l'A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a (set_diff l l') -> In a l /\ ~ In a l'A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a l /\ ~ In a l' -> In a (set_diff l l')split; [eapply set_diff_elim1 | eapply set_diff_elim2]; eauto.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a (set_diff l l') -> In a l /\ ~ In a l'A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setIn a l /\ ~ In a l' -> In a (set_diff l l')now apply set_diff_intro. Qed.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}a:Al, l':setH:In a lH0:~ In a l'In a (set_diff l l')A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}l, l':list ANoDup l -> NoDup l' -> NoDup (set_diff l l')A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}l, l':list ANoDup l -> NoDup l' -> NoDup (set_diff l l')A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}l':list AHl':NoDup l'NoDup nilA:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}l':list Ax:Al:list AH:~ In x lH':NoDup lIH:NoDup l' -> NoDup (set_diff l l')Hl':NoDup l'NoDup (if set_mem x l' then set_diff l l' else set_add x (set_diff l l'))constructor.A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}l':list AHl':NoDup l'NoDup nildestruct (set_mem x l'); auto using set_add_nodup. Qed.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}l':list Ax:Al:list AH:~ In x lH':NoDup lIH:NoDup l' -> NoDup (set_diff l l')Hl':NoDup l'NoDup (if set_mem x l' then set_diff l l' else set_add x (set_diff l l'))A:TypeAeq_dec:forall x y : A, {x = y} + {x <> y}forall (a : A) (x : set), ~ set_In a (set_diff x x)A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setH:set_In a (set_diff x x)Falseapply (set_diff_elim1 _ _ _ H). Qed. Hint Resolve set_diff_intro set_diff_trivial : core. End first_definitions. Section other_definitions. Definition set_prod : forall {A B:Type}, set A -> set B -> set (A * B) := list_prod.A:TypeAeq_dec:forall x0 y : A, {x0 = y} + {x0 <> y}a:Ax:setH:set_In a (set_diff x x)set_In a x
B^A, set of applications from A to B
Definition set_power : forall {A B:Type}, set A -> set B -> set (set (A * B)) := list_power. Definition set_fold_left {A B:Type} : (B -> A -> B) -> set A -> B -> B := fold_left (A:=B) (B:=A). Definition set_fold_right {A B:Type} (f:A -> B -> B) (x:set A) (b:B) : B := fold_right f b x. Definition set_map {A B:Type} (Aeq_dec : forall x y:B, {x = y} + {x <> y}) (f : A -> B) (x : set A) : set B := set_fold_right (fun a => set_add Aeq_dec (f a)) x (empty_set B). End other_definitions. Unset Implicit Arguments.