Library LangAlg.w_terms
This module introduces weak terms, and establishes some of their
general properties.
Fix a set of variables X.
A weak term consists of a pair whose first projection is either
a series-parallel term or the constant None (which stands for 1
in this context), and whose second projection is a list of
variables, called the set of tests of the term.
The weak term ๐ญ is the pair (None,[]).
Definition ๐_one : ๐ := (None,[]).
End s0.
Notation " ๐ญ " := ๐_one.
Section s.
Context {X : Set}.
End s0.
Notation " ๐ญ " := ๐_one.
Section s.
Context {X : Set}.
We define the sequential product of weak terms as follows.
Definition ๐_seq (u v : ๐ X) : ๐ X :=
match (u,v) with
| ((None,A),(s,B)) โ (s,A++B)
| ((s,A),(None,B)) โ (s,A++B)
| ((Some s,A),(Some t,B)) โ (Some (sโจพt),A++B)
end.
Infix " โ " := ๐_seq (at level 40).
match (u,v) with
| ((None,A),(s,B)) โ (s,A++B)
| ((s,A),(None,B)) โ (s,A++B)
| ((Some s,A),(Some t,B)) โ (Some (sโจพt),A++B)
end.
Infix " โ " := ๐_seq (at level 40).
We define the parallel product of weak terms as follows.
Definition ๐_par (u v : ๐ X) : ๐ X :=
match (u,v) with
| ((None,A),(None,B)) โ (None,A++B)
| ((None,A),(Some s,B)) โ (None,A++B++โsโ)
| ((Some s,A),(None,B)) โ (None,A++B++โsโ)
| ((Some s,A),(Some t,B)) โ (Some (sโฅt),A++B)
end.
Infix " โ " := ๐_par (at level 50).
match (u,v) with
| ((None,A),(None,B)) โ (None,A++B)
| ((None,A),(Some s,B)) โ (None,A++B++โsโ)
| ((Some s,A),(None,B)) โ (None,A++B++โsโ)
| ((Some s,A),(Some t,B)) โ (Some (sโฅt),A++B)
end.
Infix " โ " := ๐_par (at level 50).
We use the parametric ordering on series-parallel terms to
define the ordering of weak_terms.
Global Instance ๐_inf : Smaller (๐ X) :=
fun e f โ
match (e,f) with
| ((None,A),(None,B)) โ B โ A
| ((None,A),(Some u,B)) โ B โ A โง โuโ โ A
| ((Some u,A),(None,B)) โ False
| ((Some u,A),(Some v,B)) โ B โ A โง A โจ u << v
end.
fun e f โ
match (e,f) with
| ((None,A),(None,B)) โ B โ A
| ((None,A),(Some u,B)) โ B โ A โง โuโ โ A
| ((Some u,A),(None,B)) โ False
| ((Some u,A),(Some v,B)) โ B โ A โง A โจ u << v
end.
As usual, this relation is indeed a preorder.
By taking its symmetric closure, we get an equivalence relation.
Global Instance ๐_equiv : Equiv (๐ X) := fun e f โ e โค f โง f โค e.
Global Instance ๐_equiv_Equivalence :
Equivalence equiv.
Global Instance ๐_inf_PartialOrder: PartialOrder equiv smaller.
Global Instance ๐_equiv_Equivalence :
Equivalence equiv.
Global Instance ๐_inf_PartialOrder: PartialOrder equiv smaller.
We now define the size and the set of variables of a weak term.
Global Instance ๐_size : Size (๐ X) :=
fun u โ
match u with
| (None,A) โ length A
| (Some s,A) โ โฆsโฆ + length A
end.
Global Instance ๐_variables : Alphabet ๐ X :=
fun u โ
match u with
| (None,A) โ A
| (Some u,A) โ โuโ ++ A
end.
fun u โ
match u with
| (None,A) โ length A
| (Some s,A) โ โฆsโฆ + length A
end.
Global Instance ๐_variables : Alphabet ๐ X :=
fun u โ
match u with
| (None,A) โ A
| (Some u,A) โ โuโ ++ A
end.
Lemma variables_๐_par (s t : ๐ X) :
โs โ tโ โ โsโ ++ โtโ.
Lemma variables_๐_seq (s t : ๐ X) :
โs โ tโ โ โsโ ++ โtโ.
โs โ tโ โ โsโ ++ โtโ.
Lemma variables_๐_seq (s t : ๐ X) :
โs โ tโ โ โsโ ++ โtโ.
Both products are monotone operations.
Global Instance ๐_seq_๐_inf :
Proper (smaller ==> smaller ==> smaller) ๐_seq.
Global Instance ๐_seq_๐_equiv :
Proper (equiv ==> equiv ==> equiv) ๐_seq.
Global Instance ๐_par_๐_inf :
Proper (smaller ==> smaller ==> smaller) ๐_par.
Global Instance ๐_par_๐_equiv :
Proper (equiv ==> equiv ==> equiv) ๐_par.
Proper (smaller ==> smaller ==> smaller) ๐_seq.
Global Instance ๐_seq_๐_equiv :
Proper (equiv ==> equiv ==> equiv) ๐_seq.
Global Instance ๐_par_๐_inf :
Proper (smaller ==> smaller ==> smaller) ๐_par.
Global Instance ๐_par_๐_equiv :
Proper (equiv ==> equiv ==> equiv) ๐_par.
We now list some (in)equalities between weak terms.
Lemma ๐_par_comm e f : eโf โก fโe.
Lemma ๐_par_idem e : e โ e โก e.
Lemma ๐_seq_assoc e f g : eโ(f โ g) โก (eโf)โg.
Lemma ๐_par_assoc e f g : eโ(f โ g) โก (eโf)โg.
Lemma ๐_seq_one_l e : ๐ญ โ e โก e.
Lemma ๐_seq_one_r e : e โ ๐ญ โก e.
Lemma ๐_par_inf e f : (e โ f) โค e.
Lemma ๐_par_one_l e : (๐ญ โ e) โค ((๐ญ โ e)โe).
Lemma ๐_par_one_r e : (๐ญ โ e) โค (eโ(๐ญ โ e)).
Lemma ๐_par_one_seq_par e f : (๐ญ โ (eโf)) โก (๐ญ โ (e โ f)).
Lemma ๐_par_one_seq_par_one e f : ((๐ญ โ e)โ(๐ญโf)) โก (๐ญโ(eโf)).
Lemma ๐_par_one_seq e f : ((๐ญ โ e)โf) โก (fโ(๐ญโe)).
Lemma ๐_par_one_par e f g : (((๐ญ โ e)โf)โg) โก ((๐ญโe)โ(fโg)).
Lemma ๐_par_idem e : e โ e โก e.
Lemma ๐_seq_assoc e f g : eโ(f โ g) โก (eโf)โg.
Lemma ๐_par_assoc e f g : eโ(f โ g) โก (eโf)โg.
Lemma ๐_seq_one_l e : ๐ญ โ e โก e.
Lemma ๐_seq_one_r e : e โ ๐ญ โก e.
Lemma ๐_par_inf e f : (e โ f) โค e.
Lemma ๐_par_one_l e : (๐ญ โ e) โค ((๐ญ โ e)โe).
Lemma ๐_par_one_r e : (๐ญ โ e) โค (eโ(๐ญ โ e)).
Lemma ๐_par_one_seq_par e f : (๐ญ โ (eโf)) โก (๐ญ โ (e โ f)).
Lemma ๐_par_one_seq_par_one e f : ((๐ญ โ e)โ(๐ญโf)) โก (๐ญโ(eโf)).
Lemma ๐_par_one_seq e f : ((๐ญ โ e)โf) โก (fโ(๐ญโe)).
Lemma ๐_par_one_par e f g : (((๐ญ โ e)โf)โg) โก ((๐ญโe)โ(fโg)).
Definitions
Primed weak terms are weak terms over a duplicated alphabet, such that their set of tests are balanced (that is each variable appears positively if and only if it appears negatively).
We define the primed weak term ๐ญ'.
Definition ๐'_one : ๐' :=
exist _ (None,[]) (@balanced_nil X).
Notation " ๐ญ' " := ๐'_one.
exist _ (None,[]) (@balanced_nil X).
Notation " ๐ญ' " := ๐'_one.
We define their set of variables using the set of primed
variables of the underlining series-parallel term over the
duplicated alphabet.
Definition ๐'_variables (u : ๐') :=
match ฯ{u} with
| (None,A) โ A
| (Some u,A) โ ๐๐'_variables u ++ A
end.
match ฯ{u} with
| (None,A) โ A
| (Some u,A) โ ๐๐'_variables u ++ A
end.
The size of a primed weak term is simply its size as a weak
term.
The set of variables of a primed weak term is always balanced.
Sequential product of primed weak terms.
Definition ๐'_seq (u v : ๐') : ๐' :=
match (u,v) with
| ((exist _ (None,A) p1),(exist _ (None,B) p2)) โ
exist _ (None,A++B)
(is_balanced_app p1 p2)
| ((exist _ (None,A) p1),(exist _ (Some s,B) p2)) โ
exist _ (Some s,A++B) (is_balanced_app p1 p2)
| ((exist _ (Some s,A) p1),(exist _ (None,B) p2)) โ
exist _ (Some s,A++B) (is_balanced_app p1 p2)
| ((exist _ (Some s,A) p1),(exist _ (Some t,B) p2)) โ
exist _ (Some (sโจพt),A++B) (is_balanced_app p1 p2)
end.
Infix " โ' " := ๐'_seq (at level 40).
match (u,v) with
| ((exist _ (None,A) p1),(exist _ (None,B) p2)) โ
exist _ (None,A++B)
(is_balanced_app p1 p2)
| ((exist _ (None,A) p1),(exist _ (Some s,B) p2)) โ
exist _ (Some s,A++B) (is_balanced_app p1 p2)
| ((exist _ (Some s,A) p1),(exist _ (None,B) p2)) โ
exist _ (Some s,A++B) (is_balanced_app p1 p2)
| ((exist _ (Some s,A) p1),(exist _ (Some t,B) p2)) โ
exist _ (Some (sโจพt),A++B) (is_balanced_app p1 p2)
end.
Infix " โ' " := ๐'_seq (at level 40).
Parallel product of primed weak terms.
Definition ๐'_par (u v : ๐') : ๐':=
match (u,v) with
| ((exist _ (None,A) p1),(exist _ (None,B) p2)) โ
exist _ (None,A++B)
(is_balanced_app p1 p2)
| ((exist _ (None,A) p1),(exist _ (Some s,B) p2)) โ
exist _ (None,A++B++๐๐'_variables s)
(is_balanced_app p1 (is_balanced_app
p2(is_balanced_๐๐'_variables s)))
| ((exist _ (Some s,A) p1),(exist _ (None,B) p2)) โ
exist _ (None,A++B++๐๐'_variables s)
(is_balanced_app p1 (is_balanced_app
p2(is_balanced_๐๐'_variables s)))
| ((exist _ (Some s,A) p1),(exist _ (Some t,B) p2)) โ
exist _ (Some (sโฅt),A++B) (is_balanced_app p1 p2)
end.
Infix " โ' " := ๐'_par (at level 50).
match (u,v) with
| ((exist _ (None,A) p1),(exist _ (None,B) p2)) โ
exist _ (None,A++B)
(is_balanced_app p1 p2)
| ((exist _ (None,A) p1),(exist _ (Some s,B) p2)) โ
exist _ (None,A++B++๐๐'_variables s)
(is_balanced_app p1 (is_balanced_app
p2(is_balanced_๐๐'_variables s)))
| ((exist _ (Some s,A) p1),(exist _ (None,B) p2)) โ
exist _ (None,A++B++๐๐'_variables s)
(is_balanced_app p1 (is_balanced_app
p2(is_balanced_๐๐'_variables s)))
| ((exist _ (Some s,A) p1),(exist _ (Some t,B) p2)) โ
exist _ (Some (sโฅt),A++B) (is_balanced_app p1 p2)
end.
Infix " โ' " := ๐'_par (at level 50).
The order relations on primed weak terms are simply imported
from those of weak terms.
Global Instance ๐'_inf : Smaller ๐' := fun u v โ ฯ{u} โค ฯ{v}.
Global Instance ๐'_equiv : Equiv ๐' := fun u v โ ฯ{u} โก ฯ{v}.
Global Instance ๐'_inf_PreOrder : PreOrder smaller.
Global Instance ๐'_equiv_Equivalence: Equivalence equiv.
Global Instance ๐'_inf_PartialOrder : PartialOrder equiv smaller.
Global Instance ๐'_equiv : Equiv ๐' := fun u v โ ฯ{u} โก ฯ{v}.
Global Instance ๐'_inf_PreOrder : PreOrder smaller.
Global Instance ๐'_equiv_Equivalence: Equivalence equiv.
Global Instance ๐'_inf_PartialOrder : PartialOrder equiv smaller.
Lemma variables_๐'_par (s t : ๐') :
๐'_variables (s โ' t) โ ๐'_variables s ++ ๐'_variables t.
Lemma variables_๐'_seq (s t : ๐') :
๐'_variables (s โ' t) โ ๐'_variables s ++ ๐'_variables t.
Global Instance ๐'_par_๐'_inf :
Proper (smaller ==> smaller ==> smaller) ๐'_par.
Global Instance ๐'_seq_๐'_inf :
Proper (smaller ==> smaller ==> smaller) ๐'_seq.
Global Instance ๐'_par_๐'_equiv :
Proper (equiv ==> equiv ==> equiv) ๐'_par.
Global Instance ๐'_seq_๐'_equiv :
Proper (equiv ==> equiv ==> equiv) ๐'_seq.
Lemma ๐'_par_comm e f : e โ' f โก f โ' e.
Lemma ๐'_par_idem e : e โ' e โก e.
Lemma ๐'_seq_assoc e f g : eโ'(f โ' g) โก (eโ'f)โ'g.
Lemma ๐'_par_assoc e f g : eโ'(f โ' g) โก (eโ'f)โ'g.
Lemma ๐'_seq_one_l e : ๐ญ' โ' e โก e.
Lemma ๐'_seq_one_r e : e โ' ๐ญ' โก e.
Lemma ๐'_par_inf e f : e โ' f โค e.
Lemma ๐'_par_one_l e : ๐ญ' โ' e โค (๐ญ' โ' e)โ'e.
Lemma ๐'_par_one_r e : ๐ญ' โ' e โค eโ'(๐ญ' โ' e).
Lemma ๐'_par_one_seq_par e f : ๐ญ' โ' (eโ'f) โก ๐ญ' โ' (e โ' f).
Lemma ๐'_par_one_seq_par_one e f: (๐ญ' โ' e)โ'(๐ญ'โ'f) โก ๐ญ'โ'(eโ'f).
Lemma ๐'_par_one_seq e f : (๐ญ' โ' e)โ'f โก fโ'(๐ญ'โ'e).
Lemma ๐'_par_one_par e f g: ((๐ญ' โ' e)โ'f)โ'g โก (๐ญ'โ'e)โ'(fโ'g).
Lemma ๐'_size_๐'_par e f : โฆe โ' fโฆ โค S (โฆeโฆ + โฆfโฆ).
Lemma ๐'_size_๐'_seq e f : โฆe โ' fโฆ โค S (โฆeโฆ + โฆfโฆ).
Lemma sub_identity_par_one (A : list (@X' X)) (p : is_balanced A) :
(exist _ (None,A) p) โก ๐ญ' โ' (exist _ (None,A) p).
End primed.
Infix " โ' " := ๐'_par (at level 50).
Infix " โ' " := ๐'_seq (at level 40).
Notation "๐ญ'" := ๐'_one.
Section language.
๐'_variables (s โ' t) โ ๐'_variables s ++ ๐'_variables t.
Lemma variables_๐'_seq (s t : ๐') :
๐'_variables (s โ' t) โ ๐'_variables s ++ ๐'_variables t.
Global Instance ๐'_par_๐'_inf :
Proper (smaller ==> smaller ==> smaller) ๐'_par.
Global Instance ๐'_seq_๐'_inf :
Proper (smaller ==> smaller ==> smaller) ๐'_seq.
Global Instance ๐'_par_๐'_equiv :
Proper (equiv ==> equiv ==> equiv) ๐'_par.
Global Instance ๐'_seq_๐'_equiv :
Proper (equiv ==> equiv ==> equiv) ๐'_seq.
Lemma ๐'_par_comm e f : e โ' f โก f โ' e.
Lemma ๐'_par_idem e : e โ' e โก e.
Lemma ๐'_seq_assoc e f g : eโ'(f โ' g) โก (eโ'f)โ'g.
Lemma ๐'_par_assoc e f g : eโ'(f โ' g) โก (eโ'f)โ'g.
Lemma ๐'_seq_one_l e : ๐ญ' โ' e โก e.
Lemma ๐'_seq_one_r e : e โ' ๐ญ' โก e.
Lemma ๐'_par_inf e f : e โ' f โค e.
Lemma ๐'_par_one_l e : ๐ญ' โ' e โค (๐ญ' โ' e)โ'e.
Lemma ๐'_par_one_r e : ๐ญ' โ' e โค eโ'(๐ญ' โ' e).
Lemma ๐'_par_one_seq_par e f : ๐ญ' โ' (eโ'f) โก ๐ญ' โ' (e โ' f).
Lemma ๐'_par_one_seq_par_one e f: (๐ญ' โ' e)โ'(๐ญ'โ'f) โก ๐ญ'โ'(eโ'f).
Lemma ๐'_par_one_seq e f : (๐ญ' โ' e)โ'f โก fโ'(๐ญ'โ'e).
Lemma ๐'_par_one_par e f g: ((๐ญ' โ' e)โ'f)โ'g โก (๐ญ'โ'e)โ'(fโ'g).
Lemma ๐'_size_๐'_par e f : โฆe โ' fโฆ โค S (โฆeโฆ + โฆfโฆ).
Lemma ๐'_size_๐'_seq e f : โฆe โ' fโฆ โค S (โฆeโฆ + โฆfโฆ).
Lemma sub_identity_par_one (A : list (@X' X)) (p : is_balanced A) :
(exist _ (None,A) p) โก ๐ญ' โ' (exist _ (None,A) p).
End primed.
Infix " โ' " := ๐'_par (at level 50).
Infix " โ' " := ๐'_seq (at level 40).
Notation "๐ญ'" := ๐'_one.
Section language.
Open Scope lang.
Context { X : Set }.
Context { X : Set }.
The function T ฯ t is the full language if the assignment ฯ
is test-compatible with the set of tests of the weak term t, or
the empty language otherwise.
The interpretation of the weak term (s,A) with respect to the
assignment ฯ is either the ฯ-interpretation of s (as a series
parallel term) if ฯ is test-compatible with A, or 0
otherwise.
Global Instance to_lang_๐ {ฮฃ} : semantics ๐ language X ฮฃ :=
fun ฯ t โ T ฯ t โฉ (match fst t with
| None โ 1
| Some u โ โฆuโงฯ
end).
fun ฯ t โ T ฯ t โฉ (match fst t with
| None โ 1
| Some u โ โฆuโงฯ
end).
The interpretation of a sequential product is the concatenation
of the interpretations.
Lemma ๐_prod_semantics ฮฃ u v (ฯ : ๐ฌ[Xโฮฃ]) : (โฆuโvโงฯ) โ (โฆuโงฯ) โ
(โฆvโงฯ).
The interpretation of a parallel product is the intersection
of the interpretations.
Lemma ๐_intersection_semantics ฮฃ u v (ฯ : ๐ฌ[Xโฮฃ]) : โฆuโvโงฯ โ (โฆuโงฯ) โฉ (โฆvโงฯ).
Both products are monotone.
Global Instance sem_incl_๐_seq :
Proper (ssmaller ==> ssmaller ==> ssmaller) (@๐_seq X).
Global Instance sem_incl_๐_inter :
Proper (ssmaller ==> ssmaller ==> ssmaller) (@๐_par X).
Global Instance sem_eq_๐_seq :
Proper (sequiv ==> sequiv ==> sequiv) (@๐_seq X).
Global Instance sem_eq_๐_inter :
Proper (sequiv ==> sequiv ==> sequiv) (@๐_par X).
Section ฮ.
Variable ฮฃ : Set.
Proper (ssmaller ==> ssmaller ==> ssmaller) (@๐_seq X).
Global Instance sem_incl_๐_inter :
Proper (ssmaller ==> ssmaller ==> ssmaller) (@๐_par X).
Global Instance sem_eq_๐_seq :
Proper (sequiv ==> sequiv ==> sequiv) (@๐_seq X).
Global Instance sem_eq_๐_inter :
Proper (sequiv ==> sequiv ==> sequiv) (@๐_par X).
Section ฮ.
Variable ฮฃ : Set.
ฮ transforms an assignment from X to ฮฃ into an
assignment from the duplicated alphabet to the same ฮฃ.
Definition ฮ (ฯ : ๐ฌ[Xโฮฃ]) : (๐ฌ[X'โฮฃ]) :=
fun x โ
match x with
| (a,true) โ ฯ a
| (a,false) โ (ฯ a)ยฐ
end.
fun x โ
match x with
| (a,true) โ ฯ a
| (a,false) โ (ฯ a)ยฐ
end.
ฮ preserves test-compatibility.