Logic Coordination Language
The Fact Space model provides applications with a logic coordination language to cherry pick the relevant context information from the federated fact space. For instance, consider a cellular phone that wants to adapt its sound profile according to its current location. First of all, such an application would contain a set of preferences which detail which sound profile needs to be adopted in various room types. In the example application shown below, these preferences are encoded as facts published in the private fact space.
preference(meetingRoom, silent).
preference(office, default).
:Switch(?profile) :-
location -> detected(myID, ?room),
preference(?room, ?profile).
Subsequently, a Crime rule is defined which has two preconditions. First of all, it requires that there is a detected fact in a public fact space (named location), which denotes that the cellular phone is located in a room of a particular kind. The kind of room will be bound to the logic variable ?room. Additionally, a preference should be defined which determines the sound profile to be adopted for the given kind of room. When both conditions are met, the profile to adopt will be bound to the logic variable ?profile and the rule will be triggered. When the rule is triggered, it will invoke the application-specific action :Switch to ensure the cellular phone adopts the correct sound profile. Applications can supply application-level actions (such as :Switch) by providing a Java class which implements the Action interface. Such classes need to implement two methods: First of all, the activate method which is invoked whenever a rule is triggered which lists the action in its rule head. Second, the deactivate method which is invoked when one of the facts that caused the rule to trigger is retracted. In the example, the deactivate method can be used to make the cellular adopt a loud sound profile.