Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For discussion: improve isConsequences #519

Merged
merged 2 commits into from
Sep 7, 2024
Merged

For discussion: improve isConsequences #519

merged 2 commits into from
Sep 7, 2024

Conversation

BenKaufmann
Copy link
Contributor

No description provided.

@BenKaufmann BenKaufmann requested a review from rkaminsk August 30, 2024 13:11
* Only return True/Unknown for atoms that are relevant to the
  active "projection mode".
@rkaminsk
Copy link
Member

rkaminsk commented Sep 6, 2024

It seems to be working as expected now. Given

a.
b.
c.
{d}.
e :- not d.

#project a.
#project e.

#script (python)

def on_model(m):
    cons = []
    for atom in m.context.symbolic_atoms:
        if m.is_consequence(atom.literal):
            cons.append(atom.symbol)
    print(f"consequences: {' '.join(str(x) for x in cons)}")


def main(ctl):
    prj = set()
    ctl.ground()
    ctl.solve(on_model=on_model)

#end.

the output is

$ clingo project.lp --project 0
clingo version 5.7.2 (3d2f2b6e)
Reading from project.lp
Solving...
consequences: e a
Answer: 1
a b c e
consequences: a
Answer: 2
a b c d
SATISFIABLE

Models       : 2
Calls        : 1
Time         : 0.048s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
CPU Time     : 0.048s

@rkaminsk
Copy link
Member

rkaminsk commented Sep 6, 2024

Should we just merge?

@BenKaufmann
Copy link
Contributor Author

Should we just merge?

Fine with me 👍

@rkaminsk rkaminsk merged commit 332b52b into wip Sep 7, 2024
4 checks passed
@rkaminsk rkaminsk deleted the consequences branch September 7, 2024 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants