cagLl~ 82, J. Horecl~ (e~.) 
North.Holland Publishln~ Cor,~my 
© Academia, 1982 
KNOWLEDGE REPRESENTATION METHOD 
BASED ON pREDICATE CALCULUS 
IN AN INTELLIGENT CAI SYSTEM 
Barbara Belier 
Regional Computer Center 
Technical University of Pozna~ 
Poland 
The knowledge representation method is introduced 
to be applied in the ICAI system to teach prog~- 
min~ language° Knowledge about syntax and seman- 
ties of that language is represented by a set of 
axioms w~itten in the predicate calculus language, 
The directed graph of concepts is mentioned as a 
method to represent an instr~ctlonal structure of 
the domain knowledge. The pros\[ procedure to ans- 
wer student's questions is described. 
INTRODUCTION 
The early 70S have brouF~at the Intelligent CAI /ICAI/ systems \[3~4~o 
In these systems all course material is represented independently of 
teachin~ procedures. The goal of ICAI research is to obtain an indi- 
vidualization of inst1~aotion by providin~ an ability of answerln~ 
studentts questions as well as genel~atin~ remedial oomments~problems 
and advioes~ aeco1~Lin~ly to current studentPs respormos and his abi- 
lities and preferences in general. 
ICAI researchers have firstly focused their investigations on repre- 
sentation of the subject matter. Mostly semantic nets have been used 
as representation of static \[~J and procedural \[~p~\] domain knowled- 
Ge. Database of an instz~ctlo~Ll system includes also a representa- 
tion of currlculumto or~nlze an instz~uotlon of new knowledge \[~pY~ 
It is helpful in seleotln~ material to be presented to the student. 
Th£s paper presents the knowledge representation method based on pre- 
dicate calculus in an intelligent C AT system~ which is applied to 
teach the programmi~ language \[J\]o The prototype of the presented 
approach w~s an application of predloate calculus to describe pro~- 
ramsp written in ALGOL~ to l~ove their oozTe©tness~ introduced by 
~stall \[2\]. The ~aowledge about syntu and semantlos of" the prog- 
rmmni~ lan6~a~e has been represented in the form of a set of first 
oz~er logic axloms~ 
Them are given some notes how to construct the predicate calculus 
lan~age and axioms desor~bin~ the subject matter. The directed 
graph of concepts as a method to represent an instx~ctiona~ struc- 
ture of tile domain knowledge has been introduced aXong with the run- 
ner of ~enemtin~ instructional te~ts to the student° Then the pro- 
cedure answeri~ studGnt~s queat~ons has been desoribedo 
13 
14 B. BEGIER 
PREDICATE CALCULUS APPLIED TO REPRESENT EN01~EDGE ABOUT THE PRO- 
GRAMMING LANGUAGE 
The followin~ criteria may be referred to knowledge representation 
methods for ICAI systems \[.1,7\]: 
- ability to express a large set of concepts of the domain bein~ 
• taught p 
- facility of codln~ these concepts and relations amon~ them~ 
- easy way to t~ansform the formal notation into the natur~l lan- 
guage formp 
- effiolenoy of information retrieval duri~ the process of ans- 
werin~ user's query and proving the correctness of his answer~ 
- ability of automated deduction application in the question - 
answerln~ process. 
Let us conside~ a subset of an ALGOL-llke progx~ammin~ lan~uage~con- 
tainin~ simple arithmetic and logical expressions~ instruction of 
substitution and conditional and o~ instructions. We assume that 
each instruction has been written in a separate line of program. 
The predicate calculus language developed to represent knowledge a- 
bout the progI~ammlng lan6~age contains: 
- names of sets~ called sorts of objects~ representing elements 
of syntax and semantics of a pro~Tammln~ lan~uagep 
- funotions~ transformln~ obJeotsp 
- predioates~ representin~ relations between objects. 
Some sortsj functions and predicates are introduced to represent 
syntax of the prog~ammlng lan~uage.0thers represent its semantics. 
N o t a t i o n. The ordinary predicate calculus notation has been 
used. Some modifications improve the readability of statements: 
- unquantified vat-fables are gener~lly qua~t~.~le~. ~ 
- two-places predicates are written in an infix manner~ 
- binary arithmetic functions are written in an infix ma~n~rp 
- parenthesis are used in the ordinary meanin~ 
- clauses are separated by dots. 
P r o g r a m s y n t a x. The program syntax has been described 
by a set of clauses w~itten in the predicate calculus language. 
Sorts of objects /examples/~ identifier~ number~ expresslon~ arlth- 
metio expression~ logical expression~ label~ instruction~ program 
line. 
Functions transform some expressions_into te~ms~ by example: 
dod_~ wax wa-w-wa where: ~a - arithmetic expression~ 
it: wa~wa---wl wl - logical expression~ 
pod_~ id x wy~ in id - identifier~ 
sko; et~ in wy - expression~ et - label~ 
ifl: wl × wi ----in in - instruction~ 
~ri - program line. 
First of these functions constructs an expression~ which represents 
an operation of addition~ the second one gives as a result an ex- 
pression representing the "less than" relation and the others cons- 
tr~et appropriately the substitution instr~ction~ the ~ instruc- 
tion and the conditional instruction. 
Some p~edlcates have been introduced to represent the syntax rela- 
tions between syntax obJeots~ like followin~: 
wins ~wix in 
pet ~ et ~ wi 
~s ~ wl x wi 
First of these predicates indicates the location of an instruction 
KNOWLEDGE REPRESENTATION METHOD IN AN ICAI SYSTEM 15 
in a given pro~z~m llne r the second one assi~s a label at the be- 
6~i~ning of a progmam line and the third one determines the direct 
succession of two progx~um lines in a sequence. 
Example,. The syntax of a pro~am containing three followin~ substi- 
~uti one : 
J = L 
L= L+ 2 
E- K = J + L 
is described like tb~tz 
wl wins pod(J~LJ . w2 bnas wl. w2 wins pod(Lpdod(L, 2~ . 
E pet W3o w~ bnas W2o w3 wln____ss pod K~dod(J,L)) . 
P r o g r a m s e m a n t i c s° Semantics of an al~orithmic lan- 
guage is represented by a set of axioms ~rit%en in the predicate 
calculus l~age. New sorts of obJects~ functions and predicates 
are to be intrOduced. 
Sorts of ob~eetsz value~ state 
Value set contains values of ax-lthmeti0 and logical expresslons~ar- 
~ys~ subroutines or procedures etCo The particular kind of value 
is a location in a pro~nam~ represented by a progr~um llne. A state 
• is assiEned to a progx~un line and it is determined also by the ca. 
luation of variables. 
Functions evaluate expressions • 
owar: wy X st --'~T where: wy - expression~ 
and sequence of states: st ~ state~ 
haS: st ~st w~ - ~lueo 
Predicates assign states to iooatior~ in a program: 
stwe c-st ~wi 
stzm ~st ×wi 
Pirs$,c~" them associates a state to a program line before an execu- 
tion of an instruction from this lineo The second one indicateo 9 
that the control p~ssee ~o an instruction ~ri%ten in a ~iven prog- 
ram line in a ~iven state. 
Sorts o~ ob~eets~ functions and predicates are the b~is o~ a ~r~m- 
mar of ~he predicate cal~ulus lang~a~e~ which expreu~ions are ~sed 
%o repmesent knowl~d~e about %he prosx'anuruin~ lanGu~eo 
Axioms written ~n this language descx~ibe a~hme%lo 1~les~ propeP~ 
ties of ex~ressions~ seman%ics of instructions /princlple~ of exe= 
oution of instr~ctions/~ meaning of program se~nen%c or blocks etOo 
Ez~unple~ A~ axiom de~oribin~ semantics of a~ ins~muo$ion of substi- 
tution: 
wl ~in~ pod (J~X\] 
s stwe wl 
A w2 bna____~s wl 
The premises of this axiom !nelude~ %ho location el" the ~ubstltutlon 
J = X in the pro~Tam i~ne~ ~ ~ %he ~ssi~m~ of the s%~%e 
before an execution o. ~. %~.~is instrue~ion~and a faot~that the program 
line w2 directly follo~s"wlo The ooncl~slo~ says~ %.h~ a s~;ate next 
of s as %he state before an exertion of an instruction written in 
~2 and 8 value of the variable J in the state next of s is a value 
of an exp~-ession X in the ~tate s ~nd ~ ~lue of any variable Y ~ J 
doesn't ehan~e during %he %rar~fer from the state s to the next of 
~o A l~r~e subse~ o£ FORTRAN has been de$~rlbed in this manner \[~\] ° 
it tul~n8 out ~hat form%11as of p~edicate calculus a~e easy to tr~ns- 
16 'B. BEGIER 
form into na%~ral la~ e~os£~. Axles are divided into sim- 
ple sentences. Translati~ rales are applied to simple sentences. 
Each object has and me in natur~l l~ge. Also an appropriate ~- 
%ural language expression is selected for eaohfunotion.Eaah predi- 
cate cOrTesponds with a verb phrase in natural language. The proper 
translation rules for functions and objects sure applied with refe- 
rence te arguments of a predloate.~lation ~les for Polish lan- 
guage have been reported in \[I\] as well as their a~plication to all 
axioms descrlbin~ FORTRAN. 
DIRECTED GRAPH AS A D~rHOD OF INSTRUCTIONAL STRUCTURE REPRESENTATION 
An assumption is done that all knowledge to be tau6ht can be divided 
to instructional units.Thus the first step to oonstr~ot an instruc- 
tional structure representation is to select such units /concepts/. 
Each of them has a name and at least one sentence can be told about 
it /unreal concepts are not allowed/.Some introductory concepts are 
assumed to be known to the student. 
The next step is to specify all relations between concepts.These re- 
lations could be: 
/a/ Concept X is a part of Y, 
/b/ Concept X has a property~ represented by Z~ 
~ oncept X is a reason Or a Justification of T, 
Concept X belongs to the object class represented by K, 
/e/ Concept X is an alternative of A~ 
/f/ Concept X is equivalent to W at least in some circumstances. 
Each relation corresponds with a graph, which nodes represent con- 
cepts from an introduced set of concepts.The composition of all ob- 
tained 6~aphs rerults in a final graph~whlch represents an instruc- 
tional structure of the subject matter.Because of the different in- 
terpretation of the particular arches of this ~Taph /which are de- 
scribed by various relationships/ the "superior-inferior" relation 
is introduced as the universal one which represents every relation 
between concepts.Thus the dlrested ~phhas been obtained,~ith ar- 
rows directed to the superior concepts. 
A set of axioms is associated with each node of the concept graph. 
Also some other information may be associated with it. 
ANSWERING STUDENT'S QUESTIONS 
The followin~ problems have to be solved| 
- choice and specifyin~ of classes of user's queries,which can 
be answered by the ICAI system~ 
- reco@~nition of a main subject of the query, 
translation of the query from natural language to the predicate 
calculus language formula, 
- application of the automated theorem-provin~ techniques to re- 
trieve an answer, 
- generatin~ of an answer in natura~ language form. 
Three classes of queries have been qonsidered: 
/I/ Decision queries of gener~l\form in natural language 
<interrogative particle> < sentence> 7 
where: <interrogative partiole>/existin~ in Polish/ deter- 
mines that a question belongs to this class 9 
~entenoe> - indicative sentence, 
KNOWLEDGE REPRESENTATION lVlETHOD IN AN ICAI SYSTEM 17 
which require an answer in the form .Y~s, or "No". 
/2/ Objective quez-lee of ~enez~al foz~ in natuz~l lansuage 
Whloh ~senex~l name> <predloate~ ? 
whloh require to retrieve an object posessi~E some glven 
features as an answer. 
The quez 7 of this class may be tz~nsformed into the forml 
Which X satisfies a oo~Litlon: W (X) ~ A ~) ? 
whePez Y - an object to be foundp 
W ~ - distinctive predicate of a set~ which is spe- 
cified by ~genez~L1 name> in the query, A(X) 
-. formula obtained iron the tz~nslated queryp 
which describes some prope~ties of X. 
/3/ Problem quex-ies of general form in natural language /a/ ~ 
<clause> ? 
whloh can be t~sfo .treed into the form: 
Which Z eatlsfies: Z~ ~clause> ? 
/b/ What is implied by ~elause> ? 
which can be tz~nsfo~med into the formz 
Which Z satisfies = ~olause~Z ? 
In the above problem queries: Z - the clause to be found t 
~olause~ - clause obta/ned from the tx~nslate~ query. 
P~oblem queries ~equlre an answer in the foz~ of a senten- 
COo 
An analysis Of a userts quex-y should flx the main subject of it in 
the terms of a subset of conoepts~represented on the concept g~ph. 
A dofiD/tlon of acceptable language of user's queries involves the 
form of translation rules from n~tux~tl lan~u.age into the predloate 
calculus formula. It is worth notloln~ that: 
- querles in the natural lar~ua~e £orm have the threefold nature~ 
it means they can be counted into the three mentioned above olasses~ 
- queries fragments in the form of indicative clauses are built 
from expressed in natural language p~edloates~introduee~ in the pre- 
sent ed f or~alization~ 
- in respect of quantity of expressions the language of user's 
queries is comparable with the laa1&~e obtained in the process of 
translation of p~ed/oate calculus axioms into natural lan~ua~e~ 
- lan@uaGe o~ user's queries and the predloate calculus l~a~e 
have a common base of basle concepts because the sorts of ob~eots~ 
functions and pFedicates introduced in the predloate calculus lan- 
guage correspond with some specified natural language expressions. 
It has been submitted that questlon-answering problem m~y be solved 
with an application o~ auto~te~ theorem-pyo~,in~ teohnlques~ namely 
on the base o\[ the resolution principle \[8\] ,This method~ based only 
on the s~rnteac of olauses~ doesn't require to control the proo~ pro- 
cedure by the user,The resolution prlnelple requires to convert all 
formulas into the Skolem conjunctive form. Thus each formula beco- 
mes a set of olauses~ each of them bei~E a dlsjunotion of literals, 
The question-ans~ering procedure for deolslon queries tries to pro- 
~e that a negation of formula ~ ob%alned after translation of the qu- 
er~ is false, I£ it's so~ an answer is "Yes". If a proo~ procedure 
applied to the formula in its a~firmati~/e ~or~ provides a sucoess~ 
an answer is "NO".Some questions may be unsolvable in the lack of 
kno~le~e. 
The proof procedure £or objective queries examines a £ormula 
~~x (w (x} ~ A (x)) 
18 B. BEGIER 
which is supposed to be false.The proof prroedure tries to retrieve 
a counter-example, if i% exists, which will be substituted in the 
place of X o 
I% has been assumed that problem queries are in the implication form 
after the translation proeess. Question-answerin~ procedure for this 
class of queries has been reduced to such onetwhich tries to retrie- 
ve an answer from one axiom. For the first subclass of problem que- 
ries a search is made for an axiom in the implication form, ~hich 
conclusion embodies the conclusion of the formula obtained from the 
tx~ansformed query. The premises of this axiom are an answer° The 
proof procedure applied to answer a question of the second subclass 
tries to find an axiom~ which premises are implied by premises of 
the formula obtained f~om the transformed query. The conclusion of 
this axiom is an answer. 
The proper way to reduce a number of clauses taking a part in the 
resolution process is to constr,~ct an initial active set of clauses 
as a set containing only clauses of axioms concerning concepts reco- 
~LIzed in the query and clauses of formula obtained from the query. 
The translation rules,applied to transform axioms from the predica- 
te calculus language into the natural language expressions t can be 
used also to translate the retrieved answer to the natural language° 
CONCLUSIONS 
Described above ~1o~le~e representatiom method based on predicate 
calculus has been applied to the large subset of FORTRAN 1900 \[I\] . 
I% has been sho~n that this method satisfies criteria required in 
the ICAI system. An application of the predicate calculus language 
to describe knowledge about the programming language provides the 
automated answering of student's questions,whlch is the main advan- 
tage of this method. 
T~Lis method is applicable to those domains of ~owledge, which can 
be represented by the set of first or~er logic axioms, with regard 
to their formalized nature. 

REFERENCES 

\[J\] Begier B. ~ Method of representation of subject matter in the 
computer system to teach pro~ammlng lan~ua~e~ Ph.D. Thesis 
/in Polish/, Reg. Comp. Center, Tech. Univ. of Pozna~ /1980/. 

\[2\] Burstall R.M.~ Formal description of program str~cture and se- 
mantics in first order logic, Math. Intell. 5 /1969/ 79-98 

/3\] Carbenell J.R.~ AI in CAI: an artificial intelli~ence approach 
to computer-assisted instruction, IEEE Trans. on Man-Machine 
Systems 11 /1970/ 190-202 

\[4\] Clancey W.J,, Be~et J.S., Cohen J.R. ~ Appllcations-oriented 
AI research= education, Rep. STAN-CS-79-749~ Dep. of Comp. So., 
Stanford Univ. /July 1979/ 

\[5\] Computer-aided instruction system to t~ch the pro~ammlng lan- 
guage FORTRA~ Rep. of Re~. Compo Centerp Teoh.Unlv.Poznad /1980/ 

\[6\] Goldstein I.P. ~ The genetic graph: a representation for the eve. 
lution of procedural Enowledge, Int.J.Man-Machine Studies 11 
/1979/ 51-77 

\[~\] Laubsch J.H., Some tho~h% about represen¢ing knowledge in in- 
structional systems~ Fourth Int. Joint Conf. on Art. Intel~., 
~ilisi /1975/ 122-125 

\[8\] Loveland D.W.~ Automated theorem proving= a losical basis 
/North Holland~ Amsterdam, 19~8 / 
