%% s_cars.sp -- SPARC solution to additional exercise for Section 5.5 %% (Indirect Exceptions to Defaults) %% Last Modified: 3/16/14 %% Write a program with consistency restoring rules %% representing the following information: %% "Cars normally work; in rare cases, a car does not work. %% Working cars have working engines. %% The engine of John's car does not work." %% Make sure that your program entails that John's car does not work but %% Mary's car does. %%%%%%%%%%%%%%%%%%%%%%%%%% sorts #person = {mary,john}. #car = {c1,c2}. #engine = e(#car). #thing = #car + #engine. #default = d(#car). %%%%%%%%%%%%%%%%%%%%%%%%%% predicates owns(#person,#car). works(#thing). ab(#default). %%%%%%%%%%%%%%%%%%%%%%%%%% rules works(C) :- #car(C), not ab(d(C)), not -works(C). -works(C) :+ #car(C). works(e(C)) :- #car(C), works(C). owns(john,c1). -works(e(c1)). owns(mary,c2).