(* File: Le_Ks.v  (last edited on 27/10/2000) (c) Klaus Weich  *)
Require Export Rev_App.
(*****************************************************************)
Inductive le_ni : nested_imps -> nested_imps -> Prop :=
| Le_NI_Nil : le_ni NNil NNil
| Le_NI_Cons_NN :
forall (x : nimp) (ni1 ni2 : nested_imps),
le_ni ni1 ni2 -> le_ni (Undecorated x :: ni1) (Undecorated x :: ni2)
| Le_NI_Cons_DN :
forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps),
le_ni ni1 ni2 -> le_ni (Decorated x k :: ni1) (Undecorated x :: ni2)
| Le_NI_Cons_DD :
forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps),
le_ni ni1 ni2 -> le_ni (Decorated x k :: ni1) (Decorated x k :: ni2).
intros ni1 ni2 x k le12.
elim le12; clear le12 ni1 ni2.
intros; assumption.
intros x' ni1 ni2 le12 ih in_k.
right.
apply ih.
inversion_clear in_k.
discriminate H.
assumption.
intros x' k' ni1 ni2 le12 ih in_k.
right.
apply ih.
inversion_clear in_k.
discriminate H.
assumption.
intros x' k' ni1 ni2 le12 ih in_k.
inversion_clear in_k.
left; assumption.
right; apply ih; assumption.
Qed.
intros ni; elim ni; clear ni.
apply Le_NI_Nil.
intros a; case a; clear a.
intros x N ih.
apply Le_NI_Cons_NN; assumption.
intros x k ni ih.
apply Le_NI_Cons_DD; assumption.
Qed.
intros ni1 ni2 ni3 le12.
generalize ni3; clear ni3.
elim le12; clear le12 ni1 ni2.
intros; assumption.
intros x ni1 ni2 le12 ih ni3 le23.
inversion_clear le23.
apply Le_NI_Cons_NN.
apply ih; assumption.
intros x k ni1 ni2 le12 ih ni3 le23.
inversion_clear le23.
apply Le_NI_Cons_DN.
apply ih; assumption.
intros x k ni1 ni2 le12 ih ni3 le23.
inversion_clear le23.
apply Le_NI_Cons_DN.
apply ih; assumption.
apply Le_NI_Cons_DD.
apply ih; assumption.
Qed.
(*****************************************************************)
Inductive filter_deco_spec (i : Int) (N : nested_imps) : Set :=
Filter_Deco_Spec_Intro :
forall ni1 : nested_imps,
le_ni N ni1 ->
(forall (x : nimp) (k : kripke_tree),
In (Decorated x k) ni1 -> forces_t k (Atom i)) ->
filter_deco_spec i N.
intros i ni.
elim ni; clear ni.
fold NNil in |- *.
apply Filter_Deco_Spec_Intro with NNil.
apply Le_NI_Nil.
intros x k in_k.
inversion_clear in_k.
intros a; case a; clear a.
intros x ni ih.
elim ih; clear ih.
intros ni1 le1 forces_i.
apply Filter_Deco_Spec_Intro with (Undecorated x :: ni1).
apply Le_NI_Cons_NN; assumption.
intros x' k' in_k0.
apply forces_i with x'.
inversion_clear in_k0.
discriminate H.
assumption.
intros x k ni ih.
elim ih; clear ih.
intros ni1 le1 forces_i.
case k; clear k.
intros Atms succs.
case Atms; clear Atms.
intros t avl_t.
elim (lookup_dec unit i t avl_t).
intros d; case d; clear d.
intros lookup.
apply
Filter_Deco_Spec_Intro
with (Decorated x (node atoms (AVL_intro unit t avl_t) succs) :: ni1).
apply Le_NI_Cons_DD; assumption.
intros x' k' in_k0.
inversion_clear in_k0.
injection H; clear H; intros.
rewrite <- H; assumption.
apply forces_i with x'; assumption.
intros notlookup.
apply Filter_Deco_Spec_Intro with (Undecorated x :: ni1).
apply Le_NI_Cons_DN; assumption.
simpl in |- *; intros x' k' in_k0.
inversion_clear in_k0.
discriminate H.
apply forces_i with x'; assumption.
Qed.
(*****************************************************************)
Inductive eqv_ni : nested_imps -> nested_imps -> Prop :=
| Eqv_NI_Nil : eqv_ni NNil NNil
| Eqv_NI_Cons_NN :
forall (x : nimp) (ni1 ni2 : nested_imps),
eqv_ni ni1 ni2 -> eqv_ni (Undecorated x :: ni1) (Undecorated x :: ni2)
| Eqv_NI_Cons_DN :
forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps),
eqv_ni ni1 ni2 -> eqv_ni (Decorated x k :: ni1) (Undecorated x :: ni2)
| Eqv_NI_Cons_DD :
forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps),
eqv_ni ni1 ni2 -> eqv_ni (Decorated x k :: ni1) (Decorated x k' :: ni2)
| Eqv_NI_Cons_ND :
forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps),
eqv_ni ni1 ni2 -> eqv_ni (Undecorated x :: ni1) (Decorated x k :: ni2).

Lemma eqv_ni_trans :
forall ni1 ni2 ni3 : nested_imps,
eqv_ni ni1 ni2 -> eqv_ni ni2 ni3 -> eqv_ni ni1 ni3.