(* 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.

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).