@@ -20,7 +20,7 @@ public class SUMOKBtoTFAKB extends SUMOKBtoTPTPKB {
20
20
21
21
public static boolean initialized = false ;
22
22
23
- public static boolean debug = false ;
23
+ public static boolean debug = true ;
24
24
25
25
public static Set <String > qChildren = new HashSet <>();
26
26
public static Set <String > iChildren = new HashSet <>();
@@ -220,20 +220,38 @@ public static String translateName(String s) {
220
220
*/
221
221
public void writeSort (String t , PrintWriter pw ) {
222
222
223
- String label = translateName (t ) + "_sig" ;
223
+ String label ;
224
+ label = translateName (t ) + "_sig" ;
225
+ pw .println ("% writeSort(): term: " + t );
226
+ String bareTerm = SUMOtoTFAform .getBareTerm (t );
227
+ pw .println ("% bare term: " + bareTerm );
224
228
if (sortLabels .contains (label )) {
225
229
pw .println ("% duplicate label " + label + " for " + t );
226
230
return ;
227
231
}
228
232
else {
229
- pw .println ("% add label " + label );
233
+ pw .println ("% add label (writeSort) " + label );
230
234
sortLabels .add (label );
231
235
}
232
- String output = "tff(" + label + ",type,s__" + t ;
233
- if (Formula .isLogicalOperator (SUMOtoTFAform .getBareTerm (t )) ||
234
- SUMOtoTFAform .getBareTerm (t ).equals ("equal" ) ||
235
- kb .isRelation (SUMOtoTFAform .getBareTerm (t )))
236
- output = output + "__m" ;
236
+ String output ;
237
+ if (Formula .isInequality (bareTerm ))
238
+ t = translateName (t );
239
+ if (!t .startsWith (Formula .termSymbolPrefix ))
240
+ t = Formula .termSymbolPrefix + t ;
241
+ output = "tff(" + label + ",type," + t ;
242
+ //if (Formula.isLogicalOperator(bareTerm) ||
243
+ if (kb .isRelation (bareTerm ) ||
244
+ bareTerm .equals ("equal" )) {
245
+ // ||
246
+ // (kb.isRelation(bareTerm) && !Formula.isMathFunction(bareTerm))) {
247
+ // && !Formula.isInequality(bareTerm))) {
248
+ pw .println ("% logop: " + Formula .isLogicalOperator (bareTerm ));
249
+ pw .println ("% is relation: " + kb .isRelation (bareTerm ));
250
+ pw .println ("% is inequality: " + Formula .isInequality (bareTerm ));
251
+ pw .println ("% is math: " + Formula .isMathFunction (bareTerm ));
252
+ if (!output .endsWith (Formula .termMentionSuffix ))
253
+ output = output + Formula .termMentionSuffix ;
254
+ }
237
255
output = output + " : $i )." ;
238
256
pw .println (output );
239
257
}
@@ -257,11 +275,16 @@ public int getVariableAritySuffix(String t) {
257
275
*/
258
276
public void writeRelationSort (String t , PrintWriter pw ) {
259
277
260
- if ( debug ) System . out . println ("SUMOKBtoTFAKB.writeRelationSort(): " + t );
278
+ pw . println ("% SUMOKBtoTFAKB.writeRelationSort(): " + t );
261
279
if (t .endsWith ("Fn" ) != kb .isFunction (t ))
262
280
System .out .println ("ERROR in writeRelationSort(): is function mismatch with term name : " + t + ", " + kb .isFunction (t ));
263
- if (Formula .isLogicalOperator (t ) || Formula .isMathFunction (t ))
281
+ if (Formula .isLogicalOperator (t ) || Formula .isMathFunction (t ) || Formula .isComparisonOperator (t )) {
282
+ String label = translateName (t );
283
+ String output = "tff(" + label + ",type," + label +
284
+ " : $i )." ;
285
+ pw .println (output );
264
286
return ;
287
+ }
265
288
List <String > sig = kb .kbCache .signatures .get (t );
266
289
int endIndex = sig .size ();
267
290
if (KButilities .isVariableArity (kb ,SUMOtoTFAform .withoutSuffix (t )))
@@ -289,6 +312,10 @@ public void writeRelationSort(String t, PrintWriter pw) {
289
312
if (sigBuf .length () == 0 ) {
290
313
pw .println ("% Error in SUMOKBtoTFAKB.writeRelationSort(): " + t );
291
314
pw .println ("% Error in SUMOKBtoTFAKB.writeRelationSort(): signature: " + sig );
315
+ String label = translateName (t );
316
+ String output = "tff(" + label + ",type," + label +
317
+ " : $i )." ;
318
+ pw .println (output );
292
319
pw .flush ();
293
320
return ;
294
321
//Thread.dumpStack();
@@ -299,15 +326,15 @@ public void writeRelationSort(String t, PrintWriter pw) {
299
326
relname = relname .substring (0 ,relname .length ()-3 );
300
327
String range = sig .get (0 );
301
328
String label = translateName (t );
302
- if (label .endsWith ("_m" ))
329
+ if (label .endsWith (Formula . termMentionSuffix ))
303
330
label = label .substring (0 ,label .length ()-2 );
304
331
label = label + "_sig_rel" ;
305
332
if (sortLabels .contains (label )) {
306
333
pw .println ("% duplicate label " + label + " for " + relname );
307
334
return ;
308
335
}
309
336
else {
310
- pw .println ("% add label " + label );
337
+ pw .println ("% add label (relation sort) " + label );
311
338
sortLabels .add (label );
312
339
}
313
340
if (kb .isFunction (t )) {
@@ -320,7 +347,7 @@ public void writeRelationSort(String t, PrintWriter pw) {
320
347
" : ( " + sigStr + " ) > $o )." ;
321
348
pw .println (output );
322
349
}
323
- String output = "tff(" + label + "_m ,type," + relname + "_m" +
350
+ String output = "tff(" + label + Formula . termMentionSuffix + " ,type," + relname + Formula . termMentionSuffix +
324
351
" : $i )." ;
325
352
pw .println (output );
326
353
}
@@ -589,16 +616,18 @@ public void writeSorts(PrintWriter pw) {
589
616
handleListFn (toExtend );
590
617
String fnSuffix ;
591
618
for (String t : kb .getTerms ()) {
619
+ String bareTerm = SUMOtoTFAform .getBareTerm (t );
592
620
pw .println ("% SUMOKBtoTFAKB.writeSorts(): " + t );
593
- if (debug ) System .out .println ("SUMOKBtoTFAKB.writeSorts(): " + t );
621
+ if (debug ) System .out .println ("SUMOKBtoTFAKB.writeSorts(): t: " + t );
622
+ if (debug ) System .out .println ("SUMOKBtoTFAKB.writeSorts(): bareTerm: " + bareTerm );
594
623
if (debug ) System .out .println ("kb.isRelation(t) " + kb .isRelation (t ));
595
624
if (debug ) System .out .println ("!alreadyExtended(t): " + !alreadyExtended (t ));
596
625
if (debug ) System .out .println ("!Formula.isComparisonOperator(t)): " + !Formula .isComparisonOperator (t ));
597
626
if (debug ) System .out .println ("!Formula.isMathFunction(t)): " + !Formula .isMathFunction (t ));
598
627
if (!Character .isLetter (t .charAt (0 )) || Formula .isTrueFalse (t ))
599
628
continue ;
600
- if (kb .isFunction (t )) {
601
- if (Formula .isLogicalOperator (t ) || t .equals ("equal" ) ) {
629
+ if (kb .isFunction (bareTerm )) {
630
+ if (Formula .isLogicalOperator (bareTerm ) || t .equals ("equal" ) ) {
602
631
continue ;
603
632
}
604
633
else {
@@ -607,9 +636,9 @@ public void writeSorts(PrintWriter pw) {
607
636
processRelationSort (toExtend , t );
608
637
}
609
638
}
610
- else if (kb .isRelation (t ) && !alreadyExtended (t ) && !t .equals ("ListFn" )
611
- && !Formula .isComparisonOperator (t ) && !Formula .isMathFunction (t )) {
612
- if (hasNumericSuperArg (t ) || listOperator (t )) {
639
+ else if (kb .isRelation (bareTerm ) && !alreadyExtended (t ) && !bareTerm .equals ("ListFn" )
640
+ && !Formula .isComparisonOperator (bareTerm ) && !Formula .isMathFunction (bareTerm )) {
641
+ if (hasNumericSuperArg (bareTerm ) || listOperator (bareTerm )) {
613
642
writeRelationSort (t , pw );
614
643
processRelationSort (toExtend , t );
615
644
}
@@ -623,9 +652,10 @@ else if (kb.isRelation(t) && !alreadyExtended(t) && !t.equals("ListFn")
623
652
String sep , newTerm ;
624
653
pw .println ("% SUMOKBtoTFAKB.writeSorts(): starting on toExtend sorts" );
625
654
for (String k : toExtend .keySet ()) {
626
- vals = toExtend .get (k );
655
+ String bareTerm = SUMOtoTFAform .getBareTerm (k );
656
+ vals = toExtend .get (bareTerm );
627
657
fnSuffix = "" ;
628
- if (kb .isFunction (k ) || k .endsWith ("Fn" )) // variable arity functions with numerical suffixes not in kb yet
658
+ if (kb .isFunction (bareTerm ) || bareTerm .endsWith ("Fn" )) // variable arity functions with numerical suffixes not in kb yet
629
659
fnSuffix = "Fn" ;
630
660
for (String e : vals ) {
631
661
kb .kbCache .extendInstance (k , e + fnSuffix );
0 commit comments