Questions tagged [prolog]

Prolog is the most commonly used logic programming language. It supports non-deterministic programming through backtracking and pattern matching through unification.

Filter by
Sorted by
Tagged with
1 vote
1 answer
23 views

Books for learning horn clause logic

I want to learn prolog,two reason for that are -one can always find a counter example to the argument by searching for negation.So,one can learn by debugging the scripts.I heard that prolog is based ...
user avatar
0 votes
1 answer
38 views

Is it possible to encode contradictory horn clauses without goal clauses?

Intuitively, this seems impossible (because negation is forbidden in the head), but i am not sure. A naive (and wrong) example is p :- p But, this just means ...
user avatar
  • 247
-2 votes
1 answer
171 views

Resolution in prolog

What exaclty is resolution in prolog and how does it enables Prolog to obtain the following answer: ?- sublist([b,c],[a,b,c]). true
user avatar
1 vote
1 answer
506 views

Prolog: Deletion of all appearances of an element in a list

I am trying to create a predicate in Prolog which allows me to delete all occurrences of X in a list L. I have the following code: ...
user avatar
0 votes
0 answers
29 views

How can I translate this following simple statements to prolog

These are simple statements: Marcus was a man Marcus was a Roman All men are people Caesar was a ruler All Romans were either loyal to Caesar or hated him Everyone is loyal to someone. People only ...
user avatar
0 votes
0 answers
94 views

Sum of numbers divisible by 3 in Prolog

Give two Prolog implementations to calculate the sum of first N numbers divisible by 3. For example: N=4 -> 30 (3+6+9+12). ...
user avatar
18 votes
2 answers
5k views

Paradox? Pure Prolog is Turing-complete and yet incapable of expressing list intersection?

Pure Prolog (Prolog limited to Horn clauses only) is Turing-complete. In fact, a single Horn clause is enough for Turing-completeness. However, pure Prolog is incapable of expressing list intersection....
user avatar
  • 455
4 votes
0 answers
51 views

Efficient algorithm for factorizing symbolic sum of products

Given a sum of flat symbolic products like $axc + byc + ayc + bxc$, how can I efficiently factorize it as a product of sums like $(a+x)(b+y)c$? For my problem, the products are not commutative -- it's ...
user avatar
  • 141
0 votes
1 answer
28 views

Headless Prolog?

I've been playing around with prolog and realised something. You can do everything without predicate names. e.g. Just change all predicates $$a(b,c,d,e,..)$$ into $$prop(a,b,c,d,e,..)$$ Where $prop$ ...
user avatar
  • 263
2 votes
1 answer
115 views

How does Warrens Abstract Machine work?

I've recently learned about Prolog and Logic programming which I find pretty cool, but the compiler is currently like magic to me and I want to know how they work. After a little bit of research I ...
user avatar
1 vote
0 answers
53 views

Branch and scope globally unique identifiers

Say we are working with a Prolog-like system where variables are dynamically created in different branch contexts and scopes, yet these variables are also globally viewable by the system regardless of ...
user avatar
1 vote
0 answers
61 views

Do forward chaining (Rete) business rules (Drools, ILOG) / production rules support higher order rules and compositionality?

There is this talk http://andrewcropper.com/pubs/jelia19-typed.pdf about higher order Prolog, about use of higher-order predicates (that takes other predicates as arguments) and compositionality of ...
user avatar
  • 1,351
1 vote
0 answers
71 views

Mutually contradicting rules in Prolog

What will happen in a Prolog program, if I set two rules/facts which contradict each other.. will it go with the rule/fact that appears first.. or it will show an error?
user avatar
1 vote
1 answer
66 views

Substructural Prolog?

Substructural logic is logic without some or all of the structural rules. Is substructural Prolog, substructural logic programming possible? My question is connected with article https://link.springer....
user avatar
  • 1,351
2 votes
2 answers
126 views

What is the connection between the logic and the logic programming?

As I understand, then logic (i.e. particular theory of logic with some theory's axioms and some possible assignments of the variables) describes some specific world (in the non-modal case) or some set ...
user avatar
  • 1,351
0 votes
0 answers
45 views

Channeling Constraints in Constraint Handling Rules (CHR)

Suppose we have a constraint satisfaction problem that can be defined as its constraints in two different viewpoints $V_1$ and $V_2$. Moreover, there are two variables $A$ and $B$ from $V_1$ and $V_2$ ...
user avatar
  • 3,512
4 votes
0 answers
43 views

How does negation as failure work with variables?

Let's say we have the following rule: p -: X ≠ Y, X = Y Stating that $\forall x.y. x \neq y \land x = y \implies p$. Now let us suppose that we are searching for ...
user avatar
  • 756
2 votes
0 answers
42 views

what are the limitations of definite clause grammars?

Definite clause grammars have been around for a long time but there are not the answer to every parsing problem or we would not need to invent new formalisms. Are there any languages they cannot ...
user avatar
3 votes
1 answer
809 views

Convert FOL clauses to PROLOG

I am very new to PROLOG so it might be a very trivial question, but I absolutely have no idea how to solve it. There are 4 sentences I need to formulate into PROLOG code: All hounds howl at ...
user avatar
  • 39
1 vote
0 answers
35 views

Is there any difference in the expressiveness of boolean grammars versus definite clause grammars?

Definite clause grammars have been around a long time and are included in logic languages such as Prolog. They can be translated into (are just syntactic sugar for) Prolog programs and are therefore ...
user avatar
3 votes
2 answers
1k views

How do we translate first order logic's universal quantifier (the $\forall$) and the existential quantifier (the $\exists$) to Prolog?

I'm trying to convert some English statements to first order logic statements and I'm trying to use Prolog to verify the translations. My question is: how do I convert a first order logic statement (...
user avatar
0 votes
2 answers
157 views

What are constraints on some new logic programming language and system?

As I understand, everyone can create logic programming language and system by declaring that the valid program of some logic programming language is the set of statements in the form: ...
user avatar
  • 1,351
11 votes
3 answers
563 views

How often is Prolog/ASP used in non-research areas?

I've just recently found out about KRR (Knowledge representation and Reasoning) and ASP, not hearing a thing about them before (except a bit about prolog). I've read a bit about them and one of their ...
user avatar
  • 211
2 votes
1 answer
204 views

What is the computation model of Prolog?

Several computation models have representative programming language counterparts, as, according to this answer, Snobol for rewriting systems, APL for combinators, Lisp/Scheme for lambda calculus, and ...
user avatar
  • 121
1 vote
1 answer
2k views

Hamiltonian path and minimum spanning tree

Suppose i have a graph and i want to find minimum-spanning-tree. As in imperative languages we have to take specific steps from everynode(example ,we use kruskal's algorithm or prim's algorithm) to ...
user avatar
  • 253
3 votes
1 answer
110 views

Programmatically checking equivalence of statements

So as part of a theorem-prover/checker, I'm using Prolog to try to determine the equivalence of statements that have been parsed into tree form, e.g. $x=2$ is represented as ...
user avatar
  • 31
3 votes
1 answer
403 views

Generalization of Horn clauses in logic programming?

As far as I understand, Prolog and related languages are restricted to inference rules of the form $$ p_1 \land \dots \land p_n \rightarrow q$$ which is equivalent to the Horn clause $$ \neg p_1 \lor \...
user avatar
  • 153
2 votes
1 answer
521 views

How to determine if prolog query will give an answer or not?

Explain what will happen if we try to evaluate the query “path(a,e).”. When the query was actually run, it kept looping.I used the following method. Is it correct? When evaluating $path(Z,e)$, if $...
user avatar
2 votes
1 answer
187 views

Is there an implementation of higher kinded types in typed lambda calculus?

I can see that we can do higher kinded types ( * -> *) -> * in Scala and Haskell and other languages. I'm looking for a simpler vanilla implementation of just ...
user avatar
  • 1,189
3 votes
0 answers
229 views

Open Standard Prolog Knowledge Bases [closed]

Are there any standard Prolog knowledge bases available anywhere that have the same purpose as Cyc, namely to encode generally accepted common sense and human knowledge? Typically containing ...
user avatar
  • 131
1 vote
1 answer
4k views

Horn clause to Prolog [closed]

At the needs of my HW at uni I need to transform some Horn clauses to Prolog but I cannot figure out how to do it. I found out some guides but they describe how to do it with only one fact. So can you ...
user avatar
  • 205
20 votes
2 answers
5k views

What makes PROLOG Turing-complete?

I know that it can be proven PROLOG is Turing-complete by constructing a program that simulates a Turing machine like this: ...
user avatar
6 votes
2 answers
774 views

Proper terminology in Prolog/logical programming theory?

I have a good understanding of how to program using logic languages, but I'm currently writing up a paper describing some of my work, and I wanted to ensure that I wasn't abusing the proper ...
user avatar
  • 29.1k
27 votes
2 answers
9k views

How to implement a Prolog interpreter in a purely functional language?

Is there a clear reference, with pseudo-code, on how to go about implementing a Prolog interpreter in a purely functional language? That which I have found so far seems to deal only with imperative ...
user avatar
  • 373
17 votes
4 answers
4k views

Can constraint satisfaction problems be solved with Prolog?

Is "party attendance" type of problems solvable in Prolog? For example: Burdock Muldoon and Carlotta Pinkstone both said they would come if Albus Dumbledore came. Albus Dumbledore and Daisy ...
user avatar