- First broken steps towards prec() computation for each claim label.
This commit is contained in:
parent
0e0f52c6aa
commit
9634034ebb
@ -3,6 +3,7 @@
|
|||||||
#include "tac.h"
|
#include "tac.h"
|
||||||
#include "terms.h"
|
#include "terms.h"
|
||||||
#include "termlists.h"
|
#include "termlists.h"
|
||||||
|
#include "memory.h"
|
||||||
#include "runs.h"
|
#include "runs.h"
|
||||||
#include "knowledge.h"
|
#include "knowledge.h"
|
||||||
#include "symbols.h"
|
#include "symbols.h"
|
||||||
@ -316,6 +317,7 @@ void
|
|||||||
commEvent (int event, Tac tc)
|
commEvent (int event, Tac tc)
|
||||||
{
|
{
|
||||||
/* Add an event to the roledef, send or read */
|
/* Add an event to the roledef, send or read */
|
||||||
|
Claimlist cl;
|
||||||
Term fromrole = NULL;
|
Term fromrole = NULL;
|
||||||
Term torole = NULL;
|
Term torole = NULL;
|
||||||
Term msg = NULL;
|
Term msg = NULL;
|
||||||
@ -360,7 +362,7 @@ commEvent (int event, Tac tc)
|
|||||||
/* now parse tuple info */
|
/* now parse tuple info */
|
||||||
if (trip == NULL || trip->next == NULL)
|
if (trip == NULL || trip->next == NULL)
|
||||||
{
|
{
|
||||||
error ("Problem with %i event on line %i.", event, tc->lineno);
|
error ("Problem with claim %i event on line %i.", event, tc->lineno);
|
||||||
}
|
}
|
||||||
fromrole = tacTerm (trip);
|
fromrole = tacTerm (trip);
|
||||||
claimbig = tacTerm (tacTuple ((trip->next)));
|
claimbig = tacTerm (tacTuple ((trip->next)));
|
||||||
@ -396,6 +398,31 @@ commEvent (int event, Tac tc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* store claim in claim list */
|
||||||
|
|
||||||
|
// First check whether label is unique
|
||||||
|
cl = sys->claimlist;
|
||||||
|
while (cl != NULL)
|
||||||
|
{
|
||||||
|
if (isTermEqual (cl->label, label))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*@todo This should not error exit, but automatically generate a fresh claim label.
|
||||||
|
*/
|
||||||
|
error ("Claim label is not unique at line %i.",tc->lineno);
|
||||||
|
}
|
||||||
|
cl = cl->next;
|
||||||
|
}
|
||||||
|
// Assert: label is unique, add claimlist info
|
||||||
|
cl = memAlloc (sizeof (struct claimlist));
|
||||||
|
cl->label = label;
|
||||||
|
cl->rolename = fromrole;
|
||||||
|
cl->count = 0;
|
||||||
|
cl->failed = 0;
|
||||||
|
cl->prec = NULL;
|
||||||
|
cl->next = sys->claimlist;
|
||||||
|
sys->claimlist = cl;
|
||||||
|
|
||||||
/* handles all claim types differently */
|
/* handles all claim types differently */
|
||||||
|
|
||||||
if (claim == CLAIM_Secret)
|
if (claim == CLAIM_Secret)
|
||||||
@ -719,3 +746,24 @@ tacTermlist (Tac tc)
|
|||||||
}
|
}
|
||||||
return tl;
|
return tl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Compute prec() sets for each claim.
|
||||||
|
void
|
||||||
|
compute_prec_sets (const System sys)
|
||||||
|
{
|
||||||
|
Claimlist cl;
|
||||||
|
|
||||||
|
// Process each individual claim
|
||||||
|
cl = sys->claimlist;
|
||||||
|
while (cl != NULL)
|
||||||
|
{
|
||||||
|
//!@todo compute transitive closure
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Preprocess after system compilation
|
||||||
|
void
|
||||||
|
preprocess (const System sys)
|
||||||
|
{
|
||||||
|
compute_prec_sets(sys);
|
||||||
|
}
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
#define COMPILER
|
#define COMPILER
|
||||||
|
|
||||||
void compile (System sys, Tac tc, int maxruns);
|
void compile (System sys, Tac tc, int maxruns);
|
||||||
|
void preprocess (const System sys);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -288,6 +288,9 @@ main (int argc, char **argv)
|
|||||||
compile (sys, spdltac, maxruns->ival[0]);
|
compile (sys, spdltac, maxruns->ival[0]);
|
||||||
scanner_cleanup ();
|
scanner_cleanup ();
|
||||||
|
|
||||||
|
/* preprocess */
|
||||||
|
preprocess (sys);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (DEBUGL (1))
|
if (DEBUGL (1))
|
||||||
{
|
{
|
||||||
|
12
src/runs.c
12
src/runs.c
@ -81,6 +81,8 @@ systemInit ()
|
|||||||
sys->untrusted = NULL;
|
sys->untrusted = NULL;
|
||||||
sys->secrets = NULL; // list of claimed secrets
|
sys->secrets = NULL; // list of claimed secrets
|
||||||
sys->attack = NULL;
|
sys->attack = NULL;
|
||||||
|
/* no protocols => no protocol preprocessed */
|
||||||
|
sys->claimlist = NULL;
|
||||||
|
|
||||||
/* matching CLP */
|
/* matching CLP */
|
||||||
sys->constraints = NULL; // no initial constraints
|
sys->constraints = NULL; // no initial constraints
|
||||||
@ -99,12 +101,22 @@ systemInit ()
|
|||||||
void
|
void
|
||||||
systemReset (const System sys)
|
systemReset (const System sys)
|
||||||
{
|
{
|
||||||
|
Claimlist cl;
|
||||||
|
|
||||||
/* some initial counters */
|
/* some initial counters */
|
||||||
sys->statesLow = 0; // number of explored states
|
sys->statesLow = 0; // number of explored states
|
||||||
sys->statesHigh = 0; // this is not as ridiculous as it might seem
|
sys->statesHigh = 0; // this is not as ridiculous as it might seem
|
||||||
sys->explore = 1; // do explore the space
|
sys->explore = 1; // do explore the space
|
||||||
sys->claims = 0; // number of claims encountered
|
sys->claims = 0; // number of claims encountered
|
||||||
sys->failed = 0; // number of failed claims
|
sys->failed = 0; // number of failed claims
|
||||||
|
cl = sys->claimlist;
|
||||||
|
while (cl != NULL)
|
||||||
|
{
|
||||||
|
cl->count = 0;
|
||||||
|
cl->failed = 0;
|
||||||
|
cl = cl->next;
|
||||||
|
}
|
||||||
|
|
||||||
sys->knowPhase = 0; // knowledge transition id
|
sys->knowPhase = 0; // knowledge transition id
|
||||||
|
|
||||||
termlistDestroy (sys->secrets); // remove old secrets list
|
termlistDestroy (sys->secrets); // remove old secrets list
|
||||||
|
24
src/runs.h
24
src/runs.h
@ -2,6 +2,7 @@
|
|||||||
#define RUNS
|
#define RUNS
|
||||||
|
|
||||||
#include "terms.h"
|
#include "terms.h"
|
||||||
|
#include "termmaps.h"
|
||||||
#include "termlists.h"
|
#include "termlists.h"
|
||||||
#include "knowledge.h"
|
#include "knowledge.h"
|
||||||
#include "constraints.h"
|
#include "constraints.h"
|
||||||
@ -154,6 +155,26 @@ struct tracebuf
|
|||||||
Varbuf variables;
|
Varbuf variables;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! The container for the claim info list
|
||||||
|
struct claimlist
|
||||||
|
{
|
||||||
|
//! The term element for this node.
|
||||||
|
Term label;
|
||||||
|
//! The name of the role in which it occurs.
|
||||||
|
Term rolename;
|
||||||
|
//! Number of occurrences in system exploration.
|
||||||
|
int count;
|
||||||
|
//! Number of occurrences that failed.
|
||||||
|
int failed;
|
||||||
|
//! Preceding label list
|
||||||
|
Termlist prec;
|
||||||
|
//! Next node pointer or NULL for the last element of the function.
|
||||||
|
struct claimlist *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Shorthand for claimlist pointers.
|
||||||
|
typedef struct claimlist *Claimlist;
|
||||||
|
|
||||||
//! The main state structure.
|
//! The main state structure.
|
||||||
struct system
|
struct system
|
||||||
{
|
{
|
||||||
@ -206,6 +227,9 @@ struct system
|
|||||||
Termlist variables;
|
Termlist variables;
|
||||||
Termlist untrusted;
|
Termlist untrusted;
|
||||||
|
|
||||||
|
/* protocol preprocessing */
|
||||||
|
Claimlist claimlist;
|
||||||
|
|
||||||
/* constructed trace pointers, static */
|
/* constructed trace pointers, static */
|
||||||
Roledef *traceEvent; // MaxRuns * maxRoledef
|
Roledef *traceEvent; // MaxRuns * maxRoledef
|
||||||
int *traceRun; // MaxRuns * maxRoledef
|
int *traceRun; // MaxRuns * maxRoledef
|
||||||
|
Loading…
Reference in New Issue
Block a user