in this text:
	the dollars sign ($) is the existential quantifier (there exists)
	and a quote symbol (") is the universal quantifier (for all)


			FIRST-ORDER LOGIC 

The uniqueness quantifier

To specify that exactly one object has a property
	$!x P(x)
	is the same as
	$x P(x) ^ "y P(y) -> x = y

When a predicate or function does not increase the 
expressiveness of a notation it can be called syntactic 
sugar.


Lambda expressions

allows construction of complex predicates and functions

	Aunt (a, n):
	   l a,n Gender(a) = Female ^ $p Sibling(p, a) ^ Parent(p, n)
	Difference of squares (x, y):
	   l x,y  (x * x) - (y * y)



		DOMAIN MODELING IN FIRST-ORDER LOGIC


The Kinship Domain

given predicates Parent, Spouse, Female, generate 
functions to describe other family relations

	" m,c Mother(c) = m <-> Female(m) ^ Parent(m, c)

	" x Male(x) <-> not Female(x)

	" w,h Husband(h, w) <-> Male(h) ^ Spouse(h, w)

	" p,c Child(c, p) <-> Parent(p, c)

	" g,c Grandparent(g, c) <-> $p Parent(g, p) ^ Parent(p, c)

	" x,y Sibling(x, y) <-> x != y ^ $p Parent(p, x) ^ Parent(p, y)

What about aunt, cousin, brother-in-law, ...



			THE DOMAIN OF SETS

Using EmptySet and Adjoin we can represent the domain 
of sets in first-order logic.

The empty set has no elements:

	not $ x,s Adjoin(x, s) = EmptySet

A set is the empty set or a set with elements adjoined to it:

	" s   Set(s) <->
	 (s = EmptySet) v ($ x,s2 Set(s2) ^ s = Adjoin(x, s2))

A member is an element adjoined:

	" x,s   Member(x,s) <-> 
	  $ y,s2 (s = Adjoin(y, s2) ^ (x = y v Member(x, s2)))

A subset contains only members of the second set:

	" s1,s2    Subset(s1, s2) <->
	("x Member(x,s1) -> Member(x, s2))

Two sets are equal only if they are subsets of each other.

	" s1,s2    s1 = s2 <-> Subset(s1, s2) ^ Subset (s2, s1)

Definition of Intersection:

	" x,s1,s2   Member(x, Intersection(s1, s2)) <->
	Member(x, s1) ^ Member(x, s2)

Definition of Union:

	" x,s1,s2   Member(x, Union(s1, s2)) <->
	Member(x, s1) v Member(x, s2)



			THE WUMPUS WORLD

A Simple Reflex Agent

  cannot use any information other than percepts

	"s,b,t Percept([s, b, Glitter], t) -> Action(Grab, t)

  this maps directly from percept to action.

A reflex agent can also have intermediate abstractions:

	" s,b,t Percept([s, b, Glitter], t) -> AtGold(t)

	" s,g,t Percept([s, Breeze, g], t) -> Stench(t)

	" b,g,t Percept([Stench, b, g], t) -> Stench(t)

Then combinations of percepts could yield different results:

	" t AtGold(t) -> Action(Grab, t)

	" t Stench(t) ^ not AtGold(t) -> Action(Shoot, t)

	" t Breeze(t) ^ not AtGold(t) ^ not Stench(t) -> 
	Action(BackUp, t)

Problem: No memory of previous percepts, actions.



		REPRESENTING THE WUMPUS WORLD

Situation Calculus

Include a situation identifier as last element of propositions 
or functions whose values can change.

So if our agent moves forward, turns right, and moves 
forward again, this would generate the following 
situations.

	Result(Forward, S0) = S1
	Result(Turn(Right), S1) = S2
	Result(Forward, S2) = S3

Effects of actions described relative to situations

	Portable(Gold)

	"s AtGold(s) -> Present(Gold, s)

	"x,s Present(x,s) ^ Portable(x) ->
	Holding(x, Result(Grab, s))

How do we keep track of attributes across situations that 
do not affect them?

	true afterwards <-> [an action made it true or
			     true already and no action made it false]

	"a,x,s Holding(x, Result(a,s)) <-> 
		[(a = Grab) ^ Present(x, s) ^ Portable(x))
		v (Holding(x,s) ^ a != Release)]



			PREFERENCES AMONG ACTIONS

Ordering potential actions by quality:

	" a,s Great(a, s) -> Action(a, s)

	" a,s Good(a, s) ^ (not $b Great(b, s)) -> Action(a, s)

	" a,s Medium(a, s) ^ (not $b Great(b, s) v Good(b, s)) -> 
		Action(a, s)

	" a,s Risky(a, s) ^ (not $b Great(b, s) v Good(b, s) v 
		Medium(b, s))-> Action(a, s)

Great actions: picking up gold, climbing out with gold
Good actions: moving to an OK square not yet visited
Medium actions: moving to an OK square that was visited already
Risky actions: moving to a square not known to be deadly 
	but not known to be okay either.

See any problems with this hierarchy?