<div class="notebook"> <div class="nb-cell markdown" name="md3"> # Formal Argumentation Theory This notebook is based on the [slides](https://users.cs.cf.ac.uk/CaminadaM/publications/IJCAI19_presentation.pdf) of a presentation helt at IJCAI 2019 by Martin Caminada from Cardiff University. The notebook includes the program argue.pl which provides a labeling implemention for argumentation graphs based on Prolog tabling. Interesting in this implementation is that it simply uses the declarative rules from the slide __Argument Labelling__: - Each argument is labelled __in__, __out__ or __undec__ - an argument is __in__ ⟺ - __all its__ attackers are __out__ - an argument is __out__ ⟺ - it __has an__ attacker that is __in__ - an argument is __undec__ ⟺ - __not all__ its attackers are __out__ - __and__ it does __not__ have an attacker that is __in__ </div> <div class="nb-cell html" name="htm1"> <h2>Run examples</h2> <p>Please select a graph and click the <i>play</i> button on the right side of the query</p> <div class="panel panel-default"> <div class="panel-body"> <div class="form-group"> <label>Graph</label> <div class="input-group"> <div class="input-group-btn"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Example <span class="caret"></span></button> <ul class="dropdown-menu"> </ul> </div> <input class="form-control"> </div> </div> </div> </div> <script> // Load examples from the predicate graph/1. notebook.swish() is a wrapper // around new Pengine() that fetches the sources using the same algorithm as // a query cell and set the `application` to `swish`. // notebook.$() is a shorthand for notebook.cell().find(), evaluating to a // jQuery object that matches the objects from the current cell. function loadExamples() { var seen = 0; notebook.$(".dropdown-menu").html(""); notebook.swish({ ask: "graph(Ex, _)", ondata: function(data) { notebook.$(".dropdown-menu").append('<li><a>'+data.Ex+'</li>'); if ( seen++ == 0 ) notebook.$("input").val(data.Ex); } }); } // Load the examples on page load as well as if the user clicks the // dropdown menu, so changes are reflected. loadExamples(); notebook.$(".dropdown-toggle").on("click", loadExamples); // Pass selected examples to the input field. notebook.$(".dropdown-menu").on("click", "li", function(ev) { notebook.$("input").val($(this).text()); }); // If the play button of the "parse" query is clicked, run the query, // binding Sentence to the input string. The function // notebook.bindQuery() takes the name of a query and a // function that collects the arguments and calls the query. notebook.bindQuery("label", function(q) { q.run({GraphS: notebook.$("input").val()}); }); </script> </div> <div class="nb-cell html" name="htm2"> </div> <div class="nb-cell query" name="label"> projection([GraphID, Model, Graph]), name(GraphID, GraphS), time(model(GraphID, Model)), model_graph(GraphID, Model, Graph). </div> <div class="nb-cell markdown" name="md5"> ## Access through SWISH API You can also access the argue.pl program through the [SWISH API](https://github.com/SWI-Prolog/swish/tree/master/client) using various languages. We give a simple example below using the `bash` and `curl` client. ``` $ ./swish-ask.sh --server=https://swish.swi-prolog.org argue.pl Model 'edges_model([a->b,b->a],Model)' Model "[b=out,a=in]" "[b=in,a=out]" "[b=undec,a=undec]" ``` </div> <div class="nb-cell markdown" name="md4"> ## Graph rendering The code below defines model_graph/3, combining the model and graph edges to render an argumentation graph using graphviz. </div> <div class="nb-cell program" data-background="true" name="p4"> :- use_rendering(graphviz). model_graph(GraphID, Model, digraph([rankdir='LR'|Props])) :- graph(GraphID, Edges), maplist(mnode, Model, Nodes), append(Edges, Nodes, Props). mnode(NodeID=in, Node) :- point_node(NodeID, green, Node). mnode(NodeID=out, Node) :- point_node(NodeID, red, Node). mnode(NodeID=undec, Node) :- point_node(NodeID, grey70, Node). point_node(NodeID, Color, node(NodeID, [ shape(circle), style(filled), width(0.15), fixedsize(true), color(Color), fillcolor(Color), label(""), xlabel(NodeID) ])). </div> <div class="nb-cell markdown" name="md1"> ## Example graphs Graphs from http://disco.cs.cf.ac.uk/examples/ </div> <div class="nb-cell program" data-background="true" name="p3"> graph(graph01,[ a->b,a->f,b->c,b->e,b->f, c->d,d->e,d->g,g->h,h->g ]). graph(graph02,[ a->b,b->c,c->e,d->e,e->f, f->e,g->h,h->b,h->g ]). graph(graph03,[ d->b5,d->c5,b5->b4,b5->c4, c5->c4,c5->b4,b4->b3,c4->c3, b3->b2,b3->c3,b3->c2,c3->c2, c3->b3,c3->b2,b2->b1,c2->c1, b1->a,b1->c1,c1->a,c1->b1 ]). graph(graph04,[a->b,b->c,c->d]). graph(graph05,[a->d,d->c,c->b,b->a]). graph(graph06,[a->b,b->c,c->d,d->e,e->b]). graph(graph07,[a->b,b->a,b->c,c->d,d->e,e->c]). graph(graph08,[a->b,a->c,b->a,b->c]). graph(graph09,[ b->a,c->a,d->b,d->f,e->b, f->c,f->d ]). </div> <div class="nb-cell markdown" name="md2"> Graphs from [slides](https://users.cs.cf.ac.uk/CaminadaM/publications/IJCAI19_presentation.pdf) </div> <div class="nb-cell program" data-background="true" name="p2"> graph(1, [ b -> c, c -> b, d -> c, d -> b, c -> a, b -> a ]). graph(2, [ a -> b, b -> a, b -> c, c -> d, d -> e, e -> c ]). </div> <div class="nb-cell markdown" name="md6"> This is a buggy graph from Davide Ceolin. It should have two models, but the valid model where all are unspec is missing. </div> <div class="nb-cell program" data-background="true" name="p5"> graph(bug, [a->c, b->c]). </div> <div class="nb-cell program" data-background="true" name="p1"> :- include(argue). </div> </div>