Attachment 'Permutation-Pattern-Matching-ENCODING.txt'
Download 1 % Example Input
2 % t(1,5).
3 % t(2,3).
4 % t(3,1).
5 % t(4,4).
6 % t(5,2).
7 % p(1,2).
8 % p(2,3).
9 % p(3,1).
10 % patternlength(3).
11
12 % Guess suitable subsequence
13
14 %1 <= { subt(K,I,E) : t(I,E) } <= 1 :- K=1..L, patternlength(L).
15
16 kval(1).
17 kval(N+1) :- kval(N), N < L, patternlength(L).
18 1 <= { subt(K,I,E) : t(I,E) } <= 1 :- kval(K), patternlength(L).
19 :- subt(K1,I1,_), subt(K2,I2,_), K1<K2, I1 >= I2.
20
21 solution(K,E) :- subt(K,_,E).
22
23 % Check whether the subsequence is a matching
24 :- solution(K1,ET1), solution(K2,ET2), p(K1,EP1), p(K2,EP2), ET1 < ET2, EP1 >= EP2.
Attached Files
You are not allowed to attach a file to this page.