Questions tagged [logic-programming]

Logic Programming is a programming paradigm based on first order logic.

Logic programming is a programming paradigm which is largely based on formal logic. Any program written in a logic programming language is a set of sentences in logical form, expressing facts and rules about some problem domain. Major logic programming language families include Prolog, answer set programming (ASP) and Datalog.

231 questions
4
votes
1 answer

Algorithms for Unification of list-based trees

I need a unification algorithm to handle the following situation. Each node in my expression tree has a list (associative) or a set (associative and commutative) of children. I would like to get all possible matches to a specific pattern. Here is…
3
votes
0 answers

Logic programming with multiple fact databases

I have to find a logically consistent subset of multiple fact sets (databases). Is there a logic programming language with built-in facilities to do this? If not, are there logic programming languages allowing to operate on multiple fact databases…
Paul Jurczak
  • 7,008
  • 3
  • 47
  • 72
3
votes
1 answer

What is committed-choice logic programming language?

In the logic programming community, I have heard many people talk about "committed choice logic programming language", but I am not very clear about its definition. I searched the internet, but no formal answer was found (It seems related to…
chansey
  • 1,266
  • 9
  • 20
3
votes
1 answer

What's the difference between logic programming and answer set programming

I'm currently learning how to prove the unsatisfiability of first-order logic. I've learnd in my class that resolution is one way to solve the unsatisfiability problem, e.g., tools like Prolog achieve this by implementing SLDNF resolution to try to…
Li Danyuan
  • 121
  • 8
3
votes
1 answer

How do I translate Prolog's cuts to Curry?

Here's an algorithm in Curry which takes n and matches on two strings within edit distance n of each other. lev :: Eq a => Int -> [a] -> [a] -> () lev n (a : b) (a : c) = lev n b c lev n (_ : b) (_ : c) | n > 0 = lev (n - 1) b c lev n (_ : b) c…
Wheat Wizard
  • 3,982
  • 14
  • 34
3
votes
2 answers

Are there elements of 'logic programming' in Java?

In recent years many elements of 'functional programming' have entered Java, in particular with Java 8. I have in mind lambda-expressions, functional interfaces, Java Generics, the Stream-interface, the Optional-class and similar. My question is,…
Sebastian
  • 365
  • 3
  • 17
3
votes
2 answers

Finding all nodes connected to a vertex in Prolog

I am curious about pathfinding algorithms, so I took a look at Dijkstra's. I'm using this video as a guide (and it's what I'm basing my graph on). Here is the graph I am working from: I now want to be able to find all connections of a given vertex.…
3
votes
2 answers

λProlog rejecting hypothetical reasoning queries?

I suspect that teyjus, the main implementation of λProlog, might be a bit of abandonware, but λProlog is a fascinating Prolog that is supposed to let you use higher-order logic, hypothetical reasoning and other things, which is why I'm trying to use…
MWB
  • 11,740
  • 6
  • 46
  • 91
3
votes
2 answers

Prolog ways to compare variables

I was trying to implement some graph algorithms in Prolog. I came up with an idea to use unification to build a tree from the graph structure: The graph would be defined as follows: A list of Vertex-Variable pairs where Vertex is a constant…
egst
  • 1,605
  • 3
  • 18
  • 25
3
votes
5 answers

Cool, visually-transmissible uses of Prolog

I will be teaching only one lecture on basic Prolog to students with little to no experience in programming. I'd like them to see that programming and Prolog can be used in the real world, perhaps even to do cool things. I have looked at this and…
arturomp
  • 28,790
  • 10
  • 43
  • 72
3
votes
1 answer

Correct use of logic languages as a tool

I'm interested in the "use the right tool for the job" philosophy in programming, and I have a problem I thought might be solvable with logic programming. I mean this in a naive way, because I haven't done any logic programming and am just setting…
3
votes
1 answer

Not understanding The Reasoned Schemer Chapter 5 frame 62

I am currently learning miniKanren by learning The Reasoned Schemer. And I am stuck in an exercise in Chapter 5 frame 62: (run* (x) (flatten_o (a) x)), why there are three lists in output?
Chen Wang
  • 771
  • 6
  • 8
3
votes
1 answer

Is there a logical for-all in clojure.core.logic?

I'm trying to solve the first puzzle in Smullyan's To Mock a Mockingbird using clojure.core.logic, not because it is particularly hard, but rather as an exercise. The puzzle states that there's a garden with three colors of flowers: red, yellow, and…
Sebastian Oberhoff
  • 1,271
  • 1
  • 10
  • 16
3
votes
1 answer

How does append-to-form work? (SICP's section on Logic Programming)

I am currently working through SICP's section on Logic Programming, but I got stuck in the examples regarding logical deductions, especially the append-to-form rules. How do they work? What I don't quite understand is how the second rule cdr-downs…
motxilo
  • 33
  • 2
3
votes
1 answer

how do I approach Prolog

I have taken up Prolog course in my university. The coursework requires us to write prolog programs. I am able to write simple programs, however I am finding it little hard to digest the complex programs. Any suggestions how to proceed or how do I…
lisa
  • 41
  • 5