Skip to main content

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
59 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 ...
Motorhead's user avatar
  • 291
0 votes
1 answer
23 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 ...
Gabriel F. Silva's user avatar
0 votes
1 answer
65 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 ...
Gabriel F. Silva's user avatar
1 vote
1 answer
50 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
93 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 ...
chansey's user avatar
  • 295
-2 votes
1 answer
452 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
Amit wadhwa's user avatar
2 votes
1 answer
2k 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: ...
Vladis Becker's user avatar
0 votes
0 answers
67 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 ...
KudoShinichi's user avatar
0 votes
0 answers
158 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). ...
hackermanwasd's user avatar
20 votes
2 answers
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....
MWB's user avatar
  • 505
4 votes
0 answers
66 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 ...
Bruno Kim's user avatar
  • 141
0 votes
1 answer
44 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$ ...
zooby's user avatar
  • 273
2 votes
1 answer
167 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 ...
StackMachine's 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 ...
Jean-Baptiste's user avatar
1 vote
0 answers
96 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 ...
TomR's user avatar
  • 1,401
1 vote
0 answers
141 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?
Koushik Ghosh's user avatar
1 vote
1 answer
89 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....
TomR's user avatar
  • 1,401
2 votes
2 answers
193 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 ...
TomR's user avatar
  • 1,401
0 votes
0 answers
58 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$ ...
OmG's user avatar
  • 3,582
4 votes
0 answers
61 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 ...
Christopher King's user avatar
2 votes
0 answers
65 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 ...
Bruce Adams's user avatar
3 votes
1 answer
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 ...
Nagham's user avatar
  • 39
1 vote
0 answers
57 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 ...
Bruce Adams's user avatar
3 votes
2 answers
2k 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 (...
842Mono's user avatar
  • 223
0 votes
2 answers
188 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: ...
TomR's user avatar
  • 1,401
12 votes
3 answers
708 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 ...
FloriOn's user avatar
  • 221
2 votes
1 answer
251 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_163417's user avatar
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 ...
Khan Saab's user avatar
  • 253
3 votes
1 answer
152 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 ...
Harr's user avatar
  • 31
3 votes
1 answer
525 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 \...
Roland's user avatar
  • 153
2 votes
1 answer
624 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 $...
Amy Cohen's user avatar
2 votes
1 answer
235 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 ...
hawkeye's user avatar
  • 1,199
3 votes
0 answers
237 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 ...
Nordlöw's user avatar
  • 131
3 votes
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 ...
Mario's user avatar
  • 245
23 votes
2 answers
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: ...
Lenar Hoyt's user avatar
6 votes
2 answers
801 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 ...
Joey Eremondi's user avatar
29 votes
2 answers
10k 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 ...
Jimster's user avatar
  • 393
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 ...
Tegiri Nenashi's user avatar