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
2 answers

How does prolog resolution use proof by contradiction?

I'm learning prolog, and I'm confused by the claim that prolog uses proof by contradiction: The resolution proof process makes use of a technique that is known as reduction to the absurd: suppose that the formula to be proved is false, and show…
Joseph Garvin
  • 20,727
  • 18
  • 94
  • 165
4
votes
3 answers

Is pure Prolog Turing-complete, and if so, why can't it implement list intersection?

The Wikipedia section on this topic is a mess. It states: Pure Prolog is based on a subset of first-order predicate logic, Horn clauses, which is Turing-complete. Turing completeness of Prolog can be shown by using it to simulate a Turing…
4
votes
1 answer

Using apply in core.logic Clojure (CLP) Cryptoarithmetic

(ns verbal-arithmetic (:require [clojure.core.logic :refer [all run* everyg lvar == membero fresh conde succeed fail conso resto]] [clojure.core.logic.fd :as fd])) (comment "Solving cryptarithmetic puzzle" " SEND + MORE ______ …
4
votes
0 answers

what categories do relational languages describe?

I read that lambda calculus is the language of cartesian closed categories. As I understand it, relational languages such as minikanren or (in part) prolog would then operate on those, but also other categories (since functions are a special case of…
4
votes
3 answers

Shortest way to define multiple rules in prolog

I'm trying to solve an exercise in order to become more familiar with prolog. The task is following: % Sten wants to send Lisa 100 flowers. He can choose from lilies, roses and tulips. % One lily costs $50, rose $10 and tulip $1. Find how many…
pacman.
  • 217
  • 1
  • 2
  • 9
4
votes
1 answer

How to operate on a sequence of lvars

Say I want to get all combinations of bill/coins denominations that amount to a given value, given also a set of available denominations. So for instance, for (change 14 #{1 2 5 10}) I'd expect ( {10 1, 5 0, 2 2, 1 0} {10 1, 5 0, 2 1, 1 2} …
alepeino
  • 9,551
  • 3
  • 28
  • 48
4
votes
2 answers

Uncertainty in a logic engine (Produce plausible relative positions based on local geography)

I know there's a high chance of my hitting the XY problem here, so the first chunk of this is about the more general situation. The Problem I have a set of data points containing abstract geographic-feature information, but no actual locations…
Vivian
  • 1,539
  • 14
  • 38
4
votes
2 answers

Compact vs full/verbose definition of the inverse combinator/operator in Curry

The rather fascinating 2013 introductory post to the Haskell based KiCS2 implementation of Curry by Wolfgang Jeltsch, A Taste of Curry, provides the following definition for the inverse combinator: inverse :: (a -> b) -> (b -> a) inverse f y | f x…
4
votes
1 answer

Prolog: Symmetric Rules

I'm following a Prolog tutorial that asks to define a symmetric relation. Say for instance you have the following fact in the knowledge base: colleague(john,bob). You also want colleague(bob,john) to be true, and likewise for all colleague…
Wolff
  • 1,051
  • 3
  • 18
  • 31
4
votes
2 answers

Enumerating binary trees in Prolog

I am trying to create Prolog rules to enumerate 'binary trees' in list form in Prolog. I am new to Prolog. A tree with 0 nodes is an empty list: [] A tree with 1 node is: [[],[]] A tree with 2 nodes has 2…
4
votes
4 answers

Prolog : Enumerate All Elements of Countably Infinite Results

Are there any prolog implementations that are able to enumerate all elements of countably infinite results? Let's consider to enumerate all pairs of natural numbers. If we enumerate pairs in order {(0,0), (0,1), (1,0), (0,2), (1,1), (2,0), ...}, we…
egi
  • 41
  • 3
4
votes
1 answer

Logic programming: how to distribute resources among consumers?

I have a task in which I must distribute unique resources among consumers. Rules are: each consumer has a set of resource types they can use, each resource is unique, each consumer must receive n>0 resources, all resources must be distributed. E.…
Mischa Arefiev
  • 5,227
  • 4
  • 26
  • 34
4
votes
2 answers

Modelling Constraint Logic Programs (for analysis)

Object-Oriented programs can be modelled by different models such as Automata, Process Algebras, Petri Nets or UML. Some of these models can be used to perform various kind of analysis to spot problem in performance or design. I am studying about…
4
votes
1 answer

Constraint logic programming with sets in Prolog

The clpfd is a constraint programming library for integers in SWI Prolog. Is there a similar library for sets? If not, do you know of any articles useful to implement such library? Is it doable at all? I'm looking for any kind of input really, as my…
Torgny
  • 279
  • 3
  • 10
4
votes
1 answer

Any Prolog implementation that allows left recursion?

I wonder if there is any Prolog implementation that allows left recursion in clauses. My intuition is that if the implementation uses a breadth-first goal search, it may support left recursion. But I am not quite sure. Note that I do not care…
day
  • 2,292
  • 1
  • 20
  • 23