prolog

Is z3 the most efficient solver for quantifier-free integer propositional logic? [closed]

北城以北 提交于 2019-12-23 15:44:34
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 12 months ago . Sorry that this question is subjective, but given that the Stack Overflow has the largest Z3 user base, I want to give it a try. I have a big constraint satisfaction problem that consists of many integer propositional logic formulas and a few first order logic formulas that

Remove both the value and all duplicates of that value in a list in prolog

若如初见. 提交于 2019-12-23 15:33:56
问题 I'm having some trouble removing values from a list in prolog. I have a list of colors and I want to add a list of colors to it and keep all the values that have no duplicate and remove the rest. [green, red, blue, purple, yellow, brown, orange, black, purple] so purple appears twice in this list and I want to remove both of them. This is the list I want to be returned. [green, red, blue, yellow, brown, orange, black] I currently have this to remove all the duplicates but I can't get both

Remove both the value and all duplicates of that value in a list in prolog

给你一囗甜甜゛ 提交于 2019-12-23 15:33:33
问题 I'm having some trouble removing values from a list in prolog. I have a list of colors and I want to add a list of colors to it and keep all the values that have no duplicate and remove the rest. [green, red, blue, purple, yellow, brown, orange, black, purple] so purple appears twice in this list and I want to remove both of them. This is the list I want to be returned. [green, red, blue, yellow, brown, orange, black] I currently have this to remove all the duplicates but I can't get both

Solve extremely simple equation in prolog: A = B + C?

♀尐吖头ヾ 提交于 2019-12-23 14:42:50
问题 I have an extremely simple equation that I would like to be able to solve in prolog: A = B + C I'd like to be able to write a predicate expressing this relation, that can handle any one of the arguments not being instantiated. There is no need to generalize to more complex relations or equations. myEquation(A, B, C) :- ...something... That I could call with the following semantics: myEquation(A,1,2). > A = 3. myEquation(3,B,2). > B = 1. myEquation(3,1,C). > C = 2. Any ideas? Working with

Solve extremely simple equation in prolog: A = B + C?

℡╲_俬逩灬. 提交于 2019-12-23 14:40:59
问题 I have an extremely simple equation that I would like to be able to solve in prolog: A = B + C I'd like to be able to write a predicate expressing this relation, that can handle any one of the arguments not being instantiated. There is no need to generalize to more complex relations or equations. myEquation(A, B, C) :- ...something... That I could call with the following semantics: myEquation(A,1,2). > A = 3. myEquation(3,B,2). > B = 1. myEquation(3,1,C). > C = 2. Any ideas? Working with

Solve Cannibals/Missionaries using breadth-first search (BFS) in Prolog?

隐身守侯 提交于 2019-12-23 13:35:10
问题 I am working on solving the classic Missionaries(M) and Cannibals(C) problem, the start state is 3 M and 3 C on the left bank and the goal state is 3M, 3C on the right bank. I have complete the basic function in my program and I need to implemet the search-strategy such as BFS and DFS. Basically my code is learn from the Internet. So far I can successfuly run the program with DFS method, but I try to run with BFS it always return false. This is my very first SWI-Prolog program, I can not find

Flattening a list

橙三吉。 提交于 2019-12-23 13:15:40
问题 Trying to solve exercise 07 from http://www.ic.unicamp.br/~meidanis/courses/mc336/2009s2/prolog/problemas/ I've started with a single iteration which looks like following my_flatten1([], []). my_flatten1([[A|T]|U], [A|V]) :- append(T, U1, V), my_flatten1(U, U1). my_flatten1([A|T], [A|U]) :- not(is_list(A)), my_flatten1(T, U). is_flat(A) :- my_flatten1(A, A). it seems to work just fine for the following set of queries my_flatten1([a, [b, [c, d], e]], X). my_flatten1(X, [a, b, c]). my_flatten1

Is there a BNF with arguments for non-terminal symbols?

会有一股神秘感。 提交于 2019-12-23 13:05:36
问题 In working with Prolog DCG to parse input it is nice to have an accompaning BNF of the grammar. For example: BNF <Sentence> ::= <Noun_phrase> <Verb_phrase> <Noun_phrase> ::= <Determiner> <Noun> <Verb_phrase> ::= <Verb> <Phrase> <Determiner> ::= a <Determiner> ::= the <Noun> ::= cat <Noun> ::= mouse <Verb> ::= scares <Verb> ::= hates as Prolog DCG sentence --> noun_phrase, verb_phrase. verb_phrase --> verb, noun_phrase. noun_phrase --> determiner, noun. determiner --> [a]. determiner --> [the]

Is there an automatic parallel prolog implementation?

萝らか妹 提交于 2019-12-23 13:04:53
问题 I'm currently doing some research in theoretical computer science, and one of the main tools I'm using is prolog. I've found it particularly handy for writing very quick tests to disprove conjectures. However, I've gotten to a point where the brute-force search is getting too slow. While I could use a different language, the whole point of my using prolog is that it's extremely fast/simple to write code to test a hypothesis. I'm wondering, is there an implementation of Prolog that allows for

Querying from the terminal doesn't print anything

半城伤御伤魂 提交于 2019-12-23 13:02:05
问题 When ran in the command line, this swipl -g "write(42)" -t "halt" prints 42 to STDOUT as expected. However, this swipl -g "X = 42" -t "halt" does not print anything, it simply returns. How do I get it to print what it prints in the REPL (that is, X = 42 )? Note: this is in a Windows terminal. Let me know if this actually works in a Linux terminal. 回答1: As expected, X = 42 by itself produces no output whatsoever , because (=)/2 is a completely pure predicate that does not yield any side