CHANGE: Changed setup of running & commit.

Now:

claim(A,Commit,B,data) => claim(B,Running,A,data) and also B is running the right protocol and role.
This commit is contained in:
Cas Cremers 2011-01-24 17:32:24 +01:00
parent b01bfc4dcd
commit f883499d07
4 changed files with 74 additions and 8 deletions

View File

@ -771,6 +771,14 @@ arachne_claim_weakagree (const System sys, const int claim_run,
} }
//! Test commit(X) => running(X) //! Test commit(X) => running(X)
/**
* To be precise:
*
* for all claim(a,Commit,b,data) =>
* claim(b,Running,a,data)#rid and role(rid) == ROLE(b in claim role spec)
*
* For now we assume data is non-empty
*/
int int
arachne_claim_commit (const System sys, const int claim_run, arachne_claim_commit (const System sys, const int claim_run,
const int claim_index) const int claim_index)
@ -779,8 +787,17 @@ arachne_claim_commit (const System sys, const int claim_run,
int run; int run;
Roledef rd_claim; Roledef rd_claim;
Term actor_a;
Term actor_b;
Term partner_role;
Termlist params_a;
rd_claim = roledef_shift (sys->runs[claim_run].start, claim_index); rd_claim = roledef_shift (sys->runs[claim_run].start, claim_index);
params_a = tuple_to_termlist(rd_claim->message);
actor_a = rd_claim->from;
actor_b = params_a->term;
partner_role = termLeft(rd_claim->claiminfo->parameter);
/* /*
* Iterate over all preceding events (include claim run for consistency with formal definition) * Iterate over all preceding events (include claim run for consistency with formal definition)
*/ */
@ -803,17 +820,38 @@ arachne_claim_commit (const System sys, const int claim_run,
// (Check: maybe below can also be rd->to) // (Check: maybe below can also be rd->to)
if (isTermEqual (rd->claiminfo->type, CLAIM_Running)) if (isTermEqual (rd->claiminfo->type, CLAIM_Running))
{ {
if (isTermEqual (rd->message, rd_claim->message)) // Now check whether they match up nicely
// protocols should be the same
if (sys->current_claim->protocol == rd->claiminfo->protocol)
{
Termlist params_b;
params_b = tuple_to_termlist(rd->message);
// check agent requirements
if (isTermEqual(rd->from,actor_b) && isTermEqual(params_b->term,actor_a))
{
// check role (also same protocol)
if (isTermEqual(partner_role,rd->claiminfo->rolename))
{
// check parameters
if (isTermlistEqual (params_a->next,params_b->next))
{ {
// Claim holds // Claim holds
termlistDelete(params_b);
termlistDelete(params_a);
return true; return true;
} }
} }
} }
termlistDelete(params_b);
}
}
}
/* next */ /* next */
rd = rd->next; rd = rd->next;
} }
} }
termlistDelete(params_a);
return false; return false;
} }

View File

@ -27,6 +27,7 @@
#include "type.h" #include "type.h"
#include "debug.h" #include "debug.h"
#include "error.h" #include "error.h"
#include "specialterm.h"
extern Protocol INTRUDER; // Pointers, to be set by the Init of arachne.c extern Protocol INTRUDER; // Pointers, to be set by the Init of arachne.c
extern Role I_M; // Same here. extern Role I_M; // Same here.
@ -607,6 +608,10 @@ isCommunicationExact (const System sys, Binding b)
} }
//! Ignore some events //! Ignore some events
/**
* Used only in graph drawing. Return true to ignore, return false to
* draw.
*/
int int
isEventIgnored (const System sys, int run, int ev) isEventIgnored (const System sys, int run, int ev)
{ {
@ -615,18 +620,29 @@ isEventIgnored (const System sys, int run, int ev)
rd = eventRoledef (sys, run, ev); rd = eventRoledef (sys, run, ev);
if (rd->type == CLAIM) if (rd->type == CLAIM)
{ {
if (run != 0) // If we are doing a reachability analysis, show all
if (isTermEqual(sys->current_claim->type, CLAIM_Reachable))
{ {
return false;
}
// If the claim type is commit, we also show running claims
if (isTermEqual(sys->current_claim->type, CLAIM_Commit) || isTermEqual(sys->current_claim->type, CLAIM_Reachable))
{
if (isTermEqual(rd->claiminfo->type, CLAIM_Running))
{
return false;
}
}
// Remaining cases: only active claim is shown
if (run == 0)
{
if (ev == sys->current_claim->ev)
{
return false;
}
}
return true; return true;
} }
else
{
if (ev != sys->current_claim->ev)
{
return true;
}
}
}
return false; return false;
} }

View File

@ -925,6 +925,17 @@ tuple_to_termlist (Term t)
} }
} }
//! Get the leftmost term of a tuple (e.g. a non-tuple)
Term termLeft(Term t)
{
t = deVar(t);
if (realTermTuple (t))
{
return termLeft(TermOp1 (t));
}
return t;
}
//! Remove all items from tlbig that occur in tlsmall, and return the pointer to the new tlbig. //! Remove all items from tlbig that occur in tlsmall, and return the pointer to the new tlbig.
Termlist Termlist
termlistMinusTermlist (const Termlist tlbig, const Termlist tlsmall) termlistMinusTermlist (const Termlist tlbig, const Termlist tlsmall)

View File

@ -77,6 +77,7 @@ int termlistOrder (Termlist tl1, Termlist tl2);
int termlist_iterate (Termlist tl, int (*func) ()); int termlist_iterate (Termlist tl, int (*func) ());
Term termlist_to_tuple (Termlist tl); Term termlist_to_tuple (Termlist tl);
Termlist tuple_to_termlist (Term t); Termlist tuple_to_termlist (Term t);
Term termLeft(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 TERMLISTADD(l,t) l = termlistAdd (l,t)