import clingo def dem(options): ctl = clingo.Control(["0", *options]) ctl.add("base", [], "1 { xep(1); xep(2) } 1. { phu }. #show xep/1.") ctl.ground([("base", [])]) hien_thi = [] ctl.solve(on_model=lambda m: hien_thi.append(tuple(sorted(map(str, m.symbols(shown=True)))))) return len(hien_thi), len(set(hien_thi)) assert dem([]) == (4, 2) assert dem(["--project=show"]) == (2, 2) print("Đếm thường", dem([]), "| Đếm sau chiếu", dem(["--project=show"]))