(* 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 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                                                     *)
(* définition inductive du type des termes : *)
Inductive term : Set :=
app : ad -> term_list -> term
with term_list : Set :=
| tnil : term_list
| tcons : term -> term_list -> term_list.
(* les principes d'induction *)
Scheme term_term_list_rec := Induction for term
Sort Set
with term_list_term_rec := Induction for term_list
Sort Set.
Scheme term_term_list_ind := Induction for term
Sort Prop
with term_list_term_ind := Induction for term_list
Sort Prop.
Fixpoint lst_length (l : term_list) : nat :=
match l with
| tnil => 0
| tcons _ l' => S (lst_length l')
end.
Fixpoint term_high (t : term) : nat :=
match t with
| app a l => S (term_high_0 l)
end
with term_high_0 (l : term_list) : nat :=
match l with
| tnil => 0
| tcons hd tl => max (term_high hd) (term_high_0 tl)
end.
(* taille des termes : *)
Fixpoint taille_term (t : term) : nat :=
match t with
| app c l => S (mtaille_term_list l)
end
with mtaille_term_list (l : term_list) : nat :=
match l with
| tnil => 0
| tcons hd tl => max (taille_term hd) (mtaille_term_list tl)
end.
(* définition des structures prec_list : adjacence des états de l'automate *)
Inductive prec_list : Set :=
| prec_cons : ad -> prec_list -> prec_list -> prec_list
| prec_empty : prec_list.
(* définition des états *)
Definition state := Map prec_list.
(* définition des automates *)
Definition preDTA := Map state.
Inductive DTA : Set :=
dta : preDTA -> ad -> DTA.
(* calcul de la taille de l'automate : *)
Fixpoint taille_0 (l : prec_list) : nat :=
match l with
| prec_empty => 0
| prec_cons x y z => S (taille_0 y + taille_0 z)
end.
Fixpoint taille_1 (s : state) : nat :=
match s with
| M0 => 0
| M1 x y => taille_0 y
| M2 x y => max (taille_1 x) (taille_1 y)
end.
Fixpoint DTA_taille (d : preDTA) : nat :=
match d with
| M0 => 0
| M1 x y => taille_1 y
| M2 x y => max (DTA_taille x) (DTA_taille y)
end.

Lemma taille_aux_2 :
forall (a : ad) (la ls : prec_list),
S (taille_0 ls) <= taille_0 (prec_cons a la ls).