diff --git a/problems/cond.lp b/problems/cond.lp new file mode 100644 index 0000000..9f98097 --- /dev/null +++ b/problems/cond.lp @@ -0,0 +1,6 @@ +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/containers.lp b/problems/containers.lp new file mode 100644 index 0000000..7c92dc6 --- /dev/null +++ b/problems/containers.lp @@ -0,0 +1,51 @@ + var(a).var(b). +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). + +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/containers.lp~ b/problems/containers.lp~ new file mode 100644 index 0000000..37b2605 --- /dev/null +++ b/problems/containers.lp~ @@ -0,0 +1,51 @@ + var(a).var(b). +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). + +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_ANYm 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/test-list.lp b/problems/test-list.lp new file mode 100644 index 0000000..6063a16 --- /dev/null +++ b/problems/test-list.lp @@ -0,0 +1,7 @@ +% 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/test-list.lp~ b/problems/test-list.lp~ new file mode 100644 index 0000000..2febb6f --- /dev/null +++ b/problems/test-list.lp~ @@ -0,0 +1,8 @@ +%eqqq(a, (0, 1)). +%eqqq(b, (0, 1)). + +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/project/diploma.odt b/project/diploma.odt index 9be0199..e2e7897 100644 Binary files a/project/diploma.odt and b/project/diploma.odt differ