![JAR search and dependency download from the Maven repository](/logo.png)
org.ggp.base.util.prover.logging.KnowledgeBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alloy-ggp-base Show documentation
Show all versions of alloy-ggp-base Show documentation
A modified version of the GGP-Base library for Alloy.
The newest version!
package org.ggp.base.util.prover.logging;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.ggp.base.util.gdl.grammar.Gdl;
import org.ggp.base.util.gdl.grammar.GdlConstant;
import org.ggp.base.util.gdl.grammar.GdlPool;
import org.ggp.base.util.gdl.grammar.GdlRule;
import org.ggp.base.util.gdl.grammar.GdlSentence;
public final class KnowledgeBase
{
private final Map> contents;
public KnowledgeBase(Set extends Gdl> description)
{
contents = new HashMap>();
for (Gdl gdl : description)
{
GdlRule rule = (gdl instanceof GdlRule) ? (GdlRule) gdl : GdlPool.getRule((GdlSentence) gdl);
GdlConstant key = rule.getHead().getName();
if (!contents.containsKey(key))
{
contents.put(key, new ArrayList());
}
contents.get(key).add(rule);
}
}
public synchronized List fetch(GdlSentence sentence)
{
GdlConstant key = sentence.getName();
if (contents.containsKey(key))
{
return contents.get(key);
}
else
{
return new ArrayList();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy