GITLAB

Francisco Coelho / zugzwang

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • zugzwang
  • code
  • python
  • api_01.py
  • 808facfe   Main text adapted to beamer Browse Code ยป
    Francisco Coelho
    2022-09-16 16:11:00 +0100  
api_01.py 399 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
from clingo.symbol import Number
from clingo.control import Control

class Context:
    def inc(self, x):
        return Number(x.number + 1)

    def seq(self, x, y):
        return [x, y]

def on_model(m):
    print(m)

ctl = Control()
ctl.add("base", [], """\
p(@inc(10)).
q(@seq(1,2)).
""")

ctl.ground(
    [("base", [])],
    context=Context())

s = ctl.solve(on_model=on_model)

print(dir(s))