Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Informatics 1 Computation and Logic, Study Guides, Projects, Research of Logic

Your answers to all the questions in this assignment should be stored in a single file called CLExOne.txt which has your name and matriculation.

Typology: Study Guides, Projects, Research

2021/2022

Uploaded on 09/27/2022

riciard
riciard 🇬🇧

4.4

(7)

234 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computation and Logic: Assessed Assignment 1 Informatics 1 01.10.2004
Informatics 1 Computation and Logic
Assessed Assignment 1
Out on Friday 1st October 2004, due noon Friday 15th October 2004
Your answers to all the questions in this assignment should be stored in
a single file called CLExOne.txt which has your name and matriculation
number on the first line. If you use different files when working on this
assessment then integrate them into CLExOne.txt before submission.
Submit CLExOne.txt before the deadline using the following command:
Shell> submit inf1 inf1a cl1 CLExOne.txt
You may discuss this assignment with other students but your submission
should be based on your own work. If you do include work carried out in
collaboration with others you must properly attribute any contributions
that they made to the work. Keep in mind that you are responsible for
deriving educational value from your assignments.
In this exercise you will use a simple proof system. It is written in the Prolog
programming language which you do not learn in this course, although we will
mention it in a few weeks time. Prolog programs are run by providing goals
for the system to solve, so when you are asked to “give a goal” to Prolog that
means to type in an expression for Prolog to attempt to solve. Prolog then comes
back with a yes (plus perhaps some values for variables) if it finds a solution or
answers no if it cannot find a solution. You then press carriage return before
giving further goals.
First copy the code for the proof system to the file prover.pl in your own
directory by going to the Informatics 1 Computation and Logic Web page and
downloading the file from the link on that page labeled “Prover for Assessed
Exercise 1” (ask a demonstrator if you don’t know how to download a file from a
Web page). You do not need to look at the contents of this file.
To start the proof system do the following:
Give the command sicstus to start the Prolog system.
Then type [prover]. to load the file into Prolog. Remember to type the full
stop at the end (a full stop is the symbol that tells Prolog you have finished
a definition or instruction).
Now try your first proof with this system. This will be the proof that the
proposition bfollows from the assumptions [a, a b]. Give the following goal (by
typing it in as given below). Rember the full stop and carriage return.
prove([a, a ---> b], b).
1
pf3
pf4

Partial preview of the text

Download Informatics 1 Computation and Logic and more Study Guides, Projects, Research Logic in PDF only on Docsity!

Informatics 1 Computation and Logic

Assessed Assignment 1

Out on Friday 1st October 2004, due noon Friday 15th October 2004

Your answers to all the questions in this assignment should be stored in a single file called CLExOne.txt which has your name and matriculation number on the first line. If you use different files when working on this assessment then integrate them into CLExOne.txt before submission. Submit CLExOne.txt before the deadline using the following command: Shell> submit inf1 inf1a cl1 CLExOne.txt You may discuss this assignment with other students but your submission should be based on your own work. If you do include work carried out in collaboration with others you must properly attribute any contributions that they made to the work. Keep in mind that you are responsible for deriving educational value from your assignments.

In this exercise you will use a simple proof system. It is written in the Prolog programming language which you do not learn in this course, although we will mention it in a few weeks time. Prolog programs are run by providing goals for the system to solve, so when you are asked to “give a goal” to Prolog that means to type in an expression for Prolog to attempt to solve. Prolog then comes back with a yes (plus perhaps some values for variables) if it finds a solution or answers no if it cannot find a solution. You then press carriage return before giving further goals.

First copy the code for the proof system to the file prover.pl in your own directory by going to the Informatics 1 Computation and Logic Web page and downloading the file from the link on that page labeled “Prover for Assessed Exercise 1” (ask a demonstrator if you don’t know how to download a file from a Web page). You do not need to look at the contents of this file.

To start the proof system do the following:

  • Give the command sicstus to start the Prolog system.
  • Then type [prover]. to load the file into Prolog. Remember to type the full stop at the end (a full stop is the symbol that tells Prolog you have finished a definition or instruction).

Now try your first proof with this system. This will be the proof that the proposition b follows from the assumptions [a, a → b]. Give the following goal (by typing it in as given below). Rember the full stop and carriage return.

prove([a, a ---> b], b).

You should get the reply yes, meaning that this is provable. Had it not been provable the answer would have been no.

The table below shows the correspondence between the notation you use in the Prolog prover and the notation given in the lecture notes.

Lecture notes Prover F ` A prove(F, A) A and B A and B A or B A or B A → B A ---> B not(A) not(A)

Exercises

  1. Write down the goal you give to the Prolog system for each of the following proofs and the answer that Prolog gives. You should find that these all can be proved.

(a) [a(1), a(X) → b(X)] b(Y ) (b) [a(1), a(2), b(2), a(X) and b(X) → c(X)] c(Y ) (c) [r(a, b), r(b, c), r(c, d), r(X, Y ) → p(X, Y ), p(A, B) and r(B, C) → p(A, C)] ` p(a, d)

  1. The prover succeeds when given the goal prove([], not(a)). and this is not a programming error. Explain what this suggests to you about the way it has been built to handle negation.
  2. The prover fails when given the goal prove([a and b], a or b). and this is not a programming error. Explain what this suggests to you about the proof system by comparing its result to the result you get using a truth table.
  3. The prover allows you to load in a set of assumptions from a file. Go to the Informatics 1 Computation and Logic Web page and download the file from the link labeled “Assumption Set for Tic-Tac-Toe”. Give this file the name axioms. You now should look in the axioms file. It contains three axioms that define how to play a basic game of Tic-Tac-Toe. The axioms contain predicates that have the following meanings: - game(P, Gs, Pw, G) denotes a game with current player P and cur- rent state of the game board Gs; leading to a win by player Pw and final board state G. A board state is a set of elements of the form m(S,P) where S is the number of a board square and P is the player occupying it. Initially the board is an empty set, denoted by [] - player(P) means P is a player. The only valid values for P are a or b.

file to a new file and replace the third expression with one or more new axioms that provide a more sophisticated move strategy. It should be pos- sible for you to devise a strategy that guarantees that the starting player will not be beaten. You may find useful the additional (supplied) predi- cate completes_row(P, G, S) which is true when player P can in the next move complete three marks on a row, column or diagonal in board state G.