Questions tagged [logical-purity]

Logical purity is the property of logic programs that are written only using Horn clauses.

There are two equally justifiable ways to characterise purity:

The first is based on the intrinsic property of the program being composed of pure predicates. A pure predicate is a true relation, which is logically sound, preserving algebraic laws like commutativity of conjunction.

The second way to characterise purity is based on the operational properties of predicates: Only monotonic (also called: "monotone") predicates are pure: If the predicate succeeds for any arguments, then it does not fail for any generalisation of these arguments, and if it fails for any combination of arguments, then it does not succeed for any specialisation of these arguments.

In addition, pure predicates must not produce side-effects.

Examples of pure predicates are (=)/2, dif/2 and CLP(FD) constraints like (#=)/2. Further examples would be (=)/2 from any E-unification.

57 questions
2
votes
2 answers

prolog doesn't give me a solution when one exists

I am working through Seven Languages in Seven Weeks, but there is something I don't understand about prolog. I have the following program (based on their wallace and grommit program): /* teams.pl */ onTeam(a, aTeam). onTeam(b, aTeam). onTeam(b,…
Alex028502
  • 3,486
  • 2
  • 23
  • 50
2
votes
1 answer

Prolog: remove member of list with non-instantiated values

I want remove all appearences of an element on a list, similar to this, but in my case, the list may have non-instantiated variables. For example: delMember(z, [A,B,A,z], L). L = [A, B, A]; false. and delMember(A, [A, B, A, z], L). L =…
lithiium
  • 647
  • 8
  • 25
2
votes
2 answers

Proper flow control in Prolog without using the non-declarative if-then-else syntax

I would like to check for an arbitrary fact and do something if it is in the knowledge base and something else if it not, but without the ( I -> T ; E)syntax. I have some facts in my knowledge…
2
votes
1 answer

Prolog: redundant program points in failure-slice?

We are implementing diagnostic tools for explaining unexpected universal non-termination in pure, monotonic Prolog programs—based on the concept of the failure-slice. As introduced in the paper "Localizing and explaining reasons for nonterminating…
repeat
  • 18,496
  • 4
  • 54
  • 166
2
votes
3 answers

Order of goals(statements) in Prolog rules

I began to study Prolog recently and faced one strange problem. Here you can see a code example (I use SWI-Prolog 7.2.3) which gives a tree of relationships and my solution of 2 tasks. /* File: ancestors.pl Author: Dave Robertson Purpose:…
2
votes
2 answers

Coroutining in Prolog: when argument is a list (it has fixed length)

Question Is it possible to schedule a goal to be executed as soon as the length of a list is known / fixed or, as @false pointed out in the comments, a given argument becomes a [proper] list? Something along this line: when(fixed_length(L), ... some…
Tudor Berariu
  • 4,910
  • 2
  • 18
  • 29
1
vote
2 answers

Delete from a list the non-duplicated items

I need to do an exercise where I must eliminate the elements of a list that are NOT duplicated, previously I made one to eliminate the elements of a list that ARE duplicated. This is my code to eliminate the elements that ARE duplicated in a list…
1
vote
1 answer

`less/2` relation in Peano arithmetic

This less-than predicate in Peano arithmetic less(0, s(_)). less(s(X), s(Y)) :- less(X, Y). loops when ?- less(X, Y), X=s(0), Y=0. Is there a better way to write less/2 (using Horn clauses only)?
MWB
  • 11,740
  • 6
  • 46
  • 91
1
vote
2 answers

Pure Prolog Peano List Intersection

Assume we are only looking at lists of Peano numbers. And lets assume pure_2 Prolog is not pure_1 Prolog with dif/2, but rather with pure_1 Prolog with when/2. Can we implement list intersection? We would step back and pick up ideas from programming…
user502187
0
votes
1 answer

Is this the smallest Prolog program whose halting is unknown?

It is unknown whether the following 6-clause "pure" Prolog program halts. :- f(s(s(s(s(s(s(s(s(N)))))))),F), m(S,S,s(F)). f(o,s(o)). f(s(N),G) :- f(N,F), m(s(N),F,G). m(o,_,o). m(s(X),Y,Z) :- a(Y,P,Z),…
0
votes
0 answers

Pure Prolog δλ-Calculus Equality

It is not so difficult to conceive an appartness relation for Peano numbers. Its even possible to make a reified eq/3 predicate like here. Question is now, whether we can push the boundary and also implement Scheme equal? predicate in a pure and…
user502187
0
votes
1 answer

How does unify predicate (=)/2 differ from first order equality?

The tag logical purity mentions (=)/2 as pure. Is it "intrinsically" pure or "operational" pure? To the best of my knowledge it can be defined by this Horn clause: ∀x(=(x, x)) Which is this Prolog fact, if were not already a built-in: X = X. This…
user502187
1 2 3
4