Specifying Infinite Languages - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Specifying Infinite Languages

Description:

Let T be an alphabet with a given ordering on its symbols. ... a are ordered before all strings beginning b, and b before c, etc. Within groups ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 17
Provided by: kenb97
Category:

less

Transcript and Presenter's Notes

Title: Specifying Infinite Languages


1
Specifying Infinite Languages
the problem of infinite languages finite state
machines
2
Ordering Languages
  • Let T be an alphabet with a given ordering on its
    symbols. Say T a, b, c, d, .... Strings over
    T can be ordered in two ways
  • Dictionary Order
  • All strings beginning a are ordered before all
    strings beginning b, and b before c, etc. Within
    groups of strings beginning with the same symbol,
    strings are ordered by their second symbol, and
    so on. ? is always the first string.
  • Lexical Order
  • Strings are ordered by their length, with the
    shortest first. Within groups of strings of the
    same length, strings are ordered in dictionary
    order. ? is always the first string.

3
Specifying Infinite Languages
L1 xn n 1, 2, 3, ... What elements
are in L1?
L2 xn n 1, 4, 9, 16, ... What elements
are in L2?
L3 xn n 1,4, 9, 48, ... What elements are
in L3?
Can we devise a clear and precise method for
defining infinite languages?
4
Recognising Languages
  • We will tackle the problem of defining languages
    by considering how we would recognise them
  • We will define an abstract machine that, given a
    string, produces the answer "yes" or "no".
  • The abstract machine will be the specification of
    the language.

Problem Can we recognise infinite
languages? i.e. given a language description and
a string, is there an algorithm that will answer
yes or no (correctly)?
5
Finite State Automata
  • A finite state automaton is an abstract model of
    a simple machine (or computer).
  • The machine can be in a finite number of states.
    It receives symbols as input, and the result of
    receiving a particular input in a particular
    state moves the machine to a specified new state.
    Certain states are finishing states, and if the
    machine is in one of those states when the input
    ends, it has ended successfully (or has accepted
    the input).

6
Example FSA
a
2
3
a,b
a
1
b
a
b
4
b
A1
7
FSA Formal Definition
  • A Finite State Automaton is a 5-tuple (Q, I, F,
    T, E)
  • Q is a finite set (called states)
  • I is a subset of Q (called initial states)
  • F is a subset of Q (called final states)
  • T is an alphabet
  • E is a subset of Q ?(T ?) ? Q (called edges).
  • Essentially, an FSA is a labelled, directed graph
    - that is, a set of nodes with directed arcs
    (arrows) between nodes, and where each arc may
    have a label from an alphabet.

8
Example formal definition
Example formal definition of A1 Q 1, 2,
3, 4 I 1 F 4 T a, b E (1,a,2),
(1,b,4), (2,a,3), (2,b,4), (3,a,3),
(3,b,3), (4,a,2), (4,b,4)
9
Definitions
  • if (x,a,y) is an edge, x is its start state and y
    is its end state
  • a path is a sequence of edges such that the end
    state of one is the start state of the next
  • a path is successful if the start state of the
    first edge is an initial state, and the end state
    of the last is a final state
  • the label of a path is the sequence of edge
    labels
  • a string is accepted by a FSA if it is the label
    of a successful path

10
Definition of a finite state language
  • Let A be a FSA. The language accepted by A is the
    set of strings accepted by A, denoted L(A)
  • The language accepted by A1 is the set of strings
    of a's and b's which end in a b, and in which no
    two a's are adjacent.

11
Non-determinism
  • We wanted to use FSAs as a mechanism to recognise
    languages, simply following the edges as we input
    symbols from a string.
  • The way we have defined FSAs gives a problem -
    they are non-deterministic. That is, we may have
    a choice at certain times.
  • There could be a number of edges with the same
    label leaving a state some edges could be
    labelled with ? there could be more than one
    start state.

12
Deterministic FSA
  • A FSA is deterministic (DFSA) if
  • there is only one initial state
  • there are no ?-labelled edges
  • for any pair of state and symbol (q,t), there is
    at most one edge (q,t, p)
  • A FSA is non-deterministic (NDFSA) if any one of
    the above does not hold

A DFSA is a specification of an algorithm for
determining whether or not a string is a member
of a given language
13
Transition Functions
  • The transition function of a FSA A is the
    function
  • ? (x, t) ? y ? edge (x, t, y) in A
  • The transition matrix of a FSA A is a matrix with
    one row for each state, and one column for each
    symbol in the alphabet, such that the entry in
    row q, column t is ?(q,t)

Example a b 1 2 4 2 3 4 3 3 3
4 2 4
initial state
final state
14
Recognition Problem
  • Problem Given a DFSA, A (Q,I,F,T,E), and a
    string w, determine whether w ? L(A).
  • Note denote the current state by q, and the
    current input symbol t. Since A is deterministic,
    ?(q,t) will always be a singleton set or will be
    undefined. If it is undefined, denote it by ? (?
    Q).

15
Recognition Algorithm
  • 1. add symbol to end of w
  • 2. q initial state
  • 3. t first symbol of w
  • 4. while (t ? and q ? ?)
  • 5. begin
  • 6. q ?(q,t)
  • 7. t next symbol of w
  • 8. end
  • 9. return ((t ) (q ? F))

16
Next lecture
what is the difference between DFSA and NDFSA?
Write a Comment
User Comments (0)
About PowerShow.com