MHB Determine if the string is in L(G)

  • Thread starter Thread starter mathmari
  • Start date Start date
  • Tags Tags
    String
AI Thread Summary
To determine if a string w is in the language of a context-free grammar G in Chomsky normal form using an O(n^3) algorithm, dynamic programming can be effectively employed. The approach involves constructing a table where for each substring of w, the set of non-terminal symbols that can derive that substring is recorded. Specifically, for every substring defined by indices i and s (where 1 ≤ i ≤ i+s ≤ n), the algorithm iteratively calculates which non-terminals can generate the substring x_i...x_{i+s}. This process is executed in a nested loop, varying the length of the substring s from 1 to n-1, allowing for a comprehensive examination of all possible substrings in the string w. This method is detailed in several computational theory texts, providing a structured framework for implementing the algorithm.
mathmari
Gold Member
MHB
Messages
4,984
Reaction score
7
Hey! :o

I have to write an $O(n^3)$ algorithm to determine whether a given string $w=a_1 a_2 \dots a_n$ is in $L(G)$, where $G=(N,\Sigma ,P, S)$ is a context-free grammar in Chomsky normal form.

Could you give me some hints how to do that?? (Wondering)
 
Technology news on Phys.org
Could you explain me how we could use the dynamic programming in this case?? (Wondering)
 
This is described in Section 3.6 in [1], Theorem 7.16 in [2] and Section 7.4.4 in [3]. Briefly, the idea is the following. Given a word $x_1\dots x_n$, for each $i$ and $s$ such that $1\le i\le i+s\le n$ find the set $N[i,i+s]$ of all symbols that can derive $x_i\dots x_{i+s}$. This computation occurs in a loop where $s$ changes from 1 to $n-1$.

[1] Lewis, Papadimitriou. Elements of the Theory of Computation. 2nd edition.

[2] Sipser. Introduction to the Theory of Computation. 2nd edition.

[3] Hopcroft, Motwani, Ullman. Introduction to Automata Theory, Languages, and Computation. 2nd edition.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top