(* 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                                                     *)
(* fonction de suppression des états non coaccessibles *)
Fixpoint non_coacc_kill (d : preDTA) (m : Map bool) {struct m} : preDTA :=
match d, m with
| M0, M0 => M0 state
| M1 a s, M1 a' b => if N.eqb a a' && b then M1 state a s else M0 state
| M2 x y, M2 z t => M2 state (non_coacc_kill x z) (non_coacc_kill y t)
| _, _ => M0 state
end.
Definition predta_kill_non_coacc (d : preDTA) (a : ad) : preDTA :=
non_coacc_kill d (predta_coacc_states d a).
Definition dta_kill_non_coacc (d : DTA) : DTA :=
match d with
| dta p a => dta (predta_kill_non_coacc p a) a
end.
Definition predta_kill_non_coacc_lazy (d : preDTA)
(a : ad) : preDTA := non_coacc_kill d (predta_coacc_states_0 d a).
Definition dta_kill_non_coacc_lazy (d : DTA) : DTA :=
match d with
| dta p a => dta (predta_kill_non_coacc_lazy p a) a
end.
(* démo : un état apparait dans non_coacc_kill ssi il est coacc *)
(* coaccessibilité des états conservée en supprimant les coaccessibles *)
Definition predta_kill_non_coacc_def_0 (d : preDTA)
(a0 a1 : ad) : Prop :=
preDTA_ref_ok d ->
coacc d a0 a1 -> coacc (predta_kill_non_coacc d a0) a0 a1.
(* sémantique de reconnaissance dans les coaccessibles *)
(* sens trivial : si un terme est reconnu par l'automate où on a kille les non coaccessibles alors il est reconnu dans l automate *)
Definition predta_kill_non_coacc_rec_def_0 (p : preDTA)
(a : ad) (t : term) (pr : reconnaissance p a t) :=
forall (p0 : preDTA) (m : Map bool),
p = non_coacc_kill p0 m ->
ensemble_base state p0 m -> reconnaissance p0 a t.
Definition predta_kill_non_coacc_rec_def_1 (p : preDTA)
(s : state) (t : term) (pr : state_reconnait p s t) :=
forall (p0 : preDTA) (m : Map bool),
p = non_coacc_kill p0 m ->
ensemble_base state p0 m -> state_reconnait p0 s t.
Definition predta_kill_non_coacc_rec_def_2 (p : preDTA)
(pl : prec_list) (lt : term_list) (pr : liste_reconnait p pl lt) :=
forall (p0 : preDTA) (m : Map bool),
p = non_coacc_kill p0 m ->
ensemble_base state p0 m -> liste_reconnait p0 pl lt.

Lemma predta_kill_non_coacc_rev :
forall (p : preDTA) (a : ad) (t : term) (m : Map bool),
reconnaissance (non_coacc_kill p m) a t ->
ensemble_base state p m -> reconnaissance p a t.