diff -rubB R8/Src/c4.5rules.c R8p/Src/c4.5rules.c
--- R8/Src/c4.5rules.c	Mon Oct  9 19:19:51 1995
+++ R8p/Src/c4.5rules.c	Mon Oct  2 16:38:16 2000
@@ -4,8 +4,8 @@
 /*  -----------------------------------------------------------------	 */
 /*									 */
 /*************************************************************************/
+/* Prolog output by Kamran Karimi karimi@cs.uregina.ca */
 
-
 #include "defns.i"
 #include "types.i"
 
@@ -31,6 +31,9 @@
 short		VERBOSITY = 0,
 		TRIALS;
 
+Boolean		PROLOG	  = false,
+		PROLOG_CV = false;
+
 Boolean		UNSEENS	  = false,
 		SIGTEST	  = false,	/* use significance test in rule pruning */
 		SIMANNEAL = false;	/* use simulated annealing */
@@ -71,7 +74,7 @@
 
     /*  Process options  */
 
-    while ( (o = getopt(Argc, Argv, "f:uv:c:r:F:a")) != EOF )
+    while ( (o = getopt(Argc, Argv, "f:uv:c:r:F:ap:")) != EOF )
     {
 	if ( FirstTime )
 	{
@@ -108,6 +111,18 @@
 			break;
 	    case 'a':	SIMANNEAL = true;
 			printf("\tSimulated annealing for selecting rules\n");
+			break;
+	    case 'p':	if(atoi(optarg) == 0)
+	 		{
+				PROLOG = true;
+	    			printf("\tProlog output.\n");
+	 		}
+	 		else if(atoi(optarg) == 1)
+	 		{
+	 			PROLOG = true;
+	    			PROLOG_CV = true;
+	    			printf("\tProlog output with confidence value.\n");
+	    		}
 			break;
 	    case '?':	printf("unrecognised option\n");
 			exit(1);
diff -rubB R8/Src/genrules.c R8p/Src/genrules.c
--- R8/Src/genrules.c	Mon Jul 19 04:48:59 1999
+++ R8p/Src/genrules.c	Thu Apr  6 02:11:36 2000
@@ -54,6 +54,8 @@
 
 	printf("\nFinal rules from tree %d:\n", t);
 	PrintIndexedRules();
+	
+	if(PROLOG) PrintIndexedPrologRules();
 	    
 	/*  Make sure there is enough room for the new ruleset  */
 
diff -rubB R8/Src/rules.c R8p/Src/rules.c
--- R8/Src/rules.c	Thu Feb 29 00:30:09 1996
+++ R8p/Src/rules.c	Thu Oct 12 16:05:34 2000
@@ -394,6 +393,157 @@
 	PrintRule(RuleIndex[ri]);
     }
     printf("\nDefault class: %s\n", ClassName[DefaultClass]);
+}
+
+
+    PrintIndexedPrologRules()
+{
+    short ri;
+    char PFn[500];	/* Prolog output name */
+    FILE *Pf;
+    
+    strcpy(PFn, FileName);
+    strcat(PFn, ".pl");
+    if ( ! ( Pf = fopen(PFn, "w") ) ) Error(0, PFn, " for writing");
+
+    fprintf(Pf,":- op(800, xfx, ule).\n");
+    fprintf(Pf,":- op(800, xfx, ug).\n\n");
+    
+    ForEach(ri, 1, NRules )
+    {
+	PrintPrologRule(RuleIndex[ri], Pf);
+    }
+    fprintf(Pf, "\nclass(%c%s).\n\n", tolower(ClassName[DefaultClass][0]),
+    					&ClassName[DefaultClass][1]);
+
+    /* The following helper functions might be needed */
+    fprintf(Pf, "\n/* ule unifies the left hand side or performs =< */\n");
+    fprintf(Pf, "A ule B :- var(A), A = B.\n");
+    fprintf(Pf, "A ule B :- A =< B.\n");
+
+    fprintf(Pf, "\n/* ug unifies the left hand side or performs > */\n");
+    fprintf(Pf, "A ug B :- var(A), A is B + 1.\n");
+    fprintf(Pf, "A ug B :- A > B.\n");
+
+    fprintf(Pf, "\n/* umember unifies a variable, or performs member() */\n");
+    fprintf(Pf, "umember(A, B) :- var(A), [X|_] = B, A = X.\n");
+    fprintf(Pf, "umember(A, B) :- member(A, B).\n");   
+    fprintf(Pf, "\nmember(A, [A|_]).\n");
+    fprintf(Pf, "member(A, [_|B]) :- member(A, B).\n");
+   
+    if(PROLOG_CV)
+    {
+	    fprintf(Pf, "\n/*random() is used to implement the error values*/\n");
+	    fprintf(Pf, "seed(13).\n");
+	    fprintf(Pf, "random(R, N) :- seed(S), N is (S mod R), retract(seed(S)),\n\
+\t NewSeed is (125 * S + 1) mod 4096, asserta(seed(NewSeed)), !.\n");
+    }
+}
+
+    PrintPrologRule(r, Pf)
+/*  ---------  */
+    RuleNo r;
+    FILE *Pf;
+{
+    short d;
+    Test tp;
+    Attribute Att;
+
+    fprintf(Pf, "class(");
+    ForEach(d, 0, MaxAtt)
+	fprintf(Pf, "%c%s, ", toupper(AttName[d][0]), &AttName[d][1]);
+
+    fprintf(Pf, "%c%s) :- ", tolower(ClassName[Rule[r].Rhs][0]),
+    			&ClassName[Rule[r].Rhs][1]);
+    if(PROLOG_CV)
+	fprintf(Pf, "random(1000, N__), N__ < %3d", (int)(1000 * (1 - Rule[r].Error)));
+
+    ForEach(d, 1, Rule[r].Size)
+    {
+        if(PROLOG_CV)
+        	fprintf(Pf, ", ");
+        PrintPrologCondition(Rule[r].Lhs[d], Pf);
+        if(!PROLOG_CV)
+        	if(d < Rule[r].Size) fprintf(Pf, ", ");
+    }
+    fprintf(Pf, ".\n");
+}
+
+    PrintPrologCondition(c, Pf)
+/*  --------------  */
+    Condition c;
+    FILE *Pf;
+{
+    Test tp;
+    DiscrValue v, pv, Last, Values=0;
+    Boolean First=true;
+    Attribute Att;
+
+    tp = c->CondTest;
+    v = c->TestValue;
+    Att = tp->Tested;
+
+    if ( v < 0 )
+    {
+/*	fprintf(Pf, "%s", toupper(AttName[Att]);
+	printf(Pf, " is unknown\n");
+*/	return;
+    }
+
+    switch ( tp->NodeType )
+    {
+	case BrDiscr:
+	    fprintf(Pf, "%c%s", toupper(AttName[Att][0]), &AttName[Att][1]);
+	    fprintf(Pf, " = %c%s", tolower(AttValName[Att][v][0]), &AttValName[Att][v][1]);
+	    break;
+
+	case ThreshContin:
+	    fprintf(Pf, "%c%s", toupper(AttName[Att][0]), &AttName[Att][1]);	
+	    fprintf(Pf, " %s %g", ( v == 1 ? "ule" : "ug" ), tp->Cut);
+	    break;
+
+	case BrSubset:
+	    /*  Count values at this branch  */
+
+	    for ( pv=1 ; Values <= 1 && pv <= MaxAttVal[Att] ; pv++ )
+	    {
+		if ( In(pv, tp->Subset[v]) )
+		{
+		    Last = pv;
+		    Values++;
+		}
+	    }
+
+	    if ( Values == 1 )
+	    {
+		fprintf(Pf, "%c%s", toupper(AttName[Att][0]), &AttName[Att][1]);	
+		fprintf(Pf, " = %c%s", tolower(AttValName[Att][Last][0]),
+					&AttValName[Att][Last][1]);
+		break;
+	    }
+
+	    fprintf(Pf, "umember(");
+	    fprintf(Pf, "%c%s, ", toupper(AttName[Att][0]), &AttName[Att][1]);	
+	    
+	    ForEach(pv, 1, MaxAttVal[Att])
+	    {
+		if ( In(pv, tp->Subset[v]) )
+		{
+		    if ( First )
+		    {
+			fprintf(Pf, "[");
+			First = false;
+		    }
+		    else
+		    {
+			fprintf(Pf, ", ");
+		    }
+		    fprintf(Pf, "%c%s", tolower(AttValName[Att][pv][0]),
+		    				&AttValName[Att][pv][1]);
+		}
+	    }
+	    fprintf(Pf, "]");
+    }
 }
 
 
diff -rubB R8/Src/rulex.i R8p/Src/rulex.i
--- R8/Src/rulex.i	Mon Oct  9 19:19:52 1995
+++ R8p/Src/rulex.i	Mon Oct  2 16:31:20 2000
@@ -20,6 +20,8 @@
 extern Boolean	SIGTEST,	/* use Fisher's test in rule pruning */
 		SIMANNEAL;	/* use simulated annealing */
 
+extern Boolean 	PROLOG, PROLOG_CV;	/* Output the rules in Prolog form */
+
 extern float	SIGTHRESH,	/* sig level used in rule pruning */
 		REDUNDANCY,	/* factor governing encoding tradeoff
 				   between rules and exceptions */
