- Repaired a pruning method that still needed a lemma. It was a bit

overzealous and killed a woolam-mutual attack.
This commit is contained in:
ccremers 2005-05-19 14:43:32 +00:00
parent 5ddcbd0fe5
commit 0540b744e2
3 changed files with 116 additions and 22 deletions

View File

@ -52,6 +52,8 @@ Role I_RRS;
Role I_RRSD; Role I_RRSD;
static int indentDepth; static int indentDepth;
static int prevIndentDepth;
static int indentDepthChanges;
static int proofDepth; static int proofDepth;
static int max_encryption_level; static int max_encryption_level;
static int num_regular_runs; static int num_regular_runs;
@ -136,6 +138,10 @@ arachneInit (const System mysys)
num_intruder_runs = 0; num_intruder_runs = 0;
max_encryption_level = 0; max_encryption_level = 0;
indentDepth = 0;
prevIndentDepth = 0;
indentDepthChanges = 0;
return; return;
} }
@ -159,22 +165,23 @@ arachneDone ()
#define isBound(rd) (rd->bound) #define isBound(rd) (rd->bound)
#define length step #define length step
//! Indent print //! Indent prefix print
void void
indentPrint () indentPrefixPrint (const int annotate, const int jumps)
{ {
if (sys->output == ATTACK && globalError == 0) if (sys->output == ATTACK && globalError == 0)
{ {
// Arachne, attack, not an error // Arachne, attack, not an error
// We assume that means DOT output // We assume that means DOT output
eprintf ("// "); eprintf ("// %i\t", annotate);
} }
else else
{ {
// If it is not to stdout, or it is not an attack... // If it is not to stdout, or it is not an attack...
int i; int i;
for (i = 0; i < indentDepth; i++) eprintf ("%i\t", annotate);
for (i = 0; i < jumps; i++)
{ {
if (i % 3 == 0) if (i % 3 == 0)
eprintf ("|"); eprintf ("|");
@ -185,6 +192,35 @@ indentPrint ()
} }
} }
//! Indent print
/**
* More subtle than before. Indentlevel changes now cause a counter to be increased, which is printed. Nice to find stuff in attacks.
*/
void
indentPrint ()
{
if (indentDepth != prevIndentDepth)
{
indentDepthChanges++;
while (indentDepth != prevIndentDepth)
{
if (prevIndentDepth < indentDepth)
{
indentPrefixPrint (indentDepthChanges, prevIndentDepth);
eprintf ("{\n");
prevIndentDepth++;
}
else
{
prevIndentDepth--;
indentPrefixPrint (indentDepthChanges, prevIndentDepth);
eprintf ("}\n");
}
}
}
indentPrefixPrint (indentDepthChanges, indentDepth);
}
//! Print indented binding //! Print indented binding
void void
binding_indent_print (const Binding b, const int flag) binding_indent_print (const Binding b, const int flag)
@ -733,6 +769,7 @@ bind_existing_to_goal (const Binding b, const int run, const int index)
newruns = 0; // New runs introduced newruns = 0; // New runs introduced
smalltermbinding = b; // Start off with destination binding smalltermbinding = b; // Start off with destination binding
indentDepth++;
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (4)) if (DEBUGL (4))
{ {
@ -751,7 +788,7 @@ bind_existing_to_goal (const Binding b, const int run, const int index)
{ {
indentPrint (); indentPrint ();
eprintf eprintf
("This introduces the obligation to decrypted the following encrypted subterms: "); ("This introduces the obligation to decrypt the following encrypted subterms: ");
termlistPrint (cryptlist); termlistPrint (cryptlist);
eprintf ("\n"); eprintf ("\n");
} }
@ -866,6 +903,8 @@ bind_existing_to_goal (const Binding b, const int run, const int index)
newruns--; newruns--;
} }
goal_unbind (b); goal_unbind (b);
indentDepth--;
return flag; return flag;
} }
@ -2399,12 +2438,12 @@ bind_goal_regular_run (const Binding b)
eprintf (", at %i\n", index); eprintf (", at %i\n", index);
} }
indentDepth++; indentDepth++;
// Bind to existing run // Bind to existing run
sflag = bind_existing_run (b, p, r, index); sflag = bind_existing_run (b, p, r, index);
// bind to new run // bind to new run
{ sflag = sflag && bind_new_run (b, p, r, index);
sflag = sflag && bind_new_run (b, p, r, index);
}
indentDepth--; indentDepth--;
return sflag; return sflag;
} }
@ -2627,20 +2666,51 @@ prune_theorems ()
{ {
error ("Agent of run %i is NULL", run); error ("Agent of run %i is NULL", run);
} }
if (!realTermLeaf (agent) /**
|| agent->stype == NULL * Check whether the agent of the run is of a sensible type.
|| (agent->stype != NULL *
&& !inTermlist (agent->stype, TERM_Agent))) * @TODO Note that this still needs a lemma.
{ */
if (sys->output == PROOF) {
{ int sensibleagent;
indentPrint ();
eprintf ("Pruned because the agent "); sensibleagent = true;
termPrint (agent);
eprintf (" of run %i is not of a compatible type.\n", run); if (!realTermLeaf (agent))
} { // not a leaf
return 1; sensibleagent = false;
} }
else
{ // real leaf
if (sys->match == 0 || !isTermVariable (agent))
{ // either strict matching, or not a variable, so we should check matching types
if (agent->stype == NULL)
{ // Too generic
sensibleagent = false;
}
else
{ // Has a type
if (!inTermlist (agent->stype, TERM_Agent))
{ // but not the right type
sensibleagent = false;
}
}
}
}
if (!sensibleagent)
{
if (sys->output == PROOF)
{
indentPrint ();
eprintf ("Pruned because the agent ");
termPrint (agent);
eprintf (" of run %i is not of a compatible type.\n",
run);
}
return 1;
}
}
agl = agl->next; agl = agl->next;
} }
run++; run++;
@ -3274,7 +3344,15 @@ arachne ()
{ {
semiRunDestroy (); semiRunDestroy ();
} }
//! Indent back
indentDepth--; indentDepth--;
if (sys->output == PROOF)
{
indentPrint ();
eprintf ("Proof complete for this claim.\n");
}
} }
// next // next
cl = cl->next; cl = cl->next;

View File

@ -7,5 +7,6 @@ void arachneInit (const System sys);
void arachneDone (); void arachneDone ();
int arachne (); int arachne ();
int get_semitrace_length (); int get_semitrace_length ();
void indentPrint ();
#endif #endif

View File

@ -12,6 +12,7 @@
#include "debug.h" #include "debug.h"
#include "term.h" #include "term.h"
#include "termmap.h" #include "termmap.h"
#include "arachne.h"
#include <malloc.h> #include <malloc.h>
static System sys; static System sys;
@ -771,6 +772,20 @@ bindings_c_minimal ()
if (termInTerm (rd->message, b->term)) if (termInTerm (rd->message, b->term))
{ {
// This term already occurs as interm in a previous node! // This term already occurs as interm in a previous node!
#ifdef DEBUG
if (DEBUGL (4))
{
// Report this
indentPrint ();
eprintf ("Binding for ");
termPrint (b->term);
eprintf
(" at r%i i%i is not c-minimal because it occurred before at r%i i%i in ",
b->run_from, b->ev_from, run, ev);
termPrint (rd->message);
eprintf ("\n");
}
#endif
return 0; return 0;
} }
} }