- Fixed --disable-intruder: it now also uses no tupling shortcuts.
This commit is contained in:
parent
a35a618a27
commit
881eccd6be
@ -1193,7 +1193,7 @@ bind_goal_new_m0 (const Binding b)
|
|||||||
Termlist subst;
|
Termlist subst;
|
||||||
|
|
||||||
m0t = tl->term;
|
m0t = tl->term;
|
||||||
subst = termMguTerm (b->term, m0t);
|
subst = termMguTerm (b->term, m0t); //! @todo This needs to be replace by the iterator one, but works for now
|
||||||
if (subst != MGUFAIL)
|
if (subst != MGUFAIL)
|
||||||
{
|
{
|
||||||
int run;
|
int run;
|
||||||
@ -1296,7 +1296,7 @@ bind_goal_new_encrypt (const Binding b)
|
|||||||
{
|
{
|
||||||
Term t1, t2;
|
Term t1, t2;
|
||||||
|
|
||||||
if (!realTermEncrypt (term))
|
if (switches.intruder && (!realTermEncrypt (term)))
|
||||||
{
|
{
|
||||||
// tuple construction
|
// tuple construction
|
||||||
error ("Goal that is a tuple should not occur!");
|
error ("Goal that is a tuple should not occur!");
|
||||||
@ -1407,20 +1407,21 @@ bind_goal_regular_run (const Binding b)
|
|||||||
int flag;
|
int flag;
|
||||||
int found;
|
int found;
|
||||||
|
|
||||||
int test_sub_unification (Termlist substlist, Termlist keylist)
|
|
||||||
{
|
|
||||||
// A unification exists; return the signal
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* This is a local function so we have access to goal
|
* This is a local function so we have access to goal
|
||||||
*/
|
*/
|
||||||
int bind_this_role_send (Protocol p, Role r, Roledef rd, int index)
|
int bind_this_role_send (Protocol p, Role r, Roledef rd, int index)
|
||||||
{
|
{
|
||||||
|
int test_sub_unification (Termlist substlist, Termlist keylist)
|
||||||
|
{
|
||||||
|
// A unification exists; return the signal
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (p == INTRUDER)
|
if (p == INTRUDER)
|
||||||
{
|
{
|
||||||
// No intruder roles here
|
// No intruder roles here
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for interm unification
|
// Test for interm unification
|
||||||
@ -1437,9 +1438,8 @@ bind_goal_regular_run (const Binding b)
|
|||||||
eprintf (", index %i\n", index);
|
eprintf (", index %i\n", index);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!termMguSubTerm
|
if (!subtermUnify
|
||||||
(b->term, rd->message, test_sub_unification, sys->know->inverses,
|
(rd->message, b->term, NULL, NULL, test_sub_unification))
|
||||||
NULL))
|
|
||||||
{
|
{
|
||||||
int sflag;
|
int sflag;
|
||||||
|
|
||||||
@ -1482,7 +1482,7 @@ bind_goal_regular_run (const Binding b)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2004,24 +2004,30 @@ select_tuple_goal ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Main recursive procedure for Arachne
|
//! Iterate a binding
|
||||||
|
/**
|
||||||
|
* For DY model, we unfold any tuples first, otherwise we skip that.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
iterate ()
|
iterateOneBinding (void)
|
||||||
{
|
|
||||||
int flag;
|
|
||||||
|
|
||||||
|
|
||||||
flag = 1;
|
|
||||||
if (!prune_theorems (sys))
|
|
||||||
{
|
|
||||||
if (!prune_claim_specifics (sys))
|
|
||||||
{
|
|
||||||
if (!prune_bounds (sys))
|
|
||||||
{
|
{
|
||||||
Binding btup;
|
Binding btup;
|
||||||
|
int flag;
|
||||||
|
|
||||||
|
// marker
|
||||||
|
flag = true;
|
||||||
|
|
||||||
// Are there any tuple goals?
|
// Are there any tuple goals?
|
||||||
|
if (switches.intruder)
|
||||||
|
{
|
||||||
|
// Maybe... (well, test)
|
||||||
btup = select_tuple_goal ();
|
btup = select_tuple_goal ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No, there are non that need to be expanded (no intruder)
|
||||||
|
btup = NULL;
|
||||||
|
}
|
||||||
if (btup != NULL)
|
if (btup != NULL)
|
||||||
{
|
{
|
||||||
/* Substitution or something resulted in a tuple goal: we immediately split them into compounds.
|
/* Substitution or something resulted in a tuple goal: we immediately split them into compounds.
|
||||||
@ -2101,6 +2107,25 @@ iterate ()
|
|||||||
flag = bind_goal_all_options (b);
|
flag = bind_goal_all_options (b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Main recursive procedure for Arachne
|
||||||
|
int
|
||||||
|
iterate ()
|
||||||
|
{
|
||||||
|
int flag;
|
||||||
|
|
||||||
|
|
||||||
|
flag = 1;
|
||||||
|
if (!prune_theorems (sys))
|
||||||
|
{
|
||||||
|
if (!prune_claim_specifics (sys))
|
||||||
|
{
|
||||||
|
if (!prune_bounds (sys))
|
||||||
|
{
|
||||||
|
// Go and pick a binding for iteration
|
||||||
|
flag = iterateOneBinding ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -234,8 +234,9 @@ goal_add (Term term, const int run, const int ev, const int level)
|
|||||||
error
|
error
|
||||||
("Trying to add a goal for an event that is not in the semistate yet.");
|
("Trying to add a goal for an event that is not in the semistate yet.");
|
||||||
#endif
|
#endif
|
||||||
if (realTermTuple (term))
|
if (switches.intruder && realTermTuple (term))
|
||||||
{
|
{
|
||||||
|
// Only split if there is an intruder
|
||||||
return goal_add (TermOp1 (term), run, ev, level) +
|
return goal_add (TermOp1 (term), run, ev, level) +
|
||||||
goal_add (TermOp2 (term), run, ev, level);
|
goal_add (TermOp2 (term), run, ev, level);
|
||||||
}
|
}
|
||||||
@ -459,7 +460,16 @@ unique_origination ()
|
|||||||
{
|
{
|
||||||
Termlist terms2, sharedterms;
|
Termlist terms2, sharedterms;
|
||||||
|
|
||||||
|
if (switches.intruder)
|
||||||
|
{
|
||||||
|
// For intruder we work with sets here
|
||||||
terms2 = tuple_to_termlist (b2->term);
|
terms2 = tuple_to_termlist (b2->term);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// For regular agents we use terms
|
||||||
|
terms2 = termlistAdd (NULL, b2->term);
|
||||||
|
}
|
||||||
sharedterms = termlistConjunct (terms, terms2);
|
sharedterms = termlistConjunct (terms, terms2);
|
||||||
|
|
||||||
// Compare terms
|
// Compare terms
|
||||||
@ -529,11 +539,22 @@ bindings_c_minimal ()
|
|||||||
{
|
{
|
||||||
// this node is *before* the from node
|
// this node is *before* the from node
|
||||||
Roledef rd;
|
Roledef rd;
|
||||||
|
int occursthere;
|
||||||
|
|
||||||
rd = roledef_shift (sys->runs[run].start, ev);
|
rd = roledef_shift (sys->runs[run].start, ev);
|
||||||
if (termInTerm (rd->message, b->term))
|
if (switches.intruder)
|
||||||
{
|
{
|
||||||
// This term already occurs as interm in a previous node!
|
// intruder: interm bindings should cater for the first occurrence
|
||||||
|
occursthere = termInTerm (rd->message, b->term);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// no intruder, then simple test
|
||||||
|
occursthere = isTermEqual (rd->message, b->term);
|
||||||
|
}
|
||||||
|
if (occursthere)
|
||||||
|
{
|
||||||
|
// This term already occurs in a previous node!
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (DEBUGL (4))
|
if (DEBUGL (4))
|
||||||
{
|
{
|
||||||
|
34
src/mgu.c
34
src/mgu.c
@ -7,6 +7,7 @@
|
|||||||
#include "type.h"
|
#include "type.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "specialterm.h"
|
#include "specialterm.h"
|
||||||
|
#include "switches.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Most General Unifier
|
Most General Unifier
|
||||||
@ -123,15 +124,12 @@ termlistSubstReset (Termlist tl)
|
|||||||
int
|
int
|
||||||
unify (Term t1, Term t2, Termlist tl, int (*callback) (Termlist))
|
unify (Term t1, Term t2, Termlist tl, int (*callback) (Termlist))
|
||||||
{
|
{
|
||||||
int proceed;
|
|
||||||
|
|
||||||
proceed = true;
|
|
||||||
/* added for speed */
|
/* added for speed */
|
||||||
t1 = deVar (t1);
|
t1 = deVar (t1);
|
||||||
t2 = deVar (t2);
|
t2 = deVar (t2);
|
||||||
if (t1 == t2)
|
if (t1 == t2)
|
||||||
{
|
{
|
||||||
return proceed && callback (tl);
|
return callback (tl);
|
||||||
}
|
}
|
||||||
|
|
||||||
int callsubst (Termlist tl, Term t, Term tsubst)
|
int callsubst (Termlist tl, Term t, Term tsubst)
|
||||||
@ -155,12 +153,12 @@ unify (Term t1, Term t2, Termlist tl, int (*callback) (Termlist))
|
|||||||
if (isTermEqual (t1, t2))
|
if (isTermEqual (t1, t2))
|
||||||
{
|
{
|
||||||
// Equal!
|
// Equal!
|
||||||
return proceed && callback (tl);
|
return callback (tl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Can never be fixed, no variables
|
// Can never be fixed, no variables
|
||||||
return proceed;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +186,7 @@ unify (Term t1, Term t2, Termlist tl, int (*callback) (Termlist))
|
|||||||
t1 = t2;
|
t1 = t2;
|
||||||
t2 = t3;
|
t2 = t3;
|
||||||
}
|
}
|
||||||
return proceed && callsubst (tl, t1, t2);
|
return callsubst (tl, t1, t2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* symmetrical tests for single variable.
|
/* symmetrical tests for single variable.
|
||||||
@ -197,25 +195,25 @@ unify (Term t1, Term t2, Termlist tl, int (*callback) (Termlist))
|
|||||||
if (realTermVariable (t2))
|
if (realTermVariable (t2))
|
||||||
{
|
{
|
||||||
if (termSubTerm (t1, t2) || !goodsubst (t2, t1))
|
if (termSubTerm (t1, t2) || !goodsubst (t2, t1))
|
||||||
return proceed;
|
return true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return proceed && callsubst (tl, t2, t1);
|
return callsubst (tl, t2, t1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (realTermVariable (t1))
|
if (realTermVariable (t1))
|
||||||
{
|
{
|
||||||
if (termSubTerm (t2, t1) || !goodsubst (t1, t2))
|
if (termSubTerm (t2, t1) || !goodsubst (t1, t2))
|
||||||
return proceed;
|
return true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return proceed && callsubst (tl, t1, t2);
|
return callsubst (tl, t1, t2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* left & right are compounds with variables */
|
/* left & right are compounds with variables */
|
||||||
if (t1->type != t2->type)
|
if (t1->type != t2->type)
|
||||||
return proceed;
|
return true;
|
||||||
|
|
||||||
/* identical compound types */
|
/* identical compound types */
|
||||||
|
|
||||||
@ -229,8 +227,7 @@ unify (Term t1, Term t2, Termlist tl, int (*callback) (Termlist))
|
|||||||
return unify (TermOp (t1), TermOp (t2), tl, callback);
|
return unify (TermOp (t1), TermOp (t2), tl, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
return proceed
|
return unify (TermKey (t1), TermKey (t2), tl, unify_combined_enc);
|
||||||
&& unify (TermKey (t1), TermKey (t2), tl, unify_combined_enc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tupling second
|
/* tupling second
|
||||||
@ -243,11 +240,10 @@ unify (Term t1, Term t2, Termlist tl, int (*callback) (Termlist))
|
|||||||
// and we try the inner terms
|
// and we try the inner terms
|
||||||
return unify (TermOp2 (t1), TermOp2 (t2), tl, callback);
|
return unify (TermOp2 (t1), TermOp2 (t2), tl, callback);
|
||||||
}
|
}
|
||||||
return proceed
|
return unify (TermOp1 (t1), TermOp1 (t2), tl, unify_combined_tup);
|
||||||
&& unify (TermOp1 (t1), TermOp1 (t2), tl, unify_combined_tup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return proceed;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -286,7 +282,10 @@ subtermUnify (Term tbig, Term tsmall, Termlist tl, Termlist keylist,
|
|||||||
proceed = proceed && unify (tbig, tsmall, tl, keycallback);
|
proceed = proceed && unify (tbig, tsmall, tl, keycallback);
|
||||||
|
|
||||||
// [2/3]: complex
|
// [2/3]: complex
|
||||||
|
if (switches.intruder)
|
||||||
|
{
|
||||||
// 2. interm unification
|
// 2. interm unification
|
||||||
|
// Only if there is an intruder
|
||||||
if (realTermTuple (tbig))
|
if (realTermTuple (tbig))
|
||||||
{
|
{
|
||||||
proceed = proceed
|
proceed = proceed
|
||||||
@ -305,6 +304,7 @@ subtermUnify (Term tbig, Term tsmall, Termlist tl, Termlist keylist,
|
|||||||
// remove last item again
|
// remove last item again
|
||||||
keylist = termlistDelTerm (keylist);
|
keylist = termlistDelTerm (keylist);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return proceed;
|
return proceed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user