(* 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: UniqueKey.v                          *)
(*                                                                     *)
(*    Definition: uniqueness of keys in association list               *)
(*                                                                     *)
(*                                    Laurent.Thery@inria.fr (2003)    *)
(***********************************************************************)
From Huffman Require Export Aux.
From Huffman Require Export Permutation.
From Huffman Require Export UList.
From Huffman Require Export sTactic.
Section UniqueKey.
Variables (A : Type) (B : Type).
(* An association list has unique keys if the keys appear only once *)
Inductive unique_key : list (A * B) -> Prop :=
| unique_key_nil : unique_key nil
| unique_key_cons :
forall (a : A) (b : B) l,
(forall b : B, ~ In (a, b) l) ->
unique_key l -> unique_key ((a, b) :: l).
Hint Constructors unique_key : core.

(* Specifications: *)
(* Inversion theorem *)
Theorem unique_key_inv : forall a l, unique_key (a :: l) -> unique_key l.
Proof using.