(* 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                                                     *)
Unset Standard Proposition Elimination Names.
(* fonction définissant la sémantique : reconnaissance d'un terme par un automate *)
Fixpoint rec_term (d : preDTA) (a : ad) (t : term)
(n : nat) {struct n} : bool :=
match n with
| O => false
| S k =>
match t with
| app c l =>
match MapGet _ d a with
| None => false
| Some lts =>
match MapGet _ lts c with
| None => false
| Some pre => rec_list_terms d pre l k
end
end
end
end
with rec_list_terms (d : preDTA) (pre : prec_list)
(l : term_list) (n : nat) {struct n} : bool :=
match n with
| O => false
| S k =>
match pre with
| prec_empty => match l with
| tnil => true
| _ => false
end
| prec_cons st stp pre' =>
match l with
| tnil => false
| tcons hd tl =>
rec_list_terms d pre' l k
|| rec_term d st hd k && rec_list_terms d stp tl k
end
end
end.
(* bornes sur l'entier décroissant (terminaison de la fonction reconnaissance *)

(* Specifications: *)
Lemma borne_0_0 :
forall p : prec_list,
prec_in_state (M0 prec_list) p -> taille_0 p <= taille_1 (M0 prec_list).
Lemma borne_0_1 :
forall (a : ad) (p' p : prec_list),
prec_in_state (M1 prec_list a p') p ->
taille_0 p <= taille_1 (M1 prec_list a p').
Lemma borne_0_2 :
forall (m0 m1 : Map prec_list) (p : prec_list),
(prec_in_state m0 p -> taille_0 p <= taille_1 m0) ->
(prec_in_state m1 p -> taille_0 p <= taille_1 m1) ->
prec_in_state (M2 prec_list m0 m1) p ->
taille_0 p <= taille_1 (M2 prec_list m0 m1).
Lemma borne_0 :
forall (s : state) (p : prec_list),
prec_in_state s p -> taille_0 p <= taille_1 s.
Lemma borne_1_0 :
forall s : state,
state_in_dta (M0 state) s -> taille_1 s <= DTA_taille (M0 state).
Lemma borne_1_1 :
forall (a : ad) (s' s : state),
state_in_dta (M1 state a s') s -> taille_1 s <= DTA_taille (M1 state a s').
Lemma borne_1_2 :
forall (m0 m1 : Map state) (s : state),
(state_in_dta m0 s -> taille_1 s <= DTA_taille m0) ->
(state_in_dta m1 s -> taille_1 s <= DTA_taille m1) ->
state_in_dta (M2 state m0 m1) s -> taille_1 s <= DTA_taille (M2 state m0 m1).
Lemma borne_1 :
forall (d : preDTA) (s : state),
state_in_dta d s -> taille_1 s <= DTA_taille d.
Lemma borne_2 :
forall (d : preDTA) (p : prec_list),
prec_in_dta d p -> taille_0 p <= DTA_taille d.