- Added keylevels to symbols. This is to help pruning the proofs, for
terms and patterns that do not originate on regular nodes.
This commit is contained in:
parent
98bff1e5e2
commit
0fc008fe33
@ -140,6 +140,9 @@ compile (Tac tc, int maxrunsset)
|
|||||||
/* process the tac */
|
/* process the tac */
|
||||||
tacProcess (tac_root);
|
tacProcess (tac_root);
|
||||||
|
|
||||||
|
/* Clean up keylevels */
|
||||||
|
symbol_fix_keylevels ();
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
levelDone ();
|
levelDone ();
|
||||||
}
|
}
|
||||||
@ -402,6 +405,14 @@ commEvent (int event, Tac tc)
|
|||||||
msg = tacTerm (tacTuple ((trip->next->next)));
|
msg = tacTerm (tacTuple ((trip->next->next)));
|
||||||
cl = NULL;
|
cl = NULL;
|
||||||
|
|
||||||
|
if (event == SEND)
|
||||||
|
{
|
||||||
|
/* set keylevels based on send events */
|
||||||
|
term_set_keylevels (fromrole);
|
||||||
|
term_set_keylevels (torole);
|
||||||
|
term_set_keylevels (msg);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CLAIM:
|
case CLAIM:
|
||||||
/* now parse tuple info */
|
/* now parse tuple info */
|
||||||
|
41
src/symbol.c
41
src/symbol.c
@ -1,8 +1,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
|
#include "debug.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -79,6 +81,7 @@ get_symb (void)
|
|||||||
t->allocnext = symb_alloc;
|
t->allocnext = symb_alloc;
|
||||||
symb_alloc = t;
|
symb_alloc = t;
|
||||||
}
|
}
|
||||||
|
t->keylevel = INT_MAX;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,6 +209,44 @@ symbolSysConst (const char *str)
|
|||||||
return symb;
|
return symb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Fix all the unset keylevels
|
||||||
|
void
|
||||||
|
symbol_fix_keylevels (void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < HASHSIZE; i++)
|
||||||
|
{
|
||||||
|
Symbol sym;
|
||||||
|
|
||||||
|
sym = symbtab[i];
|
||||||
|
while (sym != NULL)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (DEBUGL (5))
|
||||||
|
{
|
||||||
|
eprintf ("Symbol ");
|
||||||
|
symbolPrint (sym);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (sym->keylevel == INT_MAX)
|
||||||
|
{
|
||||||
|
// Nothing currently, this simply does not originate on a strand.
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (DEBUGL (5))
|
||||||
|
{
|
||||||
|
eprintf (" has keylevel %i\n", sym->keylevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
sym = sym->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! Print out according to globalError
|
//! Print out according to globalError
|
||||||
/**
|
/**
|
||||||
* Input is comparable to printf, only depends on globalError. This should be used by any function trying to do output.
|
* Input is comparable to printf, only depends on globalError. This should be used by any function trying to do output.
|
||||||
|
@ -20,6 +20,8 @@ struct symbol
|
|||||||
int type;
|
int type;
|
||||||
//! Line number at which it occurred.
|
//! Line number at which it occurred.
|
||||||
int lineno;
|
int lineno;
|
||||||
|
//! Level of occurrence in role nodes. 0 for as non-key, 1 for key only, 2 for key of key only, etc..
|
||||||
|
int keylevel;
|
||||||
//! Ascii string with name of the symbol.
|
//! Ascii string with name of the symbol.
|
||||||
const char *text;
|
const char *text;
|
||||||
//! Possible next pointer.
|
//! Possible next pointer.
|
||||||
@ -41,6 +43,7 @@ Symbol lookup (const char *s);
|
|||||||
void symbolPrint (const Symbol s);
|
void symbolPrint (const Symbol s);
|
||||||
void symbolPrintAll (void);
|
void symbolPrintAll (void);
|
||||||
Symbol symbolSysConst (const char *str);
|
Symbol symbolSysConst (const char *str);
|
||||||
|
void symbol_fix_keylevels (void);
|
||||||
|
|
||||||
void eprintf (char *fmt, ...);
|
void eprintf (char *fmt, ...);
|
||||||
|
|
||||||
|
72
src/term.c
72
src/term.c
@ -986,20 +986,26 @@ term_iterate_deVar (Term term, int (*leaf) (), int (*nodel) (),
|
|||||||
|
|
||||||
if (realTermTuple (term))
|
if (realTermTuple (term))
|
||||||
flag = flag
|
flag = flag
|
||||||
&& (term_iterate_deVar (term->left.op1, leaf, nodel, nodem, noder));
|
&&
|
||||||
|
(term_iterate_deVar
|
||||||
|
(term->left.op1, leaf, nodel, nodem, noder));
|
||||||
else
|
else
|
||||||
flag = flag
|
flag = flag
|
||||||
&& (term_iterate_deVar (term->left.op, leaf, nodel, nodem, noder));
|
&&
|
||||||
|
(term_iterate_deVar (term->left.op, leaf, nodel, nodem, noder));
|
||||||
|
|
||||||
if (nodem != NULL)
|
if (nodem != NULL)
|
||||||
flag = flag && nodem (term);
|
flag = flag && nodem (term);
|
||||||
|
|
||||||
if (realTermTuple (term))
|
if (realTermTuple (term))
|
||||||
flag = flag
|
flag = flag
|
||||||
&& (term_iterate_deVar (term->left.op1, leaf, nodel, nodem, noder));
|
&&
|
||||||
|
(term_iterate_deVar
|
||||||
|
(term->left.op1, leaf, nodel, nodem, noder));
|
||||||
else
|
else
|
||||||
flag = flag
|
flag = flag
|
||||||
&& (term_iterate_deVar (term->left.op, leaf, nodel, nodem, noder));
|
&&
|
||||||
|
(term_iterate_deVar (term->left.op, leaf, nodel, nodem, noder));
|
||||||
|
|
||||||
if (noder != NULL)
|
if (noder != NULL)
|
||||||
flag = flag && noder (term);
|
flag = flag && noder (term);
|
||||||
@ -1108,8 +1114,7 @@ term_constrain_level (const Term term)
|
|||||||
int structure;
|
int structure;
|
||||||
int flag;
|
int flag;
|
||||||
|
|
||||||
void
|
void tcl_iterate (Term t)
|
||||||
tcl_iterate (Term t)
|
|
||||||
{
|
{
|
||||||
t = deVar (t);
|
t = deVar (t);
|
||||||
structure++;
|
structure++;
|
||||||
@ -1141,3 +1146,58 @@ term_constrain_level (const Term term)
|
|||||||
tcl_iterate (term);
|
tcl_iterate (term);
|
||||||
return ((float) vars / (float) structure);
|
return ((float) vars / (float) structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Adjust the keylevels of the symbols in a term.
|
||||||
|
/**
|
||||||
|
* This is used to scan the roles. For each symbol, this function does the bookkeeping of the keylevels at which they occur.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
term_set_keylevels (const Term term)
|
||||||
|
{
|
||||||
|
void scan_levels (int level, Term t)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (DEBUGL (5))
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
c = 0;
|
||||||
|
while (c < level)
|
||||||
|
{
|
||||||
|
eprintf (" ");
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
eprintf ("Scanning keylevel %i for term ", level);
|
||||||
|
termPrint (t);
|
||||||
|
eprintf ("\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (realTermLeaf (t))
|
||||||
|
{
|
||||||
|
Symbol sym;
|
||||||
|
|
||||||
|
// So, it occurs at 'level' as key. If that is less than known, store.
|
||||||
|
sym = t->left.symb;
|
||||||
|
if (level < sym->keylevel)
|
||||||
|
{
|
||||||
|
// New minimum level
|
||||||
|
sym->keylevel = level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (realTermTuple (t))
|
||||||
|
{
|
||||||
|
scan_levels (level, t->left.op1);
|
||||||
|
scan_levels (level, t->right.op2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scan_levels (level, t->left.op);
|
||||||
|
scan_levels ((level + 1), t->right.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scan_levels (0, term);
|
||||||
|
}
|
||||||
|
@ -177,5 +177,6 @@ int term_iterate_open_leaves (const Term term, int (*func) ());
|
|||||||
void term_rolelocals_are_variables ();
|
void term_rolelocals_are_variables ();
|
||||||
int term_encryption_level (const Term term);
|
int term_encryption_level (const Term term);
|
||||||
float term_constrain_level (const Term term);
|
float term_constrain_level (const Term term);
|
||||||
|
void term_set_keylevels (const Term term);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
- Agent terms must have keylevel 0; enforce this!
|
||||||
- './scyther -a ../spdl/nsl3.spdl --increment-runs' segfaults.
|
- './scyther -a ../spdl/nsl3.spdl --increment-runs' segfaults.
|
||||||
- Select_goal should consider, for singular variables, whether their
|
- Select_goal should consider, for singular variables, whether their
|
||||||
type can be found in M_0. If so, the goal can be ignored.
|
type can be found in M_0. If so, the goal can be ignored.
|
||||||
|
Loading…
Reference in New Issue
Block a user