Index: libabac/abac.c
===================================================================
--- libabac/abac.c	(revision 9a0e1c13b5855539c74e98728da35e1d257c8f51)
+++ libabac/abac.c	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -379,8 +379,8 @@
     int size = abac_stack_size(result);
     if (size > 0) {
-        *success = 1;
+       if(!abac_pl_returning_partial(ctx->pl))
+            *success = 1;
+            else *success = 0;
     } else {
-    // XXX NOT SURE YET..
-    // return partial proof
 	*success = 0;
     }
@@ -580,2 +580,9 @@
     return principal;
 }
+
+void abac_context_set_no_partial_proof(abac_context_t *ctx)
+{ abac_pl_set_no_partial(ctx->pl); }
+
+void abac_context_set_want_partial_proof(abac_context_t *ctx)
+{ abac_pl_set_want_partial(ctx->pl); }
+
Index: libabac/abac.h
===================================================================
--- libabac/abac.h	(revision 9a0e1c13b5855539c74e98728da35e1d257c8f51)
+++ libabac/abac.h	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -219,4 +219,6 @@
 void abac_context_load_principals(abac_context_t *ctx, char *path);
 int abac_context_load_attribute_chunk(abac_context_t *ctx, abac_chunk_t cert);
+void abac_context_set_no_partial_proof(abac_context_t *ctx);
+void abac_context_set_want_partial_proof(abac_context_t *ctx);
 
 int file_exist(char *filename);
Index: libabac/abac.hh
===================================================================
--- libabac/abac.hh	(revision 9a0e1c13b5855539c74e98728da35e1d257c8f51)
+++ libabac/abac.hh	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -1221,4 +1221,15 @@
             { abac_context_load_directory(m_ctx, path); }
 /*** 
+f  void set_no_partial_proof()
+      (C:abac_context_set_no_partial_proof)
+   void set_want_partial_proof()
+        enable and disable the partial proof on query proof failure 
+      (C:abac_context_set_want_partial_proof)
+***/
+            void set_no_partial_proof()
+            { abac_context_set_no_partial_proof(m_ctx); }
+            void set_want_partial_proof()
+            { abac_context_set_want_partial_proof(m_ctx); }
+/*** 
 f  std::vector<Attribute> query(char *, char *, bool &)
      the string version is for query that is composed by hand with SHA or
@@ -1234,5 +1245,5 @@
      returns true/false in success
      returns a proof upon success, 
-     partial proof on failure (not implemented yet) 
+             a partial proof on failure by default 
 ***/
             std::vector<Attribute> query(char *role, char *principal, bool &success) {
Index: libabac/abac_aspect.c
===================================================================
--- libabac/abac_aspect.c	(revision 9a0e1c13b5855539c74e98728da35e1d257c8f51)
+++ libabac/abac_aspect.c	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -745,4 +745,11 @@
 }
 
+int abac_aspect_aspect_param_cnt(abac_aspect_t *ptr) {
+    if(ptr->aspect_params) {
+         return abac_param_list_cnt(ptr->aspect_params);
+    }
+    return 0;
+}
+
 char *abac_aspect_aspect_param_string(abac_aspect_t *ptr) {
     assert(ptr != NULL);
Index: libabac/abac_internal.h
===================================================================
--- libabac/abac_internal.h	(revision 9a0e1c13b5855539c74e98728da35e1d257c8f51)
+++ libabac/abac_internal.h	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -30,4 +30,5 @@
 
 abac_aspect_t *abac_aspect_role_principal_new(char *principal_name);
+int abac_aspect_aspect_param_cnt(abac_aspect_t *ptr);
 char *abac_aspect_aspect_param_string(abac_aspect_t *ptr);
 abac_aspect_t *abac_aspect_linking_new(int, char*,char*, char*);
@@ -79,4 +80,5 @@
 char* abac_item_val(abac_item_t *);
 
+int abac_param_list_cnt(abac_param_list_t *ptr);
 char* abac_param_list_string(abac_param_list_t *ptr);
 void abac_param_dump(abac_param_list_t *ptr, char *offset);
Index: libabac/abac_pl_yap.c
===================================================================
--- libabac/abac_pl_yap.c	(revision 9a0e1c13b5855539c74e98728da35e1d257c8f51)
+++ libabac/abac_pl_yap.c	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -31,13 +31,40 @@
 static char *constraint_label="isABAC_constraint";
 
+/*
+x    can pLadybug buy_rockets from pAcme ? (_arg_for_fact)
+x    can pLadybug What from pAcme ? (_arg_for_what)
+x    Who can buy_rockets from pAcme ? (_arg_for_who)
+x    can pLadybug buy_rockets from Whom ? (_arg_for_whom)
+x    can pLadybug What from Whom ? (_arg_for_what_whom)
+the type ordering also dictates the order of partial proof query
+sequence
+*/
+enum _query_type_t {
+   e_PL_FACT=0,
+   e_PL_WHAT=1,
+   e_PL_WHAT_DFLT=2,
+   e_PL_WHO=3,   
+   e_PL_WHOM=4,
+   e_PL_WHAT_WHOM=5,
+   e_PL_NOMORE=6
+};
+
 // pl -- place holder for now 
 struct _abac_pl_t {
    /* a_term <- prin */
-    char *aspect_term;
-    char *prin_term;
+    char *whom;
+    char *who;
+    char *aspect;
+    char *what;
+    char *whatwith;
+    int pcnt; /* pcnt=number of params in whatwith */
+
     int query_made; /* 1+ yes, 0 no, rc is valid only if a query is made */
     int query_rc; /* rc of query call */
     int next_rc; /* rc of next-last query */
       /* proof count = abac_list_size(proof_list) */
+    int is_partial;
+    int want_partial;
+    int query_type;
     abac_list_t *proof_list; /* list of list of cred_list */ 
     long safe_t; /* holding the YAP slot for the goal */
@@ -137,10 +164,17 @@
   
     abac_pl_t *pl = abac_xmalloc(sizeof(abac_pl_t));
-    pl->aspect_term=NULL;
-    pl->prin_term=NULL;
+
+    pl->who=NULL;
+    pl->whom = NULL;
+    pl->what = NULL;
+    pl->whatwith = NULL;
+    pl->aspect = NULL;
+    pl->pcnt=0;
     pl->query_made=0;
     pl->query_rc=0;
+    pl->is_partial=0;
+    pl->want_partial=1;
+    pl->query_type=e_PL_FACT;
     pl->next_rc=0;
-      /* proof count = abac_list_size(proof_list) */
     pl->proof_list=NULL;
     pl->safe_t=0;
@@ -148,4 +182,9 @@
 }
 
+int abac_pl_returning_partial(abac_pl_t *pl)
+{
+    return pl->is_partial;
+}
+
 /* returns the number of solution so far */
 int abac_pl_proof_cnt(abac_pl_t *pl)
@@ -154,4 +193,9 @@
         return abac_list_size(pl->proof_list);
     return 0;
+}
+
+int abac_pl_is_partial(abac_pl_t *pl)
+{
+    return pl->is_partial;
 }
 
@@ -167,4 +211,14 @@
     }
     return 0;
+}
+
+void abac_pl_set_no_partial(abac_pl_t *pl)
+{
+   pl->want_partial=0;
+}
+
+void abac_pl_set_want_partial(abac_pl_t *pl)
+{
+   pl->want_partial=1;
 }
 
@@ -197,6 +251,9 @@
 
 void abac_pl_free(abac_pl_t *pl) {
-    if(pl->aspect_term) free(pl->aspect_term);
-    if(pl->prin_term) free(pl->prin_term);
+    if(pl->who) free(pl->who);
+    if(pl->whom) free(pl->whom);
+    if(pl->what) free(pl->what);
+    if(pl->whatwith) free(pl->whatwith);
+    if(pl->aspect) free(pl->aspect);
     _free_pf_list(pl->proof_list);
     free(pl);
@@ -204,5 +261,6 @@
 
 /* this is done whenever a new query starts in */
-static void _reset_pl(abac_pl_t *pl, char *aspect_term, char *prin_term)
+static void _reset_pl(abac_pl_t *pl, char *who,
+char *what, char *whom, char *aspect, char *whatwith, int pcnt)
 {
     if(pl->safe_t) {
@@ -211,15 +269,26 @@
     }
     /* free the old ones */
-    if(pl->aspect_term) free(pl->aspect_term);
-    if(pl->prin_term) free(pl->prin_term);
-    pl->aspect_term = abac_xstrdup(aspect_term);
-    pl->prin_term = abac_xstrdup(prin_term);
+    if(pl->who) free(pl->who);
+    if(pl->whom) free(pl->whom);
+    if(pl->what) free(pl->what);
+    if(pl->whatwith) free(pl->whatwith);
+    if(pl->aspect) free(pl->aspect);
+
+    pl->who = (who !=NULL)?abac_xstrdup(who):NULL;
+    pl->whom = (whom !=NULL)?abac_xstrdup(whom):NULL;
+    pl->what = (what!=NULL)?abac_xstrdup(what):NULL;
+    pl->whatwith = (whatwith!=NULL)?abac_xstrdup(whatwith):NULL;
+    pl->aspect = (aspect!=NULL)?abac_xstrdup(aspect):NULL;
+
+    pl->pcnt=pcnt;
+
     pl->query_made=0;
     pl->query_rc=0;
     pl->next_rc=0;
+    pl->is_partial=0;
+    pl->query_type=e_PL_FACT;
     _free_pf_list(pl->proof_list);
     pl->proof_list=abac_list_new();
     pl->safe_t=0;
-    
 }
 
@@ -354,29 +423,7 @@
 }
 
-/* make a query and extract just first set of result */
-static abac_list_t *_make_yap_query(abac_pl_t *pl, char *prin, char *nm, char* estring)
-{
-    YAP_Term eterm0;
-    YAP_Term eterm1;
-    YAP_Term arg[3];
-
-    abac_list_t *cred_list = abac_list_new();
-
-    if(debug) { 
-       fprintf(stderr," the principal part(%s)\n", prin);
-       fprintf(stderr," the role/oset part(%s)\n", estring);
-       fprintf(stderr," nm part(%s)\n", nm);
-    } 
-    if(prin[0]=='\'' || prin[0]=='"') {
-        arg[0]=YAP_ReadBuffer(prin,&eterm0);
-        } else {
-            arg[0]=YAP_MkAtomTerm(YAP_LookupAtom(prin)); 
-    }
-    if(debug) fprintf(stderr," the role/oset part(%s)\n", estring);
-    arg[1]=YAP_ReadBuffer(estring,&eterm1);
-
-    /* var for credential list */
-    arg[2]=YAP_MkVarTerm();
-
+abac_list_t *run_goal(abac_pl_t *pl, YAP_Term *arg)
+{
+    abac_list_t *cred_list=abac_list_new();
     YAP_Atom f = YAP_LookupAtom("isMember");
     YAP_Functor func = YAP_MkFunctor(f, 3);
@@ -388,5 +435,7 @@
     pl->next_rc=pl->query_rc;
     if (pl->query_rc) {
-        printf("YAP query succeed\n");
+        if(pl->is_partial) 
+            printf("A partial proof(type:%d)\n",pl->query_type);
+            else printf("YAP query succeed\n");
         char *tmp=NULL;
         int tmp_sz=try_again(0, &tmp);
@@ -421,8 +470,251 @@
         YAP_FreeSpaceFromYap(tmp);
     } else {
-        printf("YAP query failed\n");
-        /* YAP_Exit(1); */
+        /* don't print anything if it is running a parital proof goal */
+        if(!pl->is_partial) 
+            printf("YAP query failed\n");
+  
     }
     return cred_list;
+}
+
+/*************************************************************************/
+YAP_Term _make_term(char *term) {
+    YAP_Term eterm;
+    YAP_Term ret;
+    if(term[0]=='\'' || term[0]=='"') {
+        ret =YAP_ReadBuffer(term,&eterm);
+        } else {
+            ret = YAP_MkAtomTerm(YAP_LookupAtom(term));
+    }
+}
+
+// isMember(who,aspect(whom,what,whatwith)) 
+/* aspect(whom, what, whatwith) */
+YAP_Term _aspect_base(char *whom,char *aspect, char *what, char *whatwith)
+{
+    YAP_Term eterm;
+    YAP_Term ret;
+
+    char *estring=NULL;
+    if(whatwith)
+       asprintf(&estring, "%s(%s,%s,%s)",aspect,whom,what,whatwith);
+       else asprintf(&estring, "%s(%s,%s)",aspect,whom,what);
+    if(debug) fprintf(stderr,"_aspect_base, doing %s\n",estring);
+    ret=YAP_ReadBuffer(estring,&eterm);
+    free(estring);
+    return ret;
+}
+
+/* generate a string of whatwith that are of ?variable */
+char *_make_whatwith_var(char *whatwith, int pcnt)
+{
+/* this is a dumb count since it is in porting directory */
+   if(whatwith==NULL || pcnt==0) return NULL;  
+   char *tmp=NULL;
+   char *ptr=NULL;
+   int i;
+   for(i=0;i<pcnt;i++) {
+       ptr=tmp;
+       tmp=NULL;
+       if(i == 0)
+           asprintf(&tmp,"Whatwith%d",i);
+           else asprintf(&tmp,"%s,Whatwith%d",ptr,i);
+   }
+   return tmp;
+}
+
+/* aspect(X, Y, Whatwith) */
+YAP_Term _aspect_what_whom(char *whom,char *aspect, char *what, char *whatwith)
+{
+    YAP_Term ret=_aspect_base("Whom",aspect,"What",whatwith);
+    return ret;
+}
+
+/* aspect(whom,Y,Whatwith) */
+/* call with char *tmp=_make_whatwith_var(whatwith); */
+YAP_Term _aspect_what(char *whom,char *aspect, char *what, char *whatwith)
+{
+    YAP_Term ret=_aspect_base(whom,aspect,"What",whatwith);
+    return ret;
+}
+
+/* aspect(X,what,whatwith) */
+YAP_Term _aspect_whom(char *whom,char *aspect, char *what, char *whatwith)
+{
+    YAP_Term ret=_aspect_base("Whom",aspect,what,whatwith);
+    return ret;
+}
+
+/* aspect(whom,what,whatwith) */
+YAP_Term _aspect_fact(char *whom,char *aspect, char *what, char* whatwith)
+{
+    YAP_Term ret=_aspect_base(whom,aspect,what,whatwith);
+    return ret;
+}
+
+// Whom.What <- ladybug
+// isMember(ladybug, role(W1, W2), R)
+static void _arg_for_what_whom(YAP_Term *arg,char *who, char *whom,
+char *aspect, char*what, char *whatwith, int pcnt)
+{
+    arg[0] = _make_term(who);
+    char *tmp=_make_whatwith_var(whatwith,pcnt); 
+    arg[1] = _aspect_what_whom(who,aspect,what,tmp);
+    if(tmp) free(tmp);
+    arg[2] = YAP_MkVarTerm();
+}
+
+// pAcme.What <- ladybug
+// isMember(ladybug, role(pAcme, W), R)
+static void _arg_for_what(YAP_Term *arg,char *who, char* whom, 
+char *aspect, char*what, char*whatwith, int pcnt)
+{
+    arg[0] = _make_term(who);
+    char *tmp=_make_whatwith_var(whatwith,pcnt); 
+    arg[1] = _aspect_what(whom,aspect,what,tmp);
+    if(tmp) free(tmp);
+    arg[2] = YAP_MkVarTerm();
+}
+
+// W.rocket <- ladybug
+// isMember(ladybug, role(W, buy_rockets), R)
+static void _arg_for_whom(YAP_Term *arg, char *who, char*whom,
+char *aspect, char *what, char*whatwith)
+{
+    arg[0] = _make_term(who);
+    arg[1] = _aspect_whom(whom,aspect,what,whatwith);
+    arg[2] = YAP_MkVarTerm();
+}
+
+// Acme.rocket <- V
+// isMember(V, role(pAcme, buy_rockets), R)
+static int _arg_for_who(YAP_Term *arg, char *who,char *whom, 
+char *aspect, char* what, char*whatwith)
+{
+    arg[0] = YAP_MkVarTerm();
+    arg[1] = _aspect_fact(whom, aspect, what, whatwith);
+    arg[2] = YAP_MkVarTerm();
+}
+
+// Acme.rocket <- x 
+// isMember(x, role(pAcme, buy_rockets), R)
+static void _arg_for_fact(YAP_Term *arg,char *who,char *whom, 
+char* aspect, char *what, char*whatwith)
+{
+    arg[0] = _make_term(who);
+    arg[1] = _aspect_fact(whom, aspect, what, whatwith);
+    arg[2] = YAP_MkVarTerm();
+}
+
+
+static abac_list_t *_make_partial_query(abac_pl_t *pl)
+{
+    abac_list_t *ret=abac_list_new();
+    pl->is_partial=1;
+    char *who=pl->who;
+    char *whom=pl->whom;
+    char *aspect=pl->aspect;
+    char *what=pl->what;
+    char *whatwith=pl->whatwith;
+    int pcnt=pl->pcnt;
+    if(debug) fprintf(stderr,"making make_partial_query..\n");
+
+    switch (pl->query_type) { 
+        case e_PL_FACT: /* try what */
+            {
+            YAP_Term arg[3];
+            if(debug) fprintf(stderr,"... 1st partial attempt\n");
+            pl->query_type = e_PL_WHAT;
+            _arg_for_what(arg,who,whom, aspect, what, whatwith, pcnt);
+            ret=run_goal(pl,arg);
+            if(pcnt==0) pl->query_type= e_PL_WHAT_DFLT;
+            if(pl->query_rc) return ret;
+            break;
+            }
+        case e_PL_WHAT: /* try what with no params if need to */
+            {
+            YAP_Term arg[3];
+            if(debug) fprintf(stderr,"... 2nd partial attempt\n");
+            pl->query_type = e_PL_WHAT_DFLT;
+            _arg_for_what(arg,who,whom, aspect, what, whatwith, 0);
+            ret=run_goal(pl,arg);
+            if(pl->query_rc) return ret;
+            break;
+            }
+        case e_PL_WHAT_DFLT: /* try who */
+            {
+            YAP_Term arg[3];
+            if(debug) fprintf(stderr,"... 2nd half partial attempt\n");
+            pl->query_type = e_PL_WHO;
+            _arg_for_who(arg,who,whom, aspect, what, whatwith);
+            ret=run_goal(pl,arg);
+            if(pl->query_rc) return ret;
+            break;
+            }
+        case e_PL_WHO: /* try whom */
+            {
+            YAP_Term arg[3];
+            if(debug) fprintf(stderr,"... 3rd partial attempt\n");
+            pl->query_type = e_PL_WHOM;
+            _arg_for_whom(arg,who,whom, aspect, what, whatwith);
+            ret=run_goal(pl,arg);
+            if(pl->query_rc) return ret;
+            break;
+            }
+        case e_PL_WHOM: /* try what-whom */
+            {
+            YAP_Term arg[3];
+            if(debug) fprintf(stderr,"... 4th partial attempt\n");
+            pl->query_type = e_PL_WHAT_WHOM;
+            _arg_for_what_whom(arg,who,whom, aspect, what, whatwith,pcnt);
+            ret=run_goal(pl,arg);
+            if(pl->query_rc) return ret;
+            break;
+            }
+        default :
+            {
+            if(debug) fprintf(stderr,"... no more partial query to try\n");
+            pl->query_type = e_PL_NOMORE;
+            }
+    }
+    return ret;
+}
+
+/* make a query and extract just first set of result,
+   simple = rt0
+   aspect => role/oset
+   aspect_string => rest of params
+   prin => principal
+   issuer => issuer
+   estring =>  aspect(issuer, aspect_type_string) 
+*/
+static abac_list_t *_make_yap_query(abac_pl_t *pl, char *who,
+char *whom, char *aspect, char *what, char *whatwith, int pcnt)
+{
+    if(debug) { 
+       fprintf(stderr,"_make_yap_query: the who part(%s)\n", who);
+       fprintf(stderr,"_make_yap_query: whom part(%s)\n", whom);
+       fprintf(stderr,"_make_yap_query: the role/oset (%s)\n", aspect);
+       fprintf(stderr,"_make_yap_query: aspect what (%s)\n", what);
+       fprintf(stderr,"_make_yap_query: pcnt (%d)\n", pcnt);
+       if(whatwith)
+           fprintf(stderr,"_make_yap_query: aspect what part(%s)\n", whatwith);
+    } 
+    if(debug) fprintf(stderr,"making a yap query..\n");
+
+/* run query on fact goal */
+    YAP_Term arg[3];
+    _arg_for_fact(arg, who,whom, aspect, what, whatwith);
+    abac_list_t *ret=run_goal(pl,arg);
+
+/* fact query failed and so run partial query */
+    if(!pl->query_rc && pl->want_partial) {
+        while(pl->query_type != e_PL_NOMORE) {
+            abac_list_free(ret);
+            ret=_make_partial_query(pl);
+            if( pl->query_rc ) break;
+        }
+    }
+    return ret;
 }
 
@@ -432,7 +724,7 @@
     abac_list_t *cred_list=abac_list_new();
 
+    if(debug) fprintf(stderr,"making query_again call..\n");
     pl->next_rc=YAP_RestartGoal();
     pl->query_made++;
-    if(debug) fprintf(stderr,"query_again: another success\n");
 
     char *tmp=NULL;
@@ -440,4 +732,7 @@
     YAP_Term argterm=YAP_ArgOfTerm(3,YAP_GetFromSlot(pl->safe_t));
     if(pl->next_rc) {
+        if(debug) fprintf(stderr,"query_again: another success\n");
+        if(pl->is_partial)
+            printf("A partial proof(type:%d)\n",pl->query_type);
         while(1) {
             YAP_WriteBuffer(argterm, tmp, tmp_sz,YAP_WRITE_HANDLE_VARS);
@@ -459,4 +754,13 @@
         abac_list_add(pl->proof_list, cred_list);
         YAP_FreeSpaceFromYap(tmp);
+        } else {
+            if(debug) fprintf(stderr,"query_again: fail finding next\n");
+            if(pl->is_partial) { /* if there is more partial query to make */
+                while(pl->query_type != e_PL_NOMORE) {
+                    abac_list_free(cred_list);
+                    cred_list=_make_partial_query(pl);
+                    if( pl->query_rc ) break;
+                }
+            }
     }
     return cred_list;
@@ -496,13 +800,13 @@
         show_yap_db("DEBUG:calling within _query_with_aspect");
 
-    char *nm;
-    PROLOG(nm=abac_aspect_principal_name(head););
+    char *whom=NULL;
+    PROLOG(whom=abac_aspect_principal_name(head););
 
     /* could be obj or principal */
-    char *prin_nm=NULL;
+    char *who=NULL;
     if(abac_aspect_is_object(tail)) {
-        prin_nm=abac_aspect_object_name(tail);
+        who=abac_aspect_object_name(tail);
         } else {
-            PROLOG(prin_nm=abac_aspect_principal_name(tail););
+            PROLOG(who=abac_aspect_principal_name(tail););
     }
 
@@ -512,5 +816,5 @@
     }
 
-    if (prin_nm == NULL || nm == NULL) {
+    if (who == NULL || whom == NULL) {
         printf("fail, query's call got bad aspect names .. \n");
         YAP_Exit(1);
@@ -522,16 +826,20 @@
     PROLOG(pstring=abac_aspect_aspect_param_string(head););
 
-    char *stub=abac_aspect_type_string(head);
-    if(pstring) {
-        asprintf(&tmp,"%s(%s,%s,%s)", stub, nm, abac_aspect_aspect_name(head),pstring);
-        free(pstring);
-        } else {
-            asprintf(&tmp,"%s(%s,%s)", stub, nm, abac_aspect_aspect_name(head));
-    }
-
-    _reset_pl(pl,tmp,prin_nm);
-    abac_list_t *rlist=_make_yap_query(pl,prin_nm,nm,tmp);
+    char *aspect=abac_aspect_type_string(head);
+    int pcnt=abac_aspect_aspect_param_cnt(head);
+    char *what=abac_aspect_aspect_name(head);
+
+    _reset_pl(pl, who, what, whom, aspect, pstring, pcnt);
+
+    abac_list_t *rlist=NULL;
+    if(pcnt)
+        rlist=_make_yap_query(pl,who,whom,aspect,abac_aspect_aspect_name(head),pstring,pcnt);
+        else
+            rlist=_make_yap_query(pl,who,whom,aspect,abac_aspect_aspect_name(head),NULL,0);
+
     /* generate the resulting stack from a list */
     ret=_make_cred_stack(rlist);
+    if(tmp) free(tmp);
+    if(pstring) free(pstring);
     return ret;
 }
Index: libabac/abac_pl_yap.h
===================================================================
--- libabac/abac_pl_yap.h	(revision 9a0e1c13b5855539c74e98728da35e1d257c8f51)
+++ libabac/abac_pl_yap.h	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -19,4 +19,7 @@
 abac_stack_t *abac_pl_query_again(abac_pl_t *pl);
 abac_stack_t *abac_pl_query_with_structure(abac_pl_t *pl, abac_aspect_t *head_aspect, abac_aspect_t *tail_aspect);
+void abac_pl_set_no_partial(abac_pl_t *pl);
+void abac_pl_set_want_partial(abac_pl_t *pl);
+int abac_pl_returning_partial(abac_pl_t *pl);
 
 /* return a list of all credentials in the pl file */
Index: libabac/abac_term.c
===================================================================
--- libabac/abac_term.c	(revision 9a0e1c13b5855539c74e98728da35e1d257c8f51)
+++ libabac/abac_term.c	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -871,4 +871,11 @@
 
 /********************************************************************/
+int abac_param_list_cnt(abac_param_list_t *ptr)
+{
+   assert(ptr);
+   int cnt=abac_list_size(ptr->list);
+   return cnt;
+}
+
 abac_list_t *abac_param_list(abac_param_list_t *ptr)
 {
Index: libabac/abac_util.c
===================================================================
--- libabac/abac_util.c	(revision 9a0e1c13b5855539c74e98728da35e1d257c8f51)
+++ libabac/abac_util.c	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -28,5 +28,5 @@
 
 #define SHA1_LENGTH 40
-#define ABAC_VERSION "0.2.2"
+#define ABAC_VERSION "0.2.3"
 
 char *abac_version()
Index: libabac/prover_yap.c
===================================================================
--- libabac/prover_yap.c	(revision 9a0e1c13b5855539c74e98728da35e1d257c8f51)
+++ libabac/prover_yap.c	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -22,4 +22,5 @@
     abac_context_t *ctx = abac_context_new();
     abac_context_load_directory(ctx, opts.keystore);
+    abac_context_set_no_partial_proof(ctx);
 
     if(opts.filename) { 
@@ -79,5 +80,6 @@
         else puts("prover failed!!");
 
-    if (credentials != NULL && success) {
+    /* if returning partial, success=0, and credential is not NULL */
+    if (credentials != NULL && credentials[0] != NULL) {
         puts("credentials needed :");
         for (i = 0; credentials[i] != NULL; ++i) {
@@ -89,5 +91,5 @@
         abac_context_credentials_free(credentials);
 
-/** limit at most 2 more solution proof **/
+/** limit at most 2 more fact solution proof **/
     if(success && opts.all) {
         int n=2;
