Library Obs.product
Set Implicit Arguments.
Require Import notations decidable_prop list_dec.
Require Import equiv_obs sem_obs laws.
Section s.
Context { Idx : Set } { decIdx : decidable_set Idx }.
Context { π¦ : Idx β Graph } { decπ¦ : β i, DecidableGraph (π¦ i) }.
Context { choose_clique_π¦ : β i, choose_clique (π¦ i)}.
Notation V := (fun i β @vertex (π¦ i)).
Inductive π± : Set :=
| node (i : Idx) (a : V i).
Arguments node i a : clear implicits.
Notation " a @' i " := (node i a) (at level 5).
Definition eqπ± (u v : π±) : bool.
Defined.
Remark eqπ±_proj1 i j a b : a@'i = b@'j β i = j.
Remark eqπ±_proj2 i a b : a@'i = b@'i β a = b.
Inductive cohπ’ : relation π± :=
| coh_i i a b : a β b β cohπ’ a@'i b@'i
| coh_ij i j a b : i β j β cohπ’ a@'i b@'j.
Hint Constructors cohπ’ : core.
Lemma cohπ’_refl : Reflexive cohπ’.
Lemma cohπ’_sym : Symmetric cohπ’.
Instance π’ : Graph :=
{
vertex := π±;
coh := cohπ’;
coh_refl := cohπ’_refl;
coh_sym := cohπ’_sym
}.
Notation " a @ i " := (a @' i : @vertex π’) (at level 20).
Instance decπ’ : DecidableGraph π’.
Lemma incoh_iff_same_component_and_incoh u v :
u β£ v β β i a b, u = a@i β§ v = b@i β§ a β£ b.
Lemma dec_in_proj i Ξ± v : DecidableProp (β a, v = a@i β§ a β¨ Ξ±).
Lemma dec_compat_proj i Ξ± v : DecidableProp (β a, v = a@i β§ a β Ξ±).
Definition incompat_inject (i : Idx) (Ξ± : @clique (π¦ i)) (a : π±)
: option π±.
Defined.
Definition inject i (Ξ± : @clique (π¦ i)) : @clique π’.
Remark inject_i_member (i : Idx) (v : @vertex π’) (Ξ± : @clique (π¦ i)) :
v β¨ (@inject i Ξ±) β (β a : V i, v = a@i β§ a β¨ Ξ±).
Remark inject_i_incompat i v Ξ± :
v β inject Ξ± β (β a, v = a@i β§ a β Ξ±).
Opaque inject.
Definition incompat_project (i : Idx) (Ξ± : clique) (a : V i)
: option (V i).
Defined.
Definition project i (Ξ± : clique) : @clique (π¦ i).
Arguments project i Ξ± : clear implicits.
Notation " Ξ± β i " := (project i Ξ±) (at level 5).
Lemma project_spec i a Ξ± : a β¨ (Ξ± β i) β (a @ i) β¨ Ξ±.
Lemma project_inject i Ξ± : (inject Ξ±) β i β Ξ±.
Lemma join_project i Ξ± Ξ² :
Ξ± β i β² Ξ² β
β Ξ³ : clique, Ξ³ β i β Ξ² β§ β j, j β i β Ξ³ β j β Ξ± β j.
Lemma join_project' i Ξ± Ξ² :
Ξ± β i β² Ξ² β β Ξ³ : clique, Ξ³ β i β Ξ² β§ Ξ± β² Ξ³.
Notation π³ := (fun i β @observation (π¦ i)).
Definition π― := @observation π’.
Fixpoint obsπ¦_to_π― i (s : π³ i) : π― :=
match s with
| β¦aβ¦ β β¦a@iβ¦
| β€o β β€o
| β₯o β β₯o
| s1 β s2 β obsπ¦_to_π― s1 β obsπ¦_to_π― s2
| s1 β s2 β obsπ¦_to_π― s1 β obsπ¦_to_π― s2
| s1 β s2 β obsπ¦_to_π― s1 β obsπ¦_to_π― s2
end.
Arguments obsπ¦_to_π― i s : clear implicits.
Notation " s .{ i }" := (obsπ¦_to_π― i s) (at level 5).
Lemma obsπ¦_to_π―_sat i s Ξ± :
Ξ± β¨ s.{i} β Ξ± β i β¨ s.
Lemma choose_clique_aux I (c d : β i : Idx, π³ i) Ξ± :
(β i, i β I β§ β Ξ², Ξ± β² Ξ² β Ξ² β¨ (d i).{i} β Ξ² β¨ (c i).{i})
β¨ (β Ξ², Ξ± β² Ξ² β§ β i, i β I β Ξ² β¨ (d i).{i} β§ Β¬ Ξ² β¨ (c i).{i}) .
Definition termVect := β i : Idx, π³ i.
Definition NF := list termVect.
Definition mapNF : list Idx β termVect β list π― :=
fun l x β map (fun i β (x i).{i}) l.
Definition conj_interp : list Idx β list termVect β π― :=
fun l v β β (map (fun x β β (mapNF l x)) v).
Definition disj_interp : list Idx β list termVect β π― :=
fun l v β β (map (fun x β β (mapNF l x)) v).
Context { π : β i : Idx, relation (@observation (π¦ i)) }.
Arguments π i : clear implicits.
Hypothesis π _complete :
β i, β s t : π³ i, π i β’ s β‘ t β s β t.
Corollary π _complete_inf :
β i, β s t : π³ i, π i β’ s β¦ t β s β² t.
Reserved Notation " x =π y " (at level 80).
Inductive prod_ax : relation π― :=
| prod_idx i s t : π i s t β s.{i} =π t.{i}
| prod_impl idx x y :
(β (mapNF idx x) β β (mapNF idx y))
=π β (mapNF idx (fun i β x i β y i))
where " x =π y " := (prod_ax x y).
Notation π := (ha_ax (+) (obs_ax (+) prod_ax)).
Remark eo_prod_impl idx x y :
π β’ (β (mapNF idx x) β β (mapNF idx y))
β‘ β (mapNF idx (fun i β x i β y i)).
Instance obsπ¦_to_π―_proper i :
Proper (equiv_Obs (π i) ==> equiv_Obs π) (obsπ¦_to_π― i).
Instance obsπ¦_to_π―_proper_inf i :
Proper (inf_obs (π i) ==> inf_obs π) (obsπ¦_to_π― i).
Lemma π_sound : subrelation π sequiv.
Definition dnf_support (dnf : NF) I :=
β n i, n β dnf β Β¬ i β I β (n i) = β€o.
Definition cnf_support (cnf : NF) I :=
β n i, n β cnf β Β¬ i β I β (n i) = β₯o.
Fixpoint dnf_to_cnf I (dnf : NF) :=
match dnf with
| [] β [fun _ β β₯o]
| n::d β (flat_map (fun nc β
map (fun i j β
if i =?= j
then (n j β nc j)
else (nc j))
I) (dnf_to_cnf I d))
end.
Fixpoint cnf_to_dnf I (cnf : NF) :=
match cnf with
| [] β [fun _ β β€o]
| n::c β (flat_map (fun nd β
map (fun i j β
if i =?= j
then (n j β nd j)
else (nd j))
I) (cnf_to_dnf I c))
end.
Lemma cnf_to_dnf_support I c : dnf_support (cnf_to_dnf I c) I.
Lemma dnf_to_cnf_support I d : cnf_support (dnf_to_cnf I d) I.
Lemma cnf_to_dnf_equiv I c :
π β’ disj_interp I (cnf_to_dnf I c) β‘ conj_interp I c.
Lemma dnf_to_cnf_equiv I (dnf : NF) :
π β’ conj_interp I (dnf_to_cnf I dnf) β‘ disj_interp I dnf.
Instance cnf_support_proper_incl c :
Proper (@incl Idx ==> Basics.impl) (cnf_support c).
Instance dnf_support_proper_incl d :
Proper (@incl Idx ==> Basics.impl) (dnf_support d).
Instance cnf_support_proper c :
Proper (@equivalent Idx ==> iff) (cnf_support c).
Instance dnf_support_proper d :
Proper (@equivalent Idx ==> iff) (dnf_support d).
Lemma cnf_support_incl I J (cnf : NF) :
cnf_support cnf I β I β J β
π β’ conj_interp I cnf β‘ conj_interp J cnf.
Lemma dnf_support_incl I J (dnf : NF) :
dnf_support dnf I β I β J β
π β’ disj_interp I dnf β‘ disj_interp J dnf.
Definition atTop i (a : V i) : termVect.
Defined.
Fixpoint sup s :=
match s with
| β€o | β₯o β []
| β¦_@'iβ¦ β [i]
| sβt | sβt | s β t β sup s ++ sup t
end.
Fixpoint normal_form s : list termVect:=
match s with
| β€o β [fun _ β β€o]
| β₯o β []
| β¦a@'iβ¦ β [atTop a]
| s β t β (normal_form s)++(normal_form t)
| s β t β
cnf_to_dnf (sup s++sup t)
((dnf_to_cnf (sup s++sup t) (normal_form s))
++(dnf_to_cnf (sup s++sup t) (normal_form t)))
| s β t β
cnf_to_dnf (sup s++sup t)
(map (fun p i β (snd p iβfst p i))
(pairs (dnf_to_cnf (sup s++sup t)
(normal_form t))
(normal_form s)))
end.
Lemma normal_form_sup s : dnf_support (normal_form s) (sup s).
Lemma normal_form_eq s :
π β’ s β‘ disj_interp (sup s) (normal_form s).
Theorem π_complete s t :
π β’ s β‘ t β s β t.
Instance product_sat_dec :
β Ξ± s, DecidableProp (Ξ± β¨ s).
Lemma auxiliary i I Ξ± Ξ² Ξ³ :
Ξ± β² Ξ² β Ξ± β i β² Ξ³ β
β Ξ΄ : clique,
(Ξ± β² Ξ΄) β§ (Ξ΄ β i β Ξ³)
β§ (β j : Idx, i β j βj β I β Ξ΄ β j β Ξ² β j).
Lemma product_choose_clique : choose_clique π’.
End s.
Require Import notations decidable_prop list_dec.
Require Import equiv_obs sem_obs laws.
Section s.
Context { Idx : Set } { decIdx : decidable_set Idx }.
Context { π¦ : Idx β Graph } { decπ¦ : β i, DecidableGraph (π¦ i) }.
Context { choose_clique_π¦ : β i, choose_clique (π¦ i)}.
Notation V := (fun i β @vertex (π¦ i)).
Inductive π± : Set :=
| node (i : Idx) (a : V i).
Arguments node i a : clear implicits.
Notation " a @' i " := (node i a) (at level 5).
Definition eqπ± (u v : π±) : bool.
Defined.
Remark eqπ±_proj1 i j a b : a@'i = b@'j β i = j.
Remark eqπ±_proj2 i a b : a@'i = b@'i β a = b.
Inductive cohπ’ : relation π± :=
| coh_i i a b : a β b β cohπ’ a@'i b@'i
| coh_ij i j a b : i β j β cohπ’ a@'i b@'j.
Hint Constructors cohπ’ : core.
Lemma cohπ’_refl : Reflexive cohπ’.
Lemma cohπ’_sym : Symmetric cohπ’.
Instance π’ : Graph :=
{
vertex := π±;
coh := cohπ’;
coh_refl := cohπ’_refl;
coh_sym := cohπ’_sym
}.
Notation " a @ i " := (a @' i : @vertex π’) (at level 20).
Instance decπ’ : DecidableGraph π’.
Lemma incoh_iff_same_component_and_incoh u v :
u β£ v β β i a b, u = a@i β§ v = b@i β§ a β£ b.
Lemma dec_in_proj i Ξ± v : DecidableProp (β a, v = a@i β§ a β¨ Ξ±).
Lemma dec_compat_proj i Ξ± v : DecidableProp (β a, v = a@i β§ a β Ξ±).
Definition incompat_inject (i : Idx) (Ξ± : @clique (π¦ i)) (a : π±)
: option π±.
Defined.
Definition inject i (Ξ± : @clique (π¦ i)) : @clique π’.
Remark inject_i_member (i : Idx) (v : @vertex π’) (Ξ± : @clique (π¦ i)) :
v β¨ (@inject i Ξ±) β (β a : V i, v = a@i β§ a β¨ Ξ±).
Remark inject_i_incompat i v Ξ± :
v β inject Ξ± β (β a, v = a@i β§ a β Ξ±).
Opaque inject.
Definition incompat_project (i : Idx) (Ξ± : clique) (a : V i)
: option (V i).
Defined.
Definition project i (Ξ± : clique) : @clique (π¦ i).
Arguments project i Ξ± : clear implicits.
Notation " Ξ± β i " := (project i Ξ±) (at level 5).
Lemma project_spec i a Ξ± : a β¨ (Ξ± β i) β (a @ i) β¨ Ξ±.
Lemma project_inject i Ξ± : (inject Ξ±) β i β Ξ±.
Lemma join_project i Ξ± Ξ² :
Ξ± β i β² Ξ² β
β Ξ³ : clique, Ξ³ β i β Ξ² β§ β j, j β i β Ξ³ β j β Ξ± β j.
Lemma join_project' i Ξ± Ξ² :
Ξ± β i β² Ξ² β β Ξ³ : clique, Ξ³ β i β Ξ² β§ Ξ± β² Ξ³.
Notation π³ := (fun i β @observation (π¦ i)).
Definition π― := @observation π’.
Fixpoint obsπ¦_to_π― i (s : π³ i) : π― :=
match s with
| β¦aβ¦ β β¦a@iβ¦
| β€o β β€o
| β₯o β β₯o
| s1 β s2 β obsπ¦_to_π― s1 β obsπ¦_to_π― s2
| s1 β s2 β obsπ¦_to_π― s1 β obsπ¦_to_π― s2
| s1 β s2 β obsπ¦_to_π― s1 β obsπ¦_to_π― s2
end.
Arguments obsπ¦_to_π― i s : clear implicits.
Notation " s .{ i }" := (obsπ¦_to_π― i s) (at level 5).
Lemma obsπ¦_to_π―_sat i s Ξ± :
Ξ± β¨ s.{i} β Ξ± β i β¨ s.
Lemma choose_clique_aux I (c d : β i : Idx, π³ i) Ξ± :
(β i, i β I β§ β Ξ², Ξ± β² Ξ² β Ξ² β¨ (d i).{i} β Ξ² β¨ (c i).{i})
β¨ (β Ξ², Ξ± β² Ξ² β§ β i, i β I β Ξ² β¨ (d i).{i} β§ Β¬ Ξ² β¨ (c i).{i}) .
Definition termVect := β i : Idx, π³ i.
Definition NF := list termVect.
Definition mapNF : list Idx β termVect β list π― :=
fun l x β map (fun i β (x i).{i}) l.
Definition conj_interp : list Idx β list termVect β π― :=
fun l v β β (map (fun x β β (mapNF l x)) v).
Definition disj_interp : list Idx β list termVect β π― :=
fun l v β β (map (fun x β β (mapNF l x)) v).
Context { π : β i : Idx, relation (@observation (π¦ i)) }.
Arguments π i : clear implicits.
Hypothesis π _complete :
β i, β s t : π³ i, π i β’ s β‘ t β s β t.
Corollary π _complete_inf :
β i, β s t : π³ i, π i β’ s β¦ t β s β² t.
Reserved Notation " x =π y " (at level 80).
Inductive prod_ax : relation π― :=
| prod_idx i s t : π i s t β s.{i} =π t.{i}
| prod_impl idx x y :
(β (mapNF idx x) β β (mapNF idx y))
=π β (mapNF idx (fun i β x i β y i))
where " x =π y " := (prod_ax x y).
Notation π := (ha_ax (+) (obs_ax (+) prod_ax)).
Remark eo_prod_impl idx x y :
π β’ (β (mapNF idx x) β β (mapNF idx y))
β‘ β (mapNF idx (fun i β x i β y i)).
Instance obsπ¦_to_π―_proper i :
Proper (equiv_Obs (π i) ==> equiv_Obs π) (obsπ¦_to_π― i).
Instance obsπ¦_to_π―_proper_inf i :
Proper (inf_obs (π i) ==> inf_obs π) (obsπ¦_to_π― i).
Lemma π_sound : subrelation π sequiv.
Definition dnf_support (dnf : NF) I :=
β n i, n β dnf β Β¬ i β I β (n i) = β€o.
Definition cnf_support (cnf : NF) I :=
β n i, n β cnf β Β¬ i β I β (n i) = β₯o.
Fixpoint dnf_to_cnf I (dnf : NF) :=
match dnf with
| [] β [fun _ β β₯o]
| n::d β (flat_map (fun nc β
map (fun i j β
if i =?= j
then (n j β nc j)
else (nc j))
I) (dnf_to_cnf I d))
end.
Fixpoint cnf_to_dnf I (cnf : NF) :=
match cnf with
| [] β [fun _ β β€o]
| n::c β (flat_map (fun nd β
map (fun i j β
if i =?= j
then (n j β nd j)
else (nd j))
I) (cnf_to_dnf I c))
end.
Lemma cnf_to_dnf_support I c : dnf_support (cnf_to_dnf I c) I.
Lemma dnf_to_cnf_support I d : cnf_support (dnf_to_cnf I d) I.
Lemma cnf_to_dnf_equiv I c :
π β’ disj_interp I (cnf_to_dnf I c) β‘ conj_interp I c.
Lemma dnf_to_cnf_equiv I (dnf : NF) :
π β’ conj_interp I (dnf_to_cnf I dnf) β‘ disj_interp I dnf.
Instance cnf_support_proper_incl c :
Proper (@incl Idx ==> Basics.impl) (cnf_support c).
Instance dnf_support_proper_incl d :
Proper (@incl Idx ==> Basics.impl) (dnf_support d).
Instance cnf_support_proper c :
Proper (@equivalent Idx ==> iff) (cnf_support c).
Instance dnf_support_proper d :
Proper (@equivalent Idx ==> iff) (dnf_support d).
Lemma cnf_support_incl I J (cnf : NF) :
cnf_support cnf I β I β J β
π β’ conj_interp I cnf β‘ conj_interp J cnf.
Lemma dnf_support_incl I J (dnf : NF) :
dnf_support dnf I β I β J β
π β’ disj_interp I dnf β‘ disj_interp J dnf.
Definition atTop i (a : V i) : termVect.
Defined.
Fixpoint sup s :=
match s with
| β€o | β₯o β []
| β¦_@'iβ¦ β [i]
| sβt | sβt | s β t β sup s ++ sup t
end.
Fixpoint normal_form s : list termVect:=
match s with
| β€o β [fun _ β β€o]
| β₯o β []
| β¦a@'iβ¦ β [atTop a]
| s β t β (normal_form s)++(normal_form t)
| s β t β
cnf_to_dnf (sup s++sup t)
((dnf_to_cnf (sup s++sup t) (normal_form s))
++(dnf_to_cnf (sup s++sup t) (normal_form t)))
| s β t β
cnf_to_dnf (sup s++sup t)
(map (fun p i β (snd p iβfst p i))
(pairs (dnf_to_cnf (sup s++sup t)
(normal_form t))
(normal_form s)))
end.
Lemma normal_form_sup s : dnf_support (normal_form s) (sup s).
Lemma normal_form_eq s :
π β’ s β‘ disj_interp (sup s) (normal_form s).
Theorem π_complete s t :
π β’ s β‘ t β s β t.
Instance product_sat_dec :
β Ξ± s, DecidableProp (Ξ± β¨ s).
Lemma auxiliary i I Ξ± Ξ² Ξ³ :
Ξ± β² Ξ² β Ξ± β i β² Ξ³ β
β Ξ΄ : clique,
(Ξ± β² Ξ΄) β§ (Ξ΄ β i β Ξ³)
β§ (β j : Idx, i β j βj β I β Ξ΄ β j β Ξ² β j).
Lemma product_choose_clique : choose_clique π’.
End s.