CSC 514 Project Documentation: Group 7
CSC 514 Project Documentation: Group 7
Documentation
Group 7
Agho Adrian
Odunuga Kemi
080805015
080805065
Olubumni Morgan
080805058
Onuigbo Elizabeth
090805046
Sentence Verifier
Project Description
The verify sentence algorithm is a recursive algorithm that takes in an expression
and determines whether it is really a valid sentence or not. The algorithm is as
follows:
function verify_sentence(expression);
begin
case
expression is an atomic sentence: return SUCCESS;
expression is of the form Q X s, where Q is either or , X is a
variable,
if verify_sentence(s) returns SUCCESS
then return SUCCESS
else return FAIL;
expression is of the form s:
if verify_sentence(s) returns SUCCESS
then return SUCCESS
else return FAIL;
expression is of the form s1 op s2, where op is a binary logical
operator:
if verify_sentence(s1) returns SUCCESS and
verify_sentence(s2) returns SUCCESS
then return SUCCESS
else return FAIL;
otherwise: return FAIL
end
end.
Conceptual Design
The program takes in a string to represent the expression as input. In order to
simplify the selection of the process, symbols are first identified and extracted
out from the string (a process similar to token generation in lexical analysis). This
is achieved by passing the string through finite state automata as illustrated
bellow:
Connectives and Quantifiers: ^ (Represents Conjunction), * (Represents
Disjunction), ! (Represents Negation), ~ (represents Implication), =
(represents Equivalence), $ (represents Universal Quantifier), % (represents
Existential Quantifier).
Start
Return Conjunction
Symbol
Return Disjunction
Symbol
Return Negation
Symbol
Return Implication
Symbol
Return Equivalence
Symbol
%
Delimiter
Uppercase
Letter
Lowercase
Letter
10
12
15
Return Predicate
End
Delimiters: , ,.
8
Othe
r
Othe
r
11
Go back to
state 0
Delimit
er
Variable: Jam, Var_10_x, etc.
10
Uppercase
letter/
Lowercase
letter/ Digit/
Return Variable
Symbol
12
Uppercase
letter/
Lowercase
letter/ Digit/
Othe
r
(
13
Return Constant
Symbol
14
Return Predicate
Begin
The finite state automaton identifies symbols from the list, which are then
passed into the algorithm as a list.
Program Description
The program consists of 7 classes:
1. Symbol Class: this class represents a symbol type as used in predicate
calculus. It specifies its type (e.g. Connective), instance (e.g. Conjunction)
and its actual value (e.g. ^).
2. SymbolAnalyser Class: this class implements the finite state automata
described above. Its main method getSymbol() takes in a string, and
passes each character into a switch-case. This switch-case successfully
models the above automata.
3. SentenceVerifier Class: the sentence verifier class implements the main
verify_sentence algorithm. Its main method verifySentence() takes in a
list of symbols and recursively calls itself to verify if the sequence of
symbols in the list conform to the structure of a valid statement.
4. RunVerifier Class: this is the main class where the components of all
other classes are used. The input string is read from a text file. A
SymbolAnalyser instance is created and the string is passed into its
getSymbol method, the result of which is stored in a symbol list. A
SentenceVerifier instance is created to assess the components of the
string list. The result of the analysis is sent into an output text file.
5. ReadTextFile Class: this class implements the procedure for getting the
input string from the input text file.
6. CreateTextFile Class: this class implements the procedure for writing
the output to a text file.
7. FailException Class: a custom exception class.
n x -dimensional population,
ns individuals;
while stopping condition(s) not true do
f ( x i ( t ) ) , of each individual,
xi ( t ) ;
o
o
C( 0) , to consist of
o
o
End
C( t+1) ;
Ackley problem,
Griewank problem,
Rastrigin problem,
Rosenbrock problem, and
Spherical problem.
Conceptual Design
Genetic Individual: the genetic would form the basic element upon
which the GA operators would act upon. It would represent the genes of a
chromosome, and its fitness according to the fitness function used.
Environment: this would represent the world in which the genetic
individual exist and interact. Here the GA operations (i.e. selection,
crossover, mutation) are carried out on the genetic individuals that exist in
that environment.
Program Description
The program is a windows form application that consists of 1 form, 1 interface
and 8 classes:
Conceptual Design
The algorithm used is similar to the SGAs, the major difference to be noted is
the fitness function used:
Bias 1
Weight 1 = Gene 1
1
x1
2
Chromosome i
x2
Bias 3
D9
D2
D3
D7
D4
D5
D8
D6
D 11
Out 1
D 10
Bias 2
Program Description
The program is a windows form application that consists of the following
elements:
8. Form 1: a user interface for the input of initialization data, and to show
the output results.