I need help with two questions about Automata. Follow then
1.) build a pushdown automata that recognizes the following language:
L = {a^mb^n / m <= n}
2.) Considering the MT below, give the settings for the abcab and abab inputs
Related
How many equivalence classes in the RL relation for
{w in {a, b}* | (#a(w) mod m) = ((#b(w)+1) mod m)}
I am looking at a past test question which gives me the options
m(m+1)
2m
m^2
m^2+1
infinite
However, i claim that its m, and I came up with an automaton that I believe accepts this language which contains 3 states (for m=3).
Am I right?
Actually you're right. To see this, observe that the difference of #a(w) and #b(w), #a(w) - #b(w) modulo m, is all that matters; and there are only m possible values of this difference modulo m. So, m states are always sufficient to accept a language of this form: simply make the state corresponding to the appropriate difference the accepting state.
In your DFA, a2 corresponds to a difference of zero, a1 to a difference of one and a3 to a difference of two.
I recently had an assignment where I was asked to use pumping lemma to show that a language was not regular, and unfortunately got the wrong answer.
The language to prove is non-regular is as follows:
L = {ai bj ck: i = j or j = k}
The definition of a pumping lemma that I was given is as follows:
opponent picks m
I want to pick w to contradict the pumping lemma. Use m to pick a string w ∈ L where |w| ≥ m
opponent picks a decomposition of w subject to constraints.
I try to pick an i so that the pumped string wi ∉ L. If found, L is not regular
This subject has proven to be very difficult for me to understand and I feel like a complete airhead because of it, so a detailed explanation as to how I would properly apply a pumping lemma would be appreciated.
Intuitively, the pumping lemma says that long enough words (the length depends only on the language L) in a regular language L must contain a section (of length > 0) which can be repeated as often as desired. Repeating that section ('pumping' the original word) any number of time results in some longer words which are also in the language L.
The minimal length for the word is the m in the first step of the above definition; the number of times the section is repeated is the i in the 4th step of the above definition.
The pumping lemma is usually used to show that a language L is not regular. It is a proof by contradiction: assume that L is regular and thus the pumping lemma for regular languages is true for L. Then pick a word w which is in L of sufficient length* and show that regardless of how it is decomposed* some pumped word is not in the language. This contradicts the pumping lemma - which we know to be true. Thus our assumption that the language is regular was wrong and thus the language is not regular. The parts marked with an * cannot be chosen to make things easy - that's why in steps 1 and 3 the 'opponent' selects them.
The word w is rewritten as w = x y z, where | y | > 0 and |x y| <= m. Both x and z may be of length 0.
The usual approach is to pick xy to be a string consisting of the same letter such that having more of that same letter (after the pumping) leads to a word not in L.
No restrictions are specified for the i or the k in the language L in the post, so assuming that i = 0 is allowed, a suitable word might be b^m c^m (that is m bs followed by m cs). Now whatever decomposition the opponent might select, the y will always consist of some bs. Repeating those bs leads to a word with more bs than cs and no as, and thus i != j and j!= k and the word is not in the language.
I want to implement Dedekind's cut in Agda. I tried to represent real number first. But I am not able to define it in Agda. How to define it??
Real numbers can be constructed in a few different ways:
Following Erret Bishop's construction of real numbers in Constructive Analysis, real numbers can be formalized in Agda as a sequence of rational numbers along with a proof of convergence of this sequence:
-- Constructible Real numbers as described by Bishop
-- A real number is defined to be a sequence along
-- with a proof that the sequence is regular
record ℝ : Set where
constructor Real
field
f : ℕ -> ℚ
reg : {n m : ℕ} -> ∣ f n - f m ∣ ≤ (suc n)⁻¹ + (suc m)⁻¹
Checkout this repository for the formalized construction of an equivalence relation using this definition.
Another way to define real numbers is with Dedekind cuts, which as #vitrus mentioned, is discussed in chapter 11 in the Homotopy Type Theory book
I'm trying to understand what is this 'magical' number 'n' that is used in every application of the Pumping lemma. After hours of research on the subject, I came to the following website: http://elvis.rowan.edu/~nlt/TheoryNotes/PumpingLemma.pdf
It states
n is
the longest a string can be without having a loop. The biggest n can
be is s, though it might be smaller for some particular language.
From what I understand if there is a Language L then the pumping length of L is the amount of states in the Finite State Automata that recognizes L. Is this true?
If it is then what exactly does the last line from above say "though it might be smaller for some particular language"? Complete mess in my head. Could somebody clear it up, please?
A state doesn't recognise a language. A DFA recognises a language by accepting exactly the set of words in the languages and no others. A DFA has many states.
If there is a regular language L, which can be modelled by the Pumping Lemma, it will have a property n.
For a DFA with s states, in order for it to accept L, s must be >= n.
The last line merely states that there are some languages in which s is greater than n, rather than equal.
This is probably more suited for https://cstheory.stackexchange.com/ or https://cs.stackexchange.com/ (not quite sure of the value of both myself).
Note: Trivially, not all DFA's with sufficient states will accept the language. Also, the fact that a language passes the pumping lemma doesn't mean it's regular (but failing it means definitely isn't).
Note also, the language changes between FA and DFA - this is a bit lax, but because NDFAs have the same power as DFAs and DFAs are easier to write and understand, DFAs are used for the proof.
Edit I'll give an example of a regular language, so you can see an idea of u,v,w,z and n. Then we'll discuss s.
L = xy^nz, n > 2 (i.e. xyyz, xyyyz, xyyyyz)
u = xy
v = y
w = z
n = 4
Hence:
|z| = 3: xyz (i = 0) Not in L, but |z| < n
|z| = 4: xyyz (i = 1)
|z| = 5: xyyyz (i = 2)
etc
Hence, it's modelled by the Pumping Lemma. A DFA would need at least 4 states. So let's think of one.
-> State 1: x
State 1:
-> State 2: y
State 2:
-> State 3: y
State 3:
-> State 3: y
-> State 4: z
State 4:
Accepting state
Terminating state
4 states, as expected. Not possible to do it in less, as expected by n = 4. In this case, the example is quite simple so I don't think you can build one with more than 4 states (but that would be okay if it were needed).
I think a possibility is when you have a FA with an unreachable state. The FA has s states, but 1 is unreachable, so all strings recognizing L will be comprised of (s-1)=n states, so n<s.
I am quite confused about formal description of PDA (push down automata)
If we write down L(M), this means that PDA M recognizes language L, correct ?
then , L(M)* means that PDA M recognizes that L* right ?
but what is the L* means ? how PDA can recognize infinite combination of L ?
L(M)* means that PDA M recognizes that L* right ?
No! It means a language which is constituted from the concatenation of any number of sentences (including zero) that are valid in the language recognized by the PDA M.
Given that L(M) is context-free, it is easy to prove that L(M)* is context-free too.
To construct L(M)* , just take all the grammar of L(M), take the starting symbol S from L(M) and add two new productions R -> S R and R -> empty where R is the starting symbol of L(M)*.
So, given that L(M)* is context-free, then there is some PDA that recognize it. If you could construct a PDA for L(M), then a PDA for L(M)* should be trivial to construct, given that it is almost the same as L(M) just with two extra productions.