1% This file is part of the Attempto Parsing Engine (APE).
    2% Copyright 2008-2013, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch).
    3%
    4% The Attempto Parsing Engine (APE) is free software: you can redistribute it and/or modify it
    5% under the terms of the GNU Lesser General Public License as published by the Free Software
    6% Foundation, either version 3 of the License, or (at your option) any later version.
    7%
    8% The Attempto Parsing Engine (APE) is distributed in the hope that it will be useful, but WITHOUT
    9% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   10% PURPOSE. See the GNU Lesser General Public License for more details.
   11%
   12% You should have received a copy of the GNU Lesser General Public License along with the Attempto
   13% Parsing Engine (APE). If not, see http://www.gnu.org/licenses/.
   14
   15
   16:- module(drs_to_sdrs, [drs_to_sdrs/2]).   17
   18:- use_module(drs_ops).

DRS simplifier

Converts the DRS into a simplified form where every DRS-box is represented as a list of conditions, i.e.

drs(Dom, Conds) --> Conds

where Conds is a list of conditions (with sentence IDs).

author
- Kaarel Kaljurand
- Tobias Kuhn
version
- 2009-05-13

*/

 drs_to_sdrs(+Drs:drs, -SDrs:sdrs) is det
Removes the domain-argument from all the (non-atomic) DRS conditions, including the embedded ones.
Arguments:
Drs- is an Attempto DRS
SDrs- is an Attempto DRS with the domain-arguments removed
   46drs_to_sdrs(drs(_, Conds), SConds) :-
   47	conds_sconds(Conds, SConds).
   48
   49
   50conds_sconds([], []).
   51
   52conds_sconds([Cond | Tail], [SCond | STail]) :-
   53	simplify(Cond, SCond),
   54	!,
   55	conds_sconds(Tail, STail).
   56
   57
   58simplify(DRS, SDRS) :-
   59	DRS =.. [Op, drs(_, Conds)],
   60	unary_drs_operator(Op),
   61	conds_sconds(Conds, SConds),
   62	SDRS =.. [Op, SConds].
   63
   64simplify(DRS, SDRS) :-
   65	DRS =.. [Op, drs(_, Conds1), drs(_, Conds2)],
   66	binary_drs_operator(Op),
   67	conds_sconds(Conds1, SConds1),
   68	conds_sconds(Conds2, SConds2),
   69	SDRS =.. [Op, SConds1, SConds2].
   70
   71simplify(Conds, (SConds)) :-
   72	is_list(Conds),
   73	conds_sconds(Conds, SConds).
   74
   75simplify(Label:drs(_, Conds), Label:SConds) :-
   76	conds_sconds(Conds, SConds).
   77
   78simplify(Cond, Cond)