It is important to define from the beginning the meaning of terms for oneself (e.g. what "gold" means - a color or substance), so that there is no ambiguity later. The same applies to the order of argument of course.
relation_name = predicate
Collection of facts is called database. Database contains also rules.
or
?- predicate(arg_1, Var_1, ..).
No answer means that the question is "not provable", it does not mean that the answer is "no".
Prolog searches the database from the beginning to the end; if it finds a match it marks this place in database it instantiates the variable with the matched constan and returns this first match; if the user enters ';', the variable values are cleared and another search is being done from the place previously marked.
If there are several variables, they are instantiated one by one, for each the database is being searched from the beginning.
For conjunction of questions we use comma between goals. If there's conjunction of goals, Prolog attempts to satisfy each goal in turn, from left to right.
This means that predicate1 implies from predicate2.
The underscore _ marks an anonymous variable.
Facts
relation_name(argument_1,argument_2,...,argument_n).relation_name = predicate
Collection of facts is called database. Database contains also rules.
Questions
?- predicate(arg_1, arg_2, ..).or
?- predicate(arg_1, Var_1, ..).
No answer means that the question is "not provable", it does not mean that the answer is "no".
Prolog searches the database from the beginning to the end; if it finds a match it marks this place in database it instantiates the variable with the matched constan and returns this first match; if the user enters ';', the variable values are cleared and another search is being done from the place previously marked.
If there are several variables, they are instantiated one by one, for each the database is being searched from the beginning.
For conjunction of questions we use comma between goals. If there's conjunction of goals, Prolog attempts to satisfy each goal in turn, from left to right.
Rules
predicate1(arg_1, Var_1,..) :- predicate2(agr_2, Var_1, ..)This means that predicate1 implies from predicate2.
The underscore _ marks an anonymous variable.
Comments
Want to leave a comment? Visit this post's issue page
on GitHub and just post your comment as the issue's comment (you'll need a GitHub account. What? Like you don't have one yet?!).
Comments: