1/*****************************************************************************
    2 * This file is part of the Prolog Development Tool (PDT)
    3 * 
    4 * Author: G�nter Kniesel (among others)
    5 * WWW: http://sewiki.iai.uni-bonn.de/research/pdt/start
    6 * Mail: pdt@lists.iai.uni-bonn.de
    7 * Copyright (C): 2004-2012, CS Dept. III, University of Bonn
    8 * 
    9 * All rights reserved. This program is  made available under the terms
   10 * of the Eclipse Public License v1.0 which accompanies this distribution,
   11 * and is available at http://www.eclipse.org/legal/epl-v10.html
   12 * 
   13 ****************************************************************************/
   14
   15 /*
   16   * Assert the fact in arg1 only if it isn't there already. Succeed otherwise.
   17   */
   18:- module(database, [
   19	assert_unique_ground_fact/1, 
   20	assert_unique_fact/1,
   21	assert_unique/1
   22]).   23
   24:- use_module(logging).   25
   26:- module_transparent assert_unique_ground_fact/1, 
   27                      assert_unique_fact/1,
   28                      assert_unique/1.   29                      
   30assert_unique_ground_fact(Head) :-
   31    ( ground(Head)
   32    -> assert_unique_fact(Head)
   33     ; ctc_error('Fact assumed to be ground is not: ~w',[Head])
   34    ). 
   35
   36assert_unique(Head) :- 
   37   assert_unique_fact(Head) .
   38      
   39assert_unique_fact(Head) :-
   40% much slower than not(Head):    ( not(clause(Head,true)) 
   41    ( not(Head) 
   42      -> assert(Head)
   43      ;  true
   44    ).
   45%