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
0
votes
3 answers

Help with prolog's clauses

emissionOf(alpha). emissionOf(beta). detected(proton), detected(electron) :- emissionOf(alpha), emissionOf(beta). I'm facing the problem that for some (probably obvious) reason Prolog doesn't accept the last line of the above code. The reason has…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
0
votes
2 answers

Prolog multiply all elements of a list

I want to define a predicate in Prolog, prod_list/2 that multiplies every element of a list. I'm having problem with the empty list wish the product should be zero, instead i get false. My code is prod_list([H], H). prod_list([H|T], Product) :-…
0
votes
1 answer

Generating a parser with `inverse`, with constraints on the grammar

I recently followed through A Taste of Curry, and afterwards decided to put the trivial arithmetic parser example to test, by writing a somewhat more substantial parser: a primitive but correct and functional HTML parser. I ended up with a working…
Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
0
votes
0 answers

How do I view how Prolog got to its result/the path it took?

I have a simple Prolog predicate that spits accepts a variable, Result, that calculates a result then stores it in Result to be viewed. Sometimes I'm unsure how it comes to the answer it stores in Result and I'm curious if there's a way in Prolog to…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
0
votes
1 answer

Dijkstra path (not only distance)

I have the code that calculates the minimum distance of Dijkstra path. Can you help me edit my code in order to not only print the minimum distance, but the full path too? % min_dist(+Graph,+Start,-MinDist) min_dist(Graph,Start,MinDist):- …
charqus
  • 469
  • 1
  • 5
  • 15
0
votes
1 answer

Fixed Point and Proof theory

For any given logic program, proof theory of it uses SLD (Selective Linear Definite) resolution to find the satisfiablity of the query. For the same logic program, we can apply fixed point theorem to find the models. My question is, should we…
Badri
  • 25
  • 6
0
votes
2 answers

Can pyDatalog be used to check if all data dependencies are satisfied?

I am trying to use pyDatalog to determine if the dependencies for various features are satisfied. Some library (lA,lB,...) provides outputs (1,2,...) which are needed by features (fX,fY,...). For example: +has("lA", 1) #Library A has output…
kerblogglobel
  • 188
  • 1
  • 5
0
votes
0 answers

Product of two permutations (cycles) in Prolog

I would like to find the product of two permutations in Prolog (in cycle form) and I'm having problems with it (mostly because I can't even imagine, what it will look like). I thought about changing these permutations into another representation,…
Wanderer
  • 147
  • 1
  • 8
0
votes
1 answer

Modelling recipes and available ingredients with constraint logic

Imagine I have a number of recipes for different dishes and a larder containing various ingredients in my kitchen. I want to construct a model using core.logic which will enable me to answer the following question: for a given set of ingredients…
0
votes
1 answer

Why does creating a relationship in pyDatalog seem to give me the wrong answer?

I'm new to the concepts of Datalog, and I am exploring it through pyDatalog. I am experimenting with a unit measurement converter. So, given facts about how many inches there are in a meter, for example, it should be able to tell me how many meters…
blippy
  • 1,490
  • 1
  • 13
  • 22
0
votes
1 answer

Retrieve an answer from a list in prolog

Hello I am a beginner in Prolog and i have stuck in the following problem. Here it goes , I have a "database" which gives me information about the school schedule something like this : school(NameOfTeacher,([(Course,Day) ......]). When asking the…
stesioc
  • 1
  • 1
0
votes
1 answer

Is the Prova implemented with a Prolog compiler or Prolog interpreter?

I am looking at the Java-written Prolog system, Prova. https://prova.ws/ But it is not clear about its implementation, a Prolog compiler or Prolog interpreter? I read the manual, but did not found an answer.
Osiris Xu
  • 713
  • 1
  • 5
  • 13
0
votes
1 answer

Concurrent and Parallel Logic Programming

In the introduction to The Art of Prolog, Sterling and Shapiro defer a discussion of parallelism, concurrency, and logic programming to another book. My question is whether there is such a resource: [the] promise of parallel computers, combined…
0
votes
2 answers

pyDatalog: 'object is incompatible with the class queried' when asking a query

I'm working on a program that uses pyDatalog to query an sqlite database. The key table in the database is Event, which is defined as follows: class Event(Base): __tablename__ = 'Event' id = Column('id', Integer, primary_key = True) eventType…
highfellow
  • 35
  • 8
0
votes
1 answer

pyDatalog: is it possible to define multiple independent datalog sessions?

I'm working on some code that assesses data in a database to see if instances in a stream of incoming events comply with a set of protocols. The idea is to use pyDatalog to do this. Ideally, we would like to be able to assess the data against…
highfellow
  • 35
  • 8
1 2 3
15
16