Skip to content

Commit 3522efc

Browse files
committed
Adapt original reif.pl
* predicate_property/2 removed, because it isn't working (mthom#2443) * meta_predicate instruction was split (mthom#2444) * Few changes were adopted from SWI variant[1], because it has similar handling of (:)/2 with predicates in modules. * Scryer specific changes [1]: http://www.complang.tuwien.ac.at/ulrich/Prolog-inedit/swi/reif.pl
1 parent e88851b commit 3522efc

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

src/lib/reif.pl

+27-23
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
tfilter/3,
1212
tpartition/4
1313
%
14-
], [hidden(true)]).
14+
]).
1515
%
1616
%
1717
%
@@ -23,16 +23,16 @@
2323
U. Neumerkel and S. Kral. https://arxiv.org/abs/1607.01590 [cs.PL]. July 2016.
2424
*/
2525

26+
:- use_module(library(dif)).
2627

27-
:- meta_predicate
28-
if_(1, 0, 0),
29-
cond_t(1, 0, ?),
30-
tfilter(2, ?, ?),
31-
tpartition(2, ?, ?, ?),
32-
','(1, 1, ?),
33-
;(1, 1, ?),
34-
tmember(2, ?),
35-
tmember_t(2, ?, ?).
28+
:- meta_predicate(if_(1, 0, 0)).
29+
:- meta_predicate(cond_t(1, 0, ?)).
30+
:- meta_predicate(tfilter(2, ?, ?)).
31+
:- meta_predicate(tpartition(2, ?, ?, ?)).
32+
:- meta_predicate(','(1, 1, ?)).
33+
:- meta_predicate(;(1, 1, ?)).
34+
:- meta_predicate(tmember(2, ?)).
35+
:- meta_predicate(tmember_t(2, ?, ?)).
3636

3737
:- op(900, fy, [$]).
3838

@@ -102,7 +102,7 @@
102102
*/
103103

104104
%
105-
goal_expansion(if_(If_1, Then_0, Else_0), _L0, _M, G_0, []) :-
105+
user:goal_expansion(if_(If_1, Then_0, Else_0), G_0) :-
106106
ugoal_expansion(if_(If_1, Then_0, Else_0), G_0).
107107

108108
%
@@ -117,10 +117,7 @@
117117
%
118118
%
119119
ugoal_expansion(if_(If_1, Then_0, Else_0), Goal_0) :-
120-
subsumes_term(M:(X=Y), If_1),
121-
M:(X=Y) = If_1,
122-
atom(M),
123-
( M == reif -> true ; predicate_property(M: =(_,_,_),imported_from(reif)) ),
120+
nonvar(If_1), If_1 = (X = Y),
124121
goal_expanded(call(Then_0), Thenx_0),
125122
goal_expanded(call(Else_0), Elsex_0),
126123
!,
@@ -130,20 +127,27 @@
130127
; X = Y, Thenx_0
131128
; dif(X,Y), Elsex_0
132129
).
130+
ugoal_expansion(if_(If_1, Then_0, Else_0), Goal) :-
131+
nonvar(If_1), If_1 = dif(X, Y),
132+
goal_expanded(call(Then_0), Thenx_0),
133+
goal_expanded(call(Else_0), Elsex_0),
134+
!,
135+
Goal =
136+
( X \= Y -> Thenx_0
137+
; X == Y -> Elsex_0
138+
; X = Y, Elsex_0
139+
; dif(X,Y), Thenx_0
140+
).
133141
% if_((A_1;B_1), Then_0, Else_0)
134142
% => if_(A_1, Then_0, if_(B_1, Then_0, Else_0))
135143
ugoal_expansion(if_(If_1, Then_0, Else_0), Goal) :-
136-
subsumes_term(M:(A_1;B_1), If_1),
137-
M:(A_1;B_1) = If_1,
138-
atom(M),
139-
( M == reif -> true ; predicate_property(M:;(_,_,_),imported_from(reif)) ),
144+
subsumes_term((A_1;B_1), If_1),
145+
(A_1;B_1) = If_1,
140146
!,
141147
Goal = if_(A_1, Then_0, if_(B_1, Then_0, Else_0)).
142148
ugoal_expansion(if_(If_1, Then_0, Else_0), Goal_0) :-
143-
subsumes_term(M:(A_1,B_1), If_1),
144-
M:(A_1,B_1) = If_1,
145-
atom(M),
146-
( M == reif -> true ; predicate_property(M:','(_,_,_),imported_from(reif)) ),
149+
subsumes_term((A_1,B_1), If_1),
150+
(A_1,B_1) = If_1,
147151
!,
148152
Goal_0 = if_(A_1, if_(B_1, Then_0, Else_0), Else_0).
149153
ugoal_expansion(if_(If_1, Then_0, Else_0), Goal_0) :-

0 commit comments

Comments
 (0)