Questions tagged [functional-logic-progr]

Functional Logic Programming (or FLP in short) is a composite paradigm unifiying the Functional Programming and Logic Programming paradigms.

Prominent examples of FLP languages are Curry, Mercury and others.

10 questions
5
votes
1 answer

Haskell: Combining existential and universal quantifiers fails unexpectedly

I am trying to model the following logical implication in Haskell with GHC, version 8.6.5: (∀ a. ¬ Φ(a)) → ¬ (∃ a: Φ(a)) The definitions I used are the following: {-# LANGUAGE RankNTypes, GADTs #-} import Data.Void -- Existential quantification…
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…
3
votes
1 answer

Need clarification in understanding a custom core.logic constraint

I was trying to understand a custom core.logic constraint as defined below, (defne lefto "x appears to the left of y in collection l." [x y l] ([_ _ [x . tail]] (membero y tail)) ([_ _ [_ . tail]] (lefto x y tail))) How to interpret _ and .…
Kannan Ramamoorthy
  • 3,980
  • 9
  • 45
  • 63
3
votes
3 answers

Discussion about Abductive logic programming vs Answer Set Programming

I am looking to clarify the some things about abductive logic programming vs. Answer set programming. I with some classmates are creating a game. In this game there are "heroes" (special npcs). The heroes have goals and behaviors. (All of this is…
ssmoot
  • 31
  • 2
1
vote
0 answers

Is it possible to insert a Clojure statement in the middle of a series of core.logic calls, "à la Prolog"?

Prolog mixes logic (fallible) goals, and (infallible) processes like write/2 or assert/1. Is it possible to do so with Clojure's core.logic? For example: (pldb/with-db myFacts (l/run* [x y] (person x) (println "we found a…
1
vote
1 answer

If & Else & Pattern Matching in SML altogether?

I've been trying to compile this piece of code for 3 hours and nothing improved. I know that my datatype compiles without problem and also the first case of pattern matching . But when the second case comes in (a node with two nodes for children )…
1
vote
2 answers

Inverting `member` in Curry (PAKCS) gives no answers

With this definition: member _ [] = False member x (h:t) = if x == h then True else member x t PAKCS 2.0.1 (from Ubuntu 18.04) gives no answers, warnings or errors: Top-level binding with no type signature: member :: Prelude.Eq a => a ->…
0
votes
1 answer

Find number of successes from a list of terms/goals

I have written the following predicate exactly/2 that succeeds if exactly N of the numbers in the list L are equal to 1: :- pred exactly(int, list(int)). :- mode exactly(in, in) is semidet. :- mode exactly(out, in) is det. exactly(N, L) :- …
0
votes
2 answers

How can I design a 2-1 multiplexer with enable using only NAND gates?

So, I manage to design something but I need confirmation and my real question is the following: How can I design 4-1 multiplexer using 2 multiplexers designed as in the title of the question (using only NANDs) plus as many NOR gates as I need? To…
hack-is-art
  • 325
  • 5
  • 20
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