BaraghimianGregory1985

CALIFORNIA STATE UNIVERSITY, NORTHRIDGE
SIMULATION OF FINITE STATE AUTOMATA
~D
REGULAR EXPRESSION RECOGNITION
A graduate project submitted in partial satisfaction of
the requirements for the degree of Master of Science in
Computer Science
by
Gregory Anthony Baraghimian, I
January, 1985
I'
The Graduate Project of Gregory Anthony Baraghimian,
is approved:
California State University, Northridge
ii
r.
'
DEDICATION
I would
like
to
dedicate
this
thesis
Namely,
to my wife, Kathy, for the love and understanding
she has shown and the sacrifices she
the
has
to
iii
family.
endured
many hours required to complete my thesis.
ry, my new son.
my
during
To Grego-
TABLE OF CONTENTS
DEDICATION .
iii
ABSTRACT • .
vii
1.0 GENERAL DESCRIPTION OF THE PROJECT
1
2.0 SIMFARE REQUIREMENTS . . • . . . .
2.1 Data Base Requirements . . . . . .
2.1.1 NDFSM Data Structure .
. ..
2.1.2 DFSM Data Structure . . . . . .
2. 1. 3 RE Data Structure
. . . . .
2. 2 SIMFARE Inputs . . . .
. . . .
2.3 SIMFARE Outputs
........ .
3
3
3.0
3.1
3.2
3.3
3.4
SIMFARE DESIGN SPECIFICATION .
DFSM to RE . . . . . • . . . .
RE to NDFSM
NDFSM to DFSM . . . . . . . .
Minimum DFSM .
.
.
.
4.0 SIMFARE USER'S MANUAL
... .
4.1 Introduction • . . . .
. ..
4.2 SIMFARE Capabilities and Methodology
4.2.1 SIMFARE Features .
. ..
4.2.2 Methodology . . .
. ....
4.2.3 Limitations
. . .
. ...•
4.3 SIMFARE Menu Organization and Use
.
4.3.1 Old Construct . . . . . . .
4.3.2 New Construct
• . .
. .•. .
4.3.2.1 New FSM
..•......
4. 3. 2. 2 New RE . . .
. . . . .
4.3.3 Query/Results
...... .
4.3.3.1 Display RE •
. ..
•
4.3.3.2 Display NDFSM . . • • . . • .
4.3.3.3 Display DFSM . . • .
. ..
4.3.3.4 Display Minimum DFSM . . . . .
4.3.3.5 Simulate a Word on the DFSM . .
4.3.3.6 Compare Another Construct
4.3.3.7 See if a Word is in the DFSM .
4.3.3.8 List All Words in the DFSM • .
4.3.3.9 Count How Many Words Accepted
4.4 Sample SIMFARE Session . . . . . .
iv
.
.
.
3
.
• •
.
8
8
. . 11
. . 12
.
.
.
.
.
.
. • . . 13
. . 13
. . 14
. . '15
. . 16
. • . . 17
. . . . 18
. • . . 19
. 19
• • 20
.
. .
. .
.
.
• • • .
. 21
. 21
. 21
• 22
. 22
. 24
. 25
•
• •
• 25
. 26
. 26
27
. . 27
. 28
. 28
. 29
. . . . 29
. . . . 53
.
.
•
.
.
TABLE OF CONTENTS
5.0 FUTURE CONSIDERATIONS
. 77
. . 79
BIBLIOGRAPHY .
APPENDIX .
. .
80
A REQUIREMENTS • . • . . . • .
. . . .
A.l Functional Summary . . • .
A.2 Details Concerning System User Interactions
.
A.2.1 Requirements Diagram . . • .
A.2.2 State Diagram Specifications . . • . . . . .
A.2.3 Text Representation . . . . . . . . . . . .
A.2.3.1 User-Interactive Text Representation . . .
A.2.3.1.1 User:
. . . . . . .
. ...
A. 2 . 3 . 1 . 2 Act: . . . . . . . . . . . . . . . .
A. 2. 3 . 1 . 3 Cond:
. . . . • . . . . • . • .
. .
A.2.3.1.4 Top Level Text Representation
.
A.2.3.1.4.1 New Construct Processing . . . . . . .
A.2.3.1.4.2 Display Results
. . . • . .
.
A.2.3.2 Computational State Text Representation .
A.2.3.2.01 Create New FSM
..
A.2.3.2.02 Create New RE .
. .......
A.2.3.2.03 Display DFSM . . . . . . . • . . . . .
A.2.3.2.04 Display NDFSM . • . . . . . . . . .
A.2.3.2.05 Display Minimum DFSM . . .
. ...
A.2.3.2.06 Display RE
. . .
. ..
A.2.3.2.07 Compare DFSM . . . . .
A.2.3.2.08 Check for Word Accept .
. ..•..
A.2.3.2.09 Simulate Transition .
. ..•...
A.2.3.2.10 List All Words of a Chosen Length . . .
A.2.3.2.11 Find How Many Words Accepted
.
A.2.4 Data Structures . . .
. ....
A.2.4.1 NDFSM Data Structure .
A.2.4.2 DFSM Data Structure . . .
A.2.4.3 RE Data Structure
........
B DESIGN •
B.l Data Structures . • .
B.2 SIMFARE . . . . . • .
B.2.1 Initialize . • . . . . .
B.2.2 Menu 0 . . . . .
B.2.3 Old Construct Processing
B.2.3.1 Menu 1· . . . . . . . .
B.2.3.2 Retrieve Old Data
B.2.4 New Construct Processing
B.2.4.1 Menu 2 . . . . . . . •
B.2.4.2 Create FSM . . . . . .
v
. .
. .
. .
. .
..... . . .
. .
•..... . .
....
.
. ....
. ... .
80
80
80
82
85
89
89
89
89
90
90
91
91
93
93
94
94
95
95
96
96
96
97
97
97
97
98
98
. . 99
. . 99
.
101
. 103
. 104
.
105
.
107
. 108
109
. 111
112
TABLE OF CONTENTS
8.2.4.2.1 Choose State Names . .
8.2.4.2.1.1 Menu 21
. . . .
8.2.4.2.1.2 Menu 22
. . . . . .
8.2.4.2.2 Choose Start State .
8.2.4.2.2.1 Menu 23
. . • . .
8.2.4.2.3 Choose Accept States .
8.2.4.2.3.1 Menu 24 . . . . . .
8.2.4.2.4 Choose Input Symbols •
8.2.4.2.4.1 Menu 25 . . . . • .
8.2.4.2.4.2 Menu 26 . . . . . .
8.2.4.2.5 Get Transitions
. . .
8.2.4.2.5.1 Menu 27
. . . .
8.2.4.2.5.2 Menu 271 . . .
.
8.2.4.2.5.3 Menu 272 . . . . . •
8.2.4.2.5.4 Make Transition . .
8.2.4.2.5.5 Remove Transition
8.2.4.2.5.6 Determine Type . . .
8.2.4.3 Create RE . . . . . . .
8.2.4.3.1 Menu 28 . • • . . . •
8.2.4.4 Generate Automata . . .
8.2.4.4.1 Generate NDFSM . . .
8.2.4.4.2 Generate DFSM . • .
8.2.4.4.2.1 Null Closure . . . .
8.2.4.4.3 Generate RE . . . . .
8.2.4.4.4 Generate Minimum DFSM
8.2.4.5 Save Construct . . . . .
8.2.5 Give Results . . . . . . .
8.2.5.01 Menu 31 . • . .
8.2.5.02 Menu 32
8.2.5.03 Display RE
. . .
8.2.5.04 Display NDFSM .
8.2.5.05 Display DFSM . . . . •
8.2.5.06 Display Minimum DFSM .
8.2.5.07 Simulate DFSM •
. .
8.2.5.07.1 Menu 36 . . . . • • .
8.2.5.08 Compare Construct . . .
8.2.5.09 Member of DFSM . . . .
8.2.5.10 Words of DFSM .
8.2.5.11 Words Accepted
. . . .
vi
. . .
. . .
.
.
•
.
.
.
.
.
•
.
.
. •
. .
. •
. .
. .
. .
. .
• • .
.
. . .
. . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
. .
. .
. .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. . .
.
.
. . .
. . .
•
.
• . .
. . .
.
.
. . .
. . .
.
. . .
. . .
. . .
.
.
.
. . .
.
. . •
.
. . .
. .
.
. . .
•
.
. . .
.
. . .
. . .
. . .
. . .
.
.
. . .
•
.
•
.
•
.
.
.
.
•
.
.
. .
. .
. .
. .
.
.
• .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
.
.
113
115
116
117
118
119
120
121
123
124
125
127
128
129
130
131
132
134
136
137
139
140
142
143
144
145
146
148
149
150
151
152
153
154
155
156
158
159
160
ABSTRACT
SIMULATION OF FINITE STATE AUTOMATA
AND
REGULAR EXPRESSION RECOGNITION
by
Gregory Anthony Baraghimian, I
Master of Science in Computer Science
This
report
describes the design and implementation of a
demonstration system called the SIMulation of Finite Automata
and
software
Regular Expression recognition (SIMFARE).
system
provides
This
the user with a method of com-
paring Finite State Machines and Regular Expressions,
and
also displays the flow of input strings through the states
of a Finite State Machine.
vii
1.0
GENERAL DESCRIPTION OF THE PROJECT
When taking a course on
abstract
machines
and
abstract
grammers, it would be beneficial to have automated automata demonstration utilities at one's disposal.
ties
would,
Such utili-
at a minimum, display on a computer terminal
the flow of input through the states of a Finite State Machine.
The
ability
to
visualize
this process in this
fashion would enable the student to clearly grasp the concepts of the course material.
This project, which I have called SIMFARE
Finite
of
Automata and Regular Expression recognition), is a
design of such software utilities.
the
(SIMulation
design
of
The
project
entails
a computer program which demonstrates, in
user-interactive fashion, the operations of and
relation-
ships between finite automata and regular expressions.
The specific goals of SIMFARE, which allow the user to obtain
a good understanding of finite state machines (FSMs)
and regular expressions (REs) are as follows.
1.
Construct a picture of a non-deterministic
FSM from a state transition function.
•.:".
1
2
2.
Construct a picture of a deterministic
from a non-deterministic FSM.
FSM
3.
Find an equivalent FSM which has the minumum
number of states.
4.
Simulate a computation of a
FSM for a given input string.
5.
Construct the equivalent FSMs
(both deterministic and non-deterministic)
from a RE
(and vice versa).
6.
Determine if an input string is a member
the language generated by a RE.
of
7.
Determine if an input string is accepted
a FSM.
by
8.
Show all the words of a certain length which
are members of a RE, or equivalently, are
accepted by a FSM.
9.
Determine if a FSM accepts zero,
number,
or an infinite number
strings.
deterministic
a finite
of input
10. Compare two FSMs for equivalence.
The remaining chapters discuss the requirements,
sign,
and
the
user's manual of SIMFARE.
contain the actual documents:
the
de-
The appendices
Appendix A is the
require-
ments document and Appendix B is the design document.
v .
2.0
SIMFARE REQUIREMENTS
The requirements document explains the functions that SIMFARE should perform.
This chapter briefly covers the data
base requirements, the user supplied
and
the
outputs
inputs
generated by SIMFARE.
to
SIMFARE,
For the complete
requirements document, consult Appendix A.
2.1
DATA BASE REQUIREMENTS
SIMFARE uses three
fundamental
data
structures.
These
a non-deterministic finite state machine (NDFSM), a
are:
deterministic finite state machine (DFSM), and
a
regular
expression (RE).
2.1.1
NDFSM DATA STRUCTURE - The record
non-deterministic
finite
structure
Start
AcceptStates
a
state machine is given below in
Pascal code.
type NDFSM = record
Numstates
StateNames
of
(l .. MaxNumStates];
array (l .. MaxNumStates] of
Names;
integer;
array [l .. MaxNumStates] of
Boolean;
3
4
NumSymbols
SymbolNames
[l .• MaxNumSymbols]~
array [l .. MaxNumSymbols] of
Transition
array [l •• MaxNumStates] of array
[l .• MaxNumSymbols] of TransType
Names~
end~
where,
Names= array [l .. MaxNameLength] of
ascii~
TransType = record
Count : integer~
Link : LinkType
end~
LinkType = record
Val : [l .. MaxNumStates]~
Next : LinkType
end~
The following example explains what these Pascal
tions
implement.
Suppose
bars at 15 cents each.
inserting
any
declara-
a vending machine sells candy
A candy bar may
be
purchased
by
one of the following combinations of coins
into the vending machine:
three nickels, one at a time
one dime, followed by one nickel
one nickel, followed by one dime
Now, in a Pascal program, if "VM" is
type
"NDFSM",
then
the
declared
SetUpVM~
be
of
following Pascal procedure will
correctly implement the vending machine:
Procedure
to
5
Begin
VM.NumStates
VM.StateNames[l]
VM.StateNames[2]
VM.StateNames[3]
VM.StateNames[4]
VM.Start :=
{ there are four states }
:= 4~
1~
: = ' START ' ~
: = 'FIVE'~
: = 'TEN'~
: = 'ACCEPT'
~
{ these are
{
the names
{
of the
{
four states
l
}
}
}
{ the first state is the start state }
VM.AcceptStates[l] :=False~ { only the
VM.AcceptStates[2] :=False; {
fourth state
VM.AcceptStates[3] :=False; [
is an
{
VM.AcceptStates[4] :=True~
accepting state
VM.NumSymbols := 2;
J
J
J
}
{ there are two input symbols }
}
VM.SymbolNames[l] := 'nickel'; { these are the
{ input symbol names }
VM.Symbo1Names[2] : = • dime • ~
{
[
[
{
{
{
[
{
{
{
[
{
{
{
[
{
{
{
The remaining assignments of this procedure define
the transition function. One transition, for
example, takes the machine from the START state to
state "FIVE" if the current input symbol is
"nickel". Since the START state is state 1 and
"nickel" is the first input symbol, then the
desired element of the Transition array is
Transition[l][l]. Since there is only one state
which the machine may transition to when reading
"nickel" at the START state, the Count field of
of the Transition[l][l] record has the value "1".
The value of the first Link field,
Transition[l][l].Link.Val, is "2" since the state
to be transitioned to under the current conditions
is state "FIVE". Since there is only one state
which can be transitioned to under t~e current
conditions, the value of
Transition[l][l].Link.Next is null.
VM.Transition[l][l].Count := 1~
VM.Transition[l][l].Link.Val := 2;
VM.Transition[l][l].Link.Next :=null;
VM.Transition[l][2].Link.Count := 1~
VM.Transition[l][2].Link.Val := 3~
VM.Transition[l][2].Link.Next := null;
VM.Transition[l][3].Count := 0~
VM.Transition[l][4].Count := 0~
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
6
VM.Transition[2][1].Count := 1;
VM.Transition[2][1].Link.Val := 3;
VM.Transition[2][1].Link.Next := null7
VM.Transition[2][2].Count := 17
VM.Transition[2][2].Link.Val := 47
VM.Transition[2][2].Link.Next := null7
VM.Transition[2][3].Count := 0;
VM.Transition[2][4].count := 07
VM.Transition[3][1].Count := 17
VM.Transition[3][1].Link.Va1 := 4;
VM.Transition[3][1].Link.Next :=null;
VM.Transition[3][2].Count := 07
VM.Transition[3][2].Count := 07
VM.Transition[3][2].Count := 0;
VM.Transition[4][1].Count := 0;
VM.Transition[4][2].Count := 07
VM.Transition[4][3].Count := 07
VM.Transition[4][4].Count := 0;
End;
Refer to Figure 2-1 for the
this machine.
tic.)
pictorial
representation
of
(Note that this machine is also determinis-
7
I
-------------->1
1
I
I
I
---1
!-----"-\
FIVE
I
1----I
!dime
\------/
I
I
I
I
I
I
nickel
nickel!
I
I
----> I
I
1-------\
.
START
\-------1
I
I
I
I
dime!
I
I
I
I
--> I
-------------->1
1
FIGURE 2-1
//======\\
II
I I ACCEPT I I
----- > I I
II
I
\\======//
I
I
I
I
I
I nickel
-----> I I
/-------\
TEN
\-------1
I
1---I
FINITE STATE MACHINE EXAMPLE
State Diagram Specification
8
2.1.2
DFSM DATA STRUCTURE - The record
structure
for
a
deterministic finite state machine is identical to that of
the NDFSM, as given above, with the
the
that
if
'M', is in state 'q' (where 'q' is a member
machine,
of the set, 'K', of states of 'M'),
symbol
restriction
and
the
next
input
to be read is 'a', then the transition, d(q,a), is
a member of 'K' and is the uniquely
which 'M' passes.
type DFSM
=
determined
state
to
Therefore, the record structure is,
record
Transition
array [1 .. MaxNumStates] of array
[ 1. .MaxNumsymbols] of integer
end;
2.1.3
RE DATA STRUCTURE - A regular expression is
internally as a tree and has the following type.
type NodePtr
=
ANode;
Node = record
Val
integer;
sons : [1 .. MaxNumSons];
Ptr : array [1 .. MaxNumSons] of NodePtr
end;
var
RE
NODEPTR;
stored
The following example explains what these Pascal
tions
implement.
Suppose
that
the regular expression,
" ( (123)+(xyz) )", is to be implemented.
program,
declara-
Now, in
a
Pascal
if "RE" is declared as above, then the following
Pascal procedure will correctly implement the regular
ex-
pression:
Procedure SetUpRE:
Begin
{ Assuming that the input symbols, "123" and "xyz", }
{are mapped to the integers, 1 and 2, respectively,}
{ and that the OR operator, "+", is mapped to the
}
{ integer 0, then the "Val" field of the "Node"
}
{ record simply contains the integer representation }
{ of either an input symbol or an operator.
}
REA.Val := 0:
{ denotes the OR operator }
REA.Sons := 2:
{ points to the two input strings }
REA.Ptr[l]A.Val := 1:
{denotes the symbol "123"}
REA.Ptr[l]A.Sons := 0: { does not point any further }
REA.Ptr[2]A.Val := 2:
{denotes the symbol "xyz"}
REA.Ptr[2]A.Sons := 0 { does not point any further }
End:
Refer to Figure 2-2 for the
this regular expression.
pictorial
representation
of
10
I
---------------1
1
I
I
I
I
I
I
I
I
I
I
1-----\
+
\-----/
I
1--------------I
I
I
I
I
I
I
I
I
I
I
1-----\
1-----\
\-----1
\-----1
I
I
I 123 I
I
I
FIGURE 2-2
I
I
I xyz I
I
I
REGULAR EXPRESSION EXAMPLE
State Diagram Specification
11
2.2
SIMFARE INPUTS
SIMFARE requires the user
structures
listed
in
to
supply
section 2.1.
one
of
the
three
Given this input re-
cord, SIMFARE will internally generate the
two
remaining
structures, along with the corresponding minimum DFSM.
this point, SIMFARE
has
prepared
four
equivalent
At
data
structures and is ready to supply output as desired by the
user.
12
2.3
SIMFARE OUTPUTS
SIMFARE will perform the following operations,
or
more
2.2.
using
one
of the four data structures mentioned in section
The user selects the operation to be performed, cho-
osing
from
the
list below, and SIMFARE will display the
results.
1.
Determine whether or not a user supplied word is
a member of the language accepted by the DFSM.
2.
Simulate the state transition diagram of the DFSM
for a user supplied word.
3.
List all words of a certain length, specified by
the user, which are accepted by the FSM, or are
members of the language accepted by the RE.
4.
State how many words are accepted by the FSM,
where the possible answer is either "zero", "a
finite number", or "an infinite number".
5.
Compare two FSMs for equivalence.
3.0
SIMFARE DESIGN SPECIFICATION
The overall design document defines
data
ab-
discusses
the
non-trivial algorithms used in the design of SIMFARE.
For
stractions
and
modules.
This
the
chapter
major
the complete design document, consult Appendix B.
3.1
DFSM TO RE
The method used to convert a DFSM to a RE is based on
the
proof of the theorem, "If a language is accepted by a finite automaton, then it is regular." (This theorem
on
pages
69-73
of reference [5].) Informally, the proof
defines a deterministic finite automaton, M, and
to find a regular language, R, such that R
=
number
proceeds
L(M).
and "j" are states of the DFSM, and "k" is one
the
appears
If "i"
more
than
of states of the DFSM, then it has been shown
algorithmically that if
R(i,j,k+l)
=
R(i,j,k) U R(i,k,k)R(k,k,k)*R(k,j,k),
then, by induction, the language R is regular.
This equation states that to get from state-i
to
state-j
without passing through a state numbered greater than k, M
may either
13
14
1.
go from state-i to state-j without
passing
through a state numbered greater then k-1; or
2.
go
1.
from state-i to state-k;
then
2.
from state-k to state-k repeatedly;
3.
from state-k to state-j;
then
in each case without passing through a state numbered greater than k-1.
3.2
RE TO NDFSM
The method used to construct a NDFSM, N, which accepts the
language
denoted by the regular expression, R, is as fo1-
lows.
R is first decomposed into its primitive components.
each
component,
follows.
induction.
For
the NDFSM is constructed inductively, as
Parts 1 and 2 form the basis and part 3
is
the
15
1.
For each null symbol, construct the NDFSM:
1-----\
I
I
I
i
//===\\
I null
II
1---------->1 I
I
II
II
\\===//
\-----1
2.
For each non-null symbol, a, in R, construct
NDFSM:
1-----\
I
I
I
I
j
a
g
II
II
II
\\===//
Each time a new state is needed, it
new name.
3.3
the
//===\\
II
II
1---------->1 I
I
\-----1
3.
f
II
II
is
given
a
Having constructed components for the basis regular expressions,
they are combined in. ways that
correspond to the way compound regular expressions are formed from smaller regular expressions.
NDFSM TO DFSM
The method used to construct a DFSM from a
NDFSM
is
the
typical subset construction, a description of which can be
found on pages 91-93 of reference [1].
16
3.4
MINIMUM DFSM
The method used to construct a minimum-state DFSM
DFSM
can
be
found
on
pages
99-103
from
a
of reference [2].
Basically, there are four steps:
1.
Construct the dual of the DFSM.
2.
Apply the previously mentioned
tion to the dual.
3.
Construct the dual of the
4.
Apply the subset construction once again.
The
result will be a DFSM which accepts the same
input strings as the original DFSM, and which has
the smallest number of states of any finite automaton equivalent to the original DFSM.
subset
construc-
resul~.
(1
•
4.0
SIMFARE USER'S MANUAL
The User's Manual describes the features and use
of
SIM-
FARE.
The Menu Organization Section is one major section of
User's
Manual.
The
the
screen is split into two regions, a
text region where SIMFARE displays the choices to
be
se-
lected from each menu, and a graphics region where the actual results (FSMs and REs) are displayed.
The Sample Session Section is the other major
the
User's
Manual.
of
A novice user can better understand
SIMFARE and the results of the menus through a
display
section
series
of
screens, accompanied by explanatory text that il-
lustrates an actual SIMFARE session.
The actual SIMFARE User's Manual document follows.
17
18
SIMFARE USER'S MANUAL
4.1
INTRODUCTION
SIMFARE (SIMulation of Finite Automata and Regular Expressions) is an interactive program for displaying the operations of and relationships
between
finite
automata
and
regular expressions.
Section 4.2 lists the major capabilities and
features
of
SIMFARE and presents the methodology for its use.
Section 4.3 presents the user with detailed procedures for
using SIMFARE.
Section 4.4 is a sample SIMFARE session.
19
4.2
SIMFARE CAPABILITIES AND METHODOLOGY
SIMFARE has many capabilities and features.
Section 4.2.1
gives
Section 4.2.2
an
overview
of these capabilities.
defines how these capabilities are realized in SIMFARE.
4.2.1
SIMFARE FEATURES - The specific functions
of
SIM-
FARE allow the user to obtain a good understanding of finite state machines (FSMs) and regular
expressions
(REs).
SIMFARE can:
1.
Construct a picture of a non-deterministic
from a state transition function.
2.
Construct a picture of a deterministic FSM from a
non-deterministic FSM.
3.
Find an equivalent
number of states.
4.
Simulate a computation for a given input string.
5.
Construct the equivalent FSMs (both deterministic
and non-determinstic) from aRE (and vice versa).
6.
Determine if an input string is a member
language generated by a RE.
7.
Determine if an input string
FSM.
8.
Show all the words of a certain length which are
members of a RE or, equivalently, are. accepted by
a FSM.
9.
Determine if a FSM accepts zero, a finite number,
or an infinite number of input strings.
FSM
which
has
is
the
accepted
FSM
minumum
of
the
by
a
20
10. Compare two FSMs for equivalence.
4.2.2
METHODOLOGY - SIMFARE performs its various
functions through the use of menus.
available:
for
display
Two sets of menus are
one set for creating FSMs and REs, and one set
displaying the results as listed in the previous sec-
tion.
The screen is split into
two
sections:
where
the
choices to be selected from
SIMFARE
displays
a
text
each menu, and a graphics region where the actual
(FSMs and REs) are displayed (see FIGURE 4-1).
tal line of text separating the two sections
appear
ice.
on
to
region
results
A horizonwill
always
instruct the user on how to make the next cho-
This line appears in reverse video (black characters
a
white background), and is also used as the location
where the error messages are displayed.
You use the four arrow keys for all of the menus that
quire a choice from a number of options.
re-
21
4.2.3
LIMITATIONS - SIMFARE may be used
on
any
Teleray
terminal, model number lOT.
4.3
SIMFARE MENU ORGANIZATION AND USE
Upon invoking SIMFARE, the Main Menu (FIGURE 4-2) will appear on the screen.
At this point, you may choose to ere-
ate a new SIMFARE construct (a FSM or aRE), or call up
previously
created
construct.
Once either of these cho-
ices has been made and SIMFARE returns to the
you
a
Main
Menu,
may select "QUERY/RESULTS" in order to invoke the de-
monstrations to be applied
to
the
chosen
SIMFARE
con-
struct.
4.3.1
OLD CONSTRUCT - If you wish to work with a
construct
which
was
previously created, then select the
choice "OLD CONSTRUCT" of the Main Menu.
selection,
you
will
retrieve
all
Upon entering this name,
does
not
this
SIMFARE
the information pertaining to the old
construct (previously saved on disk).
which
Following
be prompted for the name of the old
construct (FIGURE 4-3).
will
SIMFARE
correspond
to
If you enter a name
an existing SIMFARE con-
struct, then an error message will be
displayed
and
you
22
may retry to enter an old construct name.
4.3.2
NEW CONSTRUCT - If you wish to create a new SIMFARE
construct,
then
select
this
option from the Main Menu;
the New Construct Menu (FIGURE 4-4) will then
yed.
be
displa-
At this point, you must specify whether a new finite
state machine or a new regular expression
fined.
is
to
be
de-
After defining the new construct, SIMFARE prompts
for a file name under which the construct
will
be
saved
for future SIMFARE sessions.
4.3.2.1
NEW FSM -At this point, you will begin to define
a new FSM.
Follow the steps below.
1.
Choose the number of states (from 1
(FIGURE 4-5)
to
8).
2.
Enter the names of each state.
Each name
may be up to 15 characters in length, comprised of the upper case characters 11 A-Z 11
and 11 0-9 11 (FIGURE 4-6) .
3.
Choose the start state (FIGURE 4-7).
4.
Choose the accepting state(s) (FIGURE 4-8).
After each accepting state is chosen, its
name will be displayed in reverse video.
5.
Choose the number of input symbols
to 8)· (FIGURE 4-9).
6.
Enter the names of each input symbol.
(from
1
Each
(l'
23
name may be up to 8 characters long, comprised of the lower case characters "a-z"
and "0-9" (FIGURE 4-10). If the null input
symbol is desired, then its name must be
"null".
7.
Enter the transition function as follows.
First,
the states are graphically drawn
somewhat like circles. The start state has
an arrow pointing into its corresponding
circle, and the accepting state(s) are represented by two concentric circles (FIGURE
4-11). Then, the state names and input symbol names are listed to the right of the
state diagram.
(also FIGURE 4-11).
Now,
for each transition, the steps below follow.
1.
Select the "Choose Source State" option,
and choose the source state for the
transition.
2.
Select the "Choose Destination State"
option and choose the destination state
for the transition.
3.
Select the "Make Transition" option, and
choose the input symbol to be used for
the transition.
4.
If a mistake has been made,
then the
"Remove Transition" option may be selected.
5.
When all transitions have been defined,
choose the "Transition Function Complete" option.
Note that when creating the FSM, the
show
two
arcs
crossing each other.
display
will
never
This may not be the
24
case when it comes time to view the results.
4.3.2.2
NEW RE - At this point, you will be
prompted
to
enter a new regular expression following the rules:
1.
There may be up to seven input symbol names, plus
the null symbol.
2.
A symbol name may be at most eight characters in
length (composed of small letters a-z, and/or the
numbers 0-9).
3.
If the null symbol is desired,
name is "null".
4.
The syntax of a RE is:
: :=
re
where
5.
( , a, )
(re.re)
its
symbol
(re*)
, ,
a is a typical input symbol name.
The entire length of a RE may not exceed 60 characters.
The following examples are
above.
(re+re)
then
given
to
clarify
the
rules
Assume that there are three input symbols with the
names 'xyz', '123', and 'abc'.
1.
(xyz)
2.
((xyz)+(l23))
3.
((abc).(l23))
4.
( (abc)*)
5.
((123).(((abc)+(xyz))*))
25
4.3.3
QUERY/RESULTS - Once
struct,
old
you
choose
a
SIMFARE
or new, control is returned to the Main Menu
where the Query/Results option may be selected.
this
selection,
SIMFARE
more
types
of
Following
prompts for the type of results
which you want to be displayed (FIGURE 4-12).
are
con-
results
than
will
Since there
fit on one menu
screen, there is an option, "next menu", which,
when
se-
lected, will prompt you for the remaining types of results
to be displayed (FIGURE 4-13).
All
together,
there
nine different types of results to choose from.
inder of this section describes exactly how
are
The rema-
SIMFARE
per-
forms with respect to each of these nine results.
4.3.3.1
from
the
DISPLAY RE - To view the RE, select
first Query/Results menu;
to be displayed (FIGURE 4-14).
this
option
it will cause the RE
Note that
the
RE
to
be
displayed is either the one entered when creating the current SIMFARE construct, or is the one which SIMFARE generated
internally
current construct.
by using the FSM entered by creating the
If the latter case is
true,
but
the
RE, which SIMFARE generated, is greater than 60 characters
26
long, then it can not be displayed.
4.3.3.2
then
DISPLAY NDFSM - If you wish to
selecting
this
view
with
a
table
transitions
be
displayed,
of state names and a table of input
symbol names (FIGURE 4-15).
which
NDFSM,
option from the first Query/Results
menu will cause the states of the NDFSM to
along
the
you
You are now
desire
to see.
free
to
choose
Note that if the
NDFSM was internally generated by SIMFARE (because you defined
the
current construct as aRE or a DFSM), then the
state names and the input symbol names are defined by SIMFARE
as
"START",
"STATE2",
"symbol2", .•. , "symbolS",
•
•
•
I
"STATES", and "null",
respectively.
Also,
if
the
NDFSM was internally generated by SIMFARE, and it requires
more than eight states, it can not be displayed.
4.3.3.3
DISPLAY DFSM - If you wish to view the DFSM, then
selecting
this
option
from the first Query/Results menu
will cause the states of the DFSM to be
with
a
table
along
of state names and a table of input symbol
names (FIGURE 4-16).
transitions
displayed,
You are now
you desire to see.
free
to
choose
which
Note that if the DFSM was
27
internally generated by SIMFARE (because you
current
construct
as
a
RE
defined
the
or a NDFSM), then the state
names and the input symbol names are defined by SIMFARE as
II
START
II I
II
STATE2
.•. , "symbolS",
II I
.•• , "STATES", and "null", "symbol2",
respectively.
Also,
if
the
DFSM
was
internally generated by SIMFARE, and it requires more than
eight states, it can not be displayed.
4.3.3.4
DISPLAY MINIMUM DFSM - If you wish
Minimum
DFSM,
then
to
be
of
the
free
the
Minimum
displayed, along with a table of state names
and a table of input symbol names (FIGURE 4-17).
now
view
selecting this option from the first
Query/Results menu will cause the states
DFSM
to
to
You
are
choose which transitions you desire to see.
Note that since the minimum DFSM was internally
generated
by SIMFARE, the state names and the input symbol names are
defined by SIMFARE as "START",
"STATE2"
I
•
•
•
I
"STATES",
and "null", "symbol2", ... , "symbolS", respectively.
4.3.3.5
low
DFSM,
SIMULATE A WORD ON THE DFSM- If you wish to fol-
the
flow
then
by
of a word, which you generate, through the
selecting
this
option
from
the
first
28
Query/Results menu will cause the following to occur.
1.
You enter the word to be tested {FIGURE 4-18).
The word is defined by a series of input symbols,
up to a maximum of 20.
2.
The DFSM and the word are displayed, along with
the state name table and the input symbol name
table {FIGURE 4-19). At this point, you may step
through each symbol of the word until the word is
accepted, or is exhausted.
4.3.3.6
COMPARE ANOTHER CONSTRUCT - If you wish to deter-
mine if the current SIMFARE construct is equivalent to one
previously created, then selecting this
first
option
from
the
Query/Results menu will cause SIMFARE to prompt you
for the old construct name.
Then SIMFARE will display ei-
ther "Equivalent", or "Not Equivalent" {FIGURE 4-20).
4.3.3.7
SEE IF A WORD IS IN THE
DFSM- If
you
wish
to
find out if a certain word is a member of the language accepted by the DFSM, then selecting this
option
from
the
second Query/Results menu will cause SIMFARE to prompt you
for the word.
word
SIMFARE will then
reply
with
"Yes,
this
is in the language", or "No, this word is not in the
language" {FIGURE 4-21).
defined
by
The word, which
you
supply
is
a series of input symbols, up to a maximum of
29
20.
4.3.3.8
tain
LIST ALL WORDS IN THE DFSM - If you wish
to
ob-
a list of all words of length "k" or less (where you
supply "k", a non-negative integer less than or
ten),
which
DFSM,
then
are
menu
this
will
option
from
the
second
cause SIMFARE to prompt you for
the integer, "k", followed by a listing of all such
(FIGURE 4-22).
to
members of the language accepted by the
selecting
Query/Results
equal
words
Note that the screen will display up to 15
words at a time.
4.3.3.9
find
COUNT HOW MANY WORDS ACCEPTED - If
you
wish
to
out how many members are in the language accepted by
the DFSM, then
Query/Results
selecting
this
option
from
the
second
menu will cause SIMFARE to respond with ei-
ther "zero members", "a finite number of members", or
infinite number of members" (FIGURE 4-23).
"an
0
'
30
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
screen title
*
graphics
region
1---------------------------------------------------l
prompts and messages
1---------------------------------------------------l
I
I
I
I
I
text
region
FIGURE 4-1
General Screen Format
31
*
SIMFARE Main Menu
*
1---------------------------------------------------l
Use arrows to
then CR to continue.
1---------------------------------------------------l
Old Construct
select~
I
I
I
I
I
I
I
New Construct
Query/Results
End SIMFARE Session
FIGURE 4-2
SIMFARE Main Menu
32
*
Old Construct Selection
I
I
I
I
I
*
1---------------------------------------------------l
Enter name of old construct.
1---------------------------------------------------l
I
I
I
I
I
I
FIGURE 4-3
Old Construct Selection
33
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
New Construct Selection
*
I
I
I
I
I
I
I
1----------------------------------------------------l
I
Use arrows to select, then CR to continue.
I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
FSM
RE
back to Main Menu
FIGURE 4-4
New Construct Selection
I
I
I
I
I
I
34
*
New FSM Creation
*
----------------------------------------------------1
Enter number of states (1-8).
I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
I
I
I
I
FIGURE 4-5
New FSM Creation
35
*
New FSM Creation
*
1.
2.
3.
4.
5.
6.
7.
8.
Enter next state name, and CR to continue.
FIGURE 4-6
New FSM Creation
State Name Entry
36
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
New FSM Creation
*
Choose Start State:
1.
STATE!
2.
STATE2
3.
STATE3
4.
STATE4
5.
STATES
6.
STATE6
7.
STATE7
8.
STATES
1---------------------------------------------------l
Use arrows to select, then CR to continue.
1---------------------------------------------------l
I
I
I
I
I
FIGURE 4-7
New FSM Creation
Start State Selection
,, '
37
*
New FSM Creation
*
Choose Accepting States:
1.
STATE I
2.
STATE2
3.
STATE3
4.
STATE4
5.
STATES
6.
STATE6
7.
STATE7
8.
STATES
Use arrows to select, then CR to continue.
-----~----------------------------------------------
DONE
FIGURE 4-8
New FSM Creation
Accepting State Selection
38
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
New FSM Creation
*
1---------------------------------------------------l
Enter number of input symbols (1 to 8).
1----------------------------------------------------l
I
I
I
I
I
I
I
I
I
I
I
I
FIGURE 4-9
New FSM Creation
39
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
New FSM Creation
*
1.
2.
3.
4.
s.
6.
7.
a.
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
1----------------------------------------------------l
I Enter next input symbol name, and CR to continue. I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
I
I
I
I
FIGURE 4-10
New FSM Creation
Input Symbol Selection
40
*
New FSM Creation
1------\
------>I
I
1
I
I
\------1
1------\
1------\
2
3
I
I
I
I
\------1
I
I
\------1
1------\
1------\
I
I
4
I
I
I
I
I
I
s
\------1
\------1
1------\
1------\
6
7
I
I
I
I
\------1
I
I
I
I
\------1
//======\\
II
II s
II
II
I
I
I
\\======/I
*
I
I State Names:
I
I 1. STATE!
I 2. STATE2
I 3. STATE3
I 4. STATE4
I s. STATES
I 6. STATE6
I 7. STATE7
I s. STATES
I
I
I
I
I
I
I Input Symbols:
I
I 1. symboll
I 2. symbol2
I 3. symbol3
I 4. symbol4
I S. symbolS
I 6. symbol6
I 7. symbol 7
I s. symbolS
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
1----------------------------------------------------l
I
Use arrows to select, then CR to continue.
I
1----------------------------------------------------l
I
Choose Source State
Make Transition
I
I
I
I
I
I
Choose Destination State
Remove Transition I
Transition Function Complete
FIGURE 4-11
New FSM Creation
Transition Function Entry
I
I
41
*
Query/Results Selection
*
Use arrows to select, then CR to continue.
Display RE
Display Minimum DFSM
Next Menu
Display NDFSM
Simulate Word on DFSM
Main Menu
Display DFSM
Compare Another Construct
FIGURE 4-12
Query/Results
Main Selection
42
*
Query/Results Selection
*
Use arrows to select, then CR to continue.
See if Word is Accepted by DFSM
Next Menu
List all words accepted by DFSM
Main Menu
Count how many words accepted
FIGURE 4-13
Query/Results
Main Selection Continued
43
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
Display RE
*
*
Input Symbols:
1.
2.
3.
4.
5.
6.
7.
8.
symbol1
symbol2
symbol3
symbol4
symbolS
symbol6
symbol?
symbolS
I
I
1----------------------------------------------------l
I
Hit CR when finished viewing the RE.
I
1-------------------------~--------------------------l
I
I
I
I
I
I
I
I
I
I
I
I
FIGURE 4-14
Display RE
44
Display
*
1------\
------>1
I
1
NDFSM
*
State Names:
I
I
1.
2.
3.
4.
S.
6.
7.
8.
\------1
1------\
1------\
2
3
I
I
I
I
I
I
\------1
\------1
1------\
1------\
I
I
4
I
I
I
I
I
I
\------1
s
I
I
\------1
1------\
1------\
6
7
I
I
STATE!
STATE2
STATE3
STATE4
STATES
STATE6
STATE7
STATE8
all
I
I
I
I
\------1
I
I
\------1
//======\\
II 8
II
II
II
\\======//
Input Symbols:
1.
2.
3.
4.
S.
6.
7.
8.
symbol!
symbol2
symbol3
symbol4
symbolS
symbol6
symbol7
symbol8
Use arrows to select, then CR to continue.
Choose Source State
Remove All Transition Arcs
Back to Query/Results Menu
FIGURE 4-lS
Display NDFSM
4S
Display DFSM
*
*
1------\
.------>I
I
1
State Names:
I
I
1.
2.
3.
4.
S.
6.
7.
S.
\------1
1------\
1------\
2
3
I
I
I
I
I
I
\------1
\------1
1------\
I
I
4
1------\
I
I
I
I
\----.,--1
s
I
I
\------1
1------\
I
I
I
I
STATEl
STATE2
STATE3
STATE4
STATES
STATE6
STATE7
STATES
all
6
1------\
I
I
I
I
\------1
7
I
I
\------1
//======\\
II s
II
II
II
\\======//
Input Symbols:
1.
2.
3.
4.
S.
6.
7.
S.
symboll
symbol2
symbol3
symbol4
symbolS
symbol6
symbol7
symbolS
Use arrows to select, then CR to continue.
Choose Source State
Remove All Transition Arcs
Back to Query/Results Menu
FIGURE 4-16
Display DFSM
46
*
Display Minimum DFSM
I
1------\
------>1
1
I
I
I
\------1
1------\
1------\
2
3
I
I
I
I
I
I
\------1
\------1
1------\
I
I
4
1------\
I
I
I
I
s
1------\
1------\
6
I
I
I
I
\------1
7
I
I
\------1
//======\\
I
I
I
I
\------1
\------1
I
I
I
I
II
II
s
II
II
\\======/I
*
I State Names:
I
I 1. STATEl
I 2. STATE2
I 3. STATE3
I 4. STATE4
I s. STATES
I 6. STATE6
I 7. STATE7
I s. STATES
I
all
I
I
I
I
I Input Symbols:
I
I 1. symbol!
I 2. symbol2
I 3. symbol3
I 4. symbol4
I S. symbolS
I 6. symbol6
I 7. symbol7
I s. symbolS
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
1----------------------------------------------------l
I
Use arrows to select, then CR to continue.
I
1----------------------------------------------------l
I
I
I
I
I
I
I
Choose source State
Remove All Transition Arcs
Back to Query/Results Menu
FIGURE 4-17
Display Minimum DFSM
I
I
I
I
I
47
DFSM Simulation
*
*
l . symboll
2. symbol2
3. symbol3
4. symbol4
5. symbolS
6. symbol6
7. symbol?
8. symbolS
Use arrows to select, then CR to continue.
1---------------------------------------------------l
I
I
I
I
I
done
FIGURE 4-18
DFSM Simulation
Word Entry
48
I
* DFSM Simulation
I
I
/------\
I
------ > I 1
I
I
I
I
I
\------/
I
I
I
/------\
1------\
I
I 2
I
I 3
I
I
I
I
I
I
I
\------1
\------1
I
I 1------\
1------\
I
I s
I
I I 4
I I
I
I
I
I \------1
\------1
I
I
1------\
1------\
I
I 6
I
I 7
I
I
I
I
I
I
I
\------/
\------/
I
I
I
//======\\
I
II 8 . II
I
II
II
I
\\======!I
*
I
I
State Names: I
I
1. STATE!
I
2. STATE2
I
3. STATE3
I
4. STATE4
I
5. STATES
I
6. STATE6
I
7. STATE7
I
8. STATE8
I
all
I
I
I
I
I
!Input Symbols: I
I
I
I 1. symbo 11
I
I 2 . symbo 12
I
I 3. symbol3
I
I 4. symbol4
I
I
I ·s. symbolS
I 6. symbol6
I
I 7. symbol 7
I
I
I 8. symbol8
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
1----------------------------------------------------l
I
Hit CR when ready for next transition.
I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
I
I
I
I
FIGURE 4-19
DFSM Simulation
49
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
Compare Another Construct
*
the result is displayed here
1----------------------------------------------------l
Hit CR to continue.
1----------------------------------------------------l
I
I
I
I
I
I
I
Enter construct name --->
FIGURE 4-20
Compare Another Construct
I
I
I
I
I
I
so
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
See If A Word Is In The DFSM
*
1. symbol!
2. symbol2
3. symbol3
4. symbol4
S. symbolS
6. symbol6
7. symbol7
8. symbolS
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
I
I
1----------------------------------------------------l
I
Use arrows to select, then CR to continue.
I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
done
FIGURE 4-21
See If A Word Is In The DFSM
I
I
I
I
I
I
(l
•
51
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
List All Words In The DFSM
*
1. word!
2. word2
3. word3
4. word4
5. wordS
6. word6
7. word7
8. wordS
9. word9
10. wordlO
11. wordll
12. wordl2
13. wordl3
14. wordl4
15. wordlS
I
I
1----------------------------------------------------l
I
Hit CR to continue.
I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
Enter maximum word length ---
FIGURE 4-22
List All Words In The DFSM
I
I
I
I
I
I
52
*
Count How Many Words Accepted
*
the response is displayed here
I
I
I
1---------------------------------------------------l
Hit CR to continue.
1---------------------------------------------------l
I
I
I
I
I
I
FIGURE 4-23
Count How Many Words Accepted
53
4.4
SAMPLE SIMFARE SESSION
This section consists of a series of screens
a
sample SIMFARE session.
Screens are accompanied by ex-
planatory discussion to explain the
supplied
by
Joe
Youser.
illustrating
sequence
of
entries
Let's say that Joe decides to
enter the characteristics of a finite state machine
acts
like
a
vending machine.
candy bars at 15 cents a piece.
chased
which
The vending machine sells
A candy bar may
be
pur-
by inserting any one of the following combinations
of coins into the vending machine:
three nickels, one at a time
one dime, followed by one nickel
one nickel, followed by one dime
Now, to use SIMFARE in implementing the
Joe continues as follows.
vending
machine,
54
SCREEN I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
What System --->
70
User ---------->
31,10
Password ------>
BYDSR2
Ready> SIMFARE
Here, Joe has logged on to the PDP-11/70 computer
and has started up SIMFARE by typing "SIMFARE".
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
system,
55
SCREEN II
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
SIMFARE Main Menu
I
I
*
I
1----------------------------------------------------l
I
Use arrows to select, then CR to continue.
I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
Old Construct
---> New Construct
Query/Results
End SIMFARE Session
SIMFARE displays the Main Menu and prompts Joe to use the
arrow keys to make a selection. Joe needs to create a new
construct in order to implement the vending machine, so he
moves the cursor (using the down arrow key once) to "New
Construct" and then hits the return key to tell SIMFARE to
accept the selection.
I
56
SCREEN III
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
New Construct Selection
*
I
I
1----------------------------------------------------l
I
Use arrows to select, then CR to continue.
I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
I
---> FSM
RE
back to Main Menu
Joe wishes to create a new finite state machine,
chooses "FSM" (i.e. he simply presses CR).
I
I
I
I
I
I
I
so
he
'
57
SCREEN IV
New FSM Creation
*
*
Enter number of states (1-8).
--->
4
Joe enters a "4", followed by a CR, to signify the number
of states to be included in his finite state machine.
58
SCREEN V
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
New FSM Creation
1.
START
2.
FIVE
3.
TEN
4.
ACCEPT
*
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
1----------------------------------------------------l
I
Enter next state name, and CR to continue.
I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
I
I
I
I
I
I
Joe enters the names of the four states. Note that state
names must be made up of a combination of capital letters
and the ten digits. If, for example, Joe entered "Start"
as the name of the first state, rather than "START", the
error message, "Invalid state name", would appear, and Joe
would then have to re-enter the name.
59
SCREEN VI
*
New FSM Creation
Choose Start State:
---> 1.
START
2.
FIVE
3.
TEN
4.
ACCEPT
*
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I"
I
I
I
I
----------------------------------------------------1
Use arrows to select, then CR to continue.
I
----------------------------------------------------1I
I
I
I
I
I
I
Joe selects the first state,"START", as the start state.
60
SCREEN VII
*
New FSM Creation
*
Choose Accepting States:
1.
START
2.
FIVE
3.
TEN
4.
ACCEPT
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
----------------------------------------------------1
Use arrows to select, then CR to continue.
I
----------------------------------------------------1I
DONE
I
I
I
I
I
I
I
First, Joe positions the cursor next to the fourth state,
"ACCEPT", and hits the return key to signify the accepting
state. Then, Joe positions the cursor next to the word
"DONE" to signify that there are no more accepting states.
61
SCREEN VIII
I
I
I
I
I
I
I
I
*
New FSM Creation
*
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
1----------------------------------------------------l
I
Enter number of input symbols (1 to 8).
I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
I
I
I
I
I
I
---> 2
Joe enters a "2" to tell SIMFARE that there
input symbols in the finite state machine.
will
be
two
62
SCREEN IX
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
New FSM Creation
*
1. nickel
2. dime
I
I
1----------------------------------------------------l
I Enter next input symbol name, and CR to continue. I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
I
I
I
I
Here, Joe enters the names for the two input symbols.
Note that a name is composed of any combination of the
lower case letters and the ten digits.
63
SCREEN X
I
I
I
I
I
I
1------\
------>1
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
1
I
I
I
\------1
I
I
New FSM Creation
*
1------\
I
I
2
I
I
\------1
*
I
I State Names:
I
I --> 1. START
I
2. FIVE
I
3. TEN
I
4. ACCEPT
/------\1
I 3
II
I
II
\------/1
//======\\
II 4
II
II
II
\\======!/
I
I
I
I
I
I
I
I
I
I
Input Symbols:
1. nickel
2. dime
1---------------------------------------------------l
Use arrows to select, then CR to continue.
1---------------------------------------------------l --> Choose Source State
Make Transition
I
I
Choose Destination State
I
Transition Function Complete
I
Remove Transition
At this point, Joe is ready to enter the transition function. In this case, the first transition will be from the
"START" state to the "FIVE" state on the input symbol
"nickel".
So, Joe selects the "Choose Source State" option from the menu by hitting the return key. Then, SIMFARE positions the cursor over the "START" state name, and
Joe hits the return key again. Now, the source state has
been identified.
(l
64
SCREEN XI
I
I
I
I
I
*
I
I
I
------>1 1
I
I
I
I
I
\------1
I
I
1------\
/------\1
I 2
I
I 3
II
I
I
I
II
1------\
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
New FSM Creation
\------1
*
State Names:
1. START
--> 2. FIVE
3. TEN
4. ACCEPT
\------1
!!======\\
II
II
4
II
II
\\======!!
Input Symbols:
1. nickel
2. dime
I
I
1----------------------------------------------------l
I
Use arrows to select, then CR to continue.
I
1----------------------------------------------------l
I
Choose Source State
Make Transition
I
I
I
I
I
I
--> Choose Destination State
Transition Function Complete
Remove Transition I
I
I
----------------------------------------------~-------
Next, Joe selects the "Choose Destination State" option
from the menu by hitting the down arrow followed by a CR.
Then SIMFARE positions the cursor over the "START" state
and is waiting for Joe to select the destination state.
So, Joe hits the down arrow followed by a CR, thus selecting state "FIVE".
'
65
SCREEN XII
I
I
I
I
I
I
New FSM Creation
*
------>1
I
I
I
I
---------1-l
I
I
-->I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
/------\
1
I
I
I
\------/
I
I
I
I /------\
2
I
\------/
I
I
I
I
/------\1
I
I
3
*
State Names:
1.
2.
3.
4.
START
FIVE
TEN
ACCEPT
II
II
\------/1
//======\\
II 4
II
II
II
\\======//
I
I
I
I
I
I
I
I
I
I
Input Symbols:
--> 1. nickel
2. dime
I
I
1----------------------------------------------------l
I
Use arrows to select, then CR to continue.
I
1----------------------------------------------------l
I
Choose Source State
--> Make Transition
I
I
I
I
I
I
Choose Destination State
Transition Function Complete
Remove Transition I
I
I
Now, Joe selects the "Make Transition" option from the
menu.
He then positions the cursor at the input symbol
"nickel" and hits the return key.
SIMFARE responds by
drawing an arc from the source state to the destination
state. Imbedded within the arc is the number "1" signifying that the first input symbol (i.e. "nickel") is the
one which takes the state "START" to the state "FIVE".
66
SCREEN XIII
*
I
I
I
I
I
I
I
I
I
I
I
I
I
New FSM Creation
/------\
------> I 1
I
---------1-l
I
I
I
I
-->
l-2---------
\------/
I------\
I 2
I
I
\------/
I
I
I
1------\ I
3
I<-I
I
\------1
1//======\\
Ill
III
4
II
II
1\\======//
I
I
I
I
*
I
I State Names:
I
I
1. START
I
2. FIVE
3. TEN
I
I
4. ACCEPT
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I Input Symbols:
I
I
1. nickel
1--> 2. dime
I
I
I
I
I
I
I
I
1----------------------------------------------------l
I
Use arrows to select, then CR to continue.
I
1----------------------------------------------------l
I
Choose Source State
--> Make Transition
I
I
I
I
I
I
Choose Destination State
Transition Function Complete
Remove Transition I
I
I
Next, Joe wishes to define the transition which goes from
the "START" state to the "TEN" state on the input symbol
"dime". Since the "START" state is already chosen as the
source state, Joe selects the "Choose Destination State"
option from the menu and chooses the "TEN" state.
Then,
he selects the "Make Transition" option from the menu and
chooses the input symbol "dime".
SIMFARE responds by
drawing the appropriate arc.· Imbedded in the arc is the
digit "2" signifying that the transition can occur on the
second input symbol (i.e. "dime").
67
SCREEN XIV
I
I
I
I
I
I
1------\
------>1
I
1
I
I
\------1
I
I
I
New FSM Creation
*
1------\
I
2
I
1------\
I 3
I
I -------2-l
l-1----->1
I
I I
\------1
\------1
I I
I
*
I
I State Names:
I
1. START
I
2. FIVE
I
3. TEN
I
4. ACCEPT
I
I
I
I I
I I //======\\
II
I ->II 4
II
II
I
I
I
\\======!!
Input Symbols:
I
I
I
1. nickel
2. dime
I
1---------------------------------------------------l
Use arrows to select, then CR to continue.
1---------------------------------------------------l
Choose Source State
Make Transition
I
I
I
I
Choose Destination State
Remove Transition
Transition Function Complete
Now, Joe has defined all of the transitions which occur
with the "START" state as the source, so he chooses another source state, state "FIVE".
Whenever a new source
state is chosen, all previously drawn arcs are cleared by
SIMFARE so that the work area is clean.
(Note that this
allows Joe to back up and redefine transitions if necessary.) Joe then proceeds to define the required transitions
with "FIVE" as the source state.
68
SCREEN XV
I
I
* New FSM Creation *
I
I
I
I
/------\
I State Names:
I
------>I 1
I
I
1. START
I
I
I
I
2. FIVE
I
\------/
I
3. TEN
I
I
4. ACCEPT
I
I
I
/------\
1------\
I
I
I 2
I
I 3
I
I
I
I
I
I
I
I
I
\------/
\------1
I
I
I
I
I //======\\
Ill 4
II
I
II
I
I II
I \\======//
I
I
!Input Symbols:
I
I
1. nickel
I
I
2. dime
I
I
I
I
1---------------------------------------------------l
Use arrows to select, then CR to continue.
1---------------------------------------------------Choose Source State
Make Transition
l
I
I
I
I
Choose Destination State
Remove Transition
--> Transition Function Complete
Joe continues until every transition has been defined. He
then selects the "Transition Function Complete" option
from the menu, thus completing the entire entry of the new
finite state machine.
Before returning to the Main Menu,
SIMFARE will prompt the user for the name of the file in
which the new construct will be saved for future sessions
with SIMFARE.
69
SCREEN XVI
*
SIMFARE Main Menu
*
Use arrows to select, then CR to continue.
Old Construct
New Construct
---> Query/Results
End SIMFARE Session
Having completely defined a new finite state machine, Joe
is now ready to use SIMFARE to generate results. At this
point, control is resumed back at the Main Menu, where Joe
selects the "Query/Results" option.
70
SCREEN XVII
*
Query/Results Selection
*
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
1----------------------------------------------------l
I
Use arrows to select, then CR to continue.
I
1----------------------------------------------------l
I
I
!->Display RE
I
I
I
I
I
Display Minimum DFSM
Next Menu
Display NDFSM
Simulate Word on DFSM
Main Menu
Display DFSM
Compare Another Construct
I
I
I
I
I
I
Joe decides that the first item he wishes to view is the
regular expression equivalent to the finite state machine
which he previously defined. Since the cursor is already
positioned next to the option "Display RE", he hits the
return key.
71
SCREEN XVIII
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
Display RE.
*
(({1.1.1}+(1.2)}+(2.1}}
Input Symbols:
1.
nickel
2.
dime
1---------------------------------------------------l
Hit CR when finished viewing the RE.
1---------------------------------------------------l
I
I
I
I
I
I
I
SIMFARE proceeds by displaying the regular expression.
The input symbols within the RE are denoted by digits, and
the input symbol names corresponding to the digits are
listed below the RE.
72
SCREEN XIX
*
Query/Results Selection
*
I
I
I
I
I
1---------------------------------------------------l
Use arrows to select, then CR to continue.
1---------------------------------------------------l
I Display RE
I
I Display NDFSM
I
I Display DFSM
I
Display Minimum DFSM
Simulate Word on DFSM
->Next Menu
Main Menu
Compare Another Construct
Now Joe decides that the next item he wishes to see is not
among the choices found on this menu, so he selects the
"Next Menu" option.
73
SCREEN XX
*
Query/Results Selection
I
I
*
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
1----------------------------------------------------l
I
Use arrows to select, then CR to continue.
I
1----------------------------------------------------l
I
I
I
See if Word is Accepted by DFSM
I
I -->List all words accepted by DFSM
I
I
Count how many words accepted
I
Next Menu I
I
Main Menu I
I
I
I
Joe decides that he wishes to determine how many words accepted by his FSM have at most two input symbols. So, he
selects the "List all words accepted by DFSM" option from
the menu.
74
SCREEN XXI
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
*
List All Words In The DFSM
*
1. five.ten
2. ten.five
I
1----------------------------------------------------l
I
Hit CR to continue.
I
1----------------------------------------------------l
I
I
I
I
I
I
I
I
I
I
Enter maximum word length ---> 2
I
I
I
I
I
I
I
I
First, SIMFARE prompts Joe for the maximum word length, to
which Joe responds with "2". Then, SIMFARE proceeds to
list all of the words contained in the language generated
by the regular expression (or, equivalently, all of the
words accepted by the finite state machine) which are of
length two or less.
75
SCREEN XXII
*
Query/Results Selection
*
Use arrows to select, then CR to continue.
Display RE
Display Minimum DFSM
Next Menu
Display NDFSM
Simulate Word on DFSM
Display DFSM
Compare Another Construct
-->Main Menu
Now Joe decides to complete his session with
he selects the "Main Menu" option.
SIMFARE,
so
76
SCREEN XXIII
*
SIMFARE Main Menu
*
I
I
I
I
----------------------------------------------------1
Use arrows to select, then CR to continue.
I
----------------------------------------------------1
Old Construct
New Construct
Query/Results
--->
End Simfare Session
I
I
I
I
I
I
I
I
-----------------------------------------------------1
Joe then selects the "End SIMFARE Session" option from the
Main Menu.
(l'
{J
5.0
FUTURE CONSIDERATIONS
The design of SIMFARE is completely
self-contained.
The
implementation was straight forward, however, time has not
permitted a complete implementation as
requirements.
Specifically,
the
specified
by
algorithms to generate
the minimum-state DFSM and to compare two DFSMs for
valence
have
not
been implemented.
the algorithm to compare two DFSMs
find
the
partition
Also,
the
equi-
Anyone implementing
for
equivalence
will
method described on pages 110-114 of
reference [3] completely straight forward, yet
suming.
the
minimum-state
time
con-
DFSM can be generated
using the elegant procedure described on pages 275-276
of
reference [2].
There are some other nice features that could be added
to
the' current implementation of SIMFARE (whether or not they
were specified in the original requirements).
These are:
1.
extend the length of state names and input symbol
names to be greater than one character.
2.
highlight (using inverse video) the curent state
and current input symbol when performing the simulation of a computation.
77
•
78
3.
allow changes in the definition of an already existing FSM.
4.
when choosing an "old construct", allow any old
construct to be chosen, rather than simply the
most recently created construct.
BIBLIOGRAPHY
1.
Aho, A.
Compiier
1979.
v.,
Principles of
Addison-WesleY,
2.
Beckman, F.
Programming.
S.
Mathematical
Foundations
of
Reading, MA: Add1son-Wesley, 1981.
3.
Denning, P. J., Dennis, J. B., and Qualitz, J.
E. Machines, Languages and Computation. Englewood
Cliffs, NJ: Prent1ce Hall, 1978.
4.
Hopcroft, J.
to Automata
Read1ng, MA:
5.
Lewis, H. R., and Papadimitriou, C. H.
Elements
of the Theory of Computation. Englewood Cliffs,
NJ: Prent1ce Hall; 1981.
6.
Savitch, W. J. Abstract Machines and
Boston: Little, Brown and Co., 1982.
and Ullman, J.
D.
Reading, MA:
Design.
E., and Ullman, J. D.
Introduction
Theory, Languages, and Computat1on.
Add1son-Wesley, 1979.
79
Grammars.
APPENDIX A
Requirements
A.l
FUNCTIONAL SUMMARY
Appendix A describes the functionality of SIMFARE (SIMulation of Finite Automata and Regular Expression recognition). SIMFARE is a computer program (written to satisfy
the thesis/project requirements for the Master of Science
degree in the field of Computer Science at California
State University, Northridge) which accepts as input, the
definition of a finite state machine or a regular expression, and outputs information such as a pictorial representation of the finite state machine with a simulation of
an input string being processed by the machine. Typical
users are the students enrolled in a Junior level automata, or theory of languages course. The Department of Computer Science at California State University Northridge
offers this type of course, namely, Computer Science 310 Automata, Languages, and Computation. SIMFARE gives these
students insight into the definitions, use of, and relationships among finite state automata and regular expressions.
The physical environment under which SIMFARE runs
is System 70 at CSUN (a PDP-11/70 computer running under
the RSTS/E operating system).
A.2
DETAILS CONCERNING SYSTEM USER INTERACTIONS
This section describes the functions
from the point of view of the user.
to SIMFARE is either a finite state
regular expression (RE). The user
80
that SIMFARE performs
In general, the input
machine (FSM) or a
supplies SIMFARE with
81
one
of
the
following
three
constructs:
a
non-deterministic finite state machine (NDFSM), a deterministic finite state machine (DFSM), or aRE. Given any
one of these constructs, SIMFARE will generate the remaining two equivalent constructs along with the minimum-state
DFSM.
For example,
if the user enters a RE, then the
equivalent NDFSM, DFSM, and minimum-state DFSM will be
generated. Note that in general, the generated constructs
may not be unique, and SIMFARE will simply generate one of
each construct.
The output of SIMFARE is user selectable and may consist
of a pictorial display of any of the above four constructions (the form of the pictorial display will be discussed
in detail later on in this appendix), along with:
1.
The determination of whether or not a user supplied word is a member of the language accepted
by the RE.
2.
A simulation of the state transition
the DFSM for a user supplied word.
3.
A list of all words of length less than or equal
to a certain number, specified by the user, which
are accepted by the FSM, or are members of the
language accepted by the RE.
4.
A statement as to how many words are accepted by
the FSM,
where the possible answer is either
"zero",
"a finite number", or "an
infinite
number".
5.
A comparison for equivalence of two FSM's.
diagram
of
The remainder of this section describes, in reasonable detail,
the inputs, the outputs, and the state changes wich
occur in going from the inputs to the outputs.
82
A.2.1
REQUIREMENTS DIAGRAM
The requirements diagram annotates the data flow between
the parts of SIMFARE. Figure A-1 gives the definitions
for the diagram elements. Refer to Figure A-2 for the requirements diagram of SIMFARE.
{)
83
ACTIVITY
NAME
activity or process
DATA NAME
data flow
I
I FILE NAME
I
data file
------------>
I
I
1-----------1
I SOURCE OR I
I DESTINA- I
I TION NAME I
source
1-----------1
I
FIGURE A-1
I
REQUIREMENTS DIAGRAM ELEMENT DEFINITIONS
'
Q
84
1--------1
I
I
-----1
1
I
I
RESPONSE-A I
I
I
I
I
I
USER
1-----
1-------- I
----------
------------
I
I
I
I RESPONSE-B
I
I
I
--->1----------1<--1
CRT/
I
I KEYBOARD I
RESPONSE-A
RESPONSE-B
----------------------l----------l--------------------1
------------
I
I
I
I
I
I ------------
->I
I
I
I
I
I
1----------
1 DATABASE I
I DRIVER I
I
I
-----------1
PROMPTS
RESULTS
RESPONSE-DATA
------------
I
I
I
------------>1
I
I
1
I
I
I
I
---------------
------------->1
RESPONSE-DATA I
FIGURE A-2
I
I
I
I
I
I
------------ I
1<-
OUTPUT I
RESULTS I
DRIVER I
I
------------
SIMFARE
FILE(S)
REQUIREMENTS DIAGRAM
'
85
Each of the data flow items shown in the requirements diagram is defined in the Data Dictionary. The corresponding data dictionary is as follows.
data
definition
RESPONSE-A
see the state diagram specifications
RESPONSE-B
see the state diagram specifications
RESPONSE-DATA
see the data structures specifications
PROMPTS
see the state diagram specifications
RESULTS
see the state diagram specifications
A.2.2
STATE DIAGRAM SPECIFICATIONS
The "State Diagrams" on the following pages are used to
represent the SIMFARE requirements. The states are labelled to indicate the type of action that is currently in
progress.
The directed arcs between the states are numbered and refer the reader to the "Text Representation".
A state appears either in the form of a solid rectangle,:
or a rectangle with diagonal corners. A solid rectangle
indicates that the state is complex and may have a state
diagram specification of its own. A rectangle with diagonal corners is simple and its meaning is self-explanatory.
An arc with no source state is pointing to the starting
state of each state diagram.
Note that each complex state of this section has a corresponding Text Representation appearing in the next section.
86
1------\
I
I
I
------------------->1
I
----I
I
I
I
1 I
91
I 8
I
I
v
I
-->/----------\
--------------------1
1
I
I
I
I
------->1
1
I
I
2
31
I
I
I
I
I
------------create
I
->I
new
I
1 construct I
I
I
-------------
I
stop
1-------------------------
display I
main
I
menu
I
1<-----------
\----------/
I
I
I
41
51
I
I
I
I
I
I
I
I
I
I
I /-----------\
I I retrieve I
->I
old
I
I construct I
I
I
A
\-----------1
FIGURE A-3
I
I
I
\------/
I
I
I
61
7
I
I
I
I
I
----------I
I
I display I<--I results I
I
I
-----------
SIMFARE TOP LEVEL
State Diagram Specification
87
I
I
I
I
s I
I
1------------\
------------->1
1-----
display
I
I 6
new
I
I
construct 1<---menu
1
I
I
------------------1
1
I
1-------------------I
I
\------------/
I
I
I
I
2 I
4 I
I 1
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I -------------1 I
I
I
I
A
-->1
1
I
I
create
new
FSM
1---I
I
I
FIGURE A-4
A
3
-------------I
I
----1
I
I
I
create
new
RE
NEW CONSTRUCT PROCESSING
State Diagram Specification
1<---
I
I
I
88
1--------------------\1----------->
19
------------------->1
I
1------1
display
results
I
-------->I
1<-----1
\--------------------1
1
2 I
4
I
6
I
display NDFSM
1<---
I
I
------------------------
I
display minimum DFSM
display RE
I
I
7
1<-------
I
I 9
----------------------
----1
compare two DFSM's
5
1<---
--------------
-------1
10 I
I
I 3
-----------------
----1
8
1<---
display DFSM
----1
I
v
I
I 1
----------------
----1
1<----
--------------------~-
12 I
I
I 11
-----------------------------------
----1
determine if a word is accepted
1<--13
I
14
-------------------------------------
----1
20
1---------
simulate a transition on the DFSM
I
I
1<--15 I
16 I
--------------------------------------
----1
list all words of a certain length
I
1<--17 I
18 I
--------------------------------
------1
find how many words accepted
FIGURE A-5
DISPLAY RESULTS
State Diagram Specification
I
1<------
89
A.2.3
TEXT REPRESENTATION
This section gives an associated text representation for
each complex state of the previous section. The text representation may have two forms. One form is for those
complex states that are highly user-interactive, and the
other form is for complex states that tend to be more computational.
A.2.3.1 USER-INTERACTIVE TEXT REPRESENTATION - If an arc
of a state is thought of asconnect1ng a "from-node" to a
"to-node", then the text representation of an arc may be
any combination of the following three forms.
user: text-1
act:
text-2
cond: text-3
A.2.3.1.1 USER: text-1 - "Text-1" is a command string
entered by the user wh1ch causes processing to travel from
the from-node to the to-node, e.g., "run SIMFARE", or "Y"
(which could mean the user answered 'yes' to a question).
The set of all the "Text-l"'s appearing in the Text Representation form the "Response-A" and "Response-B" listed in
the requirements diagram.
A.2.3.1.2 ACT: text-2 - "Text-2" is the SIMFARE action
to be taken in order to get from the from-node to the
to-node, e.g., display a menu or convert aRE to a NDFSM.
The set of all "Text-2"'s appearing in the Text Representation form the "Prompts" and the "Results" listed in the
requirements diagram.
---------
---
--
·--- ----
--------·---------
il
90
A.2.3.1.3 COND: text-3 - "Text-3" is a condition to be
checked by SIMFARE.
Flow will go from the from-node to
the to-node only
if
the
condition
holds,
e.g.,
response="Y".
A.2.3.1.4
TOP LEVEL TEXT REPRESENTATION -
1.
user:
act:
"Run SIMFARE"
DISPLAY-MAIN-MENU
2.
user:
cond:
act:
SELECTION
SELECTION = "N"
DISPLAY-NEW-CONSTRUCT-MENU
3.
cond:
act:
NEW-CONSTRUCT-PROCESSING complete
DISPLAY-MAIN-MENU with new construct
selected for displaying results
4.
user:
cond:
act:
SELECTION
SELECTION = "0"
DISPLAY-OLD-CONSTRUCT-MENU
5.
cond:
act:
OLD-CONSTRUCT-PROCESSING complete
DISPLAY-MAIN-MENU with old construct
selected for displaying results
6.
user:
cond:
act:
SELECTION
SELECTION = "D"
DISPLAY-RESULTS-MENU using the selected
construct
7.
cond:
act:
DISPLAY-RESULTS-MENU complete
DISPLAY-MAIN-MENU
8.
user:
cond:
act:
SELECTION
SELECTION = "E"
terminate session with SIMFARE
9.
user:
cond:
act:
SELECTION
SELECTION <> "N", "0", "D", or "E"
DISPLAY-HELP-FOR-MAIN-MENU
'
91
A.2.3.1.4.1
NEW CONSTRUCT PROCESSING -
1.
user:
cond:
act:
SELECTION
SELECTION = "F"
CREATE-NEW-FSM
2.
cond:
act:
CREATE-NEW-FSM complete
DISPLAY-NEW-CONSTRUCT-MENU
3.
user:
cond:
act:
SELECTION
SELECTION = "R"
CREATE-NEW-RE
4.
cond:
act:
CREATE-NEW-RE complete
DISPLAY-NEW-CONSTRUCT-MENU
5.
user:
cond:
act:
SELECTION
SELECTION = "E"
DISPLAY-MAIN-MENU
6.
user:
cond:
act:
SELECTION
SELECTION <> "F", "R", or "E"
DISPLAY-HELP-FOR-NEW-CONSTRUCT-MENU
A.2.3.1.4.2
DISPLAY RESULTS -
1.
user:
cond:
act:
SELECTION
SELECTION = "D"
DISPLAY-DFSM
2.
cond:
act:
DISPLAY-DFSM complete
DISPLAY-RESULTS-MENU
3.
user:
cond:
act:
SELECTION
SELECTION = "N"
DISPLAY-NDFSM
4.
cond:
act:
DISPLAY-NDFSM complete
DISPLAY-RESULTS-MENU
5.
user:
cond:
act:
SELECTION
SELECTION = "M"
DISPLAY-MIN-DFSM
92
6.
cond:
act:
DISPLAY-MIN-DFSM complete
DISPLAY-RESULTS-MENU
7.
user:
cond:
act:
SELECTION
SELECTION = "R"
DISPLAY-RE
8.
cond:
act:
DISPLAY-RE complete
DISPLAY-RESULTS-MENU
9.
user:
cond:
act:
SELECTION
SELECTION = "C"
COMPARE-DFSM
10. cond:
act:
COMPARE-DFSM complete
DISPLAY-RESULTS-MENU
11. user:
cond:
act:
SELECTION
SELECTION = "W"
CHECK-FOR-WORD-ACCEPT
12. cond:
act:
CHECK-FOR-WORD-ACCEPT complete
DISPLAY-RESULTS-MENU
13. user:
cond:
act:
SELECTION
SELECTION = "S"
SIMULATE-TRANSITION
14. cond:
act:
SIMULATE-TRANSITION complete
DISPLAY-RESULTS-MENU
15. user:
cond:
act:
SELECTION
SELECTION = "L"
LIST-ALL-WORDS-OF-CHOSEN-LENGTH
16. cond:
act:
LIST-ALL-WORDS-OF-CHOSEN-LENGTH complete
DISPLAY-RESULTS-MENU
17. user:
cond:
act:
SELECTION
SELECTION = "A"
FIND-HOW-MANY-WORDS-ACCEPTED
18. cond:
act:
FIND-HOW-MANY-WORDS-ACCEPTED complete
DISPLAY-RESULTS-MENU
19. user:
cond:
SELECTION
SELECTION
=
"E"
93
act:
20. user:
cond:
act:
DISPLAY-MAIN-MENU
SELECTION
SELECTION <> "D" "N" "M" "R" "C"
"W", "S", "L", "A", or "E"
DISPLAY-HELP-FOR-DISPLAY-RESULTS-MENU
I
I
I
I
I
A.2.3.2 COMPUTATIONAL STATE TEXT
REPRESENTATION - The
text representations given below apply to the more computationally bound states of the state diagrams.
The requirements are precisely stated,
rather than giving a
pseudo-interactive description of the state activities.
A.2.3.2.1 CREATE NEW FSM - SIMFARE will prompt the user
for the spec1f1cat1ons- of a finite state machine under
which the following rules hold.
1.
There may be up to eight states.
2.
A state name may be at most eight characters in
length (composed of capital letters A-Z, and/or
the digits 0-9).
3.
There must be exactly one start state.
4.
There may be from zero to eight accepting states.
5.
There may be up to seven input symbol names, plus
the null symbol.
6.
An input symbol name may be at most eight characters in length (composed of small letters a-z,
and/or the numbers 0-9).
7.
If the null symbol is desired, then it must be
explicitly defined by the user and its symbol
name must be "null".
94
A.2.3.2.2 CREATE NEW RE - SIMFARE will prompt the user
for a regular expression which satisfies the following
rules.
1.
There may be up to seven input symbol names, plus
the null symbol.
2.
A symbol name may be at most eight characters in
length (composed of small letters a-z, and/or the
digits 0-9).
3.
If the null symbol is desired,
name is "null".
4.
The syntax of a RE is:
re
::=
('a')
then
its
symbol
I (re+re) I (re.re) I (re*)
where 'a' is a typical input symbol name.
5.
The entire length of a RE may not exceed 60 characters.
The following examples are given to clarify the rules
above. Assume that there are three input symbols with the
names 'xyz', '123', and 'abc'. Five valid regular expressions are:
1.
(xyz}
2.
((xyz)+(123))
3•
( ( abc ) . ( 1 2 3 ) )
4.
{ (abc)*)
5.
((123).(((abc)+(xyz))*))
A.2.3.2.3 DISPLAY DFSM - After the DFSM is obtained, either directly from the user, or by calculating it from the
equivalent NDFSM, the user may view it.
The following
rules will be enforced.
---
--~-
-
---------~-------
-~----
------·----
95
1.
All states must appear on the screen as boxes.
2.
The start state must be appropriately marked.
3.
The accepting states, if any, must
ately marked.
4.
Inside each state box must appear either the
state name, or a one digit code number referring
the user to a table of state names, which must
also appear on the same screen.
5.
An arc which connects one state to another (or to
itself) may appear as a continuous collection of
line segments, with the input symbol which causes
the transition appearing at the beginning of the
arc, and an arrowhead appearing at the end of the
arc.
6.
The input symbol which causes a transition may
appear as a one digit code number in the diagram,
referring the user to a table of symbol names,
which must appear on the same screen.
7.
So as to avoid as much confusion on the screen as
possible,
the only arcs appearing on the screen
at any one time are all those arcs which share
the same source state in common.
8.
In order to view all of the transitioning arcs of
the machine, the user may select any state as the
source state, one at a time.
be
A.2.3.2.4 DISPLAY NDFSM - The requirements are
as those for "DISPLAY DFSM".
A.2.3.2.5 DISPLAY MIN DFSM - The
same as those for "DISPLAY DFSM".
requirements
appropri-
the
are
same
the
96
A.2.3.2.6 DISPLAY RE - The regular expression obtained
from the user, or calculated using the equivalent DFSM is
displayed using the same syntax rules as given in section
A.2.3.2.2 CREATE NEW RE.
A.2.3.2.7 COMPARE DFSM- With one SIMFARE construct active (as is always the case at this point), the user is
asked to select one of his/her remaining SIMFARE constructs, which was created earlier. These two constructs
are to be compared for equality and the result displayed.
A.2.3.2.8 CHECK FOR WORD ACCEPT - In order to tell the
user whether or--no~ word is accepted by the FSM, or,
equivalently, is a member of the language generated by the
RE,
the user enters the word according to the specifications below, and the result is displayed.
1.
The word is a string of one digit code numbers,
each code number referring the user to a list of
the actual input symbol names, appearing on the
screen.
2.
The string of codes may be no longer than 20
gits.
di-
A.2.3.2.9 SIMULATE TRANSITION - Should the user desire to
view how a mach1ne trans1t1ons on a given input, the following rules should be upheld, along with the above rules
for "DISPLAY DFSM" and "CHECK FOR WORD ACCEPT".
1.
The current symbol of the word must be highlighted so as to stand out from the rest of the word.
2.
The current state must be highlighted
stand out from the other states.
3.
The arc which is defined by the current symbol
and the current state is to be highlighted using
high intensity, and is to remain highlighted
throughout the remainder of the simulation.
so
as
to
97
A.2.3.2.10 LIST ALL WORDS OF CHOSEN LENGTH - The user may
choose a length from one to-ten, and SIMFARE should list,
sorted by length, all words of this length or less, which
are accepted by the machine.
A.2.3.2.11 FIND HOW MANY WORDS ACCEPTED - SIMFARE is to
calculate whether--zero, a finite positive number, or an
infinite number of words are accepted by the machine.
A.2.4
DATA STRUCTURES
There are three fundamental data structures used by SIMFARE.
These are used to represent: a NDFSM, a DFSM, and
a RE.
A.2.4.1 NDFSM DATA STRUCTURE - The record structure for a
non-deterministrc--finite state machine is given below in
Pascal code.
type NDFSM = record
NumStates
StateNames
[l .• MaxNumStates]~
array [l •• MaxNumStates] of
Names~
Start
AcceptStates
array [l .• MaxNumStates] of
NumSymbols
SymbolNames
[l •. MaxNumSymbols]
array [l •• MaxNumSymbols] of
Transition
array [l .. MaxNumStates] of array
[l •. MaxNumSymbols] of TransType
integer~
Boolean~
Names~
where,
98
Names= array [l .. MaxNameLength] of
ascii~
TransType = record
Count : integer~
Link : LinkType
end~
LinkType = record
Val : [l .. MaxNumstates]~
Next : LinkType
end~
A.2.4.2 DFSM DATA STRUCTURE - The record structure for a
determinst1c finite state machine is identical to that of
the NDFSM, as given above, with the restriction that if
the machine,
'M', is in state 'q' (where 'q' is a member
of the set, 'K', of states of 'M'), and the next input
symbol to be read is 'a', then the transition, d(q,a), is
a member of 'K' and is the uniquely determined state to
which 'M' passes. Therefore, the record structure is,
type DFSM = record
Transi t·ion
array [l .. MaxNumStates] of array
[l .. MaxNumSymbols] of integer
end~
A.2.4.3 RE DATA STRUCTURE - A regular expression
is
stored internally as a tree and has the following type.
type NodePtr =
ANode~
Node = record
integer~
Val
Ptr : array [l .. MaxNumSons] of
Sons : [l .. MaxNumsons]
end~
var
RE
NodePtr~
NodePtr~
APPENDIX B
Design
B.l
DATA STRUCTURES
The fundamental data structures used by SIMFARE to represent a NDFSM, a DFSM, and a RE have been explicitly described in the Requirements Document. The design shall not
alter these specifications.
The one data structure which the Requirements Document
does not explicitly state how to implement is that of a
finite state machine which appears on the terminal screen.
This section describes the data structures used to display
the FSMs.
Recall that the maximum number of states to be displayed
is eight. Each state will be the same size and will have
a fixed position on the screen.
Transition arcs which
connect one state to another will be displayed as a sequence of connected line segments.
(In the worst case,
three line segments are required for some transitions.)
Since the sequence of line segments which connects state-i
to state-j is the same sequence which connects state-j to
state-i, there are a total of 36 distinct sequences.
The
input symbols which usually appear above a transition arc
will actually be imbedded within the arcs in order to not
clutter the screen. The data structures used to implement
the FSM display are listed below.
1.
A 2-dimensional array, (8 x 2), used for locating
the positions (X and Y coordinates) of up to
99
100
eight states.
array,
(36), containing
the
segments comprising each of the
2.
A !-dimensional
number of line
transition arcs.
3.
A 3-dimensional array, (36 x 4 x 2), containing
the starting and ending coordinates of each of
the transition arcs.
4.
A 2-dimensional array, (8 x 8}, containing the
vario.us input symbols which appear on each transition arc.
5.
A 2-dimensional array, (8 x 4},
containing the
starting and ending positions of the arrows used
to designate a starting state.
101
B. 2
SIMFARE
General Description
This is the main program.
It displays the main menu and
drives the routines which create and display the finite
automata.
Calling Modules
none
Modules Called
INITIALIZE
MENU.O
OLD. CONSTRUCT. PROCESSING
NEW.CONSTRUCT.PROCESSING
GIVE.RESULTS
- Initialize the system.
- Display the main menu to
the screen.
- Retrieve a previously
defined SIMFARE construct
from storage.
- Create a new SIMFARE
construct.
- Display the results desired
by the user.
Parameters
none
Imports
none
Exports
none
Error Handling
The user must select either old, or new construct processing prior to selecting the option which displays the results.
Test Cases
1.
Select an old construct followed by selecting the
display option.
102
2.
Select a new construct followed by selecting
display option.
3.
Select the display option only.
Concrete Implementation
Initialize the system
Set CHOSEN to false
While not(DONE) do
Display the main menu
Read the selection
Case selection is:
Old
Do old construct processing
Set CHOSEN to true
New
: Do new construct processing
Set CHOSEN to true
Display
If CHOSEN is true
Then
Display the results
Else
Display appropriate
error message
End
Set (DONE) to true
the
103
B.2.1
INITIALIZE
General Description
Th1s procedure initializes the system.
Calling Modules
SIMFARE
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Initialize
- The main program.
104
B.2.2
MENU.O
General Description
Th1s procedure writes to the terminal, giving the user the
option of selecting an old SIMFARE construct, creating a
new SIMFARE construct, displaying results based on the selected construct, or terminating the SIMFARE session.
Calling Modules
SIMFARE
- The main program.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the pos1t1ons and text for the choices
Display the choices
{.\
.
105
B.2.3
OLD.CONSTRUCT.PROCESSING
General Description
This procedure retrieves a previously defined SIMFARE construct from storage.
Calling Modules
SIMFARE
Modules Called
MENU.l
RETREIVE.OLD.DATA
- The main program.
- Prompt the user for the
name of the old construct.
- Read the definitions of
the old construct.
Parameters
none
Imports
none
Exports
The definitions of a SIMFARE construct.
Error Handling
an error message if the user enters an
struct file name that is invalid.
D~splays
Test Cases
1.
Enter a valid file name.
2.
Enter an invalid file name.
Concrete Implementation
Set ERROR to true.
While (ERROR) do
Prompt for old construct name
old
con-
106
If the name is valid
then
Retreive the definitions
Set ERROR to false
else
If the user wishes to quit
then
Set ERROR to false
else
Display appropriate
error message
107
B.2.3.1 MENU.l General Description
Th1s procedure wr1tes to the terminal, prompting .the user
for the name of a previously created SIMFARE construct.
Calling Modules
OLD.CONSTRUCT.PROCESSING
- Retrieve a previously
defined SIMFARR construct
from storage.
Modules Called
none
Parameters
none
Imports
none
Exports
The name of the old SIMFARE construct file.
Error Handling
none
Test Cases
none
Concrete Implementation
Prompt the user for the old construct name
108
B.2.3.2 RETRIEVE.OLD.DATAGeneral Description
Th1s procedure reads the contents of the old construct
file and stores the information in the finite automata records.
Calling Modules
OLD.CONSTRUCT.PROCESSING
- Retrieve a previously
defined SIMFARE construct
from storage.
Modules Called
none
Parameters
none
Imports
The name of the old SIMFARE construct file.
Exports
none
Error Handling
none
Test Cases
none
Concrete
Read the
Read the
Read the
record.
Read the
Implementation
non-deterministic finite state machine record.
deterministic finite state machine record.
minimum-state deterministic finite state machine
regular expression record.
109
B.2.4
NEW.CONSTRUCT.PROCESSING
General Description
This procedure asSists the user in creating a new
construct.
Calling Modules
SIMFARE
Modules Called
MENU.2
CREATE.FSM
CREATE.RE
GENERATE.AUTOMATA
SAVE.CONSTRUCT
- The main program.
- Prompt for type of new
construct.
- Create a new FSM.
- Create a new RE.
- Generate the remaining
automata.
- Write the new construct
to disk.
Parameters
none
Imports
none
Exports
The definitions of the new SIMFARE construct.
Error Handling
none
Test Cases
1.
Enter a new FSM.
2.
Enter a new RE.
Concrete Implementation
SIMFARE
~1
110
Prompt for the TYPE of the new construct
If TYPE is FSM
then
Create the new FSM
else
Create the new RE
Generate the remaining automata
Save the complete construct on disk
'
111
B.2.4.1 MENU.2 General Description
Th1s procedure wr1tes to the terminal, giving the user the
option of creating a new FSM or a new RE.
Calling Modules
NEW.CONSTRUCT.PROCESSING
- Create a new SIMFARE
construct.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the pos1t1ons and text for the choices
Display the choices
112
B.2.4.2 CREATE.FSM General Description
This procedure ass1sts the user in creating a new FSM.
Calling Modules
NEW.CONSTRUCT.PROCESSING
Modules Called
CHOOSE.STATE.NAMES
CHOOSE.START.STATE
CHOOSE.ACCEPT.STATES
CHOOSE.INPUT.SYMBOLS
GET.TRANSITIONS
- Create a new SIMFARE
construct.
- Choose the
states.
- Choose the
- Choose the
state(s).
- Choose the
names.
- Define the
Parameters
none
Imports
none
Exports
The definition of the new FSM.
Error Handling
none
Test Cases
none
Concrete Implementation
Choose the names of the states
Choose the start state
Choose the accepting state(s)
Choose the input symbol names
Define the transitions
names of the
start state.
accepting
input symbol
transitions.
113
B.2.4.2.1 CHOOSE.STATE.NAMES General Description
Th1s procedure obtains, from the user, the state names
the new FSM.
Calling Modules
CREATE.FSM
Modules Called
MENU. 21
MENU.22
of
- Create a new FSM.
- Prompts for the number of
states.
- Prompts for the state
names.
Parameters
none
Imports
none
Exports
The names of the new states.
Error Handling
An appropriate error message is displayed if:
1.
less than one or greater than
chosen
2.
a state name is more than 15 characters long
3.
a state name is comprised
than "A-Z" and "0-9".
of
eight
states
characters
are
other
Test Cases
1.
Enter up to eight valid state names.
eight times, each time choosing a
number of states.)
(Do this
different
114
2.
Choose less than one state.
3.
Choose more than eight states.
4.
Enter a state name with a length of more than
legal characters.
5.
Enter a state name
acters.
comprised
of
illegal
15
char-
Concrete Implementation
Repeat
Get the number of states
If the number of states is not between one and eight
then
Display an appropriate error message
Until the number of states is between one and eight
For each state
Repeat
Prompt the user for the state name
If the state name is invalid
then
Display an appropriate error message
Until the state name is valid
115
B.2.4.2.1.1 MENU.21 General Description
Th1s procedure prompts the user for the number
to be included in the new FSM.
Calling Modules
CHOOSE. STATE. NAMES
of
states
- Choose the names of the
states.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the pos1tion and text for the prompt
Display the prompt
116
B.2.4.2.1.2 MENU.22 General Description
Th1s procedure prompts the user for
states to be included in the new FSM.
Calling Modules
CHOOSE.STATE.NAMES
the
names
of
- Choose the names of the
states.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the position and text for the prompt
Display the prompt
the
117
B.2.4.2.2 CHOOSE.START.STATE General Description
Th1s procedure ass1sts the user
state.
in
defining
the
start
Calling Modules
CREATE.FSM
- Create a new FSM.
Modules Called
MENU.23
- Prompt for the start state.
Parameters
none
Imports
none
Exports
The start state.
Error Handling
none
Test Cases
none
Concrete Implementation
D1splay all states
Prompt for the start state
Q .
118
B.2.4.2.2.1 MENU.23 General Description
Th1s procedure prompts the user for the starting state
the FSM.
Calling Modules
CHOOSE.START.STATE
- Choose the start state.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the positions and text for the prompt
Display the prompt
of
119
B.2.4.2.3 CHOOSE.ACCEPT.STATES General Description
Th1s procedure ass1sts the user in choosing the
states(s).
Calling Modules
CREATE.FSM
Modules Called
MENU.24
accepting
- Create new FSM.
- Prompt for the accepting
state(s).
Parameters
none
Imports
none
Exports
The accepting state(s).
Error Handling
none
Test Cases
none
Concrete Implementation
Display all states
Set DONE to false
While not DONE
Prompt for the next accepting state
Display chosen state in reverse video
120
B.2.4.2.3.1 MENU.24 General Description
Th1s procedure prompts the user for the accepting state(s)
of the FSM.
Calling Modules
CHOOSE.ACCEPT.STATES
- Choose the accepting
state(s).
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the positions and text for the choices
Display the choices
121
8.2.4.2.4 CHOOSE.INPUT.SYMBOL General Description
Th1s procedure ass1sts the user in defining the input symbols of the FSM.
Calling Modules
CREATE.FSM
Modules Called
MENU. 25
MENU.26
- Create the new FSM.
- Prompts for the number of
input symbols.
- Prompts for the input
symbol names.
Parameters
none
Imports
none
Exports
The names of the new input symbols.
Error Handling
An appropriate error message is displayed if:
1.
less than one or greater than eight input symbols
are chosen
2.
an input symbol name is more
long
3.
an input symbol name is comprised
other than "a-z" and "0-9".
4.
eight input symbols are chosen, none of which
the "null" symbol.
Test Cases
than
8
characters
of
characters
is
122
1.
Enter up to eight valid input symbol names.
(Do
this eight times, each time choosing a different
number of input symbols.)
2.
Choose less than one input symbol.
3.
Choose more than eight input symbols.
4.
Enter an input symbol name with a length of
than 8 legal characters.
5.
Enter an input symbol name comprised
characters.
6.
Choose eight input symbols, none of which is
"null" symbol.
of
more
illegal
the
Concrete Implementation
Repeat
Get the number of input symbols
If the number of input symbols is not between one and
eight
then
Display an appropriate error message
Until the number of input symbols is between one and eight
Set NULL to false
For each input symbol
Repeat
If this is the eighth input symbol and not (NULL)
then
Set the input symbol to "null"
else
Prompt the user for the input symbol name
If the input symbol name is "null" and not (NULL)
then
Set NULL to true
else
If the state name is invalid
then
Display an appropriate error message
Until the state name is valid
,, .
123
B.2.4.2.4.1 MENU.25 General Description
Th1s procedure prompts the user for the
symbols to be included in the new FSM.
Calling Modules
CHOOSE.INPUT.SYMBOLS
number
of
input
- Choose the input symbol
names.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the pos1t1on and text for the choice
Display the prompt
124
B.2.4.2.4.2 MENU.26 General Description
Th~s procedure prompts the user for the names of the input
symbols to be included in the new FSM.
Calling Modules
CHOOSE.INPUT.SYMBOLS
- Choose the input symbol
names.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the pos~tion and text for the choices
Display the choices
125
B.2.4.2.5 GET.TRANSITIONS General Description
This procedure ass1sts the user in defining the transition
function of the new FSM.
Calling Modules
CREATE.FSM
Modules Called
MENU.27
MENU. 271
MENU.272
MAKE.TRANSITION
REMOVE. TRANSITION
DETERMINE.TYPE
- Create a new FSM.
- Prompt for transition
information.
- Prompt for a source state.
- Prompt for a destination
state.
- Draw a transition.
- Remove a transition.
- Determine whether the FSM
is deterministic or not.
Parameters
none
Imports
none
Exports
The transition function of the new FSM
The type (nondeterministic or deterministic) of the new
FSM.
Error Handling
none
Test Cases
1.
Define a transition function so that the
deterministic.
FSM
is
2.
Define a transition function so that the
nondeterministic.
FSM
is
126
Concrete Implementation
Display the states, the state names, and the input symbol
names
Prompt for the ACTION to be taken
While ACTION is not TRANSITION FUNCTION COMPLETE do
If ACTION is CHOOSE SOURCE STATE
then
Prompt for a source state
If ACTION is CHOOSE DESTINATIO~ STATE
then
Prompt for a destination state
If ACTION is MAKE TRANSITION
then
Draw the transition
If ACTION is REMOVE TRANSITION
then
Remove the transition
Prompt for the next ACTION
Determine the type of the FSM
127
B.2.4.2.5.1 MENU.27 General Description
Th1s procedure prompts the user for the information
quired to create the transition function.
Calling Modules
GET.TRANSITIONS
- Define the transitions.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the pos1t1ons and text for the choices
Display the choices
re-
128
B.2.4.2.5.2 MENU.271 General Description
This procedure prompts the user for the source state of
transition of a FSM.
Calling Modules
GET.TRANSITIONS
- Define the transitions.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the positions for the choices
a
129
B.2.4.2.5.3 MENU.272 General Description
This procedure prompts the user for the destination
of a transition of a FSM.
Calling Modules
GET.TRANSITIONS
- Define the transitions.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the positions for the choices
state
130
B.2.4.2.5.4 MAKE.TRANSITION General Description
Th1s procedure prompts the user for the input symbol on
which a transition occurs from the previously chosen
source state to the previously chosen destination state.
The transition is then made.
Calling Modules
GET.TRANSITIONS
- Define the transitions.
Modules Called
none
Parameters
none
Imports
none
Exports none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the positions for the choices.
Display the new transitions.
0 .
v '
131
B.2.4.2.5.5 REMOVE.TRANSITIONS General Description
This procedure prompts the user for the input symbol on
which a transition previously created was done so incorrectly.
Calling Modules
GET.TRANSITIONS
- Define the transitions.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the positions for the choices
Remove the old transition from the display
132
B.2.4.2.5.6 DETERMINE.TYPE General Description
Th1s procedure determines whether the new FSM, which
just previously created, is deterministic or not.
Calling Modules
GET.TRANSITIONS
- Define the transitions.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set DONE to false
Set FSMTYPE to deterministic
Repeat
Read the next transition
If none remaining
then
Set DONE to true
else
If the source state and the input symbol of this
transition has already occurred
then
Set FSMTYPE to nondeterministic
was
133
Set DONE to true
Until DONE
134
B.2.4.3 CREATE.RE General Description
This procedure ass1sts the user in creating a new RE.
Calling Modules
NEW.CONSTRUCT.PROCESSING
Modules Called
MENU. 28
- Create a new SIMFARE
construct.
- Prompt for a RE.
Parameters
none
Imports
none
Exports
The definition of the new RE.
Error Handling
An appropriate error message will be displayed if:
1.
more than eight symbols are used
2.
the entire length is more than 60 characters
3.
there are eight symbols, none
"null" symbol
4.
the RE syntax is not of the form re : := ( ~a~ )
(re+re)
(re.re)
(re*) where ~a~ is a typical
input symbol name
5.
an input symbol name is greater than eight
acters long
6.
an input symbol name is comprised
other than "a-z" and "0-9".
of
which
of
is
the
char-
characters
135
Test Cases
1.
Enter eight regular expressions, each one with
different number of input symbols.
2.
Enter a regular expression with eight input
bols, none of which is the "null" symbol.
3.
Enter a regular expression comprised
than 60 characters.
4.
Enter a regular expression comprised of incorrect
symtax.
Concrete Implementation
Repeat
Prompt for the regular expression
Until the regular expression is valid
of
a
sym-
greater
136
B.2.4.3.1 MENU.28 General Description
This procedure prompts the user for the new RE.
Calling Modules
CREATE.RE
- Create a new RE.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the position for the prompt
137
B.2.4.4· GENERATE.AUTOMATAGeneral Description
This procedure generates the RE, NDFSM,
DFSM,
and
minimum-state DFSM using one of the first three constructs
as a starting point.
Calling Modules
NEW.CONSTRUCT.PROCESSING
Modules Called
GENERATE.NDFSM
GENERATE.DFSM
GENERATE.RE
GENERATE.MIN.DFSM
- Create a new SIMFARE
construct.
- Generate a NDFSM from a RE.
-Generate a.DFSM from a
NDFSM.
- Generate a RE from a DFSM.
- Generate a minimum-state
DFSM from a DFSM.
Parameters
none
Imports
The definitions of one of either a RE, a NDFSM, or a DFSM.
Exports
The definitions of a minimum-state DFSM,
other two of the RE, NDFSM, and DFSM.
Error Handling
none
Test Cases
none
Concrete Implementation
If the user entered a RE
then
Generate a NDFSM
Generate a DFSM
along
with
the
@ •
138
If the user entered a NDFSM
then
Generate a DFSM
Generate a RE
If the user entered a DFSM
then
Generate a RE
Generate a NDFSM
Generate a minimum-state DFSM
139
B.2.4.4.1 GENERATE.NDFSM General Description
This procedure generates a NDFSM from a RE.
Calling Modules
GENERATE.AUTOMATA
- Generate the remaining
automata.
Modules Called
none
Parameters
none
Imports
The definition of a regular expression.
Exports
The definition of a NDFSM.
Error Handling
An appropriate error message will be displayed if the
sulting NDFSM contains more than eight states.
re-
Test Cases
1.
Enter a RE which can be converted to a NDFSM with
at most eight states.
2.
Enter a RE which cannot be converted to
with at most eight states.
a
Concrete Implementation
Decompose the RE Into Its primitive components
Recursively combine the primitive components into the
appropriate compound components
NDFSM
140
B.2.4.4.2 GENERATE.DFSM General Description
This procedure generates a DFSM from a NDFSM.
Calling Modules
GENERATE.AUTOMATA
Modules Called
NULL.CLOSURE
- Generate the remaining
automata.
- Find the null-closure of
a set of states.
Parameters
none
Imports
The definition of a NDFSM.
Exports
The definition of a DFSM.
Error Handling
An appropriate error message will be displayed if the
sulting DFSM contains more than eight states.
re-
Test Cases
1.
Enter a NDFSM which can be converted
with at most eight states.
to
2.
Enter a NDFSM which cannot be converted to a DFSM
with at most eight states.
Concrete Implementation
While there is an unmarked state, X, of the DFSM do
Mark X
For each input symbol, A
Let T be the set of states to which there is
a
DFSM
141
a transition on A from some state in X
Let Y be the null-closure of T
If Y has not yet been added to the set of states
of the DFSM
then
Make Y and unmarked state of the DFSM
Add a transition from X to Y labeled A if not
already present
142
B.2.4.4.2.1 NULL.CLOSURE General Description
Th1s procedure f1nds the null-closure of a set of states.
Calling Modules
GENERATE.DFSM
- Generate a DFSM using
a NDFSM.
Modules Called
none
Parameters
none
Imports
The definition of a subset of a NDFSM.
Exports
A stack of states comprising the null-closure of
port.
the
Error Handling
none
Test Cases
none
Concrete Implementation
Push all states in T onto STACK
Let the null-closure of T be T
While STACK is not empty do
Pop S, the top element of STACK, off of STACK
For each state, t, with an edge from S to t labeled
"null" do
If t is not in the null-closure of T do
Add t to the null-closure of T
Push t onto STACK
im-
143
B.2.4.4.3 GENERATE.RE General Description
Th1s procedure generates a RE from a DFSM.
Calling Modules
GENERATE.AUTOMATA
- Generate the remaining
automata.
Modules Called
none
Parameters
none
Imports
The definition of a DFSM.
Exports
The definition of a RE.
Error Handling
An appropr1ate error message will be displayed if the
sulting RE is more than 60 characters long.
re-
Test Cases
1.
Enter a DFSM which can be converted to a RE of at
most 60 characters in length.
2.
Enter a DFSM which cannot be converted to a RE of
at most 60 characters in length.
Concrete Implementation
Recursively find R(i,j,k), where "i" is the start state,
"j" is the accepting state, and "k" is one more than
the number of states, and
R(i,j,k+l) = R(i,j,k) + R(i,k,k).R(k,k,k)*.R(k,j,k)
I
'
144
B.2.4.4.4 GENERATE.MIN.DFSM General Description
Th1s procedure generates a minimum-state DFSM from a DFSM.
Calling Modules
GENERATE.AUTOMATA
- Generate the remaining
automata.
Modules Called
none
Parameters
none
Imports
The definition of a DFSM.
Exports
The definition of a minimum-state DFSM.
Error Handling
none
Test Cases
none
Concrete Implementation
Partition the set of states of the DFSM into subgroups
such that two states, S and T, are in the same subgroup
if and only if for all input symbols states s and T
have transitions to states in the same group
Pick a representative from each group - these will form
the states of the minimum-state DFSM
Remove all states not reachable from the initial state
145
B.2.4.5 SAVE.CONSTRUCT General Description
Th1s procedure transfers a
RE,
NDFSM,
DFSM,
and
minimum-state DFSM from main memory to a file on a disk.
Calling Modules
NEW.CONSTRUCT.PROCESSING
- Create a new SIMFARE .
construct.
Modules Called
none
Parameters
none
Imports
The definitions of a RE, NDFSM,
DFSM.
DFSM,
and
minimum-state
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Prompt for a file name
Transfer the definitions of the new SIMFARE construct
Q .
146
B.2.5
GIVE.RESULTS
General Description
Th1s procedure d1splays results pertaining to the
SIMFARE construct.
Calling Modules
SIMFARE
Modules Called
MENU.31
MENU.32
DISPLAY.RE
DISPLAY.NDFSM
DISPLAY.DFSM
DISPLAY.MIN.DFSM
SIMULATE.DFSM
COMPARE.CONSTRUCT
MEMBER.OF.DFSM
WORDS.OF.DFSM
WORDS.ACCEPTED
Parameters
none
Imports
none
Exports
none
Error Handling
none
current
- The main program.
- Prompt for results,
first menu.
- Prompt for results,
second menu.
- Display a RE.
- Display a NDFSM.
- Display a DFSM.
- Display a minimum-state
DFSM.
- Simulate a word on a DFSM.
- Compare the current SIMFARE
construct with
- Determine if a
the DFSM.
- List all words
- Count how many
in the RE.
another.
word is in
in the DFSM.
words are
147
Test Cases
Select each of the nine types of results to be displayed.
Concrete Implementation
Prompt for SELECTION using first menu
Set Ml to true
Repeat
If SELECTION = change menus
then
If Ml is true
then
Prompt for SELECTION using second menu
Set Ml to false
else
Prompt for SELECTION using first menu
Set Ml to true
else
Display the appropriate results
Prompt for the next SELECTION
Until SELECTION = end
148
B.2.5.1 MENU.31 General Description
Th1s procedure wr1tes to the terminal, giving the user the
option of selecting the type of result to be displayed.
The available options are: display a RE, display a NDFSM,
display a DFSM, display a minimum-state DFSM, simulate a
word on the DFSM, compare the current SIMFARE construct
with another construct, go on to the next menu which
prompts for other options, and return to the main menu.
Calling Modules
GIVE.RESULTS
- Display the results desired
by the user.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the positions and text for the choices
Display the choices
149
B.2.5.2 MENU.32 General Description
Th1s procedure wr1tes to the terminal giving the user the
option of selecting a type of result to be displayed. The
available options are: determine if a word is accepted by
a RE, list all words accepted by a RE, count the number of
words accepted by a RE, go back to the previous menu,
and
return to the main menu.
Calling Modules
GIVE.RESULTS
- Display the results desired
by the user.
Modules Called
none
Parameters
none
Imports
none .
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the pos1t1ons and text for the choices
Display the choices
150
B.2.5.3 DISPLAY.RE General Description
This procedure displays the
input symbol names.
Calling Modules
GIVE. RESUJ.. TS
current
RE
along
with
- Display the results
desired by the user.
Modules Called
none
Parameters
none
Imports
The definition of the RE.
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Display the RE
Display the eight input symbol names
the
~1
•
151
B.2.5.4 DISPLAY.NDFSM General Description
This procedure displays the NDFSM
names and input symbol names.
Calling Modules
GIVE.RESULTS
Modules Called
MENU.33
along
with
the
state
- Display the results desired
by the user.
- Prompt for the NDFSM action.
Parameters
none
Imports
The definition of the NDFSM.
Exports
none
Error Handling
none
Test Cases
Using a NDFSM with eight states, choose all eight, one
a time, as the source state.
Concrete Implementation
Prompt for the ACTION to be performed
While ACTION is not END do
Perform the ACTION
Prompt for the next ACTION to be performed
at
152
B.2.5.5 DISPLAY.DFSM General Description
Th1s procedure displays the DFSM
names and input symbol names.
Calling Modules
GIVE.RESULTS
Modules Called
MENU. 34
along
with
the
state
- Display the results desired
by the user.
- Prompt for the DFSM action.
Parameters
none
Imports
The definition of the DFSM.
Exports
none
Error Handling
none
Test Cases
Using a DFSM with eight states, choose all eight, one at a
time, as the source state.
Concrete Implementation
Prompt for the ACTION to be performed
While ACTION is not END do
Perform the ACTION
Prompt for the next ACTION to be performed
153
B.2.5.6 DISPLAY.MIN.DFSM General Description
Th1s procedure displays the minimum-state DFSM along
the state names and input symbol names.
Calling Modules
GIVE.RESULTS
Modules Called
MENU.35
with
- Display the results desired
by the user.
- Prompt for the minimumstate DFSM action.
Parameters
none
Imports
The definition of the minimum-state DFSM.
Exports
none
Error Handling
none
Test Cases
Us1ng a m1nimum-state DFSM with eight states,
eight, one at a time, as the source state.
Concrete Implementation
Prompt for the ACTION to be performed
While ACTION is not END do
Perform the ACTION
Prompt for the next ACTION to be performed
choose
all
154
B.2.5.7 SIMULATE.DFSMGeneral Description
This procedure simulates the flow of a
DFSM.
Calling Modules
GIVE.RESULTS
Modules Called
MENU. 36
Parameters
none
Imports
The definition of a DFSM.
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Prompt for a word
Perform the simulation
word
through
- Displays the results
desired by the user.
- Prompt for an input word.
the
155
B.. 2.5.7.1 MENU.36General Description
This procedure prompts the user for an input word.
Calling Modules
SIMULATE.DFSM
MEMBER.OF.DFSM
- Simulate a word on a DFSM.
- Determine if a word is
in the DFSM.
Modules Called
none
Parameters
none
Imports
none
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Set the posit1ns for the pointers
Display the choices
156
B.2.5.8 COMPARE.CONSTRUCT General Description
This procedure determines whether or not the current SIMFARE construct is equivalent to one previously created.
Calling Modules
GIVE.RESULTS
- Display the results
desired by the user.
Modules Called
none
Parameters
none
Imports
The definition of the current SIMFARE construct.
Exports
none
Error Handling
An appropriate error message will be displayed if the user
wishes to compare the current SIMFARE construct with one
that does not exist, or is read-protected.
Test Cases
1.
Choose a valid SIMFARE construct to be compared.
2.
Choose an invalid SIMFARE construct
pared.
to
be
Concrete Implementation
Prompt for the construct name
If the construct can be read
then
Compare the construct with the current construct
com-
157
Display the result
else
Display the appropriate error message
(l
•
158
B.2.5.9 MEMBER.OF.DFSM General Description
Th~s procedure determines whether
or not a
member of the language generated by the DFSM.
Calling Modules
GIVE.RESULTS
Modules Called
MENU.36
word
is
- Display the results
desired by the user.
- Prompt for an input word.
Parameters
none
Imports
The definition of the SIMFARE construct.
Exports
none
Error Handling
none
Test Cases
none
Concrete Implementation
Prompt for a word
Determine if the word is accepted
Display the result
a
159
B.2.5.10 WORDS.OF.DFSM General Description
This procedure l1sts all words of length "k" or less which
are members of the language generated by the DFSM.
Calling Modules
GIVE.RESULTS
- Display the results
desired by the user.
Modules Called
none
Parameters
none
Imports
The definition of the SIMFARE construct.
Exports
none
Error Handling
An appropriate error message will be displayed if the user
enters a maximum word length of more then ten.
Test Ca.ses
Perform this procedure eleven times, varying "k" from
to eleven.
Concrete Implementation
Prompt for the maximum word length
While not ( 0 < maximum word length <= 10 ) do
Display the appropriate error message
Prompt for the maximum word length
List the words
one
160
B.2.5.11 WORDS.ACCEPTED General Description
Th1s procedure determines how many members are in the
language generated by the regular expression, where the
possible result is either "zero", "a finite number", or
"an infinite number".
Calling Modules
GIVE.RESULTS
- Display the results
desired by the user.
Modules Called
none
Parameters
none
Imports
The definition of the SIMFARE construct.
Exports
none
Error Handling
none
Test Cases
1.
Enter a SIMFARE construct such that the result of
this procedure is "zero".
2.
Enter a SIMFARE construct such that the result of
this procedure is "a finite number".
3.
Enter a SIMFARE construct such that the result of
this procedure is "an infinite number".
Concrete Implementation
161
Determine the number of words accepted
Display the result