Self-test 1 Solutions

Unification and lists 1
 
  Do the following unify and (if so) what are the variable instantiations?
 
1.

| ?- [Head |Tail] = [brian, mandy, ruth].

Head = brian,
Tail = [mandy,ruth] ? ;

no
 
2.

| ?- [Head | Tail] = [[julie, is, a, wizz]].

Head=[julie,is,a,wizz]
Tail=[] ? ;

no
 
3.

| ?- [who, typed | Tail] = [Head | these, notes, '?'].


In most Prologs, this would give an error message because "these, notes, '?'" isn't within a list.
 

4.

| ?- [sem242, unification] = [sem242, [Topic]].

no
 
5.

| ?- [sem242, [unification, backtracking, search]] = [Head |Tail].

Head = sem242,
Tail = [[unification,backtracking,search]] ? ;

no
 
6.

| ?- [sem242, [unification, backtracking, search]] = [Head, Tail].

Head = sem242,
Tail = [unification,backtracking,search] ? ;

no
 
7.

| ?- [nova, []] = [Car, Wheels, Tail].

no
 
8.

| ?- [nova] = [Head, Tail].

no
 
9.

| ?- [nova] = [Head |Tail].

Head = nova,
Tail = [] ? ;

no