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) *)
(************************************************************************)
This file is deprecated, for a tree on list, use Mergesort.v.
A development of Treesort on Heap trees. It has an average
complexity of O(n.log n) but of O(n²) in the worst case (e.g. if
the list is already sorted)
(* G. Huet 1-9-95 uses Multiset *) Require Import List Multiset PermutSetoid Relations Sorting. Section defs.
Variable A : Type. Variable leA : relation A. Variable eqA : relation A. Let gtA (x y:A) := ~ leA x y. Hypothesis leA_dec : forall x y:A, {leA x y} + {leA y x}. Hypothesis eqA_dec : forall x y:A, {eqA x y} + {~ eqA x y}. Hypothesis leA_refl : forall x y:A, eqA x y -> leA x y. Hypothesis leA_trans : forall x y z:A, leA x y -> leA y z -> leA x z. Hypothesis leA_antisym : forall x y:A, leA x y -> leA y x -> eqA x y. Hint Resolve leA_refl : core. Hint Immediate eqA_dec leA_dec leA_antisym : core. Let emptyBag := EmptyBag A. Let singletonBag := SingletonBag _ eqA_dec. Inductive Tree := | Tree_Leaf : Tree | Tree_Node : A -> Tree -> Tree -> Tree.
a is lower than a Tree T if T is a Leaf
or T is a Node holding b>a
Definition leA_Tree (a:A) (t:Tree) := match t with | Tree_Leaf => True | Tree_Node b T1 T2 => leA a b end.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall a : A, leA_Tree a Tree_Leafsimpl; auto with datatypes. Qed.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall a : A, leA_Tree a Tree_LeafA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall (a b : A) (G D : Tree), leA a b -> leA_Tree a (Tree_Node b G D)simpl; auto with datatypes. Qed.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall (a b : A) (G D : Tree), leA a b -> leA_Tree a (Tree_Node b G D)
Inductive is_heap : Tree -> Prop := | nil_is_heap : is_heap Tree_Leaf | node_is_heap : forall (a:A) (T1 T2:Tree), leA_Tree a T1 -> leA_Tree a T2 -> is_heap T1 -> is_heap T2 -> is_heap (Tree_Node a T1 T2).A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall (a : A) (T1 T2 : Tree), is_heap (Tree_Node a T1 T2) -> leA_Tree a T1 /\ leA_Tree a T2 /\ is_heap T1 /\ is_heap T2intros; inversion H; auto with datatypes. Qed. (* This lemma ought to be generated automatically by the Inversion tools *)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall (a : A) (T1 T2 : Tree), is_heap (Tree_Node a T1 T2) -> leA_Tree a T1 /\ leA_Tree a T2 /\ is_heap T1 /\ is_heap T2A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall P : Tree -> Type, P Tree_Leaf -> (forall (a : A) (T1 T2 : Tree), leA_Tree a T1 -> leA_Tree a T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a T1 T2)) -> forall T : Tree, is_heap T -> P TA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall P : Tree -> Type, P Tree_Leaf -> (forall (a : A) (T1 T2 : Tree), leA_Tree a T1 -> leA_Tree a T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a T1 T2)) -> forall T : Tree, is_heap T -> P TA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AP:Tree -> TypeX:P Tree_LeafX0:forall (a : A) (T1 T2 : Tree), leA_Tree a T1 -> leA_Tree a T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a T1 T2)T:Treeforall (a : A) (t : Tree), (is_heap t -> P t) -> forall t0 : Tree, (is_heap t0 -> P t0) -> is_heap (Tree_Node a t t0) -> P (Tree_Node a t t0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AP:Tree -> TypeX:P Tree_LeafX0:forall (a0 : A) (T1 T2 : Tree), leA_Tree a0 T1 -> leA_Tree a0 T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a0 T1 T2)T:Treea:AG:TreePG:is_heap G -> P GD:TreePD:is_heap D -> P DPN:is_heap (Tree_Node a G D)P (Tree_Node a G D)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AP:Tree -> TypeX:P Tree_LeafX0:forall (a0 : A) (T1 T2 : Tree), leA_Tree a0 T1 -> leA_Tree a0 T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a0 T1 T2)T:Treea:AG:TreePG:is_heap G -> P GD:TreePD:is_heap D -> P DPN:is_heap (Tree_Node a G D)leA_Tree a G -> leA_Tree a D /\ is_heap G /\ is_heap D -> P (Tree_Node a G D)apply X0; auto with datatypes. Qed. (* This lemma ought to be generated automatically by the Inversion tools *)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AP:Tree -> TypeX:P Tree_LeafX0:forall (a0 : A) (T1 T2 : Tree), leA_Tree a0 T1 -> leA_Tree a0 T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a0 T1 T2)T:Treea:AG:TreePG:is_heap G -> P GD:TreePD:is_heap D -> P DPN:is_heap (Tree_Node a G D)H1:leA_Tree a GH2:leA_Tree a D /\ is_heap G /\ is_heap DH3:leA_Tree a DH4:is_heap G /\ is_heap DH:is_heap GH0:is_heap DP (Tree_Node a G D)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall P : Tree -> Set, P Tree_Leaf -> (forall (a : A) (T1 T2 : Tree), leA_Tree a T1 -> leA_Tree a T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a T1 T2)) -> forall T : Tree, is_heap T -> P TA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall P : Tree -> Set, P Tree_Leaf -> (forall (a : A) (T1 T2 : Tree), leA_Tree a T1 -> leA_Tree a T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a T1 T2)) -> forall T : Tree, is_heap T -> P TA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AP:Tree -> SetH:P Tree_LeafX:forall (a : A) (T1 T2 : Tree), leA_Tree a T1 -> leA_Tree a T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a T1 T2)T:Treeforall (a : A) (t : Tree), (is_heap t -> P t) -> forall t0 : Tree, (is_heap t0 -> P t0) -> is_heap (Tree_Node a t t0) -> P (Tree_Node a t t0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AP:Tree -> SetH:P Tree_LeafX:forall (a0 : A) (T1 T2 : Tree), leA_Tree a0 T1 -> leA_Tree a0 T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a0 T1 T2)T:Treea:AG:TreePG:is_heap G -> P GD:TreePD:is_heap D -> P DPN:is_heap (Tree_Node a G D)P (Tree_Node a G D)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AP:Tree -> SetH:P Tree_LeafX:forall (a0 : A) (T1 T2 : Tree), leA_Tree a0 T1 -> leA_Tree a0 T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a0 T1 T2)T:Treea:AG:TreePG:is_heap G -> P GD:TreePD:is_heap D -> P DPN:is_heap (Tree_Node a G D)leA_Tree a G -> leA_Tree a D /\ is_heap G /\ is_heap D -> P (Tree_Node a G D)apply X; auto with datatypes. Qed.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AP:Tree -> SetH:P Tree_LeafX:forall (a0 : A) (T1 T2 : Tree), leA_Tree a0 T1 -> leA_Tree a0 T2 -> is_heap T1 -> P T1 -> is_heap T2 -> P T2 -> P (Tree_Node a0 T1 T2)T:Treea:AG:TreePG:is_heap G -> P GD:TreePD:is_heap D -> P DPN:is_heap (Tree_Node a G D)H1:leA_Tree a GH2:leA_Tree a D /\ is_heap G /\ is_heap DH3:leA_Tree a DH4:is_heap G /\ is_heap DH0:is_heap GH5:is_heap DP (Tree_Node a G D)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall (T : Tree) (a b : A), leA a b -> leA_Tree b T -> leA_Tree a TA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall (T : Tree) (a b : A), leA a b -> leA_Tree b T -> leA_Tree a Tintros; simpl; apply leA_trans with b; auto with datatypes. Qed.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeforall (a : A) (t : Tree), (forall a0 b : A, leA a0 b -> leA_Tree b t -> leA_Tree a0 t) -> forall t0 : Tree, (forall a0 b : A, leA a0 b -> leA_Tree b t0 -> leA_Tree a0 t0) -> forall a0 b : A, leA a0 b -> leA_Tree b (Tree_Node a t t0) -> leA_Tree a0 (Tree_Node a t t0)
Inductive merge_lem (l1 l2:list A) : Type := merge_exist : forall l:list A, Sorted leA l -> meq (list_contents _ eqA_dec l) (munion (list_contents _ eqA_dec l1) (list_contents _ eqA_dec l2)) -> (forall a, HdRel leA a l1 -> HdRel leA a l2 -> HdRel leA a l) -> merge_lem l1 l2. Import Morphisms.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AEquivalence (meq (A:=A))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AEquivalence (meq (A:=A))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset ATransitive (meq (A:=A))apply meq_trans. Defined.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall x y z : multiset A, meq x y -> meq y z -> meq x zA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AProper (meq (A:=A) ==> meq (A:=A) ==> meq (A:=A)) (munion (A:=A))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AProper (meq (A:=A) ==> meq (A:=A) ==> meq (A:=A)) (munion (A:=A))now apply meq_congr. Qed.A:TypeleA, eqA:relation AgtA:=fun x0 y0 : A => ~ leA x0 y0:A -> A -> PropleA_dec:forall x0 y0 : A, {leA x0 y0} + {leA y0 x0}eqA_dec:forall x0 y0 : A, {eqA x0 y0} + {~ eqA x0 y0}leA_refl:forall x0 y0 : A, eqA x0 y0 -> leA x0 y0leA_trans:forall x0 y0 z : A, leA x0 y0 -> leA y0 z -> leA x0 zleA_antisym:forall x0 y0 : A, leA x0 y0 -> leA y0 x0 -> eqA x0 y0emptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Ax, y:multiset AH:meq x yx', y':multiset AH':meq x' y'meq (munion x x') (munion y y')A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l0 : list A, Sorted leA l0 -> merge_lem l1 l0H:Sorted leA nill2:list AH0:Sorted leA l2merge_lem nil l2A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l0 : list A, Sorted leA l0 -> forall l3 : list A, Sorted leA l3 -> merge_lem l0 l3a:Al1:list AH:Sorted leA (a :: l1)l2:list AH0:Sorted leA l2merge_lem (a :: l1) l2A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l0 : list A, Sorted leA l0 -> forall l3 : list A, Sorted leA l3 -> merge_lem l0 l3a:Al1:list AH:Sorted leA (a :: l1)l2:list AH0:Sorted leA l2merge_lem (a :: l1) l2A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l0 : list A, Sorted leA l0 -> merge_lem l1 l0a:Al:list AH:Sorted leA (a :: l)l2:list AH0:Sorted leA l2merge_lem (a :: l) l2A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l0 : list A, Sorted leA l0 -> merge_lem l1 l0a:Al:list AH:Sorted leA (a :: l)merge0:forall l0 : list A, Sorted leA l0 -> merge_lem (a :: l) l0l2:list AH0:Sorted leA l2merge_lem (a :: l) l2A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2H0:Sorted leA nilmerge_lem (a :: l) nilA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)merge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)merge_lem (a :: l) (a0 :: l0)(* 1 (leA a a0) *)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0merge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA l /\ HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0merge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0merge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1merge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1Sorted leA (a :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1meq (list_contents eqA eqA_dec (a :: l1)) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec (a0 :: l0)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA lH1:HdRel leA a la0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1Sorted leA (a :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1meq (list_contents eqA eqA_dec (a :: l1)) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec (a0 :: l0)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1meq (list_contents eqA eqA_dec (a :: l1)) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec (a0 :: l0)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1meq (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l1)) (munion (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l)) (munion (SingletonBag eqA eqA_dec a0) (list_contents eqA eqA_dec l0)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1meq (munion (SingletonBag eqA eqA_dec a) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))) (munion (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l)) (munion (SingletonBag eqA eqA_dec a0) (list_contents eqA eqA_dec l0)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a1 : A, HdRel leA a1 l -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a2 : A, HdRel leA a2 l -> HdRel leA a2 (a0 :: l0) -> HdRel leA a2 l1a1:AH5:HdRel leA a1 (a :: l)H6:HdRel leA a1 (a0 :: l0)HdRel leA a1 (a :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA lH1:HdRel leA a lmerge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a a0l1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec (a0 :: l0)))H4:forall a2 : A, HdRel leA a2 l -> HdRel leA a2 (a0 :: l0) -> HdRel leA a2 l1a1:AH5:HdRel leA a1 (a :: l)H6:HdRel leA a1 (a0 :: l0)leA a1 aA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)(* 2 (leA a0 a) *)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA (a0 :: l0)Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA l0 /\ HdRel leA a0 l0Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l1 : list A, Sorted leA l1 -> forall l2 : list A, Sorted leA l2 -> merge_lem l1 l2a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 amerge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Amerge:forall l2 : list A, Sorted leA l2 -> forall l3 : list A, Sorted leA l3 -> merge_lem l2 l3a:Al:list AH:Sorted leA (a :: l)merge0:forall l2 : list A, Sorted leA l2 -> merge_lem (a :: l) l2a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1merge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1merge_lem (a :: l) (a0 :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1meq (list_contents eqA eqA_dec (a0 :: l1)) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec (a0 :: l0)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a0 :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1meq (munion (SingletonBag eqA eqA_dec a0) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))) (munion (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l)) (munion (SingletonBag eqA eqA_dec a0) (list_contents eqA eqA_dec l0)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a0 :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1meq (munion (SingletonBag eqA eqA_dec a0) (munion (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l)) (list_contents eqA eqA_dec l0))) (munion (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l)) (munion (SingletonBag eqA eqA_dec a0) (list_contents eqA eqA_dec l0)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a0 :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1meq (munion (SingletonBag eqA eqA_dec a0) (munion (SingletonBag eqA eqA_dec a) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec l0)))) (munion (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l)) (munion (SingletonBag eqA eqA_dec a0) (list_contents eqA eqA_dec l0)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a0 :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1meq (munion (munion (SingletonBag eqA eqA_dec a) (munion (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec l0))) (SingletonBag eqA eqA_dec a0)) (munion (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l)) (munion (SingletonBag eqA eqA_dec a0) (list_contents eqA eqA_dec l0)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a0 :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1meq (munion (SingletonBag eqA eqA_dec a) (munion (list_contents eqA eqA_dec l) (munion (list_contents eqA eqA_dec l0) (SingletonBag eqA eqA_dec a0)))) (munion (SingletonBag eqA eqA_dec a) (munion (list_contents eqA eqA_dec l) (munion (SingletonBag eqA eqA_dec a0) (list_contents eqA eqA_dec l0))))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a0 :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1meq (munion (SingletonBag eqA eqA_dec a) (munion (list_contents eqA eqA_dec l) (munion (SingletonBag eqA eqA_dec a0) (list_contents eqA eqA_dec l0)))) (munion (SingletonBag eqA eqA_dec a) (munion (list_contents eqA eqA_dec l) (munion (SingletonBag eqA eqA_dec a0) (list_contents eqA eqA_dec l0))))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a0 :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 l0 -> HdRel leA a1 l1forall a1 : A, HdRel leA a1 (a :: l) -> HdRel leA a1 (a0 :: l0) -> HdRel leA a1 (a0 :: l1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a2 : A, HdRel leA a2 (a :: l) -> HdRel leA a2 l0 -> HdRel leA a2 l1a1:AH5:HdRel leA a1 (a :: l)H6:HdRel leA a1 (a0 :: l0)HdRel leA a1 (a0 :: l1)apply (@HdRel_inv _ leA) with l0; trivial with datatypes. Qed.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aa:Al:list AH:Sorted leA (a :: l)a0:Al0:list AH0:Sorted leA l0H1:HdRel leA a0 l0Hle:leA a0 al1:list AH2:Sorted leA l1H3:meq (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec (a :: l)) (list_contents eqA eqA_dec l0))H4:forall a2 : A, HdRel leA a2 (a :: l) -> HdRel leA a2 l0 -> HdRel leA a2 l1a1:AH5:HdRel leA a1 (a :: l)H6:HdRel leA a1 (a0 :: l0)leA a1 a0
contents of a tree as a multiset
Nota Bene : In what follows the definition of SingletonBag
in not used. Actually, we could just take as postulate:
Parameter SingletonBag : A→multiset.
Fixpoint contents (t:Tree) : multiset A := match t with | Tree_Leaf => emptyBag | Tree_Node a t1 t2 => munion (contents t1) (munion (contents t2) (singletonBag a)) end.
equivalence of two trees is equality of corresponding multisets
Definition equiv_Tree (t1 t2:Tree) := meq (contents t1) (contents t2).
Inductive insert_spec (a:A) (T:Tree) : Type := insert_exist : forall T1:Tree, is_heap T1 -> meq (contents T1) (munion (contents T) (singletonBag a)) -> (forall b:A, leA b a -> leA_Tree b T -> leA_Tree b T1) -> insert_spec a T.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall T : Tree, is_heap T -> forall a : A, insert_spec a TA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall T : Tree, is_heap T -> forall a : A, insert_spec a TA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:Ainsert_spec a Tree_LeafA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ainsert_spec a0 (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ainsert_spec a0 (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ainsert_spec a0 (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a2 : A, insert_spec a2 T1H3:is_heap T2X0:forall a2 : A, insert_spec a2 T2a0:Aa1:leA a a0insert_spec a0 (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 ainsert_spec a0 (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a2 : A, insert_spec a2 T1H3:is_heap T2X0:forall a2 : A, insert_spec a2 T2a0:Aa1:leA a a0T0:Treei:is_heap T0m:meq (contents T0) (munion (contents T1) (singletonBag a0))l:forall b : A, leA b a0 -> leA_Tree b T1 -> leA_Tree b T0insert_spec a0 (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 ainsert_spec a0 (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a2 : A, insert_spec a2 T1H3:is_heap T2X0:forall a2 : A, insert_spec a2 T2a0:Aa1:leA a a0T0:Treei:is_heap T0m:meq (contents T0) (munion (contents T1) (singletonBag a0))l:forall b : A, leA b a0 -> leA_Tree b T1 -> leA_Tree b T0meq (contents (Tree_Node a T2 T0)) (munion (contents (Tree_Node a T1 T2)) (singletonBag a0))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 ainsert_spec a0 (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 ainsert_spec a0 (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 aT3:TreeHeapT3:is_heap T3ConT3:meq (contents T3) (munion (contents T1) (singletonBag a))LeA:forall b0 : A, leA b0 a -> leA_Tree b0 T1 -> leA_Tree b0 T3insert_spec a0 (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 aT3:TreeHeapT3:is_heap T3ConT3:meq (contents T3) (munion (contents T1) (singletonBag a))LeA:forall b0 : A, leA b0 a -> leA_Tree b0 T1 -> leA_Tree b0 T3is_heap (Tree_Node a0 T2 T3)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 aT3:TreeHeapT3:is_heap T3ConT3:meq (contents T3) (munion (contents T1) (singletonBag a))LeA:forall b0 : A, leA b0 a -> leA_Tree b0 T1 -> leA_Tree b0 T3meq (contents (Tree_Node a0 T2 T3)) (munion (contents (Tree_Node a T1 T2)) (singletonBag a0))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 aT3:TreeHeapT3:is_heap T3ConT3:meq (contents T3) (munion (contents T1) (singletonBag a))LeA:forall b0 : A, leA b0 a -> leA_Tree b0 T1 -> leA_Tree b0 T3leA_Tree a0 T2A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 aT3:TreeHeapT3:is_heap T3ConT3:meq (contents T3) (munion (contents T1) (singletonBag a))LeA:forall b0 : A, leA b0 a -> leA_Tree b0 T1 -> leA_Tree b0 T3leA_Tree a0 T3A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 aT3:TreeHeapT3:is_heap T3ConT3:meq (contents T3) (munion (contents T1) (singletonBag a))LeA:forall b0 : A, leA b0 a -> leA_Tree b0 T1 -> leA_Tree b0 T3meq (contents (Tree_Node a0 T2 T3)) (munion (contents (Tree_Node a T1 T2)) (singletonBag a0))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 aT3:TreeHeapT3:is_heap T3ConT3:meq (contents T3) (munion (contents T1) (singletonBag a))LeA:forall b0 : A, leA b0 a -> leA_Tree b0 T1 -> leA_Tree b0 T3leA_Tree a0 T3A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 aT3:TreeHeapT3:is_heap T3ConT3:meq (contents T3) (munion (contents T1) (singletonBag a))LeA:forall b0 : A, leA b0 a -> leA_Tree b0 T1 -> leA_Tree b0 T3meq (contents (Tree_Node a0 T2 T3)) (munion (contents (Tree_Node a T1 T2)) (singletonBag a0))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 aT3:TreeHeapT3:is_heap T3ConT3:meq (contents T3) (munion (contents T1) (singletonBag a))LeA:forall b0 : A, leA b0 a -> leA_Tree b0 T1 -> leA_Tree b0 T3leA_Tree a0 T1A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 aT3:TreeHeapT3:is_heap T3ConT3:meq (contents T3) (munion (contents T1) (singletonBag a))LeA:forall b0 : A, leA b0 a -> leA_Tree b0 T1 -> leA_Tree b0 T3meq (contents (Tree_Node a0 T2 T3)) (munion (contents (Tree_Node a T1 T2)) (singletonBag a0))simpl; apply treesort_twist2; trivial with datatypes. Qed.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:TreeH:is_heap Ta:AT1, T2:TreeH0:leA_Tree a T1H1:leA_Tree a T2H2:is_heap T1X:forall a1 : A, insert_spec a1 T1H3:is_heap T2X0:forall a1 : A, insert_spec a1 T2a0:Ab:leA a0 aT3:TreeHeapT3:is_heap T3ConT3:meq (contents T3) (munion (contents T1) (singletonBag a))LeA:forall b0 : A, leA b0 a -> leA_Tree b0 T1 -> leA_Tree b0 T3meq (contents (Tree_Node a0 T2 T3)) (munion (contents (Tree_Node a T1 T2)) (singletonBag a0))
Inductive build_heap (l:list A) : Type := heap_exist : forall T:Tree, is_heap T -> meq (list_contents _ eqA_dec l) (contents T) -> build_heap l.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall l : list A, build_heap lA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall l : list A, build_heap lA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Abuild_heap nilA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aforall (a : A) (l0 : list A), build_heap l0 -> build_heap (a :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Ais_heap Tree_LeafA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aforall (a : A) (l0 : list A), build_heap l0 -> build_heap (a :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aforall (a : A) (l0 : list A), build_heap l0 -> build_heap (a :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aa:Al0:list AX:build_heap l0forall T : Tree, is_heap T -> meq (list_contents eqA eqA_dec l0) (contents T) -> build_heap (a :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aa:Al0:list AX:build_heap l0T:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l0) (contents T)forall T1 : Tree, is_heap T1 -> meq (contents T1) (munion (contents T) (singletonBag a)) -> (forall b : A, leA b a -> leA_Tree b T -> leA_Tree b T1) -> build_heap (a :: l0)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aa:Al0:list AX:build_heap l0T:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l0) (contents T)T1:Treei0:is_heap T1m0:meq (contents T1) (munion (contents T) (singletonBag a))l1:forall b : A, leA b a -> leA_Tree b T -> leA_Tree b T1meq (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l0)) (contents T1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aa:Al0:list AX:build_heap l0T:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l0) (contents T)T1:Treei0:is_heap T1m0:meq (contents T1) (munion (contents T) (singletonBag a))l1:forall b : A, leA b a -> leA_Tree b T -> leA_Tree b T1meq (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l0)) (munion (contents T) (singletonBag a))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aa:Al0:list AX:build_heap l0T:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l0) (contents T)T1:Treei0:is_heap T1m0:meq (contents T1) (munion (contents T) (singletonBag a))l1:forall b : A, leA b a -> leA_Tree b T -> leA_Tree b T1meq (munion (contents T) (singletonBag a)) (contents T1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aa:Al0:list AX:build_heap l0T:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l0) (contents T)T1:Treei0:is_heap T1m0:meq (contents T1) (munion (contents T) (singletonBag a))l1:forall b : A, leA b a -> leA_Tree b T -> leA_Tree b T1meq (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l0)) (munion (singletonBag a) (contents T))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aa:Al0:list AX:build_heap l0T:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l0) (contents T)T1:Treei0:is_heap T1m0:meq (contents T1) (munion (contents T) (singletonBag a))l1:forall b : A, leA b a -> leA_Tree b T -> leA_Tree b T1meq (munion (singletonBag a) (contents T)) (munion (contents T) (singletonBag a))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aa:Al0:list AX:build_heap l0T:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l0) (contents T)T1:Treei0:is_heap T1m0:meq (contents T1) (munion (contents T) (singletonBag a))l1:forall b : A, leA b a -> leA_Tree b T -> leA_Tree b T1meq (munion (contents T) (singletonBag a)) (contents T1)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aa:Al0:list AX:build_heap l0T:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l0) (contents T)T1:Treei0:is_heap T1m0:meq (contents T1) (munion (contents T) (singletonBag a))l1:forall b : A, leA b a -> leA_Tree b T -> leA_Tree b T1meq (munion (singletonBag a) (contents T)) (munion (contents T) (singletonBag a))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aa:Al0:list AX:build_heap l0T:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l0) (contents T)T1:Treei0:is_heap T1m0:meq (contents T1) (munion (contents T) (singletonBag a))l1:forall b : A, leA b a -> leA_Tree b T -> leA_Tree b T1meq (munion (contents T) (singletonBag a)) (contents T1)apply meq_sym; trivial with datatypes. Qed.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aa:Al0:list AX:build_heap l0T:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l0) (contents T)T1:Treei0:is_heap T1m0:meq (contents T1) (munion (contents T) (singletonBag a))l1:forall b : A, leA b a -> leA_Tree b T -> leA_Tree b T1meq (munion (contents T) (singletonBag a)) (contents T1)
Inductive flat_spec (T:Tree) : Type := flat_exist : forall l:list A, Sorted leA l -> (forall a:A, leA_Tree a T -> HdRel leA a l) -> meq (contents T) (list_contents _ eqA_dec l) -> flat_spec T.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall T : Tree, is_heap T -> flat_spec TA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall T : Tree, is_heap T -> flat_spec TA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Tflat_spec Tree_LeafA:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Ta:AT1, T2:TreeH:leA_Tree a T1H0:leA_Tree a T2H1:is_heap T1X:flat_spec T1H2:is_heap T2X0:flat_spec T2flat_spec (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Ta:AT1, T2:TreeH:leA_Tree a T1H0:leA_Tree a T2H1:is_heap T1X:flat_spec T1H2:is_heap T2X0:flat_spec T2flat_spec (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Ta:AT1, T2:TreeH:leA_Tree a T1H0:leA_Tree a T2H1:is_heap T1X:flat_spec T1H2:is_heap T2X0:flat_spec T2l1:list As1:Sorted leA l1i1:forall a0 : A, leA_Tree a0 T1 -> HdRel leA a0 l1m1:meq (contents T1) (list_contents eqA eqA_dec l1)l2:list As2:Sorted leA l2i2:forall a0 : A, leA_Tree a0 T2 -> HdRel leA a0 l2m2:meq (contents T2) (list_contents eqA eqA_dec l2)flat_spec (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Ta:AT1, T2:TreeH:leA_Tree a T1H0:leA_Tree a T2H1:is_heap T1X:flat_spec T1H2:is_heap T2X0:flat_spec T2l1:list As1:Sorted leA l1i1:forall a0 : A, leA_Tree a0 T1 -> HdRel leA a0 l1m1:meq (contents T1) (list_contents eqA eqA_dec l1)l2:list As2:Sorted leA l2i2:forall a0 : A, leA_Tree a0 T2 -> HdRel leA a0 l2m2:meq (contents T2) (list_contents eqA eqA_dec l2)l:list As:Sorted leA lm:meq (list_contents eqA eqA_dec l) (munion (list_contents eqA eqA_dec l1) (list_contents eqA eqA_dec l2))h0:forall a0 : A, HdRel leA a0 l1 -> HdRel leA a0 l2 -> HdRel leA a0 lflat_spec (Tree_Node a T1 T2)A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Ta:AT1, T2:TreeH:leA_Tree a T1H0:leA_Tree a T2H1:is_heap T1X:flat_spec T1H2:is_heap T2X0:flat_spec T2l1:list As1:Sorted leA l1i1:forall a0 : A, leA_Tree a0 T1 -> HdRel leA a0 l1m1:meq (contents T1) (list_contents eqA eqA_dec l1)l2:list As2:Sorted leA l2i2:forall a0 : A, leA_Tree a0 T2 -> HdRel leA a0 l2m2:meq (contents T2) (list_contents eqA eqA_dec l2)l:list As:Sorted leA lm:meq (list_contents eqA eqA_dec l) (munion (list_contents eqA eqA_dec l1) (list_contents eqA eqA_dec l2))h0:forall a0 : A, HdRel leA a0 l1 -> HdRel leA a0 l2 -> HdRel leA a0 lmeq (munion (contents T1) (munion (contents T2) (singletonBag a))) (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Ta:AT1, T2:TreeH:leA_Tree a T1H0:leA_Tree a T2H1:is_heap T1X:flat_spec T1H2:is_heap T2X0:flat_spec T2l1:list As1:Sorted leA l1i1:forall a0 : A, leA_Tree a0 T1 -> HdRel leA a0 l1m1:meq (contents T1) (list_contents eqA eqA_dec l1)l2:list As2:Sorted leA l2i2:forall a0 : A, leA_Tree a0 T2 -> HdRel leA a0 l2m2:meq (contents T2) (list_contents eqA eqA_dec l2)l:list As:Sorted leA lm:meq (list_contents eqA eqA_dec l) (munion (list_contents eqA eqA_dec l1) (list_contents eqA eqA_dec l2))h0:forall a0 : A, HdRel leA a0 l1 -> HdRel leA a0 l2 -> HdRel leA a0 lmeq (munion (contents T1) (munion (contents T2) (singletonBag a))) (munion (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l2) (singletonBag a)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Ta:AT1, T2:TreeH:leA_Tree a T1H0:leA_Tree a T2H1:is_heap T1X:flat_spec T1H2:is_heap T2X0:flat_spec T2l1:list As1:Sorted leA l1i1:forall a0 : A, leA_Tree a0 T1 -> HdRel leA a0 l1m1:meq (contents T1) (list_contents eqA eqA_dec l1)l2:list As2:Sorted leA l2i2:forall a0 : A, leA_Tree a0 T2 -> HdRel leA a0 l2m2:meq (contents T2) (list_contents eqA eqA_dec l2)l:list As:Sorted leA lm:meq (list_contents eqA eqA_dec l) (munion (list_contents eqA eqA_dec l1) (list_contents eqA eqA_dec l2))h0:forall a0 : A, HdRel leA a0 l1 -> HdRel leA a0 l2 -> HdRel leA a0 lmeq (munion (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l2) (singletonBag a))) (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Ta:AT1, T2:TreeH:leA_Tree a T1H0:leA_Tree a T2H1:is_heap T1X:flat_spec T1H2:is_heap T2X0:flat_spec T2l1:list As1:Sorted leA l1i1:forall a0 : A, leA_Tree a0 T1 -> HdRel leA a0 l1m1:meq (contents T1) (list_contents eqA eqA_dec l1)l2:list As2:Sorted leA l2i2:forall a0 : A, leA_Tree a0 T2 -> HdRel leA a0 l2m2:meq (contents T2) (list_contents eqA eqA_dec l2)l:list As:Sorted leA lm:meq (list_contents eqA eqA_dec l) (munion (list_contents eqA eqA_dec l1) (list_contents eqA eqA_dec l2))h0:forall a0 : A, HdRel leA a0 l1 -> HdRel leA a0 l2 -> HdRel leA a0 lmeq (munion (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l2) (singletonBag a))) (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Ta:AT1, T2:TreeH:leA_Tree a T1H0:leA_Tree a T2H1:is_heap T1X:flat_spec T1H2:is_heap T2X0:flat_spec T2l1:list As1:Sorted leA l1i1:forall a0 : A, leA_Tree a0 T1 -> HdRel leA a0 l1m1:meq (contents T1) (list_contents eqA eqA_dec l1)l2:list As2:Sorted leA l2i2:forall a0 : A, leA_Tree a0 T2 -> HdRel leA a0 l2m2:meq (contents T2) (list_contents eqA eqA_dec l2)l:list As:Sorted leA lm:meq (list_contents eqA eqA_dec l) (munion (list_contents eqA eqA_dec l1) (list_contents eqA eqA_dec l2))h0:forall a0 : A, HdRel leA a0 l1 -> HdRel leA a0 l2 -> HdRel leA a0 lmeq (munion (list_contents eqA eqA_dec l1) (munion (list_contents eqA eqA_dec l2) (singletonBag a))) (munion (singletonBag a) (munion (list_contents eqA eqA_dec l1) (list_contents eqA eqA_dec l2)))A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Ta:AT1, T2:TreeH:leA_Tree a T1H0:leA_Tree a T2H1:is_heap T1X:flat_spec T1H2:is_heap T2X0:flat_spec T2l1:list As1:Sorted leA l1i1:forall a0 : A, leA_Tree a0 T1 -> HdRel leA a0 l1m1:meq (contents T1) (list_contents eqA eqA_dec l1)l2:list As2:Sorted leA l2i2:forall a0 : A, leA_Tree a0 T2 -> HdRel leA a0 l2m2:meq (contents T2) (list_contents eqA eqA_dec l2)l:list As:Sorted leA lm:meq (list_contents eqA eqA_dec l) (munion (list_contents eqA eqA_dec l1) (list_contents eqA eqA_dec l2))h0:forall a0 : A, HdRel leA a0 l1 -> HdRel leA a0 l2 -> HdRel leA a0 lmeq (munion (singletonBag a) (munion (list_contents eqA eqA_dec l1) (list_contents eqA eqA_dec l2))) (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l))apply meq_right; apply meq_sym; trivial with datatypes. Qed.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset AT:Treeh:is_heap Ta:AT1, T2:TreeH:leA_Tree a T1H0:leA_Tree a T2H1:is_heap T1X:flat_spec T1H2:is_heap T2X0:flat_spec T2l1:list As1:Sorted leA l1i1:forall a0 : A, leA_Tree a0 T1 -> HdRel leA a0 l1m1:meq (contents T1) (list_contents eqA eqA_dec l1)l2:list As2:Sorted leA l2i2:forall a0 : A, leA_Tree a0 T2 -> HdRel leA a0 l2m2:meq (contents T2) (list_contents eqA eqA_dec l2)l:list As:Sorted leA lm:meq (list_contents eqA eqA_dec l) (munion (list_contents eqA eqA_dec l1) (list_contents eqA eqA_dec l2))h0:forall a0 : A, HdRel leA a0 l1 -> HdRel leA a0 l2 -> HdRel leA a0 lmeq (munion (singletonBag a) (munion (list_contents eqA eqA_dec l1) (list_contents eqA eqA_dec l2))) (munion (SingletonBag eqA eqA_dec a) (list_contents eqA eqA_dec l))
A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall l : list A, {m : list A | Sorted leA m & permutation eqA eqA_dec l m}A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Aforall l : list A, {m : list A | Sorted leA m & permutation eqA eqA_dec l m}A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list A{m : list A | Sorted leA m & meq (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec m)}A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list Aforall T : Tree, is_heap T -> meq (list_contents eqA eqA_dec l) (contents T) -> {m0 : list A | Sorted leA m0 & meq (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec m0)}A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list AT:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l) (contents T){m0 : list A | Sorted leA m0 & meq (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec m0)}A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list AT:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l) (contents T)forall l0 : list A, Sorted leA l0 -> (forall a : A, leA_Tree a T -> HdRel leA a l0) -> meq (contents T) (list_contents eqA eqA_dec l0) -> {m1 : list A | Sorted leA m1 & meq (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec m1)}A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list AT:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l) (contents T)l0:list As:Sorted leA l0h:forall a : A, leA_Tree a T -> HdRel leA a l0m0:meq (contents T) (list_contents eqA eqA_dec l0){m1 : list A | Sorted leA m1 & meq (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec m1)}apply meq_trans with (contents T); trivial with datatypes. Qed. End defs.A:TypeleA, eqA:relation AgtA:=fun x y : A => ~ leA x y:A -> A -> PropleA_dec:forall x y : A, {leA x y} + {leA y x}eqA_dec:forall x y : A, {eqA x y} + {~ eqA x y}leA_refl:forall x y : A, eqA x y -> leA x yleA_trans:forall x y z : A, leA x y -> leA y z -> leA x zleA_antisym:forall x y : A, leA x y -> leA y x -> eqA x yemptyBag:=EmptyBag A:multiset AsingletonBag:=SingletonBag eqA eqA_dec:A -> multiset Al:list AT:Treei:is_heap Tm:meq (list_contents eqA eqA_dec l) (contents T)l0:list As:Sorted leA l0h:forall a : A, leA_Tree a T -> HdRel leA a l0m0:meq (contents T) (list_contents eqA eqA_dec l0)meq (list_contents eqA eqA_dec l) (list_contents eqA eqA_dec l0)