diff --git a/src/knowledge.c b/src/knowledge.c index 69c7533..12fd051 100644 --- a/src/knowledge.c +++ b/src/knowledge.c @@ -383,7 +383,7 @@ knowledgeInversesPrint (Knowledge know) *\sa termlistDelete() */ Termlist -knowledgeSet (Knowledge know) +knowledgeSet (const Knowledge know) { Termlist tl1, tl2; @@ -397,7 +397,7 @@ knowledgeSet (Knowledge know) * Essentially the inverse function of knowledgeSetInverses() */ Termlist -knowledgeGetInverses (Knowledge know) +knowledgeGetInverses (const Knowledge know) { if (know == NULL) return NULL; @@ -405,6 +405,20 @@ knowledgeGetInverses (Knowledge know) return know->inverses; } +//! Get all basic elements in the knowledge +/** + * This function is used by match_basic, to determine all basic elements in the knowledge set. + * Most of the time this doesn't even change, so it might become a parameter of knowledge. + * For now, this will have to do. + * + *@todo Investigate whether the basics in the knowledge set should be a parameter of knowledge, as it doesn't change very often. + */ +__inline__ Termlist +knowledgeGetBasics (const Knowledge know) +{ + return termlistAddBasics (termlistAddBasics(NULL, know->basic), know->encrypt); +} + //! check whether any substitutions where made in a knowledge set. /** * Typically, when a substitution is made, a knowledge set has to be reconstructed. diff --git a/src/knowledge.h b/src/knowledge.h index 5e5378f..ac11252 100644 --- a/src/knowledge.h +++ b/src/knowledge.h @@ -43,8 +43,9 @@ int inKnowledge (const Knowledge know, Term term); void knowledgePrint (Knowledge know); void knowledgeInversesPrint (Knowledge know); int isKnowledgeEqual (Knowledge know1, Knowledge know2); -Termlist knowledgeSet (Knowledge know); -Termlist knowledgeGetInverses (Knowledge know); +Termlist knowledgeSet (const Knowledge know); +Termlist knowledgeGetInverses (const Knowledge know); +Termlist knowledgeGetBasics (const Knowledge know); int knowledgeSubstNeeded (const Knowledge know); Knowledge knowledgeSubstDo (const Knowledge know); void knowledgeSubstUndo (const Knowledge know); diff --git a/src/match_basic.c b/src/match_basic.c index b8c5e50..85c3cad 100644 --- a/src/match_basic.c +++ b/src/match_basic.c @@ -13,20 +13,13 @@ #include "modelchecker.h" #include "match_basic.h" -Termlist +//! Get the candidates list for typeless basic stuff +__inline__ Termlist candidates (const Knowledge know) { - Termlist knowset; - Termlist candlist; - - /* candidates for typeless basic stuff */ - knowset = knowledgeSet (know); - candlist = termlistAddBasics (NULL, knowset); - termlistDelete (knowset); - return candlist; + return knowledgeGetBasics (know); } - struct fvpass { int (*solution) (struct fvpass, Knowledge);