- Improved pruning.
This commit is contained in:
parent
0f75efc787
commit
c95630f93b
@ -25,6 +25,7 @@ extern Term CLAIM_Secret;
|
|||||||
extern Term CLAIM_Nisynch;
|
extern Term CLAIM_Nisynch;
|
||||||
extern Term CLAIM_Niagree;
|
extern Term CLAIM_Niagree;
|
||||||
extern Term TERM_Agent;
|
extern Term TERM_Agent;
|
||||||
|
extern Term TERM_Hidden;
|
||||||
|
|
||||||
static System sys;
|
static System sys;
|
||||||
Protocol INTRUDER; // Pointers, to be set by the Init
|
Protocol INTRUDER; // Pointers, to be set by the Init
|
||||||
@ -303,8 +304,7 @@ iterate_role_sends (int (*func) ())
|
|||||||
*@param subterm determines whether it is a subterm unification or not.
|
*@param subterm determines whether it is a subterm unification or not.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
bind_existing_to_goal (const Binding b, const int index, const int run,
|
bind_existing_to_goal (const Binding b, const int run, const int index)
|
||||||
const int subterm)
|
|
||||||
{
|
{
|
||||||
Roledef rd;
|
Roledef rd;
|
||||||
int flag;
|
int flag;
|
||||||
@ -395,7 +395,7 @@ bind_existing_to_goal (const Binding b, const int index, const int run,
|
|||||||
//! Bind a goal to an existing regular run, if possible
|
//! Bind a goal to an existing regular run, if possible
|
||||||
int
|
int
|
||||||
bind_existing_run (const Binding b, const Protocol p, const Role r,
|
bind_existing_run (const Binding b, const Protocol p, const Role r,
|
||||||
const int index, const int subterm)
|
const int index)
|
||||||
{
|
{
|
||||||
int run, flag;
|
int run, flag;
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ bind_existing_run (const Binding b, const Protocol p, const Role r,
|
|||||||
termPrint (p->nameterm);
|
termPrint (p->nameterm);
|
||||||
eprintf (", ");
|
eprintf (", ");
|
||||||
termPrint (r->nameterm);
|
termPrint (r->nameterm);
|
||||||
eprintf (" (%i)\n", subterm);
|
eprintf ("\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
flag = 1;
|
flag = 1;
|
||||||
@ -417,7 +417,7 @@ bind_existing_run (const Binding b, const Protocol p, const Role r,
|
|||||||
{
|
{
|
||||||
if (sys->runs[run].protocol == p && sys->runs[run].role == r)
|
if (sys->runs[run].protocol == p && sys->runs[run].role == r)
|
||||||
{
|
{
|
||||||
flag = flag && bind_existing_to_goal (b, index, run, subterm);
|
flag = flag && bind_existing_to_goal (b, run, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
@ -426,7 +426,7 @@ bind_existing_run (const Binding b, const Protocol p, const Role r,
|
|||||||
//! Bind a goal to a new run
|
//! Bind a goal to a new run
|
||||||
int
|
int
|
||||||
bind_new_run (const Binding b, const Protocol p, const Role r,
|
bind_new_run (const Binding b, const Protocol p, const Role r,
|
||||||
const int index, const int subterm)
|
const int index)
|
||||||
{
|
{
|
||||||
int run;
|
int run;
|
||||||
int flag;
|
int flag;
|
||||||
@ -445,10 +445,10 @@ bind_new_run (const Binding b, const Protocol p, const Role r,
|
|||||||
termPrint (p->nameterm);
|
termPrint (p->nameterm);
|
||||||
eprintf (", ");
|
eprintf (", ");
|
||||||
termPrint (r->nameterm);
|
termPrint (r->nameterm);
|
||||||
eprintf (", run %i (subterm:%i)\n", run, subterm);
|
eprintf (", run %i\n", run);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
flag = bind_existing_to_goal (b, index, run, 1);
|
flag = bind_existing_to_goal (b, run, index);
|
||||||
remove_read_goals (newgoals);
|
remove_read_goals (newgoals);
|
||||||
roleInstanceDestroy (sys);
|
roleInstanceDestroy (sys);
|
||||||
return flag;
|
return flag;
|
||||||
@ -548,7 +548,9 @@ select_goal ()
|
|||||||
if (!b->done)
|
if (!b->done)
|
||||||
{
|
{
|
||||||
// We don't care about singular agent variables, so...
|
// We don't care about singular agent variables, so...
|
||||||
if (! (isTermVariable (b->term) && inTermlist (b->term->stype, TERM_Agent)))
|
if (!
|
||||||
|
(isTermVariable (b->term)
|
||||||
|
&& inTermlist (b->term->stype, TERM_Agent)))
|
||||||
{
|
{
|
||||||
float cons;
|
float cons;
|
||||||
|
|
||||||
@ -747,9 +749,9 @@ bind_goal_regular_run (const Binding b)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Bind to existing run
|
// Bind to existing run
|
||||||
flag = bind_existing_run (b, p, r, index, 1);
|
flag = bind_existing_run (b, p, r, index);
|
||||||
// bind to new run
|
// bind to new run
|
||||||
flag = flag && bind_new_run (b, p, r, index, 1);
|
flag = flag && bind_new_run (b, p, r, index);
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -772,7 +774,8 @@ bind_goal_regular_run (const Binding b)
|
|||||||
|
|
||||||
|
|
||||||
// Bind to all possible sends of intruder runs
|
// Bind to all possible sends of intruder runs
|
||||||
int bind_goal_old_intruder_run (Binding b)
|
int
|
||||||
|
bind_goal_old_intruder_run (Binding b)
|
||||||
{
|
{
|
||||||
int run;
|
int run;
|
||||||
int flag;
|
int flag;
|
||||||
@ -781,7 +784,7 @@ int bind_goal_old_intruder_run (Binding b)
|
|||||||
if (DEBUGL (5))
|
if (DEBUGL (5))
|
||||||
{
|
{
|
||||||
indentPrint ();
|
indentPrint ();
|
||||||
eprintf ("Try regular intruder send.\n");
|
eprintf ("Try existing intruder send.\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -799,7 +802,7 @@ int bind_goal_old_intruder_run (Binding b)
|
|||||||
{
|
{
|
||||||
if (rd->type == SEND)
|
if (rd->type == SEND)
|
||||||
{
|
{
|
||||||
flag = flag && bind_existing_to_goal (b, ev, run, 1);
|
flag = flag && bind_existing_to_goal (b, run, ev);
|
||||||
}
|
}
|
||||||
rd = rd->next;
|
rd = rd->next;
|
||||||
ev++;
|
ev++;
|
||||||
@ -836,6 +839,7 @@ int
|
|||||||
prune ()
|
prune ()
|
||||||
{
|
{
|
||||||
Termlist tl;
|
Termlist tl;
|
||||||
|
List bl;
|
||||||
|
|
||||||
if (indentDepth > 20)
|
if (indentDepth > 20)
|
||||||
{
|
{
|
||||||
@ -919,6 +923,21 @@ prune ()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for "Hidden" interm goals
|
||||||
|
bl = sys->bindings;
|
||||||
|
while (bl != NULL)
|
||||||
|
{
|
||||||
|
Binding b;
|
||||||
|
|
||||||
|
b = bl->data;
|
||||||
|
if (termInTerm (b->term, TERM_Hidden))
|
||||||
|
{
|
||||||
|
// Prune the state: we can never meet this
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
bl = bl->next;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
#include "role.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "binding.h"
|
#include "binding.h"
|
||||||
#include "warshall.h"
|
#include "warshall.h"
|
||||||
@ -14,6 +15,9 @@ static System sys;
|
|||||||
static int *graph;
|
static int *graph;
|
||||||
static int nodes;
|
static int nodes;
|
||||||
|
|
||||||
|
extern Protocol INTRUDER; // The intruder protocol
|
||||||
|
extern Role I_M; // special role; precedes all other events always
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Assist stuff
|
* Assist stuff
|
||||||
@ -93,6 +97,7 @@ void
|
|||||||
goal_graph_create ()
|
goal_graph_create ()
|
||||||
{
|
{
|
||||||
int run, ev;
|
int run, ev;
|
||||||
|
int last_m;
|
||||||
List bl;
|
List bl;
|
||||||
|
|
||||||
goal_graph_destroy ();
|
goal_graph_destroy ();
|
||||||
@ -104,6 +109,7 @@ goal_graph_create ()
|
|||||||
|
|
||||||
// Setup run order
|
// Setup run order
|
||||||
run = 0;
|
run = 0;
|
||||||
|
last_m = -1; // last I_M run
|
||||||
while (run < sys->maxruns)
|
while (run < sys->maxruns)
|
||||||
{
|
{
|
||||||
ev = 1;
|
ev = 1;
|
||||||
@ -113,6 +119,16 @@ goal_graph_create ()
|
|||||||
graph[graph_nodes (nodes, run, ev - 1, run, ev)] = 1;
|
graph[graph_nodes (nodes, run, ev - 1, run, ev)] = 1;
|
||||||
ev++;
|
ev++;
|
||||||
}
|
}
|
||||||
|
// Enforce I_M ordering
|
||||||
|
if (sys->runs[run].protocol == INTRUDER && sys->runs[run].role == I_M)
|
||||||
|
{
|
||||||
|
if (last_m != -1)
|
||||||
|
{
|
||||||
|
graph[graph_nodes (nodes, last_m, 0, run, 0)] = 1;
|
||||||
|
}
|
||||||
|
last_m = run;
|
||||||
|
}
|
||||||
|
// Next
|
||||||
run++;
|
run++;
|
||||||
}
|
}
|
||||||
// Setup bindings order
|
// Setup bindings order
|
||||||
@ -232,7 +248,8 @@ goal_add (Term term, const int run, const int ev)
|
|||||||
if (run >= sys->maxruns)
|
if (run >= sys->maxruns)
|
||||||
error ("Trying to add a goal for a run that does not exist.");
|
error ("Trying to add a goal for a run that does not exist.");
|
||||||
if (ev >= sys->runs[run].step)
|
if (ev >= sys->runs[run].step)
|
||||||
error ("Trying to add a goal for an event that is not in the semistate yet.");
|
error
|
||||||
|
("Trying to add a goal for an event that is not in the semistate yet.");
|
||||||
#endif
|
#endif
|
||||||
if (realTermTuple (term))
|
if (realTermTuple (term))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user