- Implemented ordering checks. Need some test to validate this though.
This commit is contained in:
parent
957b920b98
commit
4f534410bd
@ -4,12 +4,14 @@
|
|||||||
|
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "role.h"
|
#include "role.h"
|
||||||
|
#include "label.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "binding.h"
|
#include "binding.h"
|
||||||
#include "warshall.h"
|
#include "warshall.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
|
#include "termmap.h"
|
||||||
|
|
||||||
static System sys;
|
static System sys;
|
||||||
static int *graph;
|
static int *graph;
|
||||||
@ -342,6 +344,58 @@ goal_unbind (const Binding b)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Determine whether some label set is ordered w.r.t. send/read order.
|
||||||
|
/**
|
||||||
|
* Assumes all these labels exist in the system, within length etc, and that the run mappings are valid.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
labels_ordered (Termmap runs, Termlist labels)
|
||||||
|
{
|
||||||
|
goal_graph_create ();
|
||||||
|
while (labels != NULL)
|
||||||
|
{
|
||||||
|
// Given this label, and the mapping of runs, we want to know if the order is okay. Thus, we need to know sendrole and readrole
|
||||||
|
Labelinfo linfo;
|
||||||
|
int send_run, send_ev, read_run, read_ev;
|
||||||
|
|
||||||
|
int get_index (const int run)
|
||||||
|
{
|
||||||
|
Roledef rd;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
rd = sys->runs[run].start;
|
||||||
|
while (rd != NULL && !isTermEqual (rd->label, labels->term))
|
||||||
|
{
|
||||||
|
rd = rd->next;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (rd == NULL)
|
||||||
|
error
|
||||||
|
("Could not locate send or read for label, after niagree holds, to test for order.");
|
||||||
|
#endif
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
linfo = label_find (sys->labellist, labels->term);
|
||||||
|
send_run = termmapGet (runs, linfo->sendrole);
|
||||||
|
read_run = termmapGet (runs, linfo->readrole);
|
||||||
|
send_ev = get_index (send_run);
|
||||||
|
read_ev = get_index (read_run);
|
||||||
|
if (graph[graph_nodes (nodes, send_run, send_ev, read_run, read_ev)] ==
|
||||||
|
0)
|
||||||
|
{
|
||||||
|
// Not ordered; false
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Proceed
|
||||||
|
labels = labels->next;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
//! Prune invalid state w.r.t. <=C minimal requirement
|
//! Prune invalid state w.r.t. <=C minimal requirement
|
||||||
/**
|
/**
|
||||||
* Intuition says this can be done a lot more efficient. Luckily this is the prototype.
|
* Intuition says this can be done a lot more efficient. Luckily this is the prototype.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define BINDINGS
|
#define BINDINGS
|
||||||
|
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
|
#include "termmap.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -41,6 +42,7 @@ void goal_add (Term term, const int run, const int ev, const int level);
|
|||||||
void goal_remove_last ();
|
void goal_remove_last ();
|
||||||
int goal_bind (const Binding b, const int run, const int ev);
|
int goal_bind (const Binding b, const int run, const int ev);
|
||||||
void goal_unbind (const Binding b);
|
void goal_unbind (const Binding b);
|
||||||
|
int labels_ordered (Termmap runs, Termlist labels);
|
||||||
|
|
||||||
int bindings_c_minimal ();
|
int bindings_c_minimal ();
|
||||||
|
|
||||||
|
52
src/claim.c
52
src/claim.c
@ -4,6 +4,7 @@
|
|||||||
#include "label.h"
|
#include "label.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "binding.h"
|
||||||
|
|
||||||
#define MATCH_NONE 0
|
#define MATCH_NONE 0
|
||||||
#define MATCH_ORDER 1
|
#define MATCH_ORDER 1
|
||||||
@ -475,7 +476,8 @@ check_claim_niagree (const System sys, const int i)
|
|||||||
|
|
||||||
|
|
||||||
//! Check generic agree claim for a given set of runs, arachne style
|
//! Check generic agree claim for a given set of runs, arachne style
|
||||||
int arachne_runs_agree (const System sys, const Claimlist cl, const Termmap runs)
|
int
|
||||||
|
arachne_runs_agree (const System sys, const Claimlist cl, const Termmap runs)
|
||||||
{
|
{
|
||||||
Termlist labels;
|
Termlist labels;
|
||||||
int flag;
|
int flag;
|
||||||
@ -567,12 +569,14 @@ int arachne_runs_agree (const System sys, const Claimlist cl, const Termmap runs
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Check arachne agreement claim
|
//! Check arachne authentications claim
|
||||||
/**
|
/**
|
||||||
* Per default, occurs in run 0, but for generality we have left the run parameter in.
|
* Per default, occurs in run 0, but for generality we have left the run parameter in.
|
||||||
*@returns 1 if the claim is true, 0 if it is not.
|
*@returns 1 if the claim is true, 0 if it is not.
|
||||||
*/
|
*/
|
||||||
int arachne_claim_niagree (const System sys, const int claim_run, const int claim_index)
|
int
|
||||||
|
arachne_claim_authentications (const System sys, const int claim_run,
|
||||||
|
const int claim_index, const int require_order)
|
||||||
{
|
{
|
||||||
Claimlist cl;
|
Claimlist cl;
|
||||||
Roledef rd;
|
Roledef rd;
|
||||||
@ -584,7 +588,24 @@ int arachne_claim_niagree (const System sys, const int claim_run, const int clai
|
|||||||
if (roles_tofill == NULL)
|
if (roles_tofill == NULL)
|
||||||
{
|
{
|
||||||
// All roles have been chosen
|
// All roles have been chosen
|
||||||
return arachne_runs_agree (sys, cl, runs_involved);
|
if (arachne_runs_agree (sys, cl, runs_involved))
|
||||||
|
{
|
||||||
|
// niagree holds
|
||||||
|
if (!require_order)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Stronger claim: nisynch. Test for ordering as well.
|
||||||
|
return labels_ordered (runs_involved, cl->prec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// niagree does not hold
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -600,10 +621,12 @@ int arachne_claim_niagree (const System sys, const int claim_run, const int clai
|
|||||||
if (sys->runs[run].protocol == cl->protocol)
|
if (sys->runs[run].protocol == cl->protocol)
|
||||||
{
|
{
|
||||||
// Has to be the right name
|
// Has to be the right name
|
||||||
if (isTermEqual (sys->runs[run].role->nameterm, roles_tofill->term))
|
if (isTermEqual
|
||||||
|
(sys->runs[run].role->nameterm, roles_tofill->term))
|
||||||
{
|
{
|
||||||
// Choose, iterate
|
// Choose, iterate
|
||||||
runs_involved = termmapSet (runs_involved, roles_tofill->term, run);
|
runs_involved =
|
||||||
|
termmapSet (runs_involved, roles_tofill->term, run);
|
||||||
flag = flag || fill_roles (roles_tofill->next);
|
flag = flag || fill_roles (roles_tofill->next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -634,9 +657,18 @@ int arachne_claim_niagree (const System sys, const int claim_run, const int clai
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Test nisynch
|
//! Test niagree
|
||||||
int arachne_claim_nisynch (const System sys, const int claim_run, const int claim_index)
|
int
|
||||||
|
arachne_claim_niagree (const System sys, const int claim_run,
|
||||||
|
const int claim_index)
|
||||||
{
|
{
|
||||||
//!@todo For now, only agreement claim
|
return arachne_claim_authentications (sys, claim_run, claim_index, 0);
|
||||||
return arachne_claim_niagree (sys, claim_run, claim_index);
|
}
|
||||||
|
|
||||||
|
//! Test nisynch
|
||||||
|
int
|
||||||
|
arachne_claim_nisynch (const System sys, const int claim_run,
|
||||||
|
const int claim_index)
|
||||||
|
{
|
||||||
|
return arachne_claim_authentications (sys, claim_run, claim_index, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user