# Questions tagged [prolog]

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

38 questions
Filter by
Sorted by
Tagged with
36 views

### Are recursive Horn clauses first order?

My understanding is that recursive definitions are considered second-order since they require the fixpoint operator in order to be formulated as "true" definitions. This is even though they ...
• 272
18 views

### In the declarative semantics of definite programs, $T_P \downarrow \omega$ is not equal to the greatest fixpoint of $T_P$

I am studying theoretical computer science using the book "Foundations of Logic Programming" by J. W. Loyd. I am in the part about declarative semantics of definite programs. In the book, if ...
52 views

### Given a definite program, how do I obtain its Herbrand base?

Given a definite program, how can I obtain its Herbrand base? For instance, given the program $P$ below, what is its Herbrand base $B_P$? $p(f(x)) \leftarrow p(x)$ $q(a) \leftarrow p(x)$ I know the ...
1 vote
42 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 ...
75 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 ...
• 275
359 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
1 vote
1k 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: ...
54 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 ...
143 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). ...
6k 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....
• 485
63 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 ...
• 141
40 views

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$ ...
• 263
130 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 ...
1 vote
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 ...
1 vote
84 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 ...
• 1,381
1 vote
115 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?
1 vote
80 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....
• 1,381
158 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 ...
• 1,381
53 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$ ...
• 3,562
57 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 ...
• 778
55 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 ...
• 171
1k 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 ...
• 39
1 vote
50 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 ...
• 171
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 (...
• 223
179 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: ...
• 1,381
659 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 ...
• 211
240 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 ...
• 121
1 vote
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 ...
• 253
131 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 ...
• 31
467 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 \...
• 153
576 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 \$...
213 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 ...
• 1,199
230 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 ...
• 131
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 ...
• 225
6k 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: ...
• 333
792 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 ...
• 29.7k