I am doing my first steps in Prolog (swi-prolog) and cannot solve the following problem: How can I include existentially quantified rules to my facts; specifically, how can I include the sentence "Everybody is a friend of somebody" \forall x \exists y friend(x,y)as a fact? Every question I found so far was only about queries not facts. Thank you!
Existential quantification in Prolog facts
1.9k views Asked by huxley At
1
There are 1 answers
Related Questions in PROLOG
- How to implement locked doors game in Prolog?
- need help debugging prolog
- check if object is a binary tree in prolog
- How to sovle problem of pyswip fatal error
- Making nested list of consecutive numbers in Prolog
- looking for help in Prolog
- order of conditions in antecedent causes stackoverflow
- Assertion Failure in SWI-Prolog When Using pyswip to Consult a Prolog File
- how to run xsd2json behind proxy
- How to modify my Turbo Prolog expert system
- NodeJS Processes Handle Signals Independently?
- Prolog Filtering List using `findall` with in-line predicate or "lambda"
- Prolog - How to Convert CSV File Output Rows into Queryable Terms?
- Prolog - How To Make Prolog Query Shorter?
- Constraints in Prolog
Related Questions in LOGIC
- Anybody knows where to learn AIMA python library?
- How to render sprites for a snake game using SFML and C++
- What is causing my towers of hanoi logic to infinitely loop?
- sample query for review for improvement on big query
- How do i return an array to display from backwards
- Can I use Sumproduct arrays and check two separate criteria counting TRUE statements?
- R method for comparing NAs between two vectors
- Get latitude/longitude of an image's corners based on two other points
- How to make a chatbot using python which can understand my question and then answer it
- How to find all the possible combinations with condition?
- Strategies for Linking Recipe Ingredients with Specific Products in a Database
- How to avoid duplicate entry of Shops in a Website
- Compare row values in excel and store time value in a variable
- How to Trace a Circuit Path in a Python Matrix Based on Movement Rules?
- How Can JavaScript Handle Large Amounts of JSON Data Quickly?
Related Questions in EXISTENTIAL-OPERATOR
- Prolog: existentially quantifying
- How can I know that I exist (Using Python)
- TSQL IN and NOT IN
- Existential operator in JavaScript?
- Existential quantification in Prolog facts
- Can prolog answer undetermined instead of just yes or no?
- coffeescript not null or undefined behavior
- How does CoffeeScript's existential operator work?
- How do I use the CoffeeScript existential operator to check some object properties for undefined?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
In the example you gave, you are actually quantifying over variables not rules. With this in mind, consider the following example:
The variables in the rule are universally quantified, so you can write the rule as a logic formula like so:
∀
X∀Y(friend(X)←friend_of(X,Y))Since the variable
Ydoes not occur in the head of the rule, its universal quantifier can be moved into the body of the rule as existential quantifier:∀
X(friend(X)← ∃Yfriend_of(X,Y))Now this formula reads as: Forall
Xfriend(X)is true if there exists aYsuch thatfriend_of(X,Y)is true. This seems to be pretty close to what you wanted.If you consider facts on the other hand, they are used to state that something is the case. The fact
friend_of/2in the above example is just the short way of writingHowever, there are no variables here, so there's nothing to quantify over.
EDIT: Concerning the case in your comments, I would note that predicates constitute relations. Relations are not neccessarily symmetric, that is the reason why I named the relation
friend_of/2. That is,friend_of(a,b)does not neccessarily meanfriend_of(b,a). Relations are also not neccessarily reflexive. It is debatable whether the relation friend is reflexive or not. However, it certainly is a possible reading. With that in mind and the given examples in your comment, let's assume that you have some facts that describea,bandcas persons, like so:Then you can describe a reflexive relation
friends/2like so:The rule expressing reflexivity basically states, that everybody is friends with at least him/herself. From this rule your requirement Everybody is a friend of someone directly follows. If you query this relation you get the desired result:
The most general query also yields results for every person, although no actual friendships between two different people are stated:
Note that the facts
person/1are neccessary to restrict the answers to actual people. If you queryfriends/2with some non-person:If you try to define reflexivity without such a goal:
your definition will be too general:
And the most general query will not produce any actual people: