HomeContents: |
## 10.3 Example II## ExampleIn this example, we match 1. person(Nick, gender(male)) with 2. person(N, gender(male)) ## Matching the two structuresAgain, the top-level term is a structure, so we invoke rule 2. The two structures have the same functor and arity, but do their arguments match? ## Matching the first argumentNick matches N because N is a free variable, and Nick is an atomic constant (rule 3). N is bound to the atomic constant Nick. ## Matching the second argumentDoes gender(male) (from term 1) match with gender(male) (from term 2)? Well, they are both structures, so we invoke rule 2. They both have the same functor ("gender") and arity (1), so we try to see whether their arguments match. male (from term 1) matches male (from term 2) because they are both atomic constants and they are the same (this is rule 1). Thus the overall result is that the matching succeeds, with the variable N bound to the value Nick. ## NextNext, we look at a third and final example. PrevLite: 10.2 Example INextLite: 10.4 Example IIIPrev: 10.2 Example IUp: 10 MatchingNext: 10.4 Example III |