BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS

Description:

One of the rules is English grammars. ... Suppose w and w' are words over the vocabulary set V of a grammar G. Then: ... What is L(G), the language of this grammar? ... – PowerPoint PPT presentation

Number of Views:402
Avg rating:3.0/5.0
Slides: 24
Provided by: notesU
Category:

less

Transcript and Presenter's Notes

Title: BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS


1
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
  • CHAPTER 5
  • MODELLING COMPUTATION

SITI ZANARIAH SATARI FIST/FSKKP UMP I0910
2
CHAPTER 5 MODELLING COMPUTATION
  • CONTENT
  • 5.1 Languages and Grammars
  • 5.2 Finite-State Machines with Output
  • 5.3 Finite-State Machines with No Output
  • 5.4 Language Recognition (not cover)
  • 5.5 Turing Machines (not cover)

3
Introduction
CHAPTER 5 MODELLING COMPUTATION
  • Models of computation help us to answer the
    following questions
  • Can a task be carried out using computer?
  • If YES, How can the task be carried out?
  • Three types of structures used in models
    computation
  • Grammars
  • Used to generate words of a language and
    determine whether a word is in a language.
  • Finite-state Machines
  • Used in modeling a problem.
  • Turing Machines
  • Used to classify problems as tractable/intractable
    and solvable/unsolvable.

4
5.1 LANGUAGE AND GRAMMARS
CHAPTER 5 MODELLING COMPUTATION
  • Understand language and grammars in models of
    computation
  • Construct derivation tree

5
5.1 LANGUAGE AND GRAMMARS
Natural Language Formal Language
  • Natural Language is spoken language.
  • It is not possible to specify all the rules of
    syntax (form) in Natural language
  • One of the rules is English grammars.
  • Formal Language which are generated by grammars,
    provide models for both natural languages and
    programming languages.
  • Formal Language specified by a well defined set
    of rules/syntax.
  • Grammars help us answer the following questions
  • How can we determine whether a combination of
    words is a valid sentence in a formal language?
  • How can we generate the valid sentences of a
    formal language?

6
5.1 LANGUAGE AND GRAMMARS
Basic Terminologies
  • A vocabulary/alphabet, V is a finite nonempty set
    of elements called symbols.
  • Example V a, b, c, A, B, C, S
  • A word/sentence over V is a string of finite
    length of elements of V.
  • Example Aba
  • The empty/null string, ? is the string with no
    symbols.
  • V is the set of all words over V.
  • Example V Aba, BBa, bAA, cab
  • A language over V is a subset of V.
  • We can give some criteria to a word to be in a
    language.
  • Example cab is a subset in V and is a language.

7
5.1 LANGUAGE AND GRAMMARS
Phrase-Structure Grammars
  • A Phrase-Structure Grammars G (V, T, S, P)
    consists of
  • a vocabulary V,
  • a subset T of V consisting of terminal elements
  • a start symbol S from V
  • a finite set of productions P
  • Elements of N V T are called nonterminal
    symbols.
  • Every production in P must contain at least one
    nonterminal on its left side.
  • EXAMPLE
  • Let G (V, T, S, P), where V a, b, A, B, S,
    T a, b, S is a start symbol and P S ? ABa,
    A ? BB, B ? ab, A ? Bb. Then, G is a
    Phrase-Structure Grammar.

8
5.1 LANGUAGE AND GRAMMARS
Language L(G) of a Grammar G
  • Suppose w and w are words over the vocabulary
    set V of a grammar G. Then
  • We write w ? w if w can be obtained from w by
    using one of the productions
  • We write w ? ? w if w can be obtained from w by
    using a finite number of productions
  • The language of G consists of all words in
    terminal set T that can be obtained from the
    start symbol S by the above process
  • L (G) w ? T S ? ? w
  • EXAMPLE
  • Let G (V, T, S, P), where V a, b, A, S, T
    a, b, S is a start symbol and P S ? aA, S
    ? b, A ? aa.
  • The language of this grammar is given by L (G)
    b, aaa since we can derive aA from using S ?
    aA, and then derive aaa using A ? aa. We can also
    derive b using S ? b.

9
5.1 LANGUAGE AND GRAMMARS
EXERCISE 5.1
  • Let G (V, T, S, P), where V a, b, A, B, S,
    T a, b, S is a start symbol and P S ?AB, A
    ?Aa, B ?Bb, A ?a, B ?b. What is L(G), the
    language of this grammar?
  • Find the language L(G) over a, b, c generated
    by the grammar G with the productions
    P S
    ?aSb, aS ?Aa, AaB ?c.
  • Let V a, b, A, B, S, and T a, b. Find the
    language L(G) generated by the grammar G (V, T,
    S, P), with S is a start symbol and a set of
    productions P S ?AA, S ?B, A ?aaA, A ?aa, B
    ?bB, B ?b.

10
5.1 LANGUAGE AND GRAMMARS
Types of Grammars
Every Type 3 grammar is a Type 2 grammar. Every
Type 2 grammar is a Type 1 grammar. Every Type 1
grammar is a Type 0 grammar.
11
5.1 LANGUAGE AND GRAMMARS
Derivation Tree of Context-Free Grammar
  • Represents the language using an ordered rooted
    tree.
  • Root represents the starting symbol.
  • Internal vertices represent the nonterminal
    symbol that arise in the production.
  • Leaves represent the terminal symbols.
  • If the production A ? w arise in the derivation,
    where w is a word, the vertex that represents A
    has as children vertices that represent each
    symbol in w, in order from left to right.

12
5.1 LANGUAGE AND GRAMMARS
Example Derivation Tree
  • Let G be a context-free grammar with the
    productions P S ?aAB, A ?Bba, B ?bB, B
    ?c. The word w acbabc can be derived from S as
    follows
  • S ? aAB ?a(Bba)B ? acbaB ? acba(bB) ? acbabc
  • Thus, the derivation tree is given as follows

S
a
A
B
B
b
b
a
B
c
c
13
5.1 LANGUAGE AND GRAMMARS
EXERCISE 5.1
  • The word w cbab belongs to the language
    generated by the grammar G (V, T, S, P), where
    V a, b, c, A, B, C, S, T a, b, c, S is
    the start symbol and P S ?AB, A ?Ca, B ?Ba, B
    ?Cb, B ?b , C ?cb, C ?b. Construct the
    derivation tree for w.
  • The production rules of a grammar for simple
    arithmetic expression are
  • expression digit ( expression
    )
  • ( expression ) - ( expression )
  • expression
    operator expression
  • digit 0 1 2 3 4
    5 6 7 8 9
  • operator -  / ?
  • Construct a derivation tree for arithmetic
    expression (2 ? 5 ) - 8 and (3 7) / (9 1).

14
5.1 LANGUAGE AND GRAMMARS
EXERCISE 5.1 EXTRA
  • PAGE 793, 794, 795 and 796
  • Rosen K.H., Discrete Mathematics Its
    Applications, (Seventh Edition), McGraw-Hill,
    2007.

15
CHAPTER 5 MODELLING COMPUTATION
  • 5.2 FINITE-STATE MACHINE WITH OUTPUT
  • Understand finite state machines with output.
  • Draw state diagrams for finite state machines
    with output.
  • Construct state table for finite state machines
    with output.

16
5.2 FINITE-STATE MACHINES WITH OUTPUT
Finite State Machines
17
5.2 FINITE-STATE MACHINES WITH OUTPUT
EXERCISE 5.2
18
5.2 FINITE-STATE MACHINES WITH OUTPUT
EXERCISE 5.2 EXTRA
  • PAGE 802 and 803
  • Rosen K.H., Discrete Mathematics Its
    Applications, (Seventh Edition), McGraw-Hill,
    2007.

19
CHAPTER 5 MODELLING COMPUTATION
  • 5.3 FINITE-STATE MACHINES WITH
  • NO OUTPUT
  • Understand finite state machines with no output.
  • Draw state diagrams for finite state machines
    with no output.
  • Construct state table for finite state machines
    with no output.

20
5.3 FINITE-STATE MACHINES WITH NO OUTPUT
Finite State Machines
21
5.3 FINITE-STATE MACHINES WITH NO OUTPUT
EXERCISE 5.3
22
5.3 FINITE-STATE MACHINES WITH NO OUTPUT
EXERCISE 5.3 EXTRA
  • PAGE 814, 815, 816 and 817
  • Rosen K.H., Discrete Mathematics Its
    Applications, (Seventh Edition), McGraw-Hill,
    2007.

23
CHAPTER 5 MODELLING COMPUTATION
  • Grammars, finite state machine and Turing
    machines are three structures used in models of
    computation

SUMMARY
What NEXT? FINAL EXAMINATION
THATS ALL THANK YOU
Write a Comment
User Comments (0)
About PowerShow.com