1/*  Part of Run-Time Checker for Assertions
    2
    3    Author:        Edison Mera
    4    E-mail:        efmera@gmail.com
    5    WWW:           https://github.com/edisonm/refactor
    6    Copyright (C): 2017, Process Design Center, Breda, The Netherlands.
    7    All rights reserved.
    8
    9    Redistribution and use in source and binary forms, with or without
   10    modification, are permitted provided that the following conditions
   11    are met:
   12
   13    1. Redistributions of source code must retain the above copyright
   14       notice, this list of conditions and the following disclaimer.
   15
   16    2. Redistributions in binary form must reproduce the above copyright
   17       notice, this list of conditions and the following disclaimer in
   18       the documentation and/or other materials provided with the
   19       distribution.
   20
   21    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   22    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   23    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   24    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   25    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   26    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   27    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   28    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   29    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   31    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   32    POSSIBILITY OF SUCH DAMAGE.
   33*/
   34
   35:- module(rtcprops, [acheck/1, acheck/2, acheck/3, no_acheck/1, no_acheck/2]).   36
   37:- use_module(library(assertions)).   38:- use_module(library(metaprops)).   39:- use_module(library(globprops)).   40:- init_expansors.   41
   42:- true comp [functor/3,
   43              predicate_property/2,
   44              current_predicate/2,
   45              (>)/2,
   46              (<)/2,
   47              (>=)/2,
   48              (=<)/2,
   49              (=\=)/2,
   50              (=:=)/2,
   51              (is)/2,
   52              atomic_list_concat/2,
   53              atomic_list_concat/3,
   54              atom_number/2,
   55              atom_codes/2,
   56              sub_atom/5,
   57              maplist/2,
   58              maplist/3,
   59              maplist/4,
   60              maplist/5,
   61              memberchk/2] + no_acheck(rt).
   62
   63:- type acstatus/1.
 acstatus(Status)
Status of the assertion checker for a given property. Valid values are:
   87acstatus(unimplemented).
   88acstatus(incomplete).
   89acstatus(complete).
   90acstatus(unknown).
   91acstatus(exhaustive).
   92acstatus(impossible).
   93
   94:- type ctrt/1.
   95
   96ctrt(ct).
   97ctrt(rt).
   98
   99:- global acheck(T, Status, G) : ctrt * acstatus * callable
  100    # "The ~w assertion check of ~w has the status ~w."-[T, G, Status].
  101
  102acheck(_, _, Goal) :- call(Goal).
  103
  104:- global acheck(T, G) + equiv(acheck(T, complete, G))
  105   # "Equivalent to acheck(~w, complete, ~w)."-[T, G].
  106
  107acheck(_, Goal) :- call(Goal).
  108
  109:- global acheck(G) + equiv(acheck(ct, acheck(rt, G))).
  110
  111acheck(Goal) :- call(Goal).
  112
  113:- global no_acheck(T, G) + equiv(acheck(T, impossible, G))
  114    # "Declares that the assertion in which this comp property appears must not
  115    be checked at compile-time/run-time.".
  116
  117no_acheck(_, Goal) :- call(Goal).
  118
  119:- global no_acheck(G) + equiv(noacheck(ct, noacheck(rt, G))).
  120
  121no_acheck(Goal) :- call(Goal)