Section mu2set.
Variable N : nat.
Definition set_1 := Evar_env'' 0 N.
Definition rel_1 (s t : var_env'') := In _ set_1 s /\ In _ set_1 t.
Definition t_to_rel1 (t : bool_expr) (ve1 ve2 : var_env') :=
eval_be' t (var_env'_or ve1 (var_env'_dash N ve2)).
Definition t_to_rel (t : bool_expr) (ve1 ve2 : var_env'') :=
t_to_rel1 t (var_env''_to_env' ve1) (var_env''_to_env' ve2).
Definition new_t_to_rel (t : bool_expr) (ve1 ve2 : var_env'') :=
t_to_rel t ve1 ve2 = true /\ rel_1 ve1 ve2.
Definition state_set (S : Ensemble var_env'') := Included _ S set_1.
Definition state_rel (R : Relation var_env'') :=
forall s t : var_env'', R s t -> rel_1 s t.  (* (In ? set_1 s) /\ (In ? set_1 t).*)
Definition set_0 := Empty_set var_env''.
Definition set_ap (x : ad) (s : var_env'') :=
In _ set_1 s /\ in_dom _ x s = true.
Definition set_or := Union var_env''.
Definition set_and := Intersection var_env''.
Definition set_neg := Setminus _ set_1.
Definition set_impl (S1 S2 : Ensemble var_env'') := set_or (set_neg S1) S2.
Definition set_iff (S1 S2 : Ensemble var_env'') :=
set_and (set_impl S1 S2) (set_impl S2 S1).
Inductive set_ex (R : Relation var_env'') (S : Ensemble var_env'') :
Ensemble var_env'' :=
setex_intro :
forall s t : var_env'',
In _ set_1 s -> R s t -> In _ S t -> In _ (set_ex R S) s.
Definition set_all (R : Relation var_env'') (S : Ensemble var_env'')
(s : var_env'') :=
In _ set_1 s /\ (forall t : var_env'', R s t -> In _ S t).
Definition set_mu (f : Ensemble var_env'' -> Ensemble var_env'')
(s : var_env'') :=
forall X : Ensemble var_env'',
state_set X -> Included _ (f X) X -> In _ X s.
Definition set_renv := ad -> Ensemble var_env''.
Definition set_tenv := ad -> Relation var_env''.
Definition sre_put (sre : set_renv) (P : ad) (S : Ensemble var_env'')
(Q : ad) := if Neqb P Q then S else sre Q.
Definition te_ste_ok (te : trans_env) (ste : set_tenv) :=
forall (a : ad) (ve1 ve2 : var_env''),
new_t_to_rel (te a) ve1 ve2 <-> ste a ve1 ve2.
Definition re_sre_ok (re : rel_env) (sre : set_renv) :=
forall P : ad, bool_expr_to_var_env'' 0 N (re P) = sre P.
Fixpoint mu_form2set (ste : set_tenv) (f : mu_form) {struct f} :
set_renv -> Ensemble var_env'' :=
fun sre =>
match f with
| mu_0 => set_0
| mu_1 => set_1
| mu_ap p => set_ap p
| mu_rel_var P => sre P
| mu_neg g => set_neg (mu_form2set ste g sre)
| mu_and g1 g2 => set_and (mu_form2set ste g1 sre) (mu_form2set ste g2 sre)
| mu_or g1 g2 => set_or (mu_form2set ste g1 sre) (mu_form2set ste g2 sre)
| mu_impl g1 g2 =>
set_impl (mu_form2set ste g1 sre) (mu_form2set ste g2 sre)
| mu_iff g1 g2 => set_iff (mu_form2set ste g1 sre) (mu_form2set ste g2 sre)
| mu_all t g => set_all (ste t) (mu_form2set ste g sre)
| mu_ex t g => set_ex (ste t) (mu_form2set ste g sre)
| mu_mu P g => set_mu (fun S => mu_form2set ste g (sre_put sre P S))
end.

(* Specifications: *)
Lemma set_ap_state_set : forall x : ad, state_set (set_ap x).
Lemma var_env'_to_env''_to_env' :
forall (L U : nat) (ve : var_env') (x : ad),
var_lu L U x = true ->
var_env''_to_env' (var_env'_to_env'' L U ve) (nat_of_N x) =
ve (nat_of_N x).
Lemma le_minus_le1 : forall m n p : nat, m <= n -> m - p <= n - p.
Fixpoint ve''_to_be (ve : var_env'') (n : nat) {struct n} : bool_expr :=
match n with
| O => One
| S m =>
match in_dom _ (N_of_nat m) ve with
| true => ANd (ve''_to_be ve m) (Var (N_of_nat m))
| false => ANd (ve''_to_be ve m) (Neg (Var (N_of_nat m)))
end
end.
Lemma ve''_to_be_ok :
forall (n : nat) (ve ve' : var_env''),
bool_fun_of_bool_expr (ve''_to_be ve n) (var_env''_to_env ve') = true ->
forall m : nat,
m < n -> MapGet _ ve (N_of_nat m) = MapGet _ ve' (N_of_nat m).
Lemma ve''_to_be_ok1 :
forall (n : nat) (ve ve' : var_env''),
Evar_env'' 0 n ve ->
bool_expr_to_var_env'' 0 n (ve''_to_be ve n) ve' -> ve = ve'.
Lemma ve''_to_be_ok2 :
forall (n : nat) (ve : var_env''),
eval_be' (ve''_to_be ve n) (var_env''_to_env' ve) = true.
Lemma ve''_to_be_ok3 :
forall (n : nat) (ve : var_env''),
n <= N -> be_ok (var_lu 0 N) (ve''_to_be ve n).
Lemma env_to_be_lemma :
forall S : Ensemble var_env'',
Finite _ S ->
Included _ S (Evar_env'' 0 N) ->
exists be : bool_expr,
bool_expr_to_var_env'' 0 N be = S /\ be_ok (var_lu 0 N) be.
Lemma env_to_be_lemma1 :
forall S : Ensemble var_env'',
Included _ S (Evar_env'' 0 N) ->
exists be : bool_expr,
bool_expr_to_var_env'' 0 N be = S /\ be_ok (var_lu 0 N) be.
Lemma muevaleqset :
forall (te : trans_env) (ste : set_tenv),
ad_to_be_ok (var_lu 0 (2 * N)) te ->
te_ste_ok te ste ->
forall (f : mu_form) (re : rel_env) (sre : set_renv),
f_ok f ->
mu_form_ap_ok (var_lu 0 N) f ->
ad_to_be_ok (var_lu 0 N) re ->
re_sre_ok re sre ->
mu_form2set ste f sre = bool_expr_to_var_env'' 0 N (mu_eval N te f re).