Skip to content

Foil finding

The process of finding foils is done with a meta-program that interprets the fact representation obtained by the setup construction and searches for a modified version of the reference program that satisfies the query.

This is done with the following programs.

Construct foil candidates

construct-foil.lp

Encoding

Choice rule to allow all removables and addables to be changed

{removed(R)}:-optional(remove, R), program(R, ref).
{added(R)}:-optional(add, R), not program(R, ref).

Assert program nodes

program(N, foil):- program(N, ref), not removed(N).
program(R, foil):- added(R).

Enforce the query atoms appear in the foil model

#defined query/2.
:- query(A,0),  model(A, foil).
:- query(A,1), not model(A, foil).

Define a default cost for each model with level 1 so that there is always some optimization. cost(N, V, L) represents cost with name N, value V and level L.

cost(default, 1, 1).
:~ cost(Name, Value, Level). [Value@Level, Name]

Assert if an atom node appears in some model

some_model(1, A) :- node(A,atom), #count{W: model(A,W)}>=1.
some_model(0, A) :- node(A,atom), #count{W: model(A,W)}<=1.

Assert all rule nodes that derrive an atom that is in some model as fired

fired(R):- node(R, rule(disjunction)), #false : edge((R,A),_);
           some_model(T, A): edge((A,R),T).

Check foil model

This encoding is used in this step with the constant graph=foil to construct the foil model of the candidate foil program.

Info

This same encoding is used to construct the reference model of the reference program with the constant graph=ref.

model-subgraph.lp

Encoding

Provides satisfiability based on the program graph


Similar to the standard ASP semantics encoding, but works on the program graph simplified without the sum bodies.

#const graph=ref.
model(R,graph) :- node(R, rule(_)), program(R, graph),
    model(A,graph) : edge((A,R), 1);
    not model(A,graph) : edge((A,R), 0).
model(A,graph) : edge((R,A), _) :- model(R,graph), node(R, rule(disjunction)).
{ model(A,graph) : edge((R,A), _) } :- model(R,graph), node(R, rule(choice)).
#include "show.lp".
#show solved(graph).

show.lp

Encoding

Node and edge types

#show node/2.
#show edge/2.

Model and program membership

#show program/2.
#show model/2.

Tags

#show tag/2.

Query

#show query/2.

Optional rules (Addable/Removable)

#show optional/2.

Query

#show query/2.
#defined query/2.

So that there is no warning when using it to compute reference models

#show fired/1.
#defined fired/1.