File: onmodel-lua.lp

package info (click to toggle)
gringo 4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,260 kB
  • ctags: 10,755
  • sloc: cpp: 55,049; python: 629; yacc: 569; sh: 124; makefile: 23
file content (44 lines) | stat: -rw-r--r-- 1,164 bytes parent folder | download
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#script (lua)

Model = gringo.Model

function tostringTable(t) 
    ret   = ""
    comma = False
    for _, elem in pairs(t) do
        if comma then ret = ret .. ", "
        else          comma = true 
        end
        ret = ret .. tostring(elem)
    end
    return ret
end

function main(prg)
    on_model = function (m)
        print("shown")
        print("  positive: " .. tostringTable(m:atoms(Model.SHOWN)))
        print("  negative: " .. tostringTable(m:atoms(Model.SHOWN + Model.COMP)))
        print("csp")
        print("  positive: " .. tostringTable(m:atoms(Model.CSP)))
        print("  negative: " .. tostringTable(m:atoms(Model.CSP + Model.COMP)))
        print("atoms")
        print("  positive: " .. tostringTable(m:atoms(Model.ATOMS)))
        print("  negative: " .. tostringTable(m:atoms(Model.ATOMS + Model.COMP)))
        print("terms")
        print("  positive: " .. tostringTable(m:atoms(Model.TERMS)))
        print("  negative: " .. tostringTable(m:atoms(Model.TERMS + Model.COMP)))
    end
    prg:ground({{"base", {}}})
    prg:solve(nil, on_model)
end

#end.

{a}.
b :- a.
$x $= 1.
$y $= 2.
#show c : a.
#show b/0.
#show $x/0.