Sei sulla pagina 1di 7

1.What is role of finite automate in recognition of reguler language ? How the finite automata is designed for reguler languages.

Give different applications of FA. 2.How we can say that languages that are not recognised by FA that are recognised by PDA. 3.How to check syntax of programming language construct using syntax tree and parse tree. 4.Describe one tape turing machine.How can we say that TM is more powerful than FA and PDA. 1.ANS : The deterministic finite-state machine (DFSM) has a set of states, including an initial state and one or more final states. At each unit of time a DFSM is given a letter from its input alphabet. This causes the machine to move from its current state to a potentially new state. While in a state, the DFSM produces a letter from its output alphabet. Such a machine computes the function defined by the mapping from strings of input letters to strings of output letters. DFSMs can also be used to accept strings. A string is accepted by a DFSM if the last state entered by the machine on that input string is a final state. The language recognized by a DFSM is the set of strings that it accepts. Although there are languages that cannot be accepted by any machine with a finite number of states, it is important to note that all realistic computational problems are finite in nature and can be solved by FSMs that is regular languages. A deterministic finite-state machine (DFSM) M is a five-tuple M =(, Q, , s, F ) where , is the input alphabet, Q is the finite set of states, : Q Q is the next-state function, s is the initial state, and F is the set of final states. The DFSM M accepts the input string w if the last state entered by M on application of w starting in state s is a member of the set F . M recognizes the language L(M ) consisting of all such strings. A nondeterministic FSM (NFSM) is similarly defined except that the next-state function is replaced by a next-set function : Q 2Q that associates a set of states with each state-input pair (q, a). The NFSM M accepts the string w if there are next-state choices, whenever more than one exists, such that the last state entered under the input string w is a member of F . M accepts the language L(M ) consisting of all such strings.

Applications of finite automata include string matching algorithms, network protocols and lexical analyzers 1.String Processing Consider finding all occurrences of a short string (pattern string) within a long string (text string). This can be done by processing the text through a DFA: the DFA for all strings that end with the pattern string. Each time the accept state is reached, the current position in the text is out put. To find all occurrences of pattern 1001, construct the DFA for all strings ending in 1001.

2.Network Protocols A finite-state machine is an FA together with actions on the arcs. A trivial example for a communication link:

3.Robotics A bot is a computer-generated character in a video game.

Using finite-state machine allows automation.

4.Statecharts Statecharts model tasks as a set of states and actions. They extend FA diagrams. Here is a simplified statechart for a stopwatch.

5.Lexical Analysis In compiling a program, the first step is lexical analysis. This isolates keywords, identifiers etc., while eliminating irrelevant symbols. A token is a category, for example identifier, relation operator or specific keyword. For example, token RE keyword then variable name then [a-zA-Z][a-zA-Z0-9]*

where latter RE says it is any string of alphanumeric characters starting with a letter. 6.Lexical Analyzer A lexical analyzer takes source code as a string, and outputs sequence of tokens. For example, for i = 1 to max do x[i] = 0; might have token sequence

As a token is identified, there may be an action. For example, when a number is identified, its value is calculated, 2.ANS : Finite-automata can recognize all the regular languages i.e languages which can be represented by regular expressions or regular grammar.but there also exist some languages which can't be represented by reguler expressions. Here is an Example , Consider {wwR :w {a, b} } It is context-free, since it is generated by the grammar with rules S aSa, S bSb, S . It would seem that any device that recognizes the strings in this language

by reading them from left to right must remember the first half of the input string, so that it can check it in reverse order against the second half of the input. since we know finite automata can only remember current state and unable to remember previous state-input so above kind of language can't be remember by finite-automata. Pushdown automata is modified version of finite automata which has additional component that is Stack.Using stack memory PDA can remember current state-input as well as the previous state-input . Hence above language which is palindrome string recognition problem can be recogined by PDA. Therefore we can say that PDA is more powerful than FA.

3.ANS : Many of the methods and much of the terminology of linguistics apply to programming languages. For example, language definitions consist of three components: 1. Syntax refers to the ways symbols may be combined to create well-formed sentences (or programs) in the language. Syntax defines the formal relations between the constituents of a language, thereby providing a structural description of the various expressions that make up legal strings in the language. Syntax deals solely with the form and structure of symbols in a language without any consideration given to their meaning. 2. Semantics reveals the meaning of syntactically valid strings in a language. For natural languages, this means correlating sentences and phrases with the objects, thoughts, and feelings of our experiences. For programming languages, semantics describes the behavior that a computer follows when executing a program in the language. We might disclose this behavior by describing the relationship between the input and output of a program or by a step-by-step explanation of how a program will execute on a real or an abstract machine. 3. Pragmatics alludes to those aspects of language that involve the users of the language, namely psychological and sociological phenomena such as utility, scope of application, and effects on the users.

For programming languages, pragmatics includes issues such as ease of implementation, efficiency in application, and programming methodology. GRAMMARS AND BNF Formal methods have been more successful with describing the syntax of programming languages than with explaining their semantics. Defining the syntax of programming languages bears a close resemblance to formulating the grammar of a natural language, describing how symbols may be formed into the valid phrases of the language. The formal grammars that Noam Chomsky proposed for natural languages apply to programming languages as well. Definition : A grammar < ,N,P,S> consists of four parts: 1. A finite set of terminal symbols , the alphabet of the language, that are assembled to make up the sentences in the language. 2. A finite set N of nonterminal symbols or syntactic categories , each of which represents some collection of subphrases of the sentences. 3. A finite set P of productions or rules that describe how each nonterminal is defined in terms of terminal symbols and nonterminals. The choice of nonterminals determines the phrases of the language to which we ascribe meaning. 4. A distinguished nonterminal S, the start symbol , that specifies the principal category being definedfor example, sentence or program. In accordance with the traditional notation for programming language grammars, we represent nonterminals with the form <category-name> and productions as follows: <declaration> ::= var <variable list> : <type> ; where var, : , and ; are terminal symbols in the language. The symbol ::= is part of the language for describing grammars and can be read is defined to be or may be composed of . When applied to programming languages, this notation is known as Backus-Naur For m or BNF

4.ANS : This Turing machine model is more powerful in several ways than FA's and PDA's. First, the input head can move both forwards and backwards on the tape of the machine. Second, symbols can be written to the tape as well as read from the tape. Thus, a Turing machine has random access memory. Third, the tape has an infinite number of blank tape cells following the initial input, providing the machine with unlimited storage. A Turing machine has a special accept state and a special reject state. Once the machine enters one of these states, the decision of whether to accept or reject the input is irreversible. Also, when a transition requires that the input head be moved left when the head happens to be on the leftmost character of the input, the convention is that the head just stays where it is. The finite-state machine can be viewed as a Turing machine with two tapes, the first a read-only tape and the second a write-only output tape. A Turing machine is a lot like a pushdown automaton. Both have a finite-state machine as a central component; both have additional storage. But where a pushdown automaton uses a stack for storage, a Turing machine uses a tape, which is considered to be infinite in both directions. The tape consists of a series of squares, each of which can hold a single symbol. The tape head, or read-write head, can read a symbol from the tape, write a symbol to the tape, and move one square in either direction. The PAD can be viewed as a Turing machine with two tapes, a read-only input tape and a pushdown tape.

Potrebbero piacerti anche