import haydi as hd


class SyncDLTS(hd.DLTS):

    def __init__(self, delta, actions):
        hd.DLTS.__init__(self, actions)
        self.delta = delta

    def step(self, state, action):
        delta = self.delta
        return frozenset(delta[(s, action)] for s in state)


def is_singleton(s):
    return len(s[0]) == 1


def compute(n_states, n_alphabet):

    def check_automaton(delta):
        lts = SyncDLTS(delta.to_dict(), alphabet)
        result = lts.bfs(init_state, max_steps, return_depth=True) \
            .first(is_singleton).run()
        if result:
            return delta, result[1]

    states = hd.ASet(n_states, "q")
    alphabet = hd.ASet(n_alphabet, "a")

    delta = hd.Mapping(states * alphabet, states)
    init_state = frozenset(states)

    max_steps = (n_states**3 - n_states) / 6
    pipeline = delta.cnfs().map(check_automaton) \
                           .max(lambda x: x[1] if x else 0, size=1)
    result = pipeline.run()
    print(result)


def main():
    compute(4, 2)


if __name__ == "__main__":
    main()

@@ -12,16 +12,57 @@
 i as hd%0A
+from haydi.ext.xenv import ExperimentEnv%0A
 %0A%0Aclass 
@@ -977,22 +977,20 @@
 )%0A    re
-sult =
+turn
  pipelin
@@ -994,59 +994,221 @@
 line
-.ru
+%0A%0A%0AN_SIZE = 5%0AA_SIZE = 2%0A%0A%0Adef mai
 n()
+:
 %0A    
-print(result)%0A%0A%0Adef main():%0A
+env = ExperimentEnv(%22sync%22,%0A                        globals(),%0A                        %5B%22N_SIZE%22, %22A_SIZE%22%5D)%0A    env.parse_args()%0A%0A    results = env.run(%0A   
     
+ 
 compute(
 4, 2
@@ -1207,12 +1207,62 @@
 ute(
-4, 2
+N_SIZE, A_SIZE),%0A        write=True)%0A    print(results
 )%0A%0A%0A

add XEnv to cerny app