;;; -*- Mode: Lisp; Package: STELLA; Syntax: COMMON-LISP; Base: 10 -*- ;;; File implementing the RCC8 (Region Connection Calculus) ;;; Author: University of Southern California ;;; Version: $Id: rcc5.plm,v 1.2 2009/01/15 01:55:05 tar Exp $ ;;;;;;;;;;;;;;;;;;;;;;;;;;;; BEGIN LICENSE BLOCK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; Version: MPL 1.1/GPL 2.0/LGPL 2.1 ; ; ; ; The contents of this file are subject to the Mozilla Public License ; ; Version 1.1 (the "License"); you may not use this file except in ; ; compliance with the License. You may obtain a copy of the License at ; ; http://www.mozilla.org/MPL/ ; ; ; ; Software distributed under the License is distributed on an "AS IS" basis, ; ; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License ; ; for the specific language governing rights and limitations under the ; ; License. ; ; ; ; The Original Code is the PowerLoom KR&R System. ; ; ; ; The Initial Developer of the Original Code is ; ; UNIVERSITY OF SOUTHERN CALIFORNIA, INFORMATION SCIENCES INSTITUTE ; ; 4676 Admiralty Way, Marina Del Rey, California 90292, U.S.A. ; ; ; ; Portions created by the Initial Developer are Copyright (C) 2008 ; ; the Initial Developer. All Rights Reserved. ; ; ; ; Contributor(s): ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END LICENSE BLOCK ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; ;;;; (defmodule "RCC5" :documentation "Module for the Region Connection Calculus 5 (RCC5) relations. $Revision: 1.2 $ Implements DR, PO, PP, PPI relations directly. For EQ the standard PowerLoom equality (=) is used. That means that if equality is desired, one must create the regions using the REGION function, so that they end up being skolems. Examples: (assert (dr (region g0) (region g1))) (assert (pp (region g1) (region g2))) (assert (pp (region g2) (region g3))) (assert (= (region g3) (region g3alt))) (retrieve all (pp (region ?x) (region ?y))) (retrieve all (ppi (region ?x) (region ?y))) (retrieve all (dr (region ?x) (region ?y))) (retrieve all (not (dr (region ?x) (region ?y)))) For more background on the RCC5, consult David A. Randell and Zhan Cui and Anthony Cohn, 'A Spatial Logic Based on Regions and Connection', KR '92. Principles of Knowledge Representation and Reasoning: Proceedings of the Third International Conference, pp. 165-176, 1992. Anthony G. Cohn, Brandon Bennett, John Gooday and Nicholas M. Gotts, 'Representing and Reasoning with Qualitative Spatial Relations About Regions', in Spatial and Temporal Reasoning, Oliviero Stock (ed)., (Kluwer Academic Publishers: Boston), 1997. " :includes ("PL-KERNEL-KB")) (in-module "RCC5") (defconcept geometric-region) (defconcept geometric-region-2d (geometric-region)) (defconcept geometric-region-3d (geometric-region)) (deffunction region ((?x THING)) :-> (?g GEOMETRIC-REGION)) (defrelation dr ((?x geometric-region) (?y geometric-region)) :documentation "DR: Discrete from regions" :axioms (symmetric dr) :=> (and (not (po ?x ?y)) (not (pp ?x ?y)) (not (ppi ?x ?y)) (not (= ?x ?y))) ) (defrelation po ((?x geometric-region) (?y geometric-region)) :documentation "PO: Partially Overlapping regions" :axioms (symmetric po) :=> (and (not (dr ?x ?y)) (not (pp ?x ?y)) (not (ppi ?x ?y)) (not (= ?x ?y))) ) (defrelation pp ((?x geometric-region) (?y geometric-region)) :documentation "PP: Proper Part" :=> (and (not (dr ?x ?y)) (not (po ?x ?y)) (not (ppi ?x ?y)) (not (= ?x ?y))) ) (defrelation ppi ((?x geometric-region) (?y geometric-region)) :documentation "PPI: Proper Part Inverse" :<=> (pp ?y ?x) ; INVERSE, but want it for backward chaining :inverse pp :=> (and (not (dr ?x ?y)) (not (po ?x ?y)) (not (pp ?x ?y)) (not (= ?x ?y))) ) ;; Coverage axiom. #| ;; Disable for now, since we don't do reasoning by cases. (assert (=> (and (geometric-region ?x) (geometric-region ?y)) (or (dr ?x ?y) (po ?x ?y) (pp ?x ?y) (ppi ?x ?y) (= ?x ?y)))) |# ;; Unambiguous composition rules. (assert (=> (and (dr ?x ?y) (pp ?y ?z)) (dr ?x ?z))) (assert (=> (and (pp ?x ?y) (pp ?y ?z)) (pp ?x ?z))) (assert (=> (and (ppi ?x ?y) (ppi ?y ?z)) (ppi ?x ?z))) (assert (=> (and (ppi ?x ?y) (dr ?y ?z)) (dr ?x ?z))) #| ;;; TESTS (assert (and (pp (region g1) (region g2)) (pp (region g2) (region g3)))) (ask (ppi (region g3) (region g2))) ; => true (ask (dr (region g2) (region g3))) ; => false (retrieve all (pp ?x ?y)) ; ?x = g2, ?y = g3 ; ?x = g1, ?y = g3 (assert (dr (region g0) (region g1))) (retrieve all (dr ?x ?y)) (retrieve all (dr (region ?x) (region ?y))) (retrieve all (not (dr ?x ?y))) |#