Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and...

35
Introduction to Formal Languages Martin Fr ¨ anzle Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing, MF, Fall 2003 – p.1/16

Transcript of Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and...

Page 1: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Introduction toFormal Languages

Martin Franzle

Informatics and Mathematical Modelling

The Technical University of Denmark

02140 Languages and Parsing, MF, Fall 2003 – p.1/16

Page 2: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Formal Languages

What is it?

02140 Languages and Parsing, MF, Fall 2003 – p.2/16

Page 3: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

(Formal) Languages

� A language is a set of “legal” sentences.

A sentence is a sequence of symbols.

The symbols can be characters, words punctuation,hieroglyphs, dots and dashes (Morse code),

A formal language is a language defined by a finite set ofunambiguous rules delimiting the legal sentences from theillegal ones.

02140 Languages and Parsing, MF, Fall 2003 – p.3/16

Page 4: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

(Formal) Languages

� A language is a set of “legal” sentences.

� A sentence is a sequence of symbols.

� The symbols can be characters, words

punctuation,hieroglyphs, dots and dashes (Morse code), � � �

A formal language is a language defined by a finite set ofunambiguous rules delimiting the legal sentences from theillegal ones.

02140 Languages and Parsing, MF, Fall 2003 – p.3/16

Page 5: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

(Formal) Languages

� A language is a set of “legal” sentences.

� A sentence is a sequence of symbols.

� The symbols can be characters, words

punctuation,hieroglyphs, dots and dashes (Morse code), � � �

� A formal language is a language defined by a finite set ofunambiguous rules delimiting the legal sentences from theillegal ones.

02140 Languages and Parsing, MF, Fall 2003 – p.3/16

Page 6: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Why are they interesting?

Because formal languages arise everywhere in computing:

� Programming languages, query languages, etc.

� The inputs expected by programs:

� inputs to be keyed in, e.g. numbers in certain format, names,etc.

� sequences of button clicks in a GUI.

� Protocols for data exchange between computers (e.g. SMTP)

Knowledge of their algorithmic properties permits auto-matic generation of programs for their manipulation.

02140 Languages and Parsing, MF, Fall 2003 – p.4/16

Page 7: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Why are they interesting?

Because formal languages arise everywhere in computing:

� Programming languages, query languages, etc.

� The inputs expected by programs:

� inputs to be keyed in, e.g. numbers in certain format, names,etc.

� sequences of button clicks in a GUI.

� Protocols for data exchange between computers (e.g. SMTP)

Knowledge of their algorithmic properties permits auto-matic generation of programs for their manipulation.

02140 Languages and Parsing, MF, Fall 2003 – p.4/16

Page 8: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Some means of defining formal languages

A finite and unambiguous set of rules can be given by

1. a “computer” with finite memory such that the whole machinecan be described finitely,

“Regular languages”

2. a finite set of recursive definitions of the formif is a natural number then is an arithmetic expression,

,if and are arithmetic expressions then is anarithmetic expression,

“Context-free languages”

3.

02140 Languages and Parsing, MF, Fall 2003 – p.5/16

Page 9: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Some means of defining formal languages

A finite and unambiguous set of rules can be given by

1. a “computer” with finite memory such that the whole machinecan be described finitely,

“Regular languages”

2. a finite set of recursive definitions of the form

� if � is a natural number then � is an arithmetic expression,

� � � ,

� if ��� and ��� are arithmetic expressions then � � � ��� is anarithmetic expression,

� � �

“Context-free languages”

3.

02140 Languages and Parsing, MF, Fall 2003 – p.5/16

Page 10: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Some means of defining formal languages

A finite and unambiguous set of rules can be given by

1. a “computer” with finite memory such that the whole machinecan be described finitely,

“Regular languages”

2. a finite set of recursive definitions of the form

� if � is a natural number then � is an arithmetic expression,

� � � ,

� if ��� and ��� are arithmetic expressions then � � � ��� is anarithmetic expression,

� � �

“Context-free languages”

3. � � �

02140 Languages and Parsing, MF, Fall 2003 – p.5/16

Page 11: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Some means of defining formal languages

A finite and unambiguous set of rules can be given by

1. a “computer” with finite memory such that the whole machinecan be described finitely,

“Regular languages”

2. a finite set of recursive definitions of the form

� if � is a natural number then � is an arithmetic expression,

� � � ,

� if ��� and ��� are arithmetic expressions then � � � ��� is anarithmetic expression,

� � �

“Context-free languages”

3. � � �

02140 Languages and Parsing, MF, Fall 2003 – p.5/16

Page 12: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Regular languages:

Application domains

02140 Languages and Parsing, MF, Fall 2003 – p.6/16

Page 13: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Regular languages

arise naturally in

� descriptions of hardware components,

because these are computational devices with finite memory,

� descriptions of communication protocols,

because these engage into an alternation of finitely many differentphases,

� word classification problems, e.g.:is the next word a hyperlink, or is it to be rendered as text?

� descriptions of embedded computer systems,

because these are computers with finite memory.

02140 Languages and Parsing, MF, Fall 2003 – p.7/16

Page 14: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Regular languages

arise naturally in

� descriptions of hardware components,

because these are computational devices with finite memory,

� descriptions of communication protocols,

because these engage into an alternation of finitely many differentphases,

� word classification problems, e.g.:is the next word a hyperlink, or is it to be rendered as text?

� descriptions of embedded computer systems,

because these are computers with finite memory.

02140 Languages and Parsing, MF, Fall 2003 – p.7/16

Page 15: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Finite automata as models:

Embedded computer systems

02140 Languages and Parsing, MF, Fall 2003 – p.8/16

Page 16: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

The coffee vending machine — architecture

Vending machine

cout

Financialadministr.

Brewercontrol

caf

canccoin req

02140 Languages and Parsing, MF, Fall 2003 – p.9/16

Page 17: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

The coffee vending machine — dynamics

brewidle wait

no payno pay

(*, *, *, req, −caf)(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid(cin, *, −cout, *, *)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

02140 Languages and Parsing, MF, Fall 2003 – p.10/16

Page 18: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

An example run

brewidle wait

no payno pay

(*, *, *, req, −caf)(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid(cin, *, −cout, *, *)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, −canc, −cout, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, canc, *, −req, −caf)

Brewer control

paid

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, −cout, *, caf)

(*, *, *, *, caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

02140 Languages and Parsing, MF, Fall 2003 – p.11/16

Page 19: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

An example run

brewidle wait

no payno pay

(*, *, *, req, −caf)(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid(cin, *, −cout, *, *)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, −canc, −cout, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, canc, *, −req, −caf)

Brewer control

paid

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, −cout, *, caf)

(*, *, *, *, caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

02140 Languages and Parsing, MF, Fall 2003 – p.11/16

Page 20: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

An example run

brewidle wait

no payno pay

(*, *, *, req, −caf)(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid(cin, *, −cout, *, *)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, −canc, −cout, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, canc, *, −req, −caf)

Brewer control

paid

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, −cout, *, caf)

(*, *, *, *, caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

02140 Languages and Parsing, MF, Fall 2003 – p.11/16

Page 21: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

An example run

brewidle wait

no payno pay

(*, *, *, req, −caf)(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid(cin, *, −cout, *, *)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, −canc, −cout, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, canc, *, −req, −caf)

Brewer control

paid

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, −cout, *, caf)

(*, *, *, *, caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

02140 Languages and Parsing, MF, Fall 2003 – p.11/16

Page 22: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

An example run

brewidle wait

no payno pay

(*, *, *, req, −caf)(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid(cin, *, −cout, *, *)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, −canc, −cout, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, canc, *, −req, −caf)

Brewer control

paid

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, −cout, *, caf)

(*, *, *, *, caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

02140 Languages and Parsing, MF, Fall 2003 – p.11/16

Page 23: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

An example run

brewidle wait

no payno pay

(*, *, *, req, −caf)(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid(cin, *, −cout, *, *)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, −canc, −cout, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, canc, *, −req, −caf)

Brewer control

paid

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, −cout, *, caf)

(*, *, *, *, caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

02140 Languages and Parsing, MF, Fall 2003 – p.11/16

Page 24: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

An example run

brewidle wait

no payno pay

(*, *, *, req, −caf)(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid(cin, *, −cout, *, *)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, −canc, −cout, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, canc, *, −req, −caf)

Brewer control

paid

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, −cout, *, caf)

(*, *, *, *, caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

02140 Languages and Parsing, MF, Fall 2003 – p.11/16

Page 25: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

An example run

brewidle wait

no payno pay

(*, *, *, req, −caf)(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid(cin, *, −cout, *, *)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, −canc, −cout, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, canc, *, −req, −caf)

Brewer control

paid

(*, canc, cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, −cout, *, caf)

(*, *, *, *, caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

brewidle wait

no payno pay

(*, *, *, req, −caf)

(*, −canc, *, −req, −caf)

(*, canc, *, −req, −caf)

(*, *, *, *, caf)

Brewer control

paid

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, −canc, −cout, *, −caf)

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

brewidle wait

no payno pay

Brewer control

paid

Financial administration

(−cin, *, −cout, *, *)

(−cin, *, *, *, −caf)

(cin, *, −cout, *, *)

(cin, *, *, *, −caf)

(*, −canc, *, −req, −caf)

(*, *, *, req, −caf)

(*, −canc, −cout, *, −caf)

(*, *, *, *, caf)

(*, *, −cout, *, caf)

(*, canc, cout, *, −caf)

(*, canc, *, −req, −caf)

02140 Languages and Parsing, MF, Fall 2003 – p.11/16

Page 26: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

The coffee vending machineProduct automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, *, caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(cin, *, −cout, *, −caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(*, canc,

cout, r

eq, −

caf)

Product automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, *, caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(cin, *, −cout, *, −caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(*, canc,

cout, r

eq, −

caf)

Unreachable states!

Product automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(cin, *, −cout, *, −caf)

(*, canc,

cout, r

eq, −

caf)

(−cin, *, −cout, *, caf)

Free coffee!

02140 Languages and Parsing, MF, Fall 2003 – p.12/16

Page 27: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

The coffee vending machine

Product automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, *, caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(cin, *, −cout, *, −caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(*, canc,

cout, r

eq, −

caf)

Product automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, *, caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(cin, *, −cout, *, −caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(*, canc,

cout, r

eq, −

caf)

Unreachable states!

Product automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(cin, *, −cout, *, −caf)

(*, canc,

cout, r

eq, −

caf)

(−cin, *, −cout, *, caf)

Free coffee!

02140 Languages and Parsing, MF, Fall 2003 – p.12/16

Page 28: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

The coffee vending machine

Product automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, *, caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(cin, *, −cout, *, −caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(*, canc,

cout, r

eq, −

caf)

Product automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, *, caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(cin, *, −cout, *, −caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(*, canc,

cout, r

eq, −

caf)

Unreachable states!

Product automaton: Financial admin. * Brewer ctrl.

(*, −canc, −cout, req, −caf)

no pay no pay no pay

paid paid paid

(*, −canc, −cout, −req, −caf)

(−cin, *, −cout, req, −caf)

(−cin, −canc, −cout, −req, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(−cin, *, −cout, *, −caf)

(−cin, −can, −cout, *, −caf)

(*, canc, cout, −req, −caf)

(*, *, −cout, *, caf)

brew

idle wait brew

idle wait(−cin, canc, −cout, −req, −caf)

(cin, *, −cout, *, −caf)

(*, canc,

cout, r

eq, −

caf)

(−cin, *, −cout, *, caf)

Free coffee!

02140 Languages and Parsing, MF, Fall 2003 – p.12/16

Page 29: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

What you’ll learn

1. The model of finite automata,

2. methods for expressing properties like “free coffee”, namelyregular expressions,

3. algorithms for manipulating regular languages,

4. how to plug these algorithms together such that theyautomatically check properties like “free coffee”.

I.e., you will build programs which analyze programs!

02140 Languages and Parsing, MF, Fall 2003 – p.13/16

Page 30: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

What you’ll learn

1. The model of finite automata,

2. methods for expressing properties like “free coffee”, namelyregular expressions,

3. algorithms for manipulating regular languages,

4. how to plug these algorithms together such that theyautomatically check properties like “free coffee”.

I.e., you will build programs which analyze programs!

02140 Languages and Parsing, MF, Fall 2003 – p.13/16

Page 31: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Embedded systems in-the-large

02140 Languages and Parsing, MF, Fall 2003 – p.14/16

Page 32: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Context-free languages:

Application domains

02140 Languages and Parsing, MF, Fall 2003 – p.15/16

Page 33: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Context-free languages

arise naturally in

� in the definition of programming languages, query lang., etc.:

if � is a natural number then � is an arithmetic expression,

if ��� and ��� are arithmetic expressions then � � � ��� is an arithmeticexpression,

� � �

formal definition permits tool support by compiler-compilers,

� descriptions of expected document structures, e.g. DTDs in XML

formal def. facilitates conformance check and automatic decomposition.

You’ll learn

to formally define context-free languages,

to use compiler-compilers based on CFLs.

02140 Languages and Parsing, MF, Fall 2003 – p.16/16

Page 34: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Context-free languages

arise naturally in

� in the definition of programming languages, query lang., etc.:

if � is a natural number then � is an arithmetic expression,

if ��� and ��� are arithmetic expressions then � � � ��� is an arithmeticexpression,

� � �

formal definition permits tool support by compiler-compilers,

� descriptions of expected document structures, e.g. DTDs in XML

formal def. facilitates conformance check and automatic decomposition.

You’ll learn

to formally define context-free languages,

to use compiler-compilers based on CFLs.

02140 Languages and Parsing, MF, Fall 2003 – p.16/16

Page 35: Introduction to Formal LanguagesIntroduction to Formal Languages Martin Franzle¨ Informatics and Mathematical Modelling The Technical University of Denmark 02140 Languages and Parsing,

Context-free languages

arise naturally in

� in the definition of programming languages, query lang., etc.:

if � is a natural number then � is an arithmetic expression,

if ��� and ��� are arithmetic expressions then � � � ��� is an arithmeticexpression,

� � �

formal definition permits tool support by compiler-compilers,

� descriptions of expected document structures, e.g. DTDs in XML

formal def. facilitates conformance check and automatic decomposition.

You’ll learn

� to formally define context-free languages,

� to use compiler-compilers based on CFLs.

02140 Languages and Parsing, MF, Fall 2003 – p.16/16