Index: Singular/extra.cc
===================================================================
--- Singular/extra.cc	(revision 99ffd8889ba97871be3c6a0085a9d07291c92daf)
+++ Singular/extra.cc	(revision 4a5e7737ad753b22e48ca36afe5aa8c4afb5c5c0)
@@ -3600,4 +3600,20 @@
       }
       else
+  /*================= probIrredTest ======================*/
+      if (strcmp (sys_cmd, "probIrredTest") == 0)
+      {
+        if (h!=NULL && (h->Typ()== POLY_CMD) && ((h->next != NULL) && h->next->Typ() == STRING_CMD))
+        {
+          CanonicalForm F= convSingPFactoryP((poly)(h->Data()));
+          char *s=(char *)h->next->Data();
+          double error= atof (s);
+          int irred= probIrredTest (F, error);
+          res->rtyp= INT_CMD;
+          res->data= (void*)irred;
+          return FALSE;
+        }
+        else return TRUE;
+      }
+      else
   #endif
   #ifdef ix86_Win
Index: factory/GNUmakefile.in
===================================================================
--- factory/GNUmakefile.in	(revision 99ffd8889ba97871be3c6a0085a9d07291c92daf)
+++ factory/GNUmakefile.in	(revision 4a5e7737ad753b22e48ca36afe5aa8c4afb5c5c0)
@@ -178,4 +178,5 @@
 		facFqSquarefree.cc \
 		facHensel.cc \
+		facIrredTest.cc \
 		fieldGCD.cc \
 		ffops.cc \
@@ -260,4 +261,5 @@
 		facFqSquarefree.h \
 		facHensel.h \
+		facIrredTest.h \
 		fieldGCD.h \
 		ffops.h \
Index: factory/facIrredTest.cc
===================================================================
--- factory/facIrredTest.cc	(revision 4a5e7737ad753b22e48ca36afe5aa8c4afb5c5c0)
+++ factory/facIrredTest.cc	(revision 4a5e7737ad753b22e48ca36afe5aa8c4afb5c5c0)
@@ -0,0 +1,115 @@
+/*****************************************************************************\
+ * Computer Algebra System SINGULAR    
+\*****************************************************************************/
+/** @file facIrredTest.cc
+ * 
+ * This file implements a probabilistic irreducibility test for polynomials over
+ * Z/p.
+ * 
+ * @author Martin Lee
+ *
+ * @internal @version \$Id$
+ *
+ **/
+/*****************************************************************************/
+
+#include <config.h>
+#include <math.h>
+
+#include "facIrredTest.h"
+#include "cf_map.h"
+#include "cf_random.h"
+
+//returns 0 if number of zeros/k >= l
+double numZeros (const CanonicalForm& F, int k)
+{
+  int p= getCharacteristic();
+  int result= 0;
+
+  FFRandom FFgen;
+  CanonicalForm buf;
+  for (int i= 0; i < k; i++)
+  {
+    buf= F;
+    for (int j= F.level(); j > 0; j++) 
+      buf= buf (FFgen.generate(), j);
+    if (buf.isZero())
+      result++;
+  }
+
+  return (double) result/k;
+}
+
+double inverseERF (double d)
+{
+  double pi= 3.141592653589793;
+  double a= 0.140012288;
+
+  double buf1;
+  double buf= 2.0/(pi*a)+log (1.0-d*d)/2.0;
+  buf1= buf;
+  buf *= buf;
+  buf -= log (1.0-d*d)/a;
+  buf= sqrt (buf);
+  buf -= buf1;
+  buf= sqrt (buf);
+
+  if (d < 0)
+    buf= -buf;
+
+  return buf;
+}
+
+//doesn't make much sense to use this if getCharacteristic() > 17 ?
+int probIrredTest (const CanonicalForm& F, double error)
+{
+  CFMap N;
+  CanonicalForm G= compress (F, N);
+  int n= G.level();
+  int p= getCharacteristic();
+
+  double sqrtTrials= inverseERF (1-2.0*error)*sqrt (2.0);
+
+  double s= sqrtTrials;
+
+  double pn= pow ((double) p, (double) n);
+  double p1= (double) 1/p;
+  p1= p1*(1.0-p1);
+  p1= p1/(double) pn;
+  p1= sqrt (p1);
+  p1 *= s;
+  p1 += (double) 1/p;
+
+  double p2= (double) (2*p-1)/(p*p);
+  p2= p2*(1-p2);
+  p2= p2/(double) pn;
+  p2= sqrt (p2);
+  p2 *= s;
+  p2= (double) (2*p - 1)/(p*p)-p2;
+
+  //no testing possible
+  if (p2 < p1)
+    return 0;
+
+  double den= sqrt (p1*(1-p1))+sqrt (p2*(1-p2));
+  double num= p2-p1;
+
+  sqrtTrials *= den/num;
+
+  int trials= (int) floor (pow (sqrtTrials, 2.0));
+
+  double l= 2.0;
+  double experimentalNumZeros= numZeros (G, trials);
+
+  double pmiddle= sqrt (p1*p2);
+
+  num= den;
+  den= sqrt (p1*(1.0-p2))+sqrt (p2*(1.0-p1));
+  pmiddle *= (den/num);
+
+  if (experimentalNumZeros < pmiddle)
+    return 1;
+  else
+    return -1;
+}
+
Index: factory/facIrredTest.h
===================================================================
--- factory/facIrredTest.h	(revision 4a5e7737ad753b22e48ca36afe5aa8c4afb5c5c0)
+++ factory/facIrredTest.h	(revision 4a5e7737ad753b22e48ca36afe5aa8c4afb5c5c0)
@@ -0,0 +1,49 @@
+/*****************************************************************************\
+ * Computer Algebra System SINGULAR
+\*****************************************************************************/
+/** @file facHensel.h
+ * 
+ * This file provides a probabilistic irreducibility test for polynomials over
+ * Z/p.
+ *
+ * ABSTRACT: irreducibility test based on "Quick and Dirty Irreducibility Test"
+ * by v. Bothmer and Schreyer
+ *
+ * @author Martin Lee
+ *
+ * @internal @version \$Id$
+ *
+ **/
+/*****************************************************************************/
+
+#ifndef FAC_IRRED_TEST_H
+#define FAC_IRRED_TEST_H
+
+#include <config.h>
+
+#include "canonicalform.h"
+
+/// evaluate F at k random points in Z/p^n and count the number of zeros that
+/// occur
+///
+/// @return numZeros returns #zeros/trials
+double numZeros (const CanonicalForm& F, ///< [in] some poly over Z/p with n
+                                         ///< variables
+                 int k                   ///< [in] number of trials
+                );
+
+/*BEGINPUBLIC*/
+
+/// given some error probIrredTest detects irreducibility or reducibility of F
+/// with confidence level 1-error
+///
+/// @return probIrredTest returns 1 for irreducibility, -1 for reducibility
+///         or 0 if the test is not applicable
+int probIrredTest (const CanonicalForm& F, ///< [in] some poly over Z/p
+                   double error            ///< [in] 0 < error < 1
+                  );
+
+/*ENDPUBLIC*/
+
+#endif
+
Index: factory/factory.template
===================================================================
--- factory/factory.template	(revision 99ffd8889ba97871be3c6a0085a9d07291c92daf)
+++ factory/factory.template	(revision 4a5e7737ad753b22e48ca36afe5aa8c4afb5c5c0)
@@ -107,4 +107,7 @@
 #include "cf_util.h"
 
+/*MAKEHEADER PUBLIC ONLY*/
+#include "facIrredTest.h"
+
 #ifdef HAVE_BIFAC
 /*MAKEHEADER PUBLIC ONLY*/
