# Premise ## SIMPLE ``` procedure main { 01 flag = 0; 02 call computeCentroid; 03 call printResults; } procedure readPoint { 04 read x; 05 read y; } procedure printResults { 06 print flag; 07 print cenX; 08 print cenY; 09 print normSq; } procedure computeCentroid { 10 count = 0; 11 cenX = 0; 12 cenY = 0; 13 call readPoint; 14 while ((x != 0) && (y != 0)) { 15 count = count + 1; 16 cenX = cenX + x; 17 cenY = cenY + y; 18 call readPoint; } 19 if (count == 0) then { 20 flag = 1; } else { 21 cenX = cenX / count; 22 cenY = cenY / count; } 23 normSq = cenX \* cenX + cenY \* cenY; } ``` ## PQL ``` assign a; variable v; Select a such that Uses (a, v) pattern a (v, _) ``` ## Initial PKB ```prolog /* DESIGN ENTITIES */ procedure(main), procedure(readPoint), procedure(printResults), procedure(computeCentroid), stmt(1),stmt(2),stmt(3),stmt(4),stmt(5),stmt(6),stmt(7),stmt(8),stmt(9), stmt(10),stmt(11),stmt(12),stmt(13),stmt(14),stmt(15),stmt(16),stmt(17),stmt(18),stmt(19), stmt(20),stmt(21),stmt(22),stmt(23) stmtLst(main,1),stmtLst(main,2),stmtLst(main,3), stmtLst(readPoint,4),stmtLst(readPoint,5), stmtLst(printResults,6),stmtLst(printResults,7),stmtLst(printResults,8),stmtLst(printResults,9), stmtLst(computeCentroid,10),stmtLst(computeCentroid,11),stmtLst(computeCentroid,14 stmtLst(10,23),stmtLst(15,18),stmtLst(20,20),stmtLst(21,22), read(4),read(5), print(6),print(7),print(8),print(9), assign(1),assign(10),assign(11),assign(12),assign(15),assign(16),assign(17),assign(20),assign(21),assign(22),assign(23), /* call(s,p) :- stmt(s), procedure(p). */ call(2,computeCentroid),call(3,printResults),call(18,readPoint), /* while(s,t1,t2) :- stmt(s), stmtLst(t1,t2). */ while(14,15,18) /* if(s,t1,t2,f1,f2) :- stmt(s), stmtLst(t1,t2), stmtLst(f1,f2). */ if(19,20,20,21,22) variable(flag),variable(x),variable(y),variable(flag),variable(cenX),variable(cenY),variable(normSq),variable(count), constant(0), constant(1), # DESIGN ABSTRACTIONS follows(s1,s2) :- ```