Quotient of a formal language

From HandWiki

In mathematics and computer science, the right quotient (or simply quotient) of a language L1 with respect to language L2 is the language consisting of strings w such that wx is in L1 for some string x in L2, where L1 and L2 are defined on the same alphabet Σ. Formally:[1][2]

L1/L2={w∈Σ*∣wL2∩L1≠∅}={w∈Σ*∣∃x∈L2 : wx∈L1}

where Σ* is the Kleene star on Σ, wL2 is the language formed by concatenating w with each element of L2, and ∅ is the empty set.

In other words, for all strings in L1 that have a suffix in L2, the suffix (right part of the string) is removed.

Similarly, the left quotient of L1 with respect to L2 is the language consisting of strings w such that xw is in L1 for some string x in L2. Formally:

L2∖L1={w∈Σ*∣L2w∩L1≠∅}={w∈Σ*∣∃x∈L2 : xw∈L1}

In other words, for all strings in L1 that have a prefix in L2, the prefix (left part of the string) is removed.

Note that the operands of ∖ are in reverse order, so that L2 preceeds L1.

The right and left quotients of L1 with respect to L2 may also be written as L1L2−1 and L2−1L1 respectively.[1][3]

Example

Consider L1={anbncn∣n≥0} and L2={bicj∣i,j≥0}.

If an element of L1 is split into two parts, then the right part will be in L2 if and only if the split occurs somewhere after the final a. Assuming this is the case, if the split occurs before the first c then 0≤i≤n and j=n, otherwise i=0 and 0≤j≤n. For instance:

aa∣bbcc  (n=2,i=j=2)

aaab∣bbccc  (n=3,i=2,j=3)

aabbcc∣ϵ  (n=2,i=j=0)

where ϵ is the empty string.

Thus, the left part will be either anbn−i or anbncn−j (0≤i,j≤n), and L1/L2 can be written as:

{ apbqcr ∣ (p≥q and r=0)  or  p=q≥r  ;  p,q,r≥0 }.

Basic properties

If L,L1,L2 are languages over the same alphabet then:[3]

(L1∪L2)/L = L1/L ∪ L2/L (L1∪L2)∖L = L1∖L ∪ L2∖L

(L1∩L2)/L ⊆ L1/L ∩ L2/L (L1∩L2)∖L ⊆ L1∖L ∩ L2∖L

L∖(L1∪L2) = L∖L1 ∪ L∖L2 L∖(L1∩L2) ⊆ L∖L1 ∩ L∖L2

L1/L−L2/L ⊆ (L1−L2)/L L∖L1−L∖L2 ⊆ L∖(L1−L2)

Example proof

As an example, the third property is proved as follows:

If w∈(L1∩L2)/L, there exists x∈L such that wx∈L1∩L2. Since then wx∈L1 and wx∈L2, it must be that w∈L1/L∩L2/L. Conversely, let w∈L1/L and w∈L2/L, then there exists x1,x2∈L such that wx1∈L1 and wx2∈L2 (given w, if L1≠L2 then x1,x2 may differ). Now wx1∈L1∩ L2 and wx2∈L1∩ L2 only if x1=x2, hence (L1∩L2)/L⊆L1/L∩L2/L.

For instance, let L1={aab,bbb}, L2={abb,bbb}, L={ab,bb}.

Then L1∩L2={bbb}, hence (L1∩L2)/L={b}.

Also L1/L={a,b} and L2/L={a,b}, hence L1/L∩L2/L={a,b}.

Relationship between right and left quotients

The right and left quotients of languages L1 and L2 are related through the language reversals L1R and L2R by the equalities:[3]

L1/L2=(L2R∖L1R)R L2∖L1=(L1R/L2R)R

Proof

To prove the first equality, let w∈L1/L2. Then there exists x∈L2 such that wx∈L1. Therefore, there must exist y∈L2R such that ywR∈L1R, hence by definition wR∈L2R∖L1R. It follows that w∈(L2R∖L1R)R, and so L1/L2=(L2R∖L1R)R.

The second equality is proved in a similar manner.

Other properties

Some common closure properties of the quotient operation include:

  • The quotient of a regular language with any other language is regular.
  • The quotient of a context free language with a regular language is context free.
  • The quotient of two context free languages can be any recursively enumerable language.
  • The quotient of two recursively enumerable languages is recursively enumerable.

These closure properties hold for both left and right quotients.

See also

References

  1. ↑ 1.0 1.1 Pin, J-É. (1986). Varieties of Formal Languages. New York: Plenum Press. pp. 14. ISBN 0306422948. 
  2. ↑ Linz, Peter; Rodger, Susan H. (2023). An Introduction to Formal Languages and Automata (Seventh ed.). Burlington, MA: Jones & Bartlett Learning. pp. 112–117. ISBN 978-1284231601.  (Fifth ed. at Google Books)
  3. ↑ 3.0 3.1 3.2 Simovici, Dan A. (2024). Introduction to the Theory of Formal Languages. Singapore: World Scientific. pp. 11–12. doi:10.1142/13862. ISBN 978-9811294013.