public void removeComponent(Component c) {
//Go through all the collections it could appear in
if(c instanceof Proposition) {
Proposition p = (Proposition) c;
GdlSentence name = p.getName();
if(basePropositions.containsKey(name)) {
basePropositions.remove(name);
} else if(inputPropositions.containsKey(name)) {
inputPropositions.remove(name);
//The map goes both ways...
Proposition partner = legalInputMap.get(p);
if(partner != null) {
legalInputMap.remove(partner);
legalInputMap.remove(p);
}
} else if(name == GdlPool.getProposition(GdlPool.getConstant("INIT"))) {
throw new RuntimeException("The INIT component cannot be removed. Consider leaving it and ignoring it.");
} else if(name == GdlPool.getProposition(GdlPool.getConstant("terminal"))) {
throw new RuntimeException("The terminal component cannot be removed.");
} else {
for(Set<Proposition> propositions : legalPropositions.values()) {
if(propositions.contains(p)) {
propositions.remove(p);
Proposition partner = legalInputMap.get(p);
if(partner != null) {
legalInputMap.remove(partner);
legalInputMap.remove(p);
}
}