void ProveIt(char *goal_filename, char *rule_filename, char *fact_filename, char *output_filename) { Obj *goal; ObjList *rules; ObjList *facts; Proof *proofs; FILE *outstream; if (NULL == (outstream = StreamOpen(output_filename, "w+"))) { return; } goal = ObjFileRead(goal_filename); if (goal == NULL) { return; } rules = ObjListFileRead(rule_filename); facts = ObjListFileRead(fact_filename); fprintf(outstream, "input goal = "); ObjPrint(outstream, goal); fputc(NEWLINE, outstream); fprintf(outstream, "input rules =\n"); ObjListPrint(outstream, rules); fprintf(outstream, "input facts =\n"); ObjListPrint(outstream, facts); if (Prove1(&TsNA, NULL, goal, rules, facts, 1, 0, &proofs)) { fprintf(outstream, "found proofs:\n"); ProofPrintAll(outstream, proofs); } else { fprintf(outstream, "did not find proofs\n"); } StreamClose(outstream); }
void ContextPrintReasons(FILE *stream, Context *cx) { if (cx->makes_sense_reasons) { fputs("Makes sense because:\n", stream); ObjListPrint(stream, cx->makes_sense_reasons); } if (cx->not_make_sense_reasons) { fputs("Does not make sense because:\n", stream); ObjListPrint(stream, cx->not_make_sense_reasons); } }
Obj *ContextMapAssertion(Context *cx_parent, Context *cx_child, Obj *obj_parent) { ObjList *p; if (obj_parent == NULL) return(NULL); for (p = cx_parent->assertions; p; p = p->next) { if (p->obj == obj_parent) return(p->u.child_copy); } Dbg(DBGGEN, DBGBAD, "ContextMapAssertion failure"); ObjPrint(Log, obj_parent); fprintf(Log, "\nnot in:\n"); ObjListPrint(Log, cx_parent->assertions); Stop(); return(NULL); }