% we first allow one to write the building blocks of explanations % area(X, land) means that the object X in the image depicts land in scene, etc % given that it is a region rv(area(X), \[ land:0.3, water:0.7]). rv(linear(X), \[ road:0.1, river:0.4, shore:0.5]). rv(mouth(X,Y), \[ 0:0.5, 1:0.5]). rv(cross(X,Y), flip(0.2)). rv(beside(X,Y), flip(0.1)). rv(source(R), \[ 1:0.5, 0:0.5 ]). rv(petersout(X,Y), flip(0.1)). rv(joins(X,Y), \[ 0:0.5, 1:0.5 ]). rv(loop(X), flip(0.1)). rv(containment(X,Y), \[inside:0.1, outside:0.1, noside:0.8]). area(X,T) :- area(X):=T. linear(X,T) :- linear(X):=T. mouth(X,Y,E) :- mouth(X,Y):=E. docross(X,Y) :- cross(X,Y):=true. dontcross(X,Y) :- cross(X,Y):=false. beside(X,Y) :- beside(X,Y):=true. notbeside(X,Y) :- beside(X,Y):=false. source(R,E) :- source(R):=E. petersout(X,Y) :- petersout(X,Y):=true. doesntpeterout(X,Y) :- petersout(X,Y):=false. joins(X,Y,E) :- joins(X,Y):=E. loop(X) :- loop(X):=true. notloop(X) :- loop(X):=false. inside(X,Y) :- containment(X,Y):=inside. outside(X,Y) :- containment(X,Y):=outside. noside(X,Y) :- containment(X,Y):=noside. % the following give the mappings between image and scene bounds(X, Y) :- linear(X, XT), area(Y, YT), beside(X, Y), possbeside(XT, YT). tee(X, Y, E) :- joins(X, Y, E), linear(X, road). tee(X, Y, E) :- joins(X, Y, E), linear(X, river), linear(Y, road), source(X, E). tee(X, Y, E) :- linear(X, river), canflowto(Y), mouth(X, Y, E). chi(X, Y) :- crossable(X, Y), docross(X, Y). open(X, N) :- linear(X, river), source(X, N). open(X, N) :- linear(X, road), petersout(X, N). closed(X) :- loop(X), loopable(X). interior(X, Y) :- inside(X, Y). exterior(X, Z) :- outside(X, Z), inside(X, Y), linear(X, XT), area(Y, YT), area(Z, ZT), possreg(YT, XT, ZT). % this relies on "inside" being functional. region(X) :- area(X, T). chain(X) :- linear(X, T). % the following gives domain constraints canflowto(X) :- linear(X, river). canflowto(X) :- linear(X, shore). crossable(X, Y) :- linear(X, XT), linear(Y, YT), crosstype(XT, YT). crosstype(road, road). crosstype(road, river). crosstype(river, road). %crosstype(road, shore). %crosstype(shore, road). sourceable(X) :- linear(X, road). sourceable(X) :- linear(X, river). loopable(X) :- linear(X, road). loopable(X) :- linear(X, shore). possreg(land, road, land). possreg(land, shore, water). possreg(water, shore, land). possbeside(road, land). possbeside(river, land). possbeside(shore, land). possbeside(shore, water). % an example query is /* explain(( chain(c1), chain(c2), region(r1), region(r2), tee(c2, c1, 1), bounds(c2, r2), bounds(c1, r1), bounds(c1, r2), exterior(c1, r2) , interior(c1, r1), open(c2, 0), closed(c1) )). */ /* explain(( chain(c1), chain(c2), chain(c3), region(r1), region(r2), tee(c2, c1, 1), bounds(c2, r2), bounds(c1, r1), bounds(c1, r2), exterior(c1, r1), interior(c1, r2) , open(c2, 0), closed(c1), open(c3,0), tee(c3, c2, 1), bounds(c3, r2) )). */ /* explain(( chain(c1), open(c1, 0), open(c1, 1), region(r1), bounds(c1, r1), chain(c2), tee(c2, c1, 0), bounds(c2, r1), chain(c3), open(c3, 1), tee(c2, c3, 1), bounds(c3, r1), region(r2), bounds(c3, r2), chain(c4), open(c4, 0), chi(c3, c4), chi(c4, c3), bounds(c4, r1), bounds(c4, r2), chain(c5), closed(c5), tee(c4, c5, 1), tee(c3, c5, 0), bounds(c5, r1), bounds(c5, r2), region(r3), bounds(c5, r3), interior(c5, r3), exterior(c5, r1), exterior(c5, r2), chain(c6), closed(c6), region(r4), bounds(c6, r3), bounds(c6, r4), interior(c6, r4), exterior(c6, r3) )). */