(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU Lesser General Public License for more details.                *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
(********************************************************************** Proof of Huffman algorithm: Cover.v  Definition of a cover for a tree and some properties  Definitions: cover Laurent.Thery@inria.fr (2003) **********************************************************************)
From Huffman Require Export BTree.
From Huffman Require Export Permutation.
Section Cover.
Variable A : Type.
Variable eqA_dec : forall a b : A, {a = b} + {a <> b}.
Variable empty : A.
(* A list of trees is a cover of a tree if all the trees in the list delimit a frontier in the tree *)
Inductive cover : list (btree A) -> btree A -> Prop :=
| cover_one : forall t, cover (t :: nil) t
| cover_node :
forall l1 l2 t1 t2 t3,
permutation l1 (t1 :: t2 :: l2) ->
cover (node t1 t2 :: l2) t3 -> cover l1 t3.
Hint Constructors cover : core.

(* Specifications: *)
(* Covers are compatible with permutation *)
Theorem cover_permutation :
forall t l1 l2, cover l1 t -> permutation l1 l2 -> cover l2 t.