/*----------------------------------------------------------*/ /* Propositonal coverings, generalizations, lgg's */ /*----------------------------------------------------------*/ /* (C) 1998 Zdravko Markov */ /*----------------------------------------------------------*/ /* This file contains a collection of various predicates */ /* implementing covering (subsumption) relations between */ /* examples and hypotheses in propositional and relational */ /* representation. */ /* The attribute-value rerpesentation of the examples is: */ /* [A1=V1,...,An=Vn] for nominal attributes and */ /* [V1,V2,...,Vn] for structural attributes */ /*----------------------------------------------------------*/ /*----------------------------------------------------------*/ /* Attribute-value syntactic covering by dropping condition*/ /* covers(+H1,+H2) */ /*----------------------------------------------------------*/ covers(H1,H2) :- subset(H1,H2). /*----------------------------------------------------------*/ /* Attribute-value genaralization by dropping condition */ /* (genarates all generalizations on backtracking) */ /* generalize(+H1,-H2) */ /*----------------------------------------------------------*/ generalize(H1,H2) :- length(H1,N), template(H2,N), sublist(H2,H1). template(_,0) :- !, fail. template([_],_). template([_|T],N) :- M is N-1, template(T,M). sublist([X],[X|_]). sublist(X,[_|T]) :- sublist(X,T). sublist([X|T],[X|V]) :- sublist(T,V). /*----------------------------------------------------------*/ /* Attribute-value model of a hypothesis */ /* model(+Hypothesis,-Model) */ /*----------------------------------------------------------*/ model(H,M) :- findall(N,(example(N,_,L),covers(H,L)),M). /*----------------------------------------------------------*/ /* Attribute-value semantic covering */ /* sem_covers(+H1,+H2) */ /*----------------------------------------------------------*/ sem_covers(H1,H2) :- model(H1,M1), model(H2,M2), subset(M2,M1). /*----------------------------------------------------------*/ /* Attribute-value least general generalization (lgg) */ /* by dropping condition */ /* lgg(+H1,+H2,-LGG) */ /*----------------------------------------------------------*/ lgg(H1,H2,LGG) :- intersection(H1,H2,LGG). /*----------------------------------------------------------*/ /* Attribute-value sintactic covering by using taxonomies */ /* scoves(+H1,+H2) */ /*----------------------------------------------------------*/ scovers([],[]). scovers([X|T],[Y|L]) :- isa(Y,X), scovers(T,L). /*----------------------------------------------------------*/ /* Attribute-value model for structural attributes */ /* smodel(+Hypothesis,-Model) */ /*----------------------------------------------------------*/ smodel(H,M) :- findall(N,(example(N,_,L),scovers(H,L)),M). /*----------------------------------------------------------*/ /* Attribute-value least general generalization (lgg) */ /* by using taxonomies - son(Child,Parent) */ /* slgg(+H1,+H2,-LGG) */ /*----------------------------------------------------------*/ slgg([],[],[]) . slgg([X|T],[Y|L],[Z|V]) :- lge(X,Y,Z), slgg(T,L,V). /*----------------------------------------------------------*/ /* Auxilliary predicates */ /*----------------------------------------------------------*/ isa(X,X) . isa(X,Y) :- son(X,Z), isa(Z,Y). lge(X1,X2,X1) :- isa(X2,X1), !. lge(X1,X2,L) :- son(X1,F), lge(F,X2,L). subset([],_). subset([X|T],L) :- member(X,L), !, subset(T,L). intersection([],_,[]). intersection([X|T],L,[X|V]) :- member(X,L), !, intersection(T,L,V). intersection([_|T],L,V) :- intersection(T,L,V).