[an error occurred while processing this directive]
MTH210

Assignment


[an error occurred while processing this directive]
(none)

[an error occurred while processing this directive]
(none)
[an error occurred while processing this directive]
(none)

[an error occurred while processing this directive]
Due: Tuesday March 30


Important Notes
 This assignment is worth 10% of the course mark.
 You are allowed to work on this assignment in groups of 1, 2, 3 or 4.
Each team only hands in one assignment for the whole team.
All the members of the group must be listed on the assignment.
Please read the MTH210
General Assignment Information
and
Teamwork and Cheating Policy
before submitting your assignment.
Notes on Programing Tasks
This assignment includes a programing question which will be auto
marked. It is thus very important that you consider the following:

Your programs should be submitted using the submitmth210 command on
one of the moons. If none of your team members have access to the moons
see me.

You can resubmit your files up to the deadline, but if you resubmit after that
date marks will be deducted for lateness.
Only the last submission will be considered.

If your program does not compile you will recieve a grade of 0.

Your program must have the filename specified, otherwise it will
not compile and you will receive a grade of 0.

Submit only those files required. Do not use multiple files or make files.
 Read the instructions carefully, use the input provided, with appropriate
error checking, and provide the output required.

All programs must be in C, they will be compiled with
gcc.
Therefore check that your program compiles correctly.
(Note that the gnu compiler, gcc, is slightly more forgiving than the
strict cc compiler.)
Part 1  Recursion and Structural Induction
Preamble
The family of Central Graphs is defined recursively below. Each Central
graph has a head and each vertex of a Central
graph has an integer associated with it called its saturation. These are
also defined recursively within the definition.
Given a vertex x of a Central graph G, we denote the saturation
of x in G by
s_{G}(x). We drop the G if it is clear from context.
Definition
Some of the vertices of a central graph are called tails, according to
the following definition:
Any point with saturation less than 2 is a tail.
i.e. x ∈ V(G) is a tail if and only if
s_{G}(x) < 2.
Recursive Definition
 Base
The empty graph of order one is central.
i.e. G = ({a}, ∅) is a central graph.
a is the head and has saturation s(a) = 0.
(Note that this means that a is both a head and a tail.)
 Recursion (There is only one recursive rule)
Given Central three graphs
G_{1} = (V_{1}, E_{1}),
G_{2} = (V_{2}, E_{2}) and
G_{3} = (V_{3}, E_{3})
with V_{i} ∩ V_{j} = ∅
whenever i ≠ j and let a_{1}, a_{2} and
a_{3} be the heads of G_{1}, G_{2}
and G_{3} respectively and let b be a tail of
G_{1}.
Then
G = (V, E),
where V = V_{1} ∪ V_{2} ∪ V_{3}
and E = E_{1} ∪ E_{2} ∪ E_{3}
∪ { ba_{2}} ∪ { ba_{3}}
is also a central graph with head a_{1} and
s_{G}(x) =
 
s_{Gi}(x) + 1   if
x = a_{i}, i = 2, 3.
 s_{G}_{1}(x) + 2   if
x = b
 s_{Gi}(x)   otherwise
and x ∈ V(G_{i})


 No graph other than those obtained by repeated applications of
i  ii above is a Central graph.
Examples

By Rule i,
G_{i} = ({a_{i}}, ∅) is a Central graph
for each i = 1, 2, 3, with head a_{i} and
s(a_{i}) = 0.

Take the Central graphs from Example 1 as
G_{1}, G_{2} and G_{3}
in ii.
This yields a new Central graph:
G = ({a_{1}, a_{2},
a_{3}}, { {a_{1}a_{2} },
{a_{1}a_{3}} }),
a_{1} is the head,
s(a_{1}) = 2 and s(a_{2}) =
s(a_{2}) = 1,
thus a_{2} and a_{3} are tails.

We may now apply rule ii again, this time using two copies of G
from Example 2 above
(G and G') and another base case
H = ({b}, ∅) to produce the following:
({a_{1}, a_{2}, a_{3},
a_{1}', a_{2}', a_{3}', b},
{ {a_{1}a_{2} }, {a_{1}a_{3}},
{a_{1}'a_{2}' }, {a_{1}'a_{3}'},
{a_{2}b}, {a_{2}a_{1}'} }
).
where a_{1} is the head and
s(a_{1}) = 2,
s(a_{2}) = s(a_{1}') = 3 and
s(a_{3}) = s(a_{2}') = s(a_{3}')
= s(b) = 1,
so a_{3}, a_{2}', a_{3}', and
b are tails.

Alternately, taking the graphs in a different order, and using H
as the head (G_{1}) in ii, we get
({a_{1}, a_{2}, a_{3},
a_{1}', a_{2}', a_{3}', b},
{ {a_{1}a_{2} }, {a_{1}a_{3}},
{a_{1}'a_{2}' }, {a_{1}'a_{3}'},
{ba_{1}}, {ba_{1}'} }
).
where b is the head and
s(b) = 2,
s(a_{1}) = s(a_{1}') = 3 and
s(a_{2}) = s(a_{3}) = s(a_{2}')
= s(a_{3}') = 1,
so a_{2}, a_{3}, a_{2}' and
a_{3}', are tails.
Questions

Find central graphs with 11 and 13 vertices. Give a drawing of your graph.

Use structural induction to show that every Central graph is connected.

Show that every Central graph is a tree by using structural induction to
show that the number of edges is always one less thatn the number of vertices.

Use structural induction to show that if a Central graph is not base (is not the
graph from rule i), then given any point one of the following must hold:
 it is the head and has saturation 2;
 it is a tail and has saturation 1;
 it is not the head and has saturation 3.
Notes

You must use structural induction, no other method is acceptable.

You may assume the Tree Edge Theorems (11.5.2 and 11.5.4):
A connected graph G with n vertices is a tree if and only if
it is of size n  1.

You may assume the Inclusion/Exclusion Rule, Theorem 6.3.3 in the book:
Suppose the set two sets A and B satisfy
A ∩ B = n, then A &cup B = A + B  n
Part 2  Regular Languages and FSA's
Preamble
For this question ε is the empty string.
Define the following sets:
OP  =  { &&, , ^, == }

DIGIT  =  [09]

LETTER  =  [AZaz]

WHITE  =  [Space, Tab, ε ]

Define the following languages over the set of
OP ∪ DIGITS ∪ LETTERS ∪ WHITE.
INTEGER  =  Any number of DIGITS, but must have at least one DIGITS.


IDENTIFIER  =  Any number of LETTERS or DIGITS, but must begin with
a LETTERS.

BOOLEAN  = 
Base
Any member of IDENTIFIER or INTEGER is a member of BOOLEAN.
Recursion
If x and y are strings in BOOLEAN, then so is
x WHITE OP WHITE y.

Here WHITE OP means the concatenation of an element of WHITE
with an element of OP etc.
For example, the following are in BOOLEAN:
axy, a && x  y, a ^ 12, 12  a &&
beryl34.
The following are not in BOOLEAN:
1x && 124,  x &&,  (12 && 3)  3.

Notes:

You may use the notation Σ to indicate an arbitrary element of the set
Σ. Thus, for example, OP^{*} would indicate an arbitrary string
of elements of OP, equivalent to (&& or  or ^ or == )^{*}.
You may also use the UNIX [ ] notation, as above. So, for
example, [09] would indicate the digits 0 through 9.

Keep your strings as simple as possible.
Questions

Write regular expressions for the Languages INTEGER, IDENTIFIER and BOOLEAN.

Draw A Finite State Automaton which accepts the language BOOLEAN.
Even though you will only be submitting the FSA for the ARITHMETIC
language, it is recommended that you first draw FSAs for the other
two languages, when you are sure that they
work properly, integrate them into the BOOLEAN FSA.

Based on Algorithm 12.2.1 on page 755 of your textbook, or algorithm 12.2.2
of page 756, or otherwise, write a C program which implements the
BOOLEAN FSA you drew in 2.2. Both algorithms will need substantial
adaptations to work well with this particular FSA.
Note this question while be marked independently of the previous question, if
there is a mistake in your FSA above, you will lose marks here as well.
This part of your assignment will be tested mechanically. Read the notice
at the start of this assignment. Your program must meet the following
requirements:
 Your program should be in only one file, called fsa.c
 Your program should read one string from the command line
To do this declare your main routine as
char a;
int main(int argc, char *argv[])
{
. . .
argv[1] now points to the first command line argument.
So, printf("%s\n", argv[1]); will print the string,
a = argv[1][0]
sets a to be the first character of the
string, a = argv[1][1] the second and so on.
The string is null terminated, so argv[1][i] == 0 means that
you are at the end of the string.

Your program should return the following (return value from main):
 1 if the string that was read is an element of BOOLEAN
 0 if it isn't.
 1 on error.
 If @ is given on the command line, your program should
print out the group members names. A sample code that does this can be found
here.
Make sure that all group members are entered in this way. Those that are not
here will not get a mark for the programming portion.
Hint: if you want to see if a character, a is in a range
use >, < and an ASCII table.
For example, to check if x ∈ [09] use:
if(x >= '0' && x <= '9') . . .

The ARITHMETIC language above does not allow bracketing. So
(a  b) && c, would be an illegal string. We can modify
the definition of BOOLEAN to allow brackets. We add open bracket '('
and close bracket ')' to the alphabet and redefine BOOLEAN to
BRACKET_BOOLEAN.
BRACKET_BOOLEAN  = 

Base
Any member of IDENTIFIER or INTEGER is a member of BOOLEAN.
Recursion
If x and y are strings in BOOLEAN, then so is
x WHITE OP WHITE y
and so is
'(' WHITE x WHITE OP WHITE y WHITE ')'.

Use the Pumping Lemma to show that the modified version of this language
BRACKET_BOOLEAN is not a regular language.
Hand in
This page is maintained by Peter Danziger.
Last modified
Tuesday, 30Mar2010 06:51:35 EDT