Library LangAlg.to_lang_witness
In most this module, we establish the following lemma: for every
series-parallel term u, there exists a word w and an
interpretation ฯ such that for every other ๐๐ term v, the graph
of v is larger than the graph of u if and only if w belongs to
the ฯ-interpretation of v. This lemma will allow us to prove
completeness of our axiomatization with respect to language
interpretations.
In the second part of the module, we generalise the result to weak
terms and primed weak terms.
In this module, we call a list of natural numbers a sequence is
it of the form [a(0);a(1);...;a(n)] such that for every i<n,
a(i)+1=a(i+1). Equivalently, they are those sequences produced using
the function seq.
Let us fix a term u and a set of variables ๐ for this section.
We write the reachability relation in the graph of u as โค.
To make some definitions easier, we define the function co_nth
i l. This function returns the smallest index j such that the
jth element of the list l is equal to i.
The following simple observation follows easily from
co_nth_In.
We will mainly apply this function on lists without
duplicates. In such lists, the function is injective.
Lemma nth_NoDup {A} i j l (d1 d2 : A) :
NoDup l โ i < length l โ j < length l โ
nth i l d1 = nth j l d2 โ i = j.
NoDup l โ i < length l โ j < length l โ
nth i l d1 = nth j l d2 โ i = j.
In lists with no duplicates, we can prove the dual of lemma
co_nth_In.
Vert is a list containing exactly the vertices of the graph of
u, without any duplication, and listed in increasing order.
Definition Vert :=
filter (fun i โ inb i (vertices u)) (seq 0 (S (ln u))).
Lemma Vert_NoDup : NoDup Vert.
Lemma Vert_vertices : Vert โ vertices u.
filter (fun i โ inb i (vertices u)) (seq 0 (S (ln u))).
Lemma Vert_NoDup : NoDup Vert.
Lemma Vert_vertices : Vert โ vertices u.
The word w_u will be the witness we announced earlier. It is
defined as the sequence of natural numbers from 0 to 2 ร N -
1.
The function ฮณ finds the index of a vertex in the list
Vert. It provides us with a bijection between the vertices of u
and the numbers from 0 to N-1.
Definition ฮณ i := co_nth i Vert.
Lemma ฮณ_inj i j :
i โ (vertices u) โ j โ (vertices u) โ ฮณ i = ฮณ j โ i = j.
Lemma ฮณ_bij n : n < N โ โ i, i โ (vertices u) โง ฮณ i = n.
Lemma ฮณ_inj i j :
i โ (vertices u) โ j โ (vertices u) โ ฮณ i = ฮณ j โ i = j.
Lemma ฮณ_bij n : n < N โ โ i, i โ (vertices u) โง ฮณ i = n.
ฮณ is order preserving.
Moreover, we know that the ordering of natural numbers contains
the path ordering of vertices. Therefore using the previous lemma we
get the following monotonicity property.
The following two observations are fairly self evident.
The next few lemmas are simple observations on sequences and on
the function co_nth.
Lemma seq_app i k l :
seq i (k+l) = seq i k ++ seq (i+k) l.
Lemma seq_last i l : seq i (S l) = seq i l ++ [i+l].
Lemma rev_seq n1 l1 n2 l2 : seq n1 l1 = rev (seq n2 l2)
โ l1 = l2 โง (n1 = n2 โง l1 = 1 โจ l1 = 0).
Lemma firstn_seq n m l :
m โค l โ firstn m (seq n l) = seq n m.
Lemma skipn_seq n m l :
m โค l โ skipn m (seq n l) = seq (n+m) (l-m).
Lemma co_nth_app_right i l m :
ยฌ i โ l โ i โ m โ co_nth i (l++m) = length l + co_nth i m.
Lemma co_nth_app_left i l m :
i โ l โ co_nth i (l++m) = co_nth i l.
seq i (k+l) = seq i k ++ seq (i+k) l.
Lemma seq_last i l : seq i (S l) = seq i l ++ [i+l].
Lemma rev_seq n1 l1 n2 l2 : seq n1 l1 = rev (seq n2 l2)
โ l1 = l2 โง (n1 = n2 โง l1 = 1 โจ l1 = 0).
Lemma firstn_seq n m l :
m โค l โ firstn m (seq n l) = seq n m.
Lemma skipn_seq n m l :
m โค l โ skipn m (seq n l) = seq (n+m) (l-m).
Lemma co_nth_app_right i l m :
ยฌ i โ l โ i โ m โ co_nth i (l++m) = length l + co_nth i m.
Lemma co_nth_app_left i l m :
i โ l โ co_nth i (l++m) = co_nth i l.
In particular we can use ฯ to define w_u.
This lemma is almost tautological, but it turns out to come in
handy several times.
We now define the witnessing interpretation. For every edge
(i,a,j) in the graph of u, the word ฯ i j is in ฯ a.
Furthermore, if a belongs to the set ๐, then the empty word is
in ฯ a.
Definition ฯ : ๐ฌ[Xโnat] :=
fun a w โ
(a โ ๐ โง w = [])
โจ (โ i j, (i,a,j) โ (edges (๐ฒ u)) โง w = ฯ i j).
fun a w โ
(a โ ๐ โง w = [])
โจ (โ i j, (i,a,j) โ (edges (๐ฒ u)) โง w = ฯ i j).
A simple observation we can make is that for any letter a the
length of any word in ฯ a is even. This can be neatly extended to
the language of any series-parallel term according to ฯ.
This result mainly relies on the fact that the seq function is
essentially bijective.
If a word in the ฯ-interpretation of some term v is a
sequence, then it can be expressed as ฯ i j, for some vertices
i,j such that iโคj.
Lemma seq_lang_vertices (v : ๐๐ X) n l :
seq n l โต (โฆvโง ฯ) โ
โ i j, i โ (vertices u) โง j โ (vertices u) โง i โค j
โง seq n l = ฯ i j.
seq n l โต (โฆvโง ฯ) โ
โ i j, i โ (vertices u) โง j โ (vertices u) โง i โค j
โง seq n l = ฯ i j.
For every pair of vertices iโคj, if ฯ i j belongs to the
ฯ-interpretation of a sequential product v1โจพv2, then there
exists a vertex k between i and j, such that ฯ i k belongs
to the language of v1 and ฯ k j to that of v2. This lemma is
critical in the proof of the main lemma to make the induction case
for products go through.
Lemma seq_lang_prod (v1 v2 : ๐๐ X) i j :
i โ (vertices u) โ j โ (vertices u) โ i โค j โ
ฯ i j โต (โฆv1โจพv2โง ฯ) โ
โ k, i โค k โค j โง k โ (vertices u) โง ฯ i k โต (โฆv1โง ฯ) โง ฯ k j โต (โฆv2โง ฯ).
i โ (vertices u) โ j โ (vertices u) โ i โค j โ
ฯ i j โต (โฆv1โจพv2โง ฯ) โ
โ k, i โค k โค j โง k โ (vertices u) โง ฯ i k โต (โฆv1โง ฯ) โง ฯ k j โต (โฆv2โง ฯ).
By a simple induction on v, one can check that the empty word
belongs to the language of v exactly if all of the variables in
v belong to the set ๐.
To prove that from the fact that w_u is in the language โฆvโง
ฯ we can build a morphism from v to u, we need to
strengthen the statement slightly to make the induction work
better. The statement that turns out to be sufficient is the
following: if ฯ i j belongs to โฆvโง ฯ, then there is an
internal premorphism from v to u that must in addition map
0 to i and ln v to j.
Lemma lang_ฯ_morph (v :๐๐ X) i j :
i โ (vertices u) โ j โ (vertices u) โ i โค j โ
ฯ i j โต (โฆvโง ฯ) โ
โ ฯ, ฯ 0 = i โง ฯ (ln v) = j โง ๐ โจ (๐ฒ v) -{ฯ}โ (๐ฒ u) โง internal_map ฯ (๐ฒ v) (๐ฒ u).
i โ (vertices u) โ j โ (vertices u) โ i โค j โ
ฯ i j โต (โฆvโง ฯ) โ
โ ฯ, ฯ 0 = i โง ฯ (ln v) = j โง ๐ โจ (๐ฒ v) -{ฯ}โ (๐ฒ u) โง internal_map ฯ (๐ฒ v) (๐ฒ u).
For the converse direction, we use the following lemma, also
proved by induction on the term v.
Lemma premorphism_ฯ (v : ๐๐ X) ฯ :
๐ โจ ๐ฒ v -{ฯ}โ ๐ฒ u โ internal_map ฯ (๐ฒ v) (๐ฒ u) โ
ฯ (ฯ 0) (ฯ (ln v)) โต (โฆvโง ฯ).
๐ โจ ๐ฒ v -{ฯ}โ ๐ฒ u โ internal_map ฯ (๐ฒ v) (๐ฒ u) โ
ฯ (ฯ 0) (ฯ (ln v)) โต (โฆvโง ฯ).
With the two technical lemmas we just proved, the proof of the
main result of this module becomes very simple.
Theorem ฯ_spec (v : ๐๐ X) :
w_u โต (โฆvโง ฯ) โ ๐ โจ ๐ฒ u โฒ ๐ฒ v.
End s.
Section w.
w_u โต (โฆvโง ฯ) โ ๐ โจ ๐ฒ u โฒ ๐ฒ v.
End s.
Section w.
Weak terms
Nothing deep happens here, we just apply the results and constructions above to get a similar theorem.
Variable X : Set.
Variable dec_X : decidable_set X.
Definition word (u : ๐ X) :=
match u with
| (None,_) โ []
| (Some u,_) โ w_u u
end.
Definition ฯ' (u : ๐ X) : ๐ฌ[Xโnat] :=
match u with
| (None,A) โ fun a w โ a โ A โง w = []
| (Some u,A) โ ฯ u A
end.
Lemma ฯ'_nil u a : ฯ' u a [] โ a โ (snd u).
Lemma word_of_term_correct u v :
word u โต (โฆvโง(ฯ' u)) โ ๐ฒw u โฒ ๐ฒw v.
Corollary not_incl_witness u :
โ w (ฯ : ๐ฌ[Xโnat]), โ v, ๐ฒw u โฒ ๐ฒw v โ w โต (โฆvโงฯ).
End w.
Section t.
Variable dec_X : decidable_set X.
Definition word (u : ๐ X) :=
match u with
| (None,_) โ []
| (Some u,_) โ w_u u
end.
Definition ฯ' (u : ๐ X) : ๐ฌ[Xโnat] :=
match u with
| (None,A) โ fun a w โ a โ A โง w = []
| (Some u,A) โ ฯ u A
end.
Lemma ฯ'_nil u a : ฯ' u a [] โ a โ (snd u).
Lemma word_of_term_correct u v :
word u โต (โฆvโง(ฯ' u)) โ ๐ฒw u โฒ ๐ฒw v.
Corollary not_incl_witness u :
โ w (ฯ : ๐ฌ[Xโnat]), โ v, ๐ฒw u โฒ ๐ฒw v โ w โต (โฆvโงฯ).
End w.
Section t.
Primed weak terms
For primed weak terms, another problem arises. Because of the way we have set up the translation form terms and expressions into weak terms, it is not sufficient to have a lemma of the shape
This is the witnessing interpretation. It works mostly like the
one we built for series-parallel terms, but we make use of the
boolean in the letters from the duplicated alphabet: if (i,a,j) is
an edge, then ฯ i j is in the language ฯฮ (a,true), and its
mirror image is in the language of ฯฮ (a,false).
Definition ฯฮ (t:๐') : ๐ฌ[Xโnat] :=
fun a w โ
((a,true) โ (snd (ฯ{t})) โง w = [])
โจ (โ u, fst (ฯ{t}) = Some u
โง (โ i j,
((i,(a,true),j) โ (edges (๐ฒ u))
โง w = ฯ u i j)
โจ
((i,(a,false),j) โ (edges (๐ฒ u))
โง w = rev (ฯ u i j)))).
fun a w โ
((a,true) โ (snd (ฯ{t})) โง w = [])
โจ (โ u, fst (ฯ{t}) = Some u
โง (โ i j,
((i,(a,true),j) โ (edges (๐ฒ u))
โง w = ฯ u i j)
โจ
((i,(a,false),j) โ (edges (๐ฒ u))
โง w = rev (ฯ u i j)))).
First, we make some observations about ฯฮ.
Lemma ฯฮ_nil t a : ฯฮ t a [] โ (a,true) โ (snd (ฯ{t})).
Lemma ฮ_ฯฮ_nil t a :
ฮ (ฯฮ t) a [] โ a โ (snd (ฯ{t})).
Lemma lang_ฯฮ_even A u (v : ๐๐ X') w (p : is_balanced A):
wโต(โฆvโง(ฮ (ฯฮ (exist _ (Some u,A) p)))) โ
โ k, length w = 2 ร k.
Lemma ฮ_ฯฮ_nil t a :
ฮ (ฯฮ t) a [] โ a โ (snd (ฯ{t})).
Lemma lang_ฯฮ_even A u (v : ๐๐ X') w (p : is_balanced A):
wโต(โฆvโง(ฮ (ฯฮ (exist _ (Some u,A) p)))) โ
โ k, length w = 2 ร k.
Lemma ฯฮ_ฯ_subword t A x i j (p: is_balanced A) :
ฮ (ฯฮ (exist _ (Some t,A) p)) x (ฯ t i j) โ ฯ' (Some t,A) x (ฯ t i j).
ฮ (ฯฮ (exist _ (Some t,A) p)) x (ฯ t i j) โ ฯ' (Some t,A) x (ฯ t i j).
Hence we can transfer the presence of a witness in โฆvโง(ฮ (ฯฮ
u)) to the presence of the witness in the interpretation we set up
for weak terms.
Lemma witness_ฮ (u v : ๐') :
(word (ฯ{u})) โต (โฆฯ{v}โง (ฮ (ฯฮ u)))
โ
(word (ฯ{u})) โต (โฆฯ{v}โง (ฯ' (ฯ{u}))).
(word (ฯ{u})) โต (โฆฯ{v}โง (ฮ (ฯฮ u)))
โ
(word (ฯ{u})) โต (โฆฯ{v}โง (ฯ' (ฯ{u}))).
We now prove our witnessing lemma by putting together lemmas
witness_ฮ and word_of_term_correct.