-
Notifications
You must be signed in to change notification settings - Fork 6
/
mdsl.pl
44 lines (36 loc) · 876 Bytes
/
mdsl.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
%
% A meta DSL, or a DSL for DSLs. Ensures knowledge integrity by
% verifying relation correctness.
%
%
% Relation alias facility
%
term_expansion(relation_alias(R,A),E) :-
T1 =.. [A,X,Y],
T2 = relation(R,X,Y),
E = goal_expansion(T1,T2).
%
% Expansion for partonomy operator definitions
%
:- dynamic relation/3.
term_expansion(partonomy_operator(F),[O,E]) :-
O = (:- op(500,xfy,F)),
T1 =.. [F,X,Y],
T2 = relation(F,X,Y),
E = (term_expansion(T1,T2) :-
check_irreflexive(F,X,Y),
check_asymmetric(F,X,Y)).
%
% Auxiliary predicates
%
check_irreflexive(R,X,Y) :-
X = Y ->
throw_error([R, 'must be irreflexive']);
true.
check_asymmetric(R,X,Y) :-
apply(R,[Y,X]) ->
throw_error([R, 'must be asymmetric']);
true.
throw_error(L) :-
concat_atom(L,' ',M),
throw(error(representation_error(M),_)).