package at.ac.tuwien.dbai.alternation.examples;
import java.util.Map;
import java.util.Set;

atm Horn(char goal, Map<Character, Set<Set<Character>>> rules, Set<Character>
         facts) {
char head=goal;
Set<Character> body;
int counter=rules.keySet().size();

    state head{
        // catch cycles
        if (counter<0){
            reject;
        } else {
            counter--;
        }

        if (facts.contains(head)){
            accept;
        } else {
            exists{
                for(Set<Character> rule: rules.get(head)){
                    body{
                        body=rule;
                    }
                }
            }
        }
    }

    state body {
        forall{
            for(Character literal: body){
                head{
                    head=literal;
                }
            }
        }
    }
}