AI class homework 4

From John's wiki
Jump to navigation Jump to search

These are my notes for homework 4 of the AI class.

Homework

Logic

Note

Select whether the logical sentences are always true (T), always false (F), or sometimes true sometimes false depending on the values of the variables (?).

Code

I used the following code to solve this question.

 function print( line ) { WScript.StdOut.WriteLine( line ); }

 function implies( p, q ) {
   if ( p === true && q === false ) { return false; }
   return true;
 }

 function a( smoke, fire ) {

   return implies( smoke, fire ) === ( smoke || ! fire );

 }

 function b( smoke, fire ) {

   return implies( smoke, fire ) === implies( ! smoke, ! fire );

 }

 function c( smoke, fire ) {

   return implies( smoke, fire ) === implies( ! fire, ! smoke );

 }

 function d( big, dumb ) {

   return big || dumb || implies( big, dumb );

 }

 function e( big, dumb ) {

   return ( big && dumb ) === ! ( ! big || ! dumb );

 }

 function check_t() { return true; }
 function check_f() { return false; }
 function check_d( a ) { return a; }

 function test( label, f ) {
 
   var results = { "true": 0, "false": 0 };

   var iter = function( p1, p2 ) {

     var t = f( p1, p2 );

     results[ t.toString() ]++;

   }

   iter( false, false );
   iter( false, true  );
   iter( true , false );
   iter( true , true  );

   if ( results[ "true" ] === 4 ) {
     print( label + " all true." );
   }
   else if ( results[ "false" ] === 4 ) {
     print( label + " all false." );
   }
   else {
     print( label + " depends." );
   }
 }

 test( "a", a );
 test( "b", b );
 test( "c", c );
 test( "d", d );
 test( "e", e );

 test( "check t", check_t );
 test( "check f", check_f );
 test( "check d", check_d );

Answer

More Logic

Note

Select whether the logical sentence correctly encode the english sentence (check-mark), incorrectly encode the english sentence (X), or not a legitimate sentence in first-order logic (Err).

English Sentences and the lines with the corresponding logical sentences:

Paris and Nice are both in France.

Corresponding translations on lines 1 and 2.

There is a country that borders Iran and Syria'

Corresponding translations on lines 3 and 4.

No two bordering countries can have the same map color.

Corresponding translations on lines 5 and 6.

The fourth statement is missing a ) at the end.

Answer

Vacuum World

Note

The image represents belief states of the two-room vacuum world. In this version there are no percepts/sensors, the actions are all deterministic, and the environment is static. In the initial state you have no information about which state you are in. Your goal is to be in the leftmost of the two squares and have both squares cleaned up.

Click on the shortest sequence of actions (L, R, or S) that take you from the initial state to the goal state (determining the initial and goal states are part of the problem).

Select yes if the sequence is guaranteed to always reach the goal or no if it is not.

Answer

More Vacuum World

Note

This problem deals with a version of the two-room vacuum world where there is local sensing, dynamic dirt generation, and stochastic movement actions. Local sensing means after any action you get information about the room you are in (left or right) and whether there is dirt in that room, but no information about dirt in the other room. The world is dynamic, which means dirt can spontaneously appear in either room after an action is performed except when the robot has performed a suck action, in which case the room where the suck action has been performed will have no dirt. Left and right moves are stochastic because they can sometimes fail, for example, the robot might not move right even if the move right action is chosen. The suck action is deterministic so it will always succeed in removing dirt.

Given we start in the leftmost location and that location is clean (i.e. we start in either belief state 5 or 7), select the set of belief states we have after performing a move right action.

Answer

More Vacuum World

Note

Assume we have the same belief states that we had at the end of problem 4. We now sense that we are in the right most square and the square is dirty. Click on all the belief states given this percept.

Answer

More Vacuum World

Note

Assume we have belief states two and six. We perform a suck action. Select the belief states we have after performing the suck action.

Answer

More Vacuum World

Note

Assume we have the same belief states that we had at the end of problem 6. We now sense that we are in the right most square and the square is clean. Select the belief states we have after sensing.

Answer

Monkey and Bananas

Note

Given the plan written in red on the upper right piece of paper and the initial state described at the very bottom of the screen, select the statements that will be true in the final state after performing the plan starting in the initial state.

Clarifications:

  • The effect on ClimbUp should be: On(Monkey, b) and !Height(Monkey, Low) and Height(Monkey, High)
  • There should also be an additional precondition at Push action, add: At(b, x), where b = box.

Thanks to Naran Bayanbat for these clarifications.

It is intentional for the bananas to remain high.

Answer

Situation Calculus

Note

The domain for this problem is a combination lock with 4 digits. There are two actions

  1. dial any combination into the lock, where the result is the lock opening if the right combination (X) is dialed
  2. push a lock button (L) which makes the lock, locked

Select the axioms that correctly encode the situation.

Notation:

  • Poss(action, situation) - possible to perform action in a given situation
  • X - the correct combination

Answer