diff --git a/problems/basket/cond.lp b/problems/basket/cond.lp deleted file mode 100644 index 9f98097..0000000 --- a/problems/basket/cond.lp +++ /dev/null @@ -1,6 +0,0 @@ -person(jane). person(john). -day(mon). day(tue). day(wed). day(thu). day(fri). -available(jane) :- not on(fri). -available(john) :- not on(mon), not on(wed). -meet :- available(X) : person(X). -on(X) : day(X) :- meet. diff --git a/problems/basket/containers.lp b/problems/basket/containers.lp deleted file mode 100644 index 6243fe6..0000000 --- a/problems/basket/containers.lp +++ /dev/null @@ -1,54 +0,0 @@ - -implementation(hashlist). implementation(linkedlist). implementation(treelist). -operation(at). operation(sort). operation(insert). -relation (recommends). relation (satisfied). relation(unsupported). - -relation_score(satisfied, 0). -relation_score(recommends, 1). -relation_score(unsupported, -1). - -relation_op(at, hashlist, recommends). relation_op(at,treelist, satisfied). -relation_op(sort, linkedlist, satisfied). relation_op(sort, treelist, satisfied). relation_op(sort, hashlist, unsupported). - - -impl_fulfill(OP, IMPL, SCORE):- relation_op(OP, IMPL, RL), relation_score(RL, SCORE), operation(OP), implementation(IMPL), RL!=unsupported. -impl_not_fulfill(OP, IMPL):- relation_op(OP, IMPL, unsupported). - - -%static analysis: -var(a).var(b). -bind_var_op(a, at). -bind_var_op(a, sort). -bind_var_op(b, insert). -var_connection(a, b). - -%* var_connection(VAR_FROM, VAR_TO, connection_type) *% -%* var_cluster(VAR_FROM, VAR_TO) *% - -connection_type(ct_inherits). connection_type(ct_convert). - -var_connection(VAR_FROM, VAR_TO, CT):connection_type(CT) :- var_connection(VAR_FROM, VAR_TO). - -var_cluster_root(VAR) :- {var_connection(VAR_F, VAR, ct_inherits): var(VAR_F)} 0, var(VAR). -var_cluster(VAR0, VAR_TO) :- var_connection(VAR0, VAR_TO, ct_inherits), var_cluster_root(VAR0). -var_cluster(VAR0, VAR_TO2) :- var_connection(VAR_TO1, VAR_TO2, ct_inherits), var_cluster(VAR0, VAR_TO1). -var_cluster(VAR0, VAR0):- var_cluster_root(VAR0). - - -#domain implementation(IMPL). -%#domain var(VAR). - -impl_fulfill_cluster(VAR0, OP, IMPL, SCORE) :- var_cluster(VAR0, VAR_ANY), bind_var_op(VAR_ANY, OP), impl_fulfill(OP, IMPL, SCORE), var_cluster_root(VAR0). -impl_not_fulfill_cluster(VAR0, IMPL):-var_cluster(VAR0, VAR_ANY), bind_var_op(VAR_ANY, OP), impl_not_fulfill(OP, IMPL), var_cluster_root(VAR0). -%bind_cluster_op(VAR0, OP) :- bind_var_op(VAR0, OP). -bind_var_impl(VAR0, IMPL, SCORE_RESULT) :- SCORE_RESULT = #sum[impl_fulfill_cluster(VAR0, _, IMPL, SCORE) = SCORE], {impl_not_fulfill_cluster(VAR0, IMPL)}0, var_cluster_root(VAR0). -%:- bind_var_impl(VAR0, IMPL, _), var_cluster(VAR0, VAR_ANY), bind_var_op(VAR_ANY, OP), impl_not_fulfill(OP, IMPL). - -%impl_fulfill(OP, IMPL, SCORE) : bind_var_op(VAR, OP), var(VAR), SCORE_RESULT = 0 , relation_score(_, SCORE). -%%* *% - -#hide. -#show bind_var_impl/3. -#show var_cluster_owner/1. -#show var_connection/3. -#show bind_var_op/2. diff --git a/problems/basket/dependencies.lp b/problems/basket/dependencies.lp deleted file mode 100644 index abbe0c4..0000000 --- a/problems/basket/dependencies.lp +++ /dev/null @@ -1,8 +0,0 @@ -node(a; b; c; d). -depends(b,a). -depends(c,a). -depends(d, a). -depends(d, c). - -level(X, 0) :- not depends(X, _); node(X). -level(X, LEVEL):- LEVEL = #max{L+1, level(Y, L): level(Y, L), depends(X, Y)}; node(X); LEVEL > 0. diff --git a/problems/basket/example-computations.lp b/problems/basket/example-computations.lp deleted file mode 100644 index 4cdd8a3..0000000 --- a/problems/basket/example-computations.lp +++ /dev/null @@ -1,49 +0,0 @@ -%defines: - implementation(hashlist). implementation(linkedlist). implementation(treelist). implementation(computation). - operation(at). operation(sort). operation(insert). operation(seqaccess). - connection_type(ct_inherits). connection_type(ct_convert). - - relation (recommends). relation (satisfied). relation(unsupported). - relation_score(satisfied, 0). - relation_score(recommends, 1). - relation_score(unsupported, -1). - -%integration facts: - relation_op(seqaccess, computation, recommends). - relation_op(at, hashlist, recommends). relation_op(at,treelist, satisfied). - relation_op(sort, linkedlist, satisfied). relation_op(sort, treelist, satisfied). relation_op(sort, hashlist, unsupported). - - - -%static analysis: - var(a).var(tmp2). var(b). var(tmp3). - - var_connection(a, tmp2). - bind_var_op(tmp2, seqaccess). - var_connection(tmp2, b, ct_inherits). - var_connection(b, tmp3). - bind_var_op(tmp3, seqaccess). - -%domain rules: - impl_fulfill(OP, IMPL, SCORE):- relation_op(OP, IMPL, RL), relation_score(RL, SCORE), operation(OP), implementation(IMPL), RL!=unsupported. - impl_not_fulfill(OP, IMPL):- relation_op(OP, IMPL, unsupported). - -%reasoning rules: - { var_connection(VAR_FROM, VAR_TO, CT):connection_type(CT) }1 :- var_connection(VAR_FROM, VAR_TO). - - var_cluster_root(VAR) :- {var_connection(VAR_F, VAR, ct_inherits): var(VAR_F)} 0, var(VAR). - var_cluster(VAR0, VAR_TO) :- var_connection(VAR0, VAR_TO, ct_inherits), var_cluster_root(VAR0). - var_cluster(VAR0, VAR_TO2) :- var_connection(VAR_TO1, VAR_TO2, ct_inherits), var_cluster(VAR0, VAR_TO1). - var_cluster(VAR0, VAR0):- var_cluster_root(VAR0). - - impl_fulfill_cluster(VAR0, OP, IMPL, SCORE) :- var_cluster(VAR0, VAR_ANY), bind_var_op(VAR_ANY, OP), impl_fulfill(OP, IMPL, SCORE), var_cluster_root(VAR0). - impl_not_fulfill_cluster(VAR0, IMPL):-var_cluster(VAR0, VAR_ANY), bind_var_op(VAR_ANY, OP), impl_not_fulfill(OP, IMPL), var_cluster_root(VAR0). - bind_var_impl(VAR0, IMPL, SCORE_RESULT) :- SCORE_RESULT = #sum[impl_fulfill_cluster(VAR0, _, IMPL, SCORE) = SCORE], {impl_not_fulfill_cluster(VAR0, IMPL)}0, var_cluster_root(VAR0), implementation(IMPL). - -%pretty output: - #hide. - #show chosen_impl/2. - #show bind_var_impl/3. - #show var_cluster_owner/1. - #show var_connection/3. - #show bind_var_op/2. diff --git a/problems/basket/example-computations2.lp b/problems/basket/example-computations2.lp deleted file mode 100644 index 7a54272..0000000 --- a/problems/basket/example-computations2.lp +++ /dev/null @@ -1,55 +0,0 @@ -%defines: - implementation(hashlist). implementation(linkedlist). implementation(treelist). implementation(computation). - operation(at). operation(sort). operation(insert). operation(seqaccess). - connection_type(ct_inherits). connection_type(ct_convert). - - relation (recommends). relation (satisfied). relation(unsupported). - relation_score(satisfied, 0). - relation_score(recommends, 1). - relation_score(unsupported, -1). - -%integration facts: - relation_op(seqaccess, computation, recommends). relation_op(seqaccess, hashlist, unsupported). - relation_op(at, hashlist, recommends). relation_op(at,treelist, satisfied). - relation_op(sort, linkedlist, satisfied). relation_op(sort, treelist, satisfied). relation_op(sort, hashlist, unsupported). - - - -%static analysis: - var(a).var(tmp2). var(b). var(tmp3). var(tmp4). - - var_connection(a, tmp2). - bind_var_op(tmp2, seqaccess). - var_connection(tmp2, b). - var_connection(tmp2, b, ct_inherits). - var_connection(b, tmp3). - bind_var_op(tmp3, seqaccess). - bind_var_op(tmp4, sort). - -%domain rules: - impl_fulfill(OP, IMPL, SCORE):- relation_op(OP, IMPL, RL), relation_score(RL, SCORE), operation(OP), implementation(IMPL), RL!=unsupported. - impl_not_fulfill(OP, IMPL):- relation_op(OP, IMPL, unsupported). - impl_avail(VAR, IMPL) :- not impl_not_fulfill(OP, IMPL) : bind_var_op(VAR, OP), var(VAR), implementation(IMPL). - -%reasoning rules: - 1{setup_impl(VAR, IMPL) : implementation(IMPL) }1 :- var(VAR). - :- setup_impl(VAR, IMPL), not impl_avail(VAR, IMPL). - - var_connection(VAR1, VAR2, ct_convert) :- var(VAR1), var(VAR2), var_connection(VAR1, VAR2), setup_impl(VAR1, IMPL1), setup_impl(VAR2, IMPL2), IMPL1 != IMPL2. - :- var(VAR1), var(VAE2), 2{var_connection(VAR1, VAR2, _)} . - - setup_var_impl_fulfill(VAR, SCORE) :- SCORE := #min[impl_fulfill(OP, IMPL, RATE): bind_var_op(VAR, OP) = RATE], var(VAR). - - model_score_convert(SCORE) :- SCORE := #count{var_connection(VAR1, VAR2, ct_convert): var(VAR1) : var(VAR2)}. - model_score_impl(SCORE) :- SCORE:= [setup_var_fulfill(VAR, RATE): var(VAR) = RATE]. - -%pretty output: - #hide. - #show setup_impl/2. - #show model_score/1. - #show setup_var_impl_fulfill/2. - %#show var_connection/3. - %#show bind_var_impl/3. - %#show var_cluster_owner/1. - %#show var_connection/3. - %#show bind_var_op/2. diff --git a/problems/basket/gte.lp b/problems/basket/gte.lp deleted file mode 100644 index a9d9588..0000000 --- a/problems/basket/gte.lp +++ /dev/null @@ -1,3 +0,0 @@ -fact(a). fact(b). fact(8). a<10. - -gezero(X) :- X>=11, fact(X). diff --git a/problems/basket/kitchen.lp b/problems/basket/kitchen.lp deleted file mode 100644 index f9f0fc9..0000000 --- a/problems/basket/kitchen.lp +++ /dev/null @@ -1,13 +0,0 @@ -room(bedroom; diningroom; kitchen). - -%location(bedroom). -door(bedroom, diningroom). -door(diningroom, kitchen). - -{move(A, B)} :- location(A); door(A, B); room(A); room(B). -{move(A, B)} :- move(_, A); door(A, B); room(A); room(B). - -goal:- location(kitchen). -goal:- move(_, kitchen). - -:- not goal. diff --git a/problems/basket/test-list.lp b/problems/basket/test-list.lp deleted file mode 100644 index 6063a16..0000000 --- a/problems/basket/test-list.lp +++ /dev/null @@ -1,7 +0,0 @@ -% WORKING WITH TUPLES POSSIBILITY TESTING - -eqq(x, (0, 0)). -eqq(y, (1, 1)). -iszerosum(X, Y) :- X1 == Y1, X2 == Y2, eqq(X, (X1, X2)), eqq(Y, (Y1, Y2)). - -%plus(X, Y) :- eq(X, (ax, ay)), eq(Y, (bx, by)), ax + ay + bx + by. \ No newline at end of file diff --git a/problems/basket/test.lp b/problems/basket/test.lp deleted file mode 100644 index 8c8a729..0000000 --- a/problems/basket/test.lp +++ /dev/null @@ -1,12 +0,0 @@ -% p(1..3). q(2..4). -% { r(X): p(X), r(X): q(X) }. -% s :- #sum { r(X)=X: p(X): q(X) } 1. - -%p(1..50). -%count(X, Y):- Y = #sum {Z, Z: p(Z), Z >= X}, p(X). - -p(1..3). -2 {q(X) : p(X)}. -q(2). -:- not q(3). -:~ p(X), not q(X).[X] \ No newline at end of file diff --git a/problems/basket/timetable-tests.lp b/problems/basket/timetable-tests.lp deleted file mode 100644 index 32dcea6..0000000 --- a/problems/basket/timetable-tests.lp +++ /dev/null @@ -1,54 +0,0 @@ -man(brian; joe; chris; bob). -professor(brian; joe). -phd(chris). -asisstant(bob). - -lesson(1..10). -day(1..5). -week(even; odd). - -course(a;b;c;d;e;f;j;h;k;l;m;n). - -time(a, 10). -time(b, 12). -time(c, 20). -time(d, 3). -time(e, 17). -time(f, 15). -time(j, 9). -time(h, 7). -time(k, 11). -time(l, 14). -time(m, 8). -time(n, 17). - -room(402; 403; 404). - -course_room(a, 402). -course_room(c, 404). -course_room(d, 403). -course_room(d, 404). - -% ---- timetable(Teacher, Course, Lesson, Room, Day, Week) - - - - timetable(brian, a, 1, 402, 1, even). - timetable(brian, a, 3, 402, 1, even). - timetable(brian, a, 4, 402, 1, even). - - owl(joe) % no first lesson - :- owl(T); timetable(T, _, 1,_, _, _). - -earlybird(bob). -earlybird_score(T, Score) :- Score = #count {timetable(T, C, 1, R, D, W): course(C), room(R), day(D), week(W)}; earlybird(T) . -earlybird_score(Score) :- Score = #sum{Score2, 1: earlybird_score(T, Score2)}. -:- earlybird_score(X); X<2. - - -courseDuration(C, Span) :- Span = #count{(T, C, L, R, D, W):timetable(T, C, L, R, D, W), man(T), room(R), day(D), week(W), lesson(L)};course(C). - - - - -#show courseDuration/2. \ No newline at end of file diff --git a/problems/basket/timetable.lp b/problems/basket/timetable.lp deleted file mode 100644 index 7b0b924..0000000 --- a/problems/basket/timetable.lp +++ /dev/null @@ -1,73 +0,0 @@ -man(brian; joe; chris; bob). -professor(brian; joe). -phd(chris). -asisstant(bob). - -lesson(1..10). -day(1..5). -week(even; odd). - -course(a;b;c;d;e;f;j;h;k;l;m;n). - -time(a, 10). -time(b, 12). -time(c, 20). -time(d, 3). -time(e, 17). -time(f, 15). -time(j, 9). -time(h, 7). -time(k, 11). -time(l, 14). -time(m, 8). -time(n, 17). - -room(402; 403; 404). - -course_room(a, 402). -course_room(c, 404). -course_room(d, 403). -course_room(d, 404). - -% ---- timetable(Teacher, Course, Lesson, Room, Day, Week) - - {timetable(T, C, L, R, D, W) : lesson(L), room(R), course_assignment(T, C)} 4 :- man(T) ; day(D); week(W) . - :- timetable(T, C1, L, _, D, W); timetable(T, C2, L, _, D, W); C1 != C2. - :- timetable(T, _, L, R1, D, W); timetable(T, _, L, R2, D, W); R1 != R2. - :- timetable(T1, _, L, R, D, W); timetable(T2, _, L, R, D, W); T1 != T2. - - courseDuration(C, Span) :- Span = #count{(T, C, L, R, D, W):timetable(T, C, L, R, D, W), man(T), room(R), day(D), week(W), lesson(L)};course(C). - :- courseDuration(C, Dur); time(C, Time); Dur > Time + 10; course(C). - :- courseDuration(C, Dur); time(C, Time); Dur < Time - 10; course(C). - - %COURSE ASSIGNMENT -1{course_assignment(T, C): man(T)}1 :- course(C). - - % FIRST LESSONS ATTENDANCE, EARLY BIRDS, OWLS -owl(joe) % no first lesson -:- owl(T); timetable(T, _, 1,_, _, _). - -earlybird(bob). -earlybird_score(T, Score) :- Score = #count {timetable(T, C, 1, R, D, W): course(C), room(R), day(D), week(W)}; earlybird(T) . -earlybird_score(Score) :- Score = #sum{Score2, 1: earlybird_score(T, Score2)}. - - % CONSEQUENT LESSONS REQUIREMENTS -noholes(brian; joe). % consequent lessons -maxlesson(T, D, W, Max) :- Max = #max{L, 1: timetable(T, C, L, R, D, W), course(C), lesson(L), room(R)};day(D); week(W); noholes(T); timetable(T,_,_,_,D,W). -minlesson(T, D, W, Min) :- Min = #min{L, 1:timetable(T, C, L, R, D, W), course(C), lesson(L), room(R)};day(D); week(W); noholes(T);timetable(T,_,_,_,D,W). -numlessons(T, D, W, Nu) :- Nu = #count{L:timetable(T, C, L, R, D, W), course(C), lesson(L), room(R)};day(D); week(W); noholes(T);timetable(T,_,_,_,D,W). -noholes_score_neg(T, D, W, Score) :- Score = (1 + M1 - M2 - Num); maxlesson(T, D, W, M1); minlesson(T, D, W, M2); numlessons(T, D, W, Num); day(D); week(W); noholes(T). - - %ATTENDANCE -%scheme: attends(Man, Day, Week). -attends(chris, 1, even). % days he can attend -%:-timetable(T, _, _, _, D, W); not attends(T, D, W). - - -%spike(brian; bob). %spike load all in one day -%steady(chris). % load the same in all days - - -%order(e, k). -%order(a, n). -#show timetable/6. \ No newline at end of file diff --git a/problems/code-bugs.lp b/problems/code-bugs.lp deleted file mode 100644 index a90de4f..0000000 --- a/problems/code-bugs.lp +++ /dev/null @@ -1,12 +0,0 @@ -tag(fun1, bug(1)). -tag(fun2, bug(2)). - - -call(fun1, fun2). - - -warning(X, Y, no):- call(X, Y), tag(Y, bug(Z)), not tag(X, bug(Z)), no=Z. -%:- call(X, Y), tag(Y, bug(Z)), not tag(X, bug(Z)). - - -%#show warning/3. \ No newline at end of file diff --git a/problems/code-containers-impl.lp b/problems/code-containers-impl.lp deleted file mode 100644 index fb5941d..0000000 --- a/problems/code-containers-impl.lp +++ /dev/null @@ -1,50 +0,0 @@ -%defines - impl(llvm_array; llvm_const_array; on_the_fly). - op(seqaccess). op(randaccess). - - relation(recommends; satisfied; unsupported). - relation_score(satisfied, 0). - relation_score(recommends, 1). - relation_score(unsupported, -1). - score(-1..1). - -%domain facts: - relation_op(seqaccess, on_the_fly, recommends). - relation_op(randaccess, llvm_const_array, recommends). - relation_op(randaccess, on_the_fly, unsupported). - -%dfa analysis: - dfa_connection((5,0),(4,0),strong). - v((5,0)). %c c = b : [num]; - v((3,0)). %a2 a2 = [1 .. 100] : [num]; - v((4,0)). %b b = loop map (a1 -> el: num) : [num] - v((2,0)). %a1 a1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] : [num]; - -%compilation: - bind((5,0), op(randaccess)). - bind((4,0),impl(llvm_array)). - bind((3,0),impl(on_the_fly)). - bind((3,0),op(seqaccess)). - bind((2,0),op(seqaccess)). - bind((2,0),impl(llvm_const_array)). - -%domain rules: - -impl_fulfill(OP, IMPL) :- relation_op(OP, IMPL, unsupported). - impl_fulfill(OP, IMPL, SCORE):- SCORE = #sum{SCORE1, (OP, IMPL, RL): relation_op(OP, IMPL, RL),relation_score(RL, SCORE1)} - ; op(OP); impl(IMPL); not -impl_fulfill(OP, IMPL). - - cluster_root(VAR) :- not dfa_connection(VAR, _, strong), v(VAR). - var_cluster(VAR0, VAR_TO) :- dfa_connection(VAR_TO, VAR0, strong), cluster_root(VAR0). - var_cluster(VAR0, VAR_TO2) :- dfa_connection(VAR_TO2, VAR_TO1, strong), var_cluster(VAR0, VAR_TO1). - var_cluster(VAR0, VAR0):- cluster_root(VAR0). - - -impl_fulfill_cluster(Var0, Impl) :- var_cluster(Var0, Var_Any); bind(Var_Any, op(Op)); -impl_fulfill(Op, Impl). - impl_fulfill_cluster(VAR0, IMPL, Score) :- - Score = #sum{SCORE, (OP, IMPL, VAR_ANY): impl_fulfill(OP, IMPL, SCORE), var_cluster(VAR0, VAR_ANY), bind(VAR_ANY, op(OP))} - ; bind(VAR0, impl(IMPL)); cluster_root(VAR0); not -impl_fulfill_cluster(VAR0, IMPL). - -%optimization: -% #maximize {SCORE, (VAR0, IMPL) : impl_fulfill_cluster(VAR0, IMPL, SCORE)}. - -#show var_cluster/2. -#show impl_fulfill_cluster/3. \ No newline at end of file diff --git a/problems/unsafe-code.lp b/problems/unsafe-code.lp deleted file mode 100644 index 82d0b44..0000000 --- a/problems/unsafe-code.lp +++ /dev/null @@ -1,10 +0,0 @@ -%Static analysis: CFG -function(testfunc3) . -function(testfunc2) . -call(testfunc2, testfunc3) . - -%Function tags: -tag(testfunc3, unsafe). -%tag(testfunc2, unsafe). - -:- call(X, Y), tag(Y, unsafe), not tag(X, unsafe), function(X), function(Y). \ No newline at end of file