I have to draw a Finite Automaton that accepts the following string
Λ, a, aabc, acba and accb
In my view a(a+b+c)* this might be it's regular expression as the string is starting from a and includes an empty string as well.
Now I didn't find the logic of drawing FA as in below image
Question 1: If the string is starting with a then in FA, We are moving from x to y while reading b
Why we don't read a here.
Question 2: Why we use loop of a,b on state y and z
The language L = {λ, a, aabc, acba, accb} is finite. Therefore, L is not equivalent to the language denoted by the Kleene closure of the regular expression a(a + b + c), which is infinite. There is a simple algorithm that generates the nondeterministic finite automaton accepting a finite language, which consists of drawing paths accepting each of the strings in the language.
It's unclear what the relationship between the two languages and the diagram in the original post is, since the automaton in the diagram accepts neither language. Assuming that the nodes are labeled with their names, and circled nodes indicate acceptance, the language accepted by the automaton in the diagram is (a + b)*. In this case, the loops are used to accept the Kleene closure of (a + b). That said, it would be useful if you could clarify the meaning of the diagram.
Related
Prove that the language defined over {0,1} where the number of 0s of x=number of 1s of x is not regular.
Myhill-Nerode says that there are as many equivalence classes over the indistinguishability relation w.r.t. a regular language as there are states in a minimal DFA for that language.
Two strings w and x are indistinguishable w.r.t. a regular language L if for any y such that wy is in L, xy is also in L; and if for any z such that xz is in L, wz is in L also. In other words, w and x are indistinguishable if they can have exactly the same set of strings concatenated to them to get some string in L.
For your language, we can show the number of equivalence classes under this relation is infinite. Because no DFA has infinitely many states, this is a contradiction; by showing this we show the language is not regular.
In your case, we can show that 0^n is distinguishable from 0^m, for m > n, since the shortest string that can be appended to 0^n to get a string in your language is 1^n, whereas the shortest string that can be appended to 0^m to get a string in your language is 1^m, and m > n. Thus, each string 0^n is distinguishable from every other string 0^m, n != m, so there are infinitely many equivalence classes. As we said earlier, this means the language cannot be regular.
If we had found that a finite number of equivalence classes existed and named them, we'd have also found a minimal DFA for the language. Simply add one state per equivalence class and figure out the transitions.
I have a DFA A and a CFG G, then i have to check if G generates infinite words that A don't accept (rejected by A), and a nice complexity time.
I thought to construct a graph with the CFG and if it contains a directed cycle, then produces an infinite language. Vertices are the variables and for each production I draw some edges. The input are all words rejected by the DFA and when I found a cycle I can say that the CFG generates infinite language rejected by DFA A.
I don't know how to transform it in a algorithm or if my proposal is not correct and I have to create a new one.
Edit: Can I transform my cfg to CNF and then to a DFA ( with chomsky ).After, I try to find a cycle. But my transformed dfa can have less states than my dfa a... I need how to get the words rejected by DFA A in my cfg I think.
Given CFG G, construct PDA B. Given DFA A and PDA B, construct PDA C such that C accepts L(C) = L(B) \ L(A), where \ is set difference. Now, L(C) is precisely the language of words accepted by the PDA B (hence generated by the CFG G) but not accepted, i.e. rejected, by the DFA A.
Now, the question is whether the language of B is infinite. We can do this. One way is to convert the PDA back into a CFG, and then put the CFG in CNF - removing unnecessary and unproductive symbols. Then, create a dependency tree among nonterminal symbols. If any remaining (productive) nonterminal symbol depends upon itself, i.e., there is a loop, then the language is infinite. Otherwise, the language is finite (empty, if there are no productive symbols remaining).
I encountered this doubt in an online intro-logic open course offered by Stanford Uni.
Under the section 9.4 of this textbook here: http://logic.stanford.edu/intrologic/secondary/notes/chapter_09.html
It says:
The axioms shown here define the same relation in terms of 0 and s.(where the functional constant letter s below represents the successor function, e.g. s(0)=1, s(1)=2, s(2)=3 )
∀x.same(x,x)
∀x.(¬same(0,s(x)) ∧ ¬same(s(x),0))
∀x.∀y.(¬same(x,y) ⇒ ¬same(s(x),s(y)))
As my understanding, :
The first sentence says two identical numbers are same. The second and third sentences are used to define what is not same.
The second says no successor of any number is same to 0.
The third says if two numbers are not the same, then their successors are not same. For example, if 1≠3, then 2≠4.
However, I think the third sentence should be bi-conditional because, if I'm not wrong, the definition didn't cover the instance where the number being testified are smaller than the given number,otherwise it is possible to say if 2≠4, then 1=3.
So I wondered is this an error in text book or there's something wrong of my reasoning.
There is no error in this text book. While the statement does hold in both directions, there is no need to state it as an axiom since the other direction follows from the functional property of the successor function and the three axioms listed in the textbook.
A formal proof would involve the axioms that define the successor function. Someone more accustomed to the use of automated provers or just a good student of logic might be able to complete such a formal proof.
Here is just a sketch of a proof. It uses the symbol "=" to denote term equality, i.e. u=v means u and v are syntactically identical terms written using the symbols 0 and s(). Also "u<v" means that u and v are both ground terms and u has strictly less applications of s() than v.
Suppose
∀x.∀y.(¬same(s(x),s(y)) ⇒ ¬same(x,y))
does not hold, then there exist some terms x0 and y0 such that
same(x0,y0) and ¬same(s(x0),s(y0)).
Since s(x0) is a function, it follows from ¬same(s(x0),s(y0)) and ∀x.same(x,x) that x0 and y0 are two different terms. First let us consider the case when x0 < y0, then y0 = s(...s(x0)) where there are n applications of s() and n > 0. The other case when y0 < x0 can be handled similarly.
Substituting s(...s(x0)) for y0 in same(x0,y0) we get same(x0,s(...s(x0))).
Also x0 = s(...s(0)) where there are m applications of s() for some nonnegative integer m. Using the third axiom in the direction provided we can say that if same(s(u),s(v)) then same(u,v). Thus from same(x0,s(...s(x0))) we can "strip" m applications of s() to obtain
same(0,s(...s(0))) where there are n applications of s() in the second argument. This contradicts the second axiom. Q.E.D.
I read the question asked in Herbrand universe, Herbrand Base and Herbrand Model of binary tree (prolog) and the answers given, but I have a slightly different question more like a confirmation and hopefully my confusion will be clarified.
Let P be a program such that we have the following facts and rule:
q(a, g(b)).
q(b, g(b)).
q(X, g(X)) :- q(X, g(g(g(X)))).
From the above program, the Herbrand Universe
Up = {a, b, g(a), g(b), q(a, g(a)), q(a, g(b)), q(b, g(a)), q(b, g(b)), g(g(a)), g(g(b))...e.t.c}
Herbrand base:
Bp = {q(s, t) | s, t E Up}
Now come to my question(forgive me for my ignorance), i included q(a, g(a)) as an element in my Herbrand Universe but from the fact, it states q(a, g(b)). Does that mean that q(a, g(a)) does not suppose to be there?
Also since the Herbrand models are subset of the Herbrand base, how do i determine the least Herbrand model by induction?
Note: I have done a lot of research on this, and some parts are well clear to me but still i have this doubt in me thats why i want to seek the communities opinion. Thank you.
From having the fact q(a,g(b)) you cannot conclude whether or not q(a,g(a)) is in the model. You will have to generate the model first.
For determining the model, start with the facts {q(a,g(b)), q(b,g(b))} and now try to apply your rules to extend it. In your case, however, there is no way to match the right-hand side of the rule q(X,g(X)) :- q(X,g(g(g(X)))). to above facts. Therefore, you are done.
Now imagine the rule
q(a,g(Y)) :- q(b,Y).
This rule could be used to extend our set. In fact, the instance
q(a,g(g(b))) :- q(b,g(b)).
is used: If q(b,g(b)) is present, conclude q(a,g(g(b))). Note that we are using here the rule right-to-left. So we obtain
{q(a,g(b)), q(b,g(b)), q(a,g(g(b)))}
thereby reaching a fixpoint.
Now take as another example you suggested the rule
q(X, g(g(g(X)))) :- q(X, g(X)).
Which permits (I will no longer show the instantiated rule) to generate in one step:
{q(a,g(b)), q(b,g(b)), q(a,g(g(g(b)))), q(b, g(g(g(b))))}
But this is not the end, since, again, the rule can be applied to produce even more! In fact, you have now an infinite model!
{g(a,gn+1(b)), g(b, gn+1(b))}
This right-to-left reading is often very helpful when you are trying to understand recursive rules in Prolog. The top-down reading (left-to-right) is often quite difficult, in particular, since you have to take into account backtracking and general unification.
Concerning your question:
"Also since the Herbrand models are subset of the Herbrand base, how do i determine the least Herbrand model by induction?"
If you have a set P of horn clauses, the definite program, then you can define
a program operator:
T_P(M) := { H S | S is ground substitution, (H :- B) in P and B S in M }
The least model is:
inf(P) := intersect { M | M |= P }
Please note that not all models of a definite program are fixpoints of the
program operator. For example the full herbrand model is always a model of
the program P, which shows that definite programs are always consistent, but
it is not necessarily a fixpoint.
On the other hand each fixpoint of the program operator is a model of the
definite program. Namely if you have T_P(M) = M, then one can conclude
M |= P. So that after some further mathematical reasoning(*) one finds that
the least fixpoint is also the least model:
lfp(T_P) = inf(P)
But we need some further considerations so that we can say that we can determine
the least model by a kind of computation. Namely one easily observes that the
program operator is contiguous, i.e. preserves infinite unions of chains, since
horn clauses do not have forall quantifiers in their body:
union_i T_P(M_i) = T_P(union_i M_i)
So that again after some further mathematical reasoning(*) one finds that we can
compute the least fixpoint via iteration, witch can be used for simple
induction. Every element of the least model has a simple derivation of finite
depth:
union_i T_P^i({}) = lpf(T_P)
Bye
(*)
Most likely you find further hints on the exact mathematical reasoning
needed in this book, but unfortunately I can't recall which sections
are relevant:
Foundations of Logic Programming, John Wylie Lloyd, 1984
http://www.amazon.de/Foundations-Programming-Computation-Artificial-Intelligence/dp/3642968287
I am studying membership algorithms and I am working on this particular problem which says the following:
Exhibit an algorithm that, given any regular language L, determines whether or not L = L*
So, my first thought was, we have L* which is Kleene star of L and to determine if L = L*, well couldn't we just say that since L is regular, we know L* is by definition which states that the family of regular languages is closed under star-closure.
Therefore L will always be equal to L*?
I feel like there is definitely a lot more to it, there is probably something I am missing. Any help would be appreciated. Thanks again.
since L is regular, we know L* is by definition which states that the family of regular languages is closed under star-closure. Therefore L will always be equal to L*?
No. Regular(L) --> Regular(L*), but that does not mean that L == L*. Just because two languages are both regular does not mean that they are the same regular language. For instance, a* and b* are both regular languages, but this does not make them the same language.
A example of L != L* would be the language L = a*b*, and thus L* = (a*b*)*. The string abab is part of L* but not part of L.
As far as an algorithm goes, let me remind you that the concept of a regular language is one that can be parsed by a DFA - and for any given DFA, there is a single optimal reduction of that DFA.
The implication that you stated is wrong. Closedness under the Kleene star means only that L* is again regular, if L is regular.
One possibility to check whether L = L* is to compute the minimal automaton for both and then checking for equivalence.