Quotient of a formal language: Difference between revisions
r |
imported>Edwin of Northumbria Described term in definition. |
||
| Line 1: | Line 1: | ||
In [[mathematics]] and [[computer science]], the '''right quotient''' (or simply '''quotient''') of a [[formal language|language]] <math>L_1</math> with respect to language <math>L_2</math> is the language consisting of [[string (computer science)|strings]] | In [[mathematics]] and [[computer science]], the '''right quotient''' (or simply '''quotient''') of a [[formal language|language]] <math>L_1</math> with respect to language <math>L_2</math> is the language consisting of [[string (computer science)|strings]] <math>w</math> such that <math>wx</math> is in <math>L_1</math> for some string <math>x</math> in {{nowrap|<math>L_2</math>,}} where <math>L_1</math> and <math>L_2</math> are defined on the same [[alphabet (formal languages)|alphabet]] {{nowrap|<math>\Sigma</math>.}} Formally:<ref name="Pin">{{cite book |last=Pin |first=J-É. |author-link=Jean-Éric Pin |translator-last=Howie |translator-first=A. |date=1986 |title=Varieties of Formal Languages |location=New York |publisher=Plenum Press |isbn=0306422948 |pages=14}}</ref><ref name="Linz">{{cite book |last1=Linz |first1=Peter |last2=Rodger |first2=Susan H. |author-link2=Susan H. Rodger |name-list-style=amp |date=2023 |title=An Introduction to Formal Languages and Automata |edition=Seventh |location=Burlington, MA |publisher=Jones & Bartlett Learning |isbn=978-1284231601 |pages=112–117}} ([https://books.google.com/books?id=hsxDiWvVdBcC&dq=right+quotient+automata&pg=PA104 Fifth ed.] at [[Google Books]])</ref> | ||
<math display="block">L_1 / L_2 = \{w \in \Sigma^* \mid wL_2 \cap L_1 \neq \varnothing\} = \{w \in \Sigma^* \mid \exists x \in L_2 \ \colon\ wx \in L_1\}</math> | |||
where <math>\Sigma^*</math> is the [[Kleene star]] on <math>\Sigma</math>, <math>wL_2</math> is the language formed by [[Concatenation|concatenating]] <math>w</math> with each element of {{nowrap|<math>L_2</math>,}} and <math>\varnothing</math> is the [[empty set]]. | |||
<math | |||
In other words, | In other words, for all strings in <math>L_1</math> that have a [[Substring#Suffix|suffix]] in <math>L_2</math>, the suffix (right part of the string) is removed. | ||
Note that the | Similarly, the '''left quotient''' of <math>L_1</math> with respect to <math>L_2</math> is the language consisting of strings <math>w</math> such that <math>xw</math> is in <math>L_1</math> for some string <math>x</math> in <math>L_2</math>. Formally: | ||
<math display="block">L_2 \backslash L_1 = \{w \in \Sigma^* \mid L_2w \cap L_1 \neq \varnothing\} = \{w \in \Sigma^* \mid \exists x\in L_2 \ \colon\ xw \in L_1\}</math> | |||
In other words, for all strings in <math>L_1</math> that have a [[Substring#Prefix|prefix]] in <math>L_2</math>, the prefix (left part of the string) is removed. | |||
Note that the [[operand]]s of <math>\backslash</math> are in reverse order, so that <math>L_2</math> preceeds <math>L_1</math>. | |||
The right and left quotients of <math>L_1</math> with respect to <math>L_2</math> may also be written as <math>L_1 L_2^{-1}</math> and <math>L_2^{-1} L_1</math> respectively.<ref name="Pin"/><ref name="Simovici">{{cite book |last=Simovici |first=Dan A. |date=2024 |title=Introduction to the Theory of Formal Languages |location=Singapore |publisher=World Scientific |isbn=978-9811294013 |doi=10.1142/13862 |pages=11–12}}</ref> | |||
==Example== | ==Example== | ||
| Line 18: | Line 24: | ||
<math display="block">L_2 = \{ b^i c^j \mid i,j \ge 0 \}.</math> | <math display="block">L_2 = \{ b^i c^j \mid i,j \ge 0 \}.</math> | ||
If an element of <math>L_1</math> is split into two parts, then the right part will be in <math>L_2</math> if and only if the split occurs somewhere after the final {{nowrap|<math>a</math>.}} Assuming this is the case, if the split occurs before the first <math>c</math> then <math>0 \le i \le n</math> and {{nowrap|<math>j=n</math>}}, otherwise <math>i=0</math> and {{nowrap|<math>0 \le j \le n</math>.}} For instance: | |||
<math display="block">\{\ a^p b^q c^r \ \mid\ | |||
<math>aa \mid bbcc \ \ (n=2, i=j=2)</math> | |||
<math>aaab \mid bbccc \ \ (n=3, i=2, j=3)</math> | |||
<math>aabbcc \mid \epsilon \ \ (n=2, i=j=0)</math> | |||
where <math>\epsilon</math> is the [[empty string]]. | |||
Thus, the left part will be either <math>a^n b^{n-i}</math> or {{nowrap|<math>a^n b^n c^{n-j}</math>}} {{nowrap|<math>(0 \le i,j \le n</math>),}} and <math>L_1 / L_2</math> can be written as: | |||
<math display="block">\{\ a^p b^q c^r \ \mid\ (p \ge q \text{ and } r = 0) \ \ \text{or} \ \ p = q \ge r \ \ ; \ \ p, q, r \ge 0 \ \}.</math> | |||
==Basic properties== | |||
If <math>L, L_1, L_2</math> are languages over the same alphabet then:<ref name="Simovici"/> | |||
<math display="block">(L_1 \cup L_2) / L \ = \ L_1 / L \ \cup \ L_2 / L</math> | |||
<math display="block">(L_1 \cup L_2) \backslash L \ = \ L_1 \backslash L \ \cup \ L_2 \backslash L</math> | |||
<math display="block">(L_1 \cap L_2) / L \ \subseteq \ L_1 / L \ \cap \ L_2 / L</math> | |||
<math display="block">(L_1 \cap L_2) \backslash L \ \subseteq \ L_1 \backslash L \ \cap \ L_2 \backslash L</math> | |||
<math display="block">L \backslash (L_1 \cup L_2) \ = \ L \backslash L_1 \ \cup \ L \backslash L_2</math> | |||
<math display="block">L \backslash (L_1 \cap L_2) \ \subseteq \ L \backslash L_1 \ \cap \ L \backslash L_2</math> | |||
<math display="block">L_1 / L - L_2 / L \ \subseteq \ (L_1 - L_2) / L</math> | |||
<math display="block">L \backslash L_1 - L \backslash L_2 \ \subseteq \ L \backslash (L_1 - L_2) </math> | |||
===Example proof=== | |||
As an example, the third property is proved as follows: | |||
If {{nowrap|<math>w \in (L_1 \cap L_2) / L</math>,}} there exists <math>x \in L</math> such that {{no wrap|<math>wx \in L_1 \cap L_2</math>.}} Since then <math>wx \in L_1</math> and {{nowrap|<math>wx \in L_2</math>,}} it must be that {{nowrap|<math>w \in L_1 / L \cap L_2 / L</math>.}} Conversely, let <math>w \in L_1 / L</math> and {{nowrap|<math>w \in L_2 / L</math>,}} then there exists <math>x_1, x_2 \in L</math> such that <math>wx_1 \in L_1</math> and <math>wx_2 \in L_2</math> (given {{nowrap|<math>w</math>,}} if <math>L_1 \neq L_2</math> then <math>x_1,x_2</math> may differ). Now <math>wx_1 \in L_1 \cap \ L_2</math> and <math>wx_2 \in L_1 \cap \ L_2</math> only if {{nowrap|<math>x_1 = x_2</math>,}} hence {{nowrap|<math>(L_1 \cap L_2) / L \subseteq L_1 / L \cap L_2 / L</math>.}} | |||
==Relationship between right and left quotients== | |||
The right and left quotients of languages <math>L_1</math> and <math>L_2</math> are related through the language [[Formal language#Operations on languages|reversals]] <math>L_1^R</math> and <math>L_2^R</math> by the equalities:<ref name="Simovici"/> | |||
<math display="block">L_1 / L_2 = (L_2^R \backslash L_1^R)^R</math> | |||
<math display="block">L_2 \backslash L_1 = (L_1^R / L_2^R)^R</math> | |||
===Proof=== | |||
To prove the first equality, let {{nowrap|<math>w \in L_1 / L_2</math>.}} Then there exists <math>x \in L_2</math> such that {{nowrap|<math>wx \in L_1</math>.}} Therefore, there must exist <math>y \in L_2^R</math> such that {{nowrap|<math>yw^R \in L_1^R</math>,}} hence by definition {{nowrap|<math>w^R \in L_2^R \backslash L_1^R</math>.}} It follows that {{nowrap|<math>w \in (L_2^R \backslash L_1^R)^R</math>,}} and so {{nowrap|<math>L_1 / L_2 = (L_2^R \backslash L_1^R)^R</math>.}} | |||
The second equality is proved in a similar manner. | |||
==Other properties== | |||
Some common closure properties of the quotient operation include: | Some common closure properties of the quotient operation include: | ||
Latest revision as of 09:03, 1 July 2025
In mathematics and computer science, the right quotient (or simply quotient) of a language with respect to language is the language consisting of strings such that is in for some string in , where and are defined on the same alphabet . Formally:[1][2]
where is the Kleene star on , is the language formed by concatenating with each element of , and is the empty set.
In other words, for all strings in that have a suffix in , the suffix (right part of the string) is removed.
Similarly, the left quotient of with respect to is the language consisting of strings such that is in for some string in . Formally:
In other words, for all strings in that have a prefix in , the prefix (left part of the string) is removed.
Note that the operands of are in reverse order, so that preceeds .
The right and left quotients of with respect to may also be written as and respectively.[1][3]
Example
Consider and
If an element of is split into two parts, then the right part will be in if and only if the split occurs somewhere after the final . Assuming this is the case, if the split occurs before the first then and , otherwise and . For instance:
where is the empty string.
Thus, the left part will be either or ), and can be written as:
Basic properties
If are languages over the same alphabet then:[3]
Example proof
As an example, the third property is proved as follows:
If , there exists such that Template:No wrap Since then and , it must be that . Conversely, let and , then there exists such that and (given , if then may differ). Now and only if , hence .
Relationship between right and left quotients
The right and left quotients of languages and are related through the language reversals and by the equalities:[3]
Proof
To prove the first equality, let . Then there exists such that . Therefore, there must exist such that , hence by definition . It follows that , and so .
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.