Чи це рішення, якщо мова, описана за кількістю випадків, є регулярною?


14

Відомо, що мова слів, що містять рівну кількість 0 і 1, не є регулярною, тоді як мова слів, що містять рівну кількість 001 і 100, є регулярною ( див. Тут ).

Враховуючи два слова w1,w2 , чи вирішується мова, якщо мова слів, що містять рівну кількість і є регулярною?w1w2


Чи можете ви навести інші приклади так визначених звичайних мов, крім та 01 i , або 0 i 1 і 10 i ? Як щодо прикладу алфавіту з 3 символами? 1i001i0i110i
— бабу

Якщо є суворим підсловом w 2 , є велика ймовірність, що мова порожня, тому регулярна. Я не знаю інших прикладів. w1w2
— sdcvvc

Я з легкістю підозрюю, що наведені вище приклади є єдиними, що дозволить вирішити проблему. Якщо ви вкажете лише дві підрядки, я б припустив, що це CF ... залежно від того, що ви можете вказати щодо випадків. Ви не чітко уточнюєте, що маєте на увазі під "описом кількості випадків".
— бабу

Орган питання досить точний ІМО.
— sdcvvc

1
поки що рішення для особливих випадків залежать від ідеї, що виникнення підрядків гарантує лише поодинокі випадки втручання w 2 . тому якимось чином припускаючи, що поточні відповіді є правильними [мені ще не зрозуміло], здається, що між w 1 , w 2 існує певне співвідношення , яке гарантує в середині сканування рядка, що можна бути в будь-якому стані "рівним" або "нерівним" ", але виключається лише максимальним кінцевим числом для" нерівного "випадку. w1w2w1w2
— vzn

Відповіді:


3

Враховуючи два слова , w 2 , чи вирішується, якщо мова L слів, що містять рівну кількість w 1 і w 2w1w2Lw1w2 є регулярною?

Спочатку кілька визначень:
їх можна зробити більш короткими, а позначення можна вдосконалити, якщо вони будуть використані в доказуванні. Це лише перший проект.

Давши два слова і w 2 , ми скажемо, що: w1w2

  • завжди відбуваєтьсяз w 2 , відзначається w 1 ◃ w 2w1 w2w1◃w2 , iff

    1. для будь-якого рядка такого, що s = x w 2 y з ∣ss=xw2y і | х | 0 , | х | 1 | , | у | 0 , | у | 1 | ≥ 1 відбувається інше розкладання s = x ′ w 1 y ′ . Примітка: Умова, що х і∣x∣,∣y∣ ≥∣w1∣+∣w2∣|x|0,|x|1|,|y|0,|y|1|≥1s=x′w1y′
      xyкожен містить щонайменше 0 і 1, необхідний патологічний випадок (знайдений @sdcvvc): , w 2 = v 1 i + j і y ∈ 1 ∗w1=1i0w2=v1i+jy∈1∗ та його симетричні варіанти.
    2. є рядок з ∣ xs=xw2y таким чином, що існує максимум одне розкладання s = x ′ w 1 y ′∣x∣,∣y∣ ≥∣w1∣+∣w2∣s=x′w1y′
  • завжди триваєз w 2 , відзначено w 1 ◃ ▹w1 w2 , якщо кожен завжди відбувається з іншим,w1◃▹w2

  • і w 2 відбуваються незалежно, відзначається w 1 ▹ ◃w1w2 , якщо ні один не трапляється з іншим,w1▹◃w2

  • завжди відбувається т раз або більшеніж ш 2 , відзначено ш 1 ◃ м ш 2 , якщо для будь-якого рядка s такещо s = х ш 2 у с | х | , | у | | ≥ ∣ w 1 ∣ + ∣ w 2 ∣ є m інші розклади s = x i w 1 yw1 mw2w1◃mw2ss=xw2y∣x∣, ∣y∣| ≥∣w1∣+∣w2∣ms=xiw1yiдля такий, що i ≠ j означає x i ≠ x j .i∈[1,m]i≠jxi≠xj

Ці визначення побудовані так, що ми можемо ігнорувати те, що відбувається на кінцях рядка, де, як передбачається, відбудуться і w 2 . Прикордонні ефекти в кінці рядка потрібно аналізувати окремо, але вони являють собою обмежену кількість випадків (насправді я думаю, що я забув один-два таких крайових підпункти у своєму першому аналізі нижче, але це насправді не має значення). Визначення сумісні з перекриттям подій.w1w2

Розглянути 4 основні випадки (ігнорування симетрії між і w 2 ):w1w2

  1. Обидва слова обов'язково поєднуються разом, за винятком випадків на кінцях рядка. Це стосується лише пар форми 1 i 0 і 01 i , або 0 i 1 і 10 i . Це легко розпізнається за допомогоюкінцевого автомата,який перевіряє наявність одиноких випадків на обох кінцях рядка, який слід розпізнати, щоб переконатися, що є одиночне виникнення на обох кінцях або на жодному з них. Існує також вироджений випадок, коли w 1 = w 2 : тоді мова L, очевидно, регулярна.w1◃▹w2
    1i001i0i110iw1=w2

  2. w1◃w2, but not w2◃w1
    One of the 2 words cannot occur without the other, but the converse is not true (except possibly at the ends of the string). This happens when:

    • w1 is a substring of w2:then a finite automaton can just check that w1 does not occur outside an instance of w2.

    • і w 2 = v 1 j для деякого слова v ∈ { 0 , 1 } ∗ , v ≠ 01 i : тоді кінцевий автомат перевіряє, як і в попередньому випадку, що w 1 не трапляється відокремленим від w 2 . Однак автомат дозволяє рахувати один додатковий екземпляр w 1, який дозволить прийняти, якщо w 2w1=1i0w2=v1jv∈{0,1}∗v≠01iw1w2w1w2є суфіксом рядка. Є три інші симетричні випадки (1-0 симетрія та ліво-права симетрія).

  3. w1◃2w2
    One of the 2 words occurs twice in the other. That can be recognized by an a finite automation that checks that the smaller word never occurs in the string. The is also a slightly more complex variant that combines the two variations of case 2. In this case the automaton checks that the smaller string 1i0 never occurs, except possibly as part of v in the larger one v1j coming as a suffix of the string (and 3 other cases by symetry).

  4. w1▹◃w2
    The 2 words can occur independently of each other. We build a generalized-sequential-machine (gsm) G that output a when it recognizes an occurrence of w1 and b when recognizing an occurrence of w2, and forgets everything else. The language L is regular only if the language G(L) is regular. But G(L)={w∈{a,b}∗∣ ∣w∣a=∣w∣b} which is clearly context-free and not regular. Hence L is not regular.
    Actually we have L=G−1(G(L)). Since regular languages and context-free languages are closed under gsm mapping and inverse gsm mapping, we know also that L is context free.

One way to organize a formal proof could be the following. First build a PDA that recognizes the language. Actually it can be done with a 1-counter machine, but it is easier to have two stack symbols to avoid duplicating the finite control. Then, for the cases where it should be a FA, show that the counter can be bounded by a constant that depends only on the two words. For the other cases show that the counter can reach any arbitrary value. Of course, the PDA should be organized so that the proofs are easy enough to carry.

Representing the FA as a 2-stack-symbols PDA is probably the simplest representation for it. In the non-regular case, the finite control part of the PDA is the same as that of the GSM in the proof sketch above. Instead of outputting a's and b's like the GSM, the PDA counts the difference in number with the stack.


I had a question about context-freeness in the case of three words. I deleted it when I realised it could be analyzed similarly. I had first thought that proving non-CFness would make an original exercise, but the GSM ruins it.
— babou

2
It is not clear what do you mean by "occur independently of each other", "come necessarily together" etc. Please write formal definitions instead, and prove that they cover all cases.
— sdcvvc

1
I am not sure what you are asking, and what level of formalization you need, for what purpose. I realized that analyzing by hand possible relations of the two words is not garanteed to be correct, and does not matter anyway. What matters is whether an occurence of one word can exist without creating at the same time an occurence (or several) of the other word. The details do not matter as it will always be localized and thus manageable finitely. The two ends do not matter either as tey are localized too. Even overlaps of occurrences do not matter since they can only be finitely many in 1 place
— babou

1
I asked you about precise definitions of the terms mentioned in the comment. Thank you for writing them. Was I supposed to guess them previously? Anyway, you seem to claim that 0i1◃▹10i. This does not satisfy condition 1. of the definition of "w1 always occurs with w2", since there is no occurrence of 10i in s=0M0i11M.
— sdcvvc

Sorry, I did not mean to make you guess. It only took me time to understand what exactly you wanted. My failing only. Regarding your counter example, you are correct. But for me it only means that I have to be a little bit more careful about telomeres, in the definition of the relations. I defined them too quickly, but 0M or 1M do not convey much information in this context. This is really a boundary pathological example within a pathological case, that actually cannot occur when more than 2 symbols are used. I just do not believe it changes anything.
— babou
Використовуючи наш веб-сайт, ви визнаєте, що прочитали та зрозуміли наші Політику щодо файлів cookie та Політику конфіденційності.
Licensed under cc by-sa 3.0 with attribution required.