- Added rho/sigma/constants fields to the runs, on which the new code is
  based. Over time, .locals should be deprecated in favour of these
  better variants.
- Untyped variant is out of grace for the time being (cf. Athena interm
  problems)
- Improved graph output further.

Minor:
- Added TERMLISTADD and APPEND macros for more concise code.
This commit is contained in:
ccremers 2006-03-15 21:30:19 +00:00
parent 5624f7e7b6
commit 1ce03104c5
9 changed files with 358 additions and 226 deletions

View File

@ -25,7 +25,7 @@ selfInitiator (const System sys, const int run)
Termlist agents; Termlist agents;
Termlist seen; Termlist seen;
agents = sys->runs[run].agents; agents = sys->runs[run].rho;
seen = NULL; seen = NULL;
while (agents != NULL) while (agents != NULL)
{ {

View File

@ -53,11 +53,36 @@ extern Role I_RRSD;
* spread over all the runs. * spread over all the runs.
*/ */
static System sys = NULL;
/* /*
* code * code
*/ */
void
printVisualRun (int rid)
{
int run;
int display;
display = 1;
for (run = 0; run < rid; run++)
{
if (sys->runs[run].protocol != INTRUDER)
{
display++;
}
}
eprintf ("#%i", display);
}
//! Remap term stuff
void
termPrintRemap (const Term t)
{
termPrintCustom (t, "", "V", "(", ")", "\\{ ", " \\}", printVisualRun);
}
//! Draw node //! Draw node
void void
node (const System sys, const int run, const int index) node (const System sys, const int run, const int index)
@ -113,7 +138,7 @@ roledefDraw (Roledef rd)
label = TermOp2 (label); label = TermOp2 (label);
} }
eprintf ("_"); eprintf ("_");
termPrint (label); termPrintRemap (label);
} }
} }
@ -122,29 +147,29 @@ roledefDraw (Roledef rd)
eprintf ("read"); eprintf ("read");
optlabel (); optlabel ();
eprintf (" from "); eprintf (" from ");
termPrint (rd->from); termPrintRemap (rd->from);
eprintf ("\\n"); eprintf ("\\n");
termPrint (rd->message); termPrintRemap (rd->message);
} }
if (rd->type == SEND) if (rd->type == SEND)
{ {
eprintf ("send"); eprintf ("send");
optlabel (); optlabel ();
eprintf (" to "); eprintf (" to ");
termPrint (rd->to); termPrintRemap (rd->to);
eprintf ("\\n"); eprintf ("\\n");
termPrint (rd->message); termPrintRemap (rd->message);
} }
if (rd->type == CLAIM) if (rd->type == CLAIM)
{ {
eprintf ("claim"); eprintf ("claim");
optlabel (); optlabel ();
eprintf ("\\n"); eprintf ("\\n");
termPrint (rd->to); termPrintRemap (rd->to);
if (rd->message != NULL) if (rd->message != NULL)
{ {
eprintf (" : "); eprintf (" : ");
termPrint (rd->message); termPrintRemap (rd->message);
} }
} }
} }
@ -159,7 +184,7 @@ chooseTermNode (const Term t)
rsbuf = RUNSEP; rsbuf = RUNSEP;
RUNSEP = "x"; RUNSEP = "x";
termPrint (t); termPrintRemap (t);
RUNSEP = rsbuf; RUNSEP = rsbuf;
} }
} }
@ -502,6 +527,27 @@ iterate_first_regular_occurrences (const System sys,
return true; return true;
} }
//! Does a term occur in a run?
int
termOccursInRun (Term t, int run)
{
Roledef rd;
int e;
rd = sys->runs[run].start;
e = 0;
while (e < sys->runs[run].step)
{
if (roledefSubTerm (rd, t))
{
return true;
}
e++;
rd = rd->next;
}
return false;
}
//! Draw a class choice //! Draw a class choice
/** /**
* \rho classes are already dealt with in the headers, so we should ignore them. * \rho classes are already dealt with in the headers, so we should ignore them.
@ -532,7 +578,7 @@ drawClass (const System sys, Binding b)
run = TermRunid (varterm); run = TermRunid (varterm);
if ((run >= 0) && (run < sys->maxruns)) if ((run >= 0) && (run < sys->maxruns))
{ {
if (inTermlist (sys->runs[run].agents, varterm)) if (inTermlist (sys->runs[run].rho, varterm))
{ {
return; return;
} }
@ -553,7 +599,7 @@ drawClass (const System sys, Binding b)
eprintf ("\t"); eprintf ("\t");
chooseTermNode (varterm); chooseTermNode (varterm);
eprintf (" [label=\"Class:\\nAny "); eprintf (" [label=\"Class:\\nAny ");
termPrint (varterm); termPrintRemap (varterm);
eprintf ("\"];\n"); eprintf ("\"];\n");
eprintf ("\t"); eprintf ("\t");
chooseTermNode (varterm); chooseTermNode (varterm);
@ -601,7 +647,7 @@ drawBinding (const System sys, Binding b)
eprintf ("\t"); eprintf ("\t");
arrow (sys, b); arrow (sys, b);
eprintf (" [label=\""); eprintf (" [label=\"");
termPrint (b->term); termPrintRemap (b->term);
eprintf ("\"]"); eprintf ("\"]");
eprintf (";\n"); eprintf (";\n");
} }
@ -658,7 +704,7 @@ drawBinding (const System sys, Binding b)
{ {
// Only explicitly mention redirect term when it differs from the sent term // Only explicitly mention redirect term when it differs from the sent term
eprintf ("\\n"); eprintf ("\\n");
termPrint (b->term); termPrintRemap (b->term);
} }
eprintf ("\"]"); eprintf ("\"]");
eprintf (";\n"); eprintf (";\n");
@ -720,14 +766,14 @@ agentsOfRunPrintOthers (const System sys, const int run)
{ {
Term agent; Term agent;
termPrint (roles->term); termPrintRemap (roles->term);
eprintf (" is "); eprintf (" is ");
agent = agentOfRunRole (sys, run, roles->term); agent = agentOfRunRole (sys, run, roles->term);
if (isTermVariable (agent)) if (isTermVariable (agent))
{ {
eprintf ("any "); eprintf ("any ");
} }
termPrint (agent); termPrintRemap (agent);
eprintf ("\\l"); eprintf ("\\l");
} }
roles = roles->next; roles = roles->next;
@ -767,7 +813,7 @@ drawRegularRuns (const System sys)
eprintf ("\tsubgraph cluster_run%i {\n", run); eprintf ("\tsubgraph cluster_run%i {\n", run);
eprintf ("\t\tlabel = \""); eprintf ("\t\tlabel = \"");
eprintf ("#%i: ", run); eprintf ("#%i: ", run);
termPrint (sys->runs[run].protocol->nameterm); termPrintRemap (sys->runs[run].protocol->nameterm);
eprintf (", "); eprintf (", ");
agentsOfRunPrint (sys, run); agentsOfRunPrint (sys, run);
eprintf ("\\nTesting the second line\";\n", run); eprintf ("\\nTesting the second line\";\n", run);
@ -889,9 +935,9 @@ drawRegularRuns (const System sys)
{ {
eprintf ("Any "); eprintf ("Any ");
} }
termPrint (agentname); termPrintRemap (agentname);
eprintf (" in role "); eprintf (" in role ");
termPrint (rolename); termPrintRemap (rolename);
eprintf ("\\l"); eprintf ("\\l");
} }
@ -953,27 +999,82 @@ drawRegularRuns (const System sys)
if (showprotocol) if (showprotocol)
{ {
eprintf ("Protocol "); eprintf ("Protocol ");
termPrint (sys->runs[run].protocol-> termPrintRemap (sys->runs[run].protocol->
nameterm); nameterm);
eprintf ("\\l"); eprintf ("\\l");
} }
} }
eprintf ("Run #%i\\l", run); eprintf ("Run ");
printVisualRun (run);
eprintf ("\\l");
// print the other agents // rho, sigma, const
eprintf ("|"); void showLocal (Term told, Term tnew)
if (termlistLength (sys->runs[run].agents) > 1)
{ {
if (sys->runs[run].role->initiator) if (realTermVariable (tnew))
{ {
eprintf ("Chooses:\\l"); // Variables are mapped, maybe. But then we wonder whether they occur in reads.
termPrintRemap (told);
if (termOccursInRun (tnew, run))
{
eprintf (" : ");
termPrintRemap (deVar (tnew));
} }
else else
{ {
eprintf ("Assumes:\\l"); eprintf (" is not read");
} }
agentsOfRunPrintOthers (sys, run); }
else
{
termPrintRemap (tnew);
}
eprintf ("\\l");
}
void showLocals (Termlist tlold, Termlist tlnew,
Term tavoid)
{
while (tlold != NULL && tlnew != NULL)
{
if (!isTermEqual (tlold->term, tavoid))
{
showLocal (tlold->term, tlnew->term);
}
tlold = tlold->next;
tlnew = tlnew->next;
}
}
if (termlistLength (sys->runs[run].rho) > 1)
{
eprintf ("|");
if (sys->runs[run].role->initiator)
{
eprintf ("Initiates with:\\l");
}
else
{
eprintf ("Responds to:\\l");
}
showLocals (sys->runs[run].protocol->
rolenames, sys->runs[run].rho,
sys->runs[run].role->nameterm);
}
if (sys->runs[run].constants != NULL)
{
eprintf ("|Creates:\\l");
showLocals (sys->runs[run].role->
declaredconsts,
sys->runs[run].constants, NULL);
}
if (sys->runs[run].sigma != NULL)
{
eprintf ("|Variables:\\l");
showLocals (sys->runs[run].role->
declaredvars,
sys->runs[run].sigma, NULL);
} }
// close up // close up
@ -1113,7 +1214,7 @@ drawIntruderChoices (const System sys)
eprintf ("\t"); eprintf ("\t");
chooseTermNode (b->term); chooseTermNode (b->term);
eprintf (" [label=\"Class: any "); eprintf (" [label=\"Class: any ");
termPrint (b->term); termPrintRemap (b->term);
eprintf ("\",color=\"darkgreen\"];\n"); eprintf ("\",color=\"darkgreen\"];\n");
iterate_first_regular_occurrences (sys, firsthere, b->term); iterate_first_regular_occurrences (sys, firsthere, b->term);
@ -1135,7 +1236,7 @@ drawIntruderChoices (const System sys)
* This is not as nice as we would like it. Furthermore, the function is too big. * This is not as nice as we would like it. Furthermore, the function is too big.
*/ */
void void
dotSemiState (const System sys) dotSemiState (const System mysys)
{ {
static int attack_number = 0; static int attack_number = 0;
int run; int run;
@ -1145,16 +1246,18 @@ dotSemiState (const System sys)
int from_intruder_count; int from_intruder_count;
int nodes; int nodes;
sys = mysys;
// Open graph // Open graph
attack_number++; attack_number++;
eprintf ("digraph semiState%i {\n", attack_number); eprintf ("digraph semiState%i {\n", attack_number);
eprintf ("\tlabel = \"[Id %i] Protocol ", sys->attackid); eprintf ("\tlabel = \"[Id %i] Protocol ", sys->attackid);
p = (Protocol) sys->current_claim->protocol; p = (Protocol) sys->current_claim->protocol;
termPrint (p->nameterm); termPrintRemap (p->nameterm);
eprintf (", role "); eprintf (", role ");
termPrint (sys->current_claim->rolename); termPrintRemap (sys->current_claim->rolename);
eprintf (", claim type "); eprintf (", claim type ");
termPrint (sys->current_claim->type); termPrintRemap (sys->current_claim->type);
eprintf ("\";\n"); eprintf ("\";\n");
// Globals // Globals
@ -1242,6 +1345,7 @@ dotSemiState (const System sys)
// For debugging we might add more stuff: full dependencies // For debugging we might add more stuff: full dependencies
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (3))
{ {
int r1; int r1;
@ -1265,8 +1369,9 @@ dotSemiState (const System sys)
{ {
if (isDependEvent (r1, e1, r2, e2)) if (isDependEvent (r1, e1, r2, e2))
{ {
eprintf ("\tr%ii%i -> r%ii%i [color=grey];\n", eprintf
r1, e1, r2, e2); ("\tr%ii%i -> r%ii%i [color=grey];\n", r1,
e1, r2, e2);
} }
} }
} }

View File

@ -137,7 +137,7 @@ initiatorAgentsType (const System sys)
{ {
Termlist agents; Termlist agents;
agents = sys->runs[run].agents; agents = sys->runs[run].rho;
while (agents != NULL) while (agents != NULL)
{ {
if (!goodAgentType (agents->term)) if (!goodAgentType (agents->term))
@ -221,7 +221,7 @@ prune_theorems (const System sys)
// Check this initiator run // Check this initiator run
Termlist tl; Termlist tl;
tl = sys->runs[run].agents; tl = sys->runs[run].rho;
while (tl != NULL) while (tl != NULL)
{ {
Termlist tlscan; Termlist tlscan;
@ -280,7 +280,7 @@ prune_theorems (const System sys)
{ {
if (sys->runs[run].protocol != INTRUDER) if (sys->runs[run].protocol != INTRUDER)
{ {
if (sys->runs[run].agents != NULL) if (sys->runs[run].rho != NULL)
{ {
Term actor; Term actor;

View File

@ -226,26 +226,27 @@ ensureValidRun (const System sys, int run)
for (i = oldsize; i < sys->maxruns; i++) for (i = oldsize; i < sys->maxruns; i++)
{ {
/* init run */ /* init run */
struct run myrun = sys->runs[i]; sys->runs[i].protocol = NULL;
myrun.protocol = NULL; sys->runs[i].role = NULL;
myrun.role = NULL; sys->runs[i].step = 0;
myrun.agents = NULL; sys->runs[i].rolelength = 0;
myrun.step = 0;
myrun.index = NULL;
myrun.start = NULL;
myrun.rho = NULL; sys->runs[i].index = NULL;
myrun.sigma = NULL; sys->runs[i].start = NULL;
myrun.constants = NULL; sys->runs[i].know = NULL;
myrun.locals = NULL;
myrun.artefacts = NULL;
myrun.substitutions = NULL;
myrun.know = NULL; sys->runs[i].rho = NULL;
sys->runs[i].sigma = NULL;
sys->runs[i].constants = NULL;
myrun.prevSymmRun = -1; sys->runs[i].locals = NULL;
myrun.firstNonAgentRead = -1; sys->runs[i].artefacts = NULL;
myrun.firstReal = 0; sys->runs[i].substitutions = NULL;
sys->runs[i].prevSymmRun = -1;
sys->runs[i].firstNonAgentRead = -1;
sys->runs[i].firstReal = 0;
} }
} }
@ -321,7 +322,7 @@ agentOfRunRole (const System sys, const int run, const Term role)
// Agent variables have the same symbol as the role names, so // Agent variables have the same symbol as the role names, so
// we can scan for this. // we can scan for this.
agents = sys->runs[run].agents; agents = sys->runs[run].rho;
while (agents != NULL) while (agents != NULL)
{ {
Term agent; Term agent;
@ -367,7 +368,7 @@ staticRunSymmetry (const System sys, const int rid)
ridSymm = -1; ridSymm = -1;
runs = sys->runs; runs = sys->runs;
agents = runs[rid].agents; agents = runs[rid].rho;
while (agents != NULL) while (agents != NULL)
{ {
if (isTermVariable (agents->term)) if (isTermVariable (agents->term))
@ -378,7 +379,7 @@ staticRunSymmetry (const System sys, const int rid)
if (ridSymm == -1) if (ridSymm == -1)
return -1; return -1;
agents = runs[rid].agents; agents = runs[rid].rho;
while (ridSymm >= 0) while (ridSymm >= 0)
{ {
/* compare protocol name, role name */ /* compare protocol name, role name */
@ -391,7 +392,7 @@ staticRunSymmetry (const System sys, const int rid)
isEqual = 1; isEqual = 1;
al = agents; al = agents;
alSymm = runs[ridSymm].agents; alSymm = runs[ridSymm].rho;
while (isEqual && al != NULL) while (isEqual && al != NULL)
{ {
/* determine equality */ /* determine equality */
@ -572,7 +573,6 @@ run_localize (const System sys, const int rid, Termlist fromlist,
} }
//! Instantiate a role by making a new run for Arachne //! Instantiate a role by making a new run for Arachne
/** /**
* This involves creation of a new run(id). * This involves creation of a new run(id).
@ -588,13 +588,8 @@ roleInstanceArachne (const System sys, const Protocol protocol,
int rid; int rid;
Run runs; Run runs;
Roledef rd; Roledef rd;
Termlist scanfrom, scanto;
Termlist fromlist = NULL; // deleted at the end Termlist fromlist = NULL; // deleted at the end
Termlist tolist = NULL; // -> .locals Termlist tolist = NULL; // -> .locals
Termlist artefacts = NULL; // -> .artefacts
Termlist rho = NULL; // -> .rho
Termlist sigma = NULL; // -> .sigma
Termlist constants = NULL; // -> .constants
Term extterm = NULL; // construction thing (will go to artefacts) Term extterm = NULL; // construction thing (will go to artefacts)
/* claim runid, allocate space */ /* claim runid, allocate space */
@ -615,61 +610,54 @@ roleInstanceArachne (const System sys, const Protocol protocol,
runs[rid].step = 0; runs[rid].step = 0;
runs[rid].firstReal = 0; runs[rid].firstReal = 0;
/* scan for types in agent list */ /* Now we need to create local terms corresponding to rho, sigma, and any local constants.
/* scanners */ *
/** * We maintain our stuff in a from/to list.
* Because of pre-instantiation unification, some variables might already have been filled in.
* Ignore agent list; instead rely on role->variables.
*/ */
runs[rid].agents = NULL;
scanfrom = role->variables; void createLocal (Term oldt, int isvariable, int isrole)
while (scanfrom != NULL)
{ {
Term newt, oldt; Term newt;
/* Some care has to be taken: after we use this instantiation, we might reset it. // Create new term with the same symbol
* That is not strictly necessary: whoever set it first, is responsible for getting rid if (isvariable)
* of it again.
*/
oldt = scanfrom->term;
newt = deVar (oldt);
if (realTermVariable (newt))
{ {
/* This is a variable of the role, that is not instantiated yet. // Force variable
* Thus, it needs a local copy. newt = makeTermType (VARIABLE, TermSymb (oldt), rid);
*/
newt = makeTermType (VARIABLE, TermSymb (newt), rid);
newt->stype = oldt->stype;
artefacts = termlistAddNew (artefacts, newt);
} }
/* Now we add any role names to the agent list. Note that else
* instantiations do not matter: because if the variable is
* instantiated, the rolename will be as well, and thus they will be
* equal anyway.
*/
if (inTermlist (protocol->rolenames, oldt))
{ {
/* Add the agent name or role variable... */ // Force local (weirdly enough called global)
runs[rid].agents = termlistAppend (runs[rid].agents, newt); newt = makeTermType (GLOBAL, TermSymb (oldt), rid);
}
newt->stype = oldt->stype; // copy list of types
newt->roleVar = isrole; // set role status
if (isTermVariable (newt)) // Add to copy list
TERMLISTADD (fromlist, oldt);
TERMLISTADD (tolist, newt);
// Add to registration lists
// Everything to destructor list
TERMLISTADD (runs[rid].artefacts, newt);
// Variable / Constant?
if (isvariable)
{ {
// It is a protocol role name TERMLISTADD (sys->variables, newt);
if (isrole)
// Flag this {
newt->roleVar = 1; // role variable
newt->stype = termlistAddNew (newt->stype, TERM_Agent);
// maybe add choose?
// Note that for anything but full type flaws, this is not an issue.
// In the POR reduction, force choose was the default. Here it is not.
/* /*
* [x] * We use append to make sure the order is
* TODO currently disabled: something weird was goind on causing weird prunes, * consistent with the role names list.
* for match=2. Investigate later.
*/ */
if (0 && not_read_first (rd, oldt) && switches.match == 2) TERMLISTAPPEND (runs[rid].rho, newt);
if (!role->initiator)
{
// For non-initiators, we prepend the reading of the role names
// XXX disabled for now TODO [x] [cc]
if (0 == 1 && not_read_first (rd, oldt))
{ {
/* this term is forced as a choose, or it does not occur in the (first) read event */ /* this term is forced as a choose, or it does not occur in the (first) read event */
if (extterm == NULL) if (extterm == NULL)
@ -680,24 +668,37 @@ roleInstanceArachne (const System sys, const Protocol protocol,
{ {
extterm = makeTermTuple (newt, extterm); extterm = makeTermTuple (newt, extterm);
// NOTE: don't these get double deleted? By roledefdestroy? // NOTE: don't these get double deleted? By roledefdestroy?
artefacts = termlistAddNew (artefacts, extterm); TERMLISTAPPEND (runs[rid].artefacts, extterm);
} }
} }
} }
} }
fromlist = termlistAdd (fromlist, oldt); else
tolist = termlistAdd (tolist, newt); {
// normal variable
TERMLISTAPPEND (runs[rid].sigma, newt);
}
}
else
{
// local constant
TERMLISTADD (runs[rid].constants, newt);
}
}
/* void createLocals (Termlist list, int isvariable, int isrole)
eprintf ("Created for run %i: ", rid); {
termPrint (oldt); while (list != NULL)
eprintf (" -> "); {
termPrint (newt); createLocal (list->term, isvariable, isrole);
eprintf ("\n"); list = list->next;
*/
scanfrom = scanfrom->next;
} }
}
// Create rho, sigma, constants
createLocals (protocol->rolenames, true, true);
createLocals (role->declaredvars, true, false);
createLocals (role->declaredconsts, false, false);
/* Now we prefix the read before rd, if extterm is not NULL. Even if /* Now we prefix the read before rd, if extterm is not NULL. Even if
* extterm is NULL, rd is still set as the start and the index pointer of * extterm is NULL, rd is still set as the start and the index pointer of
@ -705,30 +706,6 @@ roleInstanceArachne (const System sys, const Protocol protocol,
*/ */
run_prefix_read (sys, rid, rd, extterm); run_prefix_read (sys, rid, rd, extterm);
/* duplicate all locals form this run */
scanto = role->locals;
while (scanto != NULL)
{
Term t = scanto->term;
if (!inTermlist (fromlist, t))
{
Term newt;
newt = create_new_local (t, rid);
if (newt != NULL)
{
artefacts = termlistAddNew (artefacts, newt);
if (realTermVariable (newt))
{
sys->variables = termlistAdd (sys->variables, newt);
}
fromlist = termlistAdd (fromlist, t);
tolist = termlistAdd (tolist, newt);
}
}
scanto = scanto->next;
}
/* TODO this is not what we want yet, also local knowledge. The local /* TODO this is not what we want yet, also local knowledge. The local
* knowledge (list?) also needs to be substituted on invocation. */ * knowledge (list?) also needs to be substituted on invocation. */
runs[rid].know = NULL; runs[rid].know = NULL;
@ -738,7 +715,6 @@ roleInstanceArachne (const System sys, const Protocol protocol,
termlistDelete (fromlist); termlistDelete (fromlist);
runs[rid].locals = tolist; runs[rid].locals = tolist;
runs[rid].artefacts = artefacts;
/* erase any substitutions in the role definition, as they are now copied */ /* erase any substitutions in the role definition, as they are now copied */
termlistSubstReset (role->variables); termlistSubstReset (role->variables);
@ -795,6 +771,10 @@ roleInstanceDestroy (const System sys)
// Destroy artefacts // Destroy artefacts
// //
termlistDelete (myrun.rho);
termlistDelete (myrun.sigma);
termlistDelete (myrun.constants);
// sys->variables might contain locals from the run: remove them // sys->variables might contain locals from the run: remove them
{ {
Termlist tl; Termlist tl;
@ -822,19 +802,6 @@ roleInstanceDestroy (const System sys)
} }
} }
/*
* Arachne does real-time reduction of memory, POR does not
* Artefact removal can only be done if knowledge sets are empty, as with Arachne
*/
Termlist artefacts;
// Remove artefacts
artefacts = myrun.artefacts;
while (artefacts != NULL)
{
free (artefacts->term);
artefacts = artefacts->next;
}
/** /**
* Undo the local copies of the substitutions. We cannot restore them however, so this might * Undo the local copies of the substitutions. We cannot restore them however, so this might
* prove a problem. We assume that the substlist fixes this at roleInstance time; it should be exact. * prove a problem. We assume that the substlist fixes this at roleInstance time; it should be exact.
@ -854,10 +821,23 @@ roleInstanceDestroy (const System sys)
} }
termlistDelete (myrun.substitutions); termlistDelete (myrun.substitutions);
/*
* Artefact removal can only be done if knowledge sets are empty, as with Arachne
*/
{
Termlist artefacts;
// Remove artefacts
artefacts = myrun.artefacts;
while (artefacts != NULL)
{
free (artefacts->term);
artefacts = artefacts->next;
}
}
// remove lists // remove lists
termlistDelete (myrun.artefacts); termlistDelete (myrun.artefacts);
termlistDelete (myrun.locals); termlistDelete (myrun.locals);
termlistDelete (myrun.agents);
// Destroy run struct allocation in array using realloc // Destroy run struct allocation in array using realloc
// Reduce run count // Reduce run count
@ -1059,7 +1039,7 @@ isRunTrusted (const System sys, const int run)
{ {
if (run >= 0 && run < sys->maxruns) if (run >= 0 && run < sys->maxruns)
{ {
if (!isAgentlistTrusted (sys, sys->runs[run].agents)) if (!isAgentlistTrusted (sys, sys->runs[run].rho))
{ {
return 0; return 0;
} }
@ -1192,7 +1172,7 @@ void
runInstancePrint (const System sys, const int run) runInstancePrint (const System sys, const int run)
{ {
termPrint (sys->runs[run].role->nameterm); termPrint (sys->runs[run].role->nameterm);
termlistPrint (sys->runs[run].agents); termlistPrint (sys->runs[run].rho);
} }
//! Print an instantiated scenario (chooses and such) //! Print an instantiated scenario (chooses and such)
@ -1350,7 +1330,7 @@ iterateLocalToOther (const System sys, const int myrun,
flag = true; flag = true;
tlo = NULL; tlo = NULL;
// construct all others occuring in the reads // construct all others occuring in the reads
for (tls = sys->runs[myrun].locals; tls != NULL; tls = tls->next) for (tls = sys->runs[myrun].sigma; tls != NULL; tls = tls->next)
{ {
Term tt; Term tt;

View File

@ -41,18 +41,21 @@ struct run
{ {
Protocol protocol; //!< Protocol of this run. Protocol protocol; //!< Protocol of this run.
Role role; //!< Role of this run. Role role; //!< Role of this run.
Termlist agents; //!< Agents involved in this run.
int step; //!< Current execution point in the run (integer) int step; //!< Current execution point in the run (integer)
int rolelength; //!< Length of role int rolelength; //!< Length of role
Roledef index; //!< Current execution point in the run (roledef pointer) Roledef index; //!< Current execution point in the run (roledef pointer)
Roledef start; //!< Head of the run definition. Roledef start; //!< Head of the run definition.
Knowledge know; //!< Current knowledge of the run. Knowledge know; //!< Current knowledge of the run.
Termlist rho; //!< As in semantics (copies in artefacts) Termlist rho; //!< As in semantics (copies in artefacts)
Termlist sigma; //!< As in semantics (copies in artefacts) Termlist sigma; //!< As in semantics (copies in artefacts)
Termlist constants; //!< As in semantics (copies in artefacts) Termlist constants; //!< As in semantics (copies in artefacts)
Termlist locals; //!< Locals of the run (will be deprecated eventually) Termlist locals; //!< Locals of the run (will be deprecated eventually)
Termlist artefacts; //!< Stuff created especially for this run. Termlist artefacts; //!< Stuff created especially for this run, which can also include tuples (anything allocated)
Termlist substitutions; //!< The substitutions as they came from the roledef unifier Termlist substitutions; //!< The substitutions as they came from the roledef unifier
int prevSymmRun; //!< Used for symmetry reduction. Either -1, or the previous run with the same role def and at least a single parameter. int prevSymmRun; //!< Used for symmetry reduction. Either -1, or the previous run with the same role def and at least a single parameter.
int firstNonAgentRead; //!< Used for symmetry reductions for equal agents runs; -1 if there is no candidate. int firstNonAgentRead; //!< Used for symmetry reductions for equal agents runs; -1 if there is no candidate.
int firstReal; //!< 1 if a choose was inserted, otherwise 0 int firstReal; //!< 1 if a choose was inserted, otherwise 0

View File

@ -1,4 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "tac.h" #include "tac.h"
#include "memory.h" #include "memory.h"
#include "switches.h" #include "switches.h"

View File

@ -313,7 +313,9 @@ termInTerm (Term t, Term tsub)
*\sa termTuplePrint() *\sa termTuplePrint()
*/ */
void void
termPrint (Term term) termPrintCustom (Term term, char *leftvar, char *rightvar, char *lefttup,
char *righttup, char *leftenc, char *rightenc,
void (*callback) (int rid))
{ {
if (term == NULL) if (term == NULL)
{ {
@ -330,23 +332,34 @@ termPrint (Term term)
#endif #endif
if (realTermLeaf (term)) if (realTermLeaf (term))
{ {
if (term->type == VARIABLE && TermRunid (term) >= 0)
eprintf (leftvar);
symbolPrint (TermSymb (term)); symbolPrint (TermSymb (term));
if (term->type == VARIABLE && TermRunid (term) >= 0) if (term->type == VARIABLE && TermRunid (term) >= 0)
eprintf ("V"); eprintf (rightvar);
if (TermRunid (term) >= 0) if (TermRunid (term) >= 0)
{
if (callback == NULL)
{ {
eprintf ("%s%i", RUNSEP, TermRunid (term)); eprintf ("%s%i", RUNSEP, TermRunid (term));
} }
else
{
callback (TermRunid (term));
}
}
if (term->subst != NULL) if (term->subst != NULL)
{ {
eprintf ("->"); eprintf ("->");
termPrint (term->subst); termPrintCustom (term->subst, leftvar, rightvar, lefttup, righttup,
leftenc, rightenc, callback);
} }
} }
if (realTermTuple (term)) if (realTermTuple (term))
{ {
eprintf ("("); eprintf ("(");
termTuplePrint (term); termTuplePrintCustom (term, leftvar, rightvar, lefttup, righttup,
leftenc, rightenc, callback);
eprintf (")"); eprintf (")");
return; return;
} }
@ -356,22 +369,32 @@ termPrint (Term term)
&& inTermlist (TermKey (term)->stype, TERM_Function)) && inTermlist (TermKey (term)->stype, TERM_Function))
{ {
/* function application */ /* function application */
termPrint (TermKey (term)); termPrintCustom (TermKey (term), leftvar, rightvar, lefttup,
eprintf ("("); righttup, leftenc, rightenc, callback);
termTuplePrint (TermOp (term)); eprintf (lefttup);
eprintf (")"); termTuplePrintCustom (TermOp (term), leftvar, rightvar, lefttup,
righttup, leftenc, rightenc, callback);
eprintf (righttup);
} }
else else
{ {
/* normal encryption */ /* normal encryption */
eprintf ("{ "); eprintf (leftenc);
termTuplePrint (TermOp (term)); termTuplePrintCustom (TermOp (term), leftvar, rightvar, lefttup,
eprintf (" }"); righttup, leftenc, rightenc, callback);
termPrint (TermKey (term)); eprintf (rightenc);
termPrintCustom (TermKey (term), leftvar, rightvar, lefttup,
righttup, leftenc, rightenc, callback);
} }
} }
} }
void
termPrint (Term term)
{
termPrintCustom (term, "", "V", "(", ")", "{ ", " }", NULL);
}
//! Print an inner (tuple) term to stdout, without brackets. //! Print an inner (tuple) term to stdout, without brackets.
/** /**
* The tuple printing only works correctly for normalized terms. * The tuple printing only works correctly for normalized terms.
@ -379,7 +402,9 @@ termPrint (Term term)
* desirable to distinguish them. * desirable to distinguish them.
*/ */
void void
termTuplePrint (Term term) termTuplePrintCustom (Term term, char *leftvar, char *rightvar, char *lefttup,
char *righttup, char *leftenc, char *rightenc,
void (*callback) (int rid))
{ {
if (term == NULL) if (term == NULL)
{ {
@ -390,14 +415,23 @@ termTuplePrint (Term term)
while (realTermTuple (term)) while (realTermTuple (term))
{ {
// To remove any brackets, change this into termTuplePrint. // To remove any brackets, change this into termTuplePrint.
termPrint (TermOp1 (term)); termPrintCustom (TermOp1 (term), leftvar, rightvar, lefttup, righttup,
leftenc, rightenc, callback);
eprintf (","); eprintf (",");
term = deVar (TermOp2 (term)); term = deVar (TermOp2 (term));
} }
termPrint (term); termPrintCustom (term, leftvar, rightvar, lefttup, righttup, leftenc,
rightenc, callback);
return; return;
} }
//! Print inner tuple
void
termTuplePrint (Term term)
{
termTuplePrintCustom (term, "", "V", "(", ")", "{ ", " }", NULL);
}
//! Make a deep copy of a term. //! Make a deep copy of a term.
/** /**
* Leaves are not copied. * Leaves are not copied.

View File

@ -172,7 +172,13 @@ int hasTermVariable (Term term);
int isTermEqualFn (Term term1, Term term2); int isTermEqualFn (Term term1, Term term2);
int termSubTerm (Term t, Term tsub); int termSubTerm (Term t, Term tsub);
int termInTerm (Term t, Term tsub); int termInTerm (Term t, Term tsub);
void termPrintCustom (Term term, char *leftvar, char *rightvar, char *lefttup,
char *righttup, char *leftenc, char *rightenc,
void (*callback) (int rid));
void termPrint (Term term); void termPrint (Term term);
void termTuplePrintCustom (Term term, char *leftvar, char *rightvar,
char *lefttup, char *righttup, char *leftenc,
char *rightenc, void (*callback) (int rid));
void termTuplePrint (Term term); void termTuplePrint (Term term);
Term termDuplicate (const Term term); Term termDuplicate (const Term term);
Term termNodeDuplicate (const Term term); Term termNodeDuplicate (const Term term);

View File

@ -61,4 +61,7 @@ Term termlist_to_tuple (Termlist tl);
Termlist tuple_to_termlist (Term t); Termlist tuple_to_termlist (Term t);
Termlist termlistMinusTermlist (const Termlist tlbig, const Termlist tlsmall); Termlist termlistMinusTermlist (const Termlist tlbig, const Termlist tlsmall);
#define TERMLISTADD(l,t) l = termlistAdd (l,t)
#define TERMLISTAPPEND(l,t) l = termlistAppend (l,t)
#endif #endif