Island of Logic Assignment #4 Programming Language, Spring 2003.

Slides:



Advertisements
Similar presentations
AE1APS Algorithmic Problem Solving John Drake. The island of Knights and Knaves is a fictional island to test peoples ability to reason logically. There.
Advertisements

ARDUINO CLUB Session 1: C & An Introduction to Linux.
Lecture 2 Introduction to C Programming
C Introduction Lesson CS1313 Spring C Introduction Lesson Outline 1.C Introduction Lesson Outline 2. hello_world.c 3.C Character Set 4.C is Case.
C Introduction Lesson CS1313 Spring C Introduction Lesson Outline 1.C Introduction Lesson Outline 2. hello_world.c 3.C Character Set 4.C is Case.
Principles of Programming Fundamental of C Programming Language and Basic Input/Output Function 1.
The Island of Knights and Knaves. Raymond Smullyan 1978 A little learning is a dangerous thing; Drink deep, or taste not the Pierian spring: There shallow.
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
1 ICS103 Programming in C Lecture 3: Introduction to C (2)
Humans, Computers, and Computational Complexity J. Winters Brock Nathan Kaplan Jason Thompson.
Review for midterm exam Dilshad M. Shahid Spring NYU.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
Variables in Java Part 2. ICS-3M1 - Mr. Martens - Variables Part 2 Recall the “int” Data Types When you divide one integer by another – you always get.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
An Introduction to Textual Programming
DEDUCTIVE DATABASE.
Chapter 1: The Foundations: Logic and Proofs
ECE 2372 Modern Digital System Design
Introduction to Python
1 VBA – podstawowe reguły języka Opracowanie Janusz Górczyński wg Microsoft Help.
Introduction to Computer Programming Using C Session 23 - Review.
Computer Programming 2 Lab(1) I.Fatimah Alzahrani.
Instructor - C. BoyleFall Semester
CSD 340 (Blum)1 Ifs. CSD 340 (Blum)2 Page that asks user for background color and changes fore color from black if user selects black as background color.
Introduction To PROLOG World view of imperative languages. World view of relational languages. A PROLOG program. Running a PROLOG program. A PROLOG.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Synthesis ENGR 1181 MATLAB 11. Topics  No new material  Covers topics that will be on the Midterm 2 Exam MATLAB 01 – Program Design MATLAB 02 – Introduction.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 22 A First Course in Database Systems.
Lecture #6 OPERATORS AND ITS TYPES By Shahid Naseem (Lecturer)
3D Puzzle Assignment #1 Programming Language, Spring 2003.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Introduction to Java Primitive Types Operators Basic input and output.
READING AND WRITING FILES. READING AND WRITING FILES SEQUENTIALLY  Two ways to read and write files  Sequentially and RA (Random Access  Sequential.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Structured Programming (4 Credits) HNDIT Week 2 – Learning Outcomes Design an algorithmic solution for simple problem such as computation of a factorial,
Variables and Expressions CMSC 201. Today we start Python! Two ways to use python: You can write a program, as a series of instructions in a file, and.
ELEE 4303 Digital II Introduction to Verilog. ELEE 4303 Digital II Learning Objectives Get familiar with background of HDLs Basic concepts of Verilog.
Computing with SAS Software A SAS program consists of SAS statements. 1. The DATA step consists of SAS statements that define your data and create a SAS.
Martin T. Press.  Main Method and Class Name  Printing To Screen  Scanner.
1. 2 You can QUOTE me on that A quote is the exact wording of a statement from a source. That statement may be a fact or it may be opinion. Quotes make.
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
Sequential Processing to Update a File Please use speaker notes for additional information!
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
CS 1428 Exam I Review. Exam Format 130 Total Points – 40 Points Writing Programs – 30 Points Tracing Algorithms and determining results – 20 Points Short.
General Discussion of “Properties” The Pumping Lemma Membership, Emptiness, Etc.
Numbers in ‘C’ Two general categories: Integers Floats
Niu Kun Discrete Mathematics Chapter 1 The Foundations: Logic and Proof, Sets, and Functions Niu Kun 离散数学.
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Decision Properties of Regular Languages
CS 1428 Exam I Review.
Notes Over 2.1 Function {- 3, - 1, 1, 2 } { 0, 2, 5 }
Applications of Propositional Logic
Programming Right from the Start with Visual Basic .NET 1/e
Structured Program Design
1.6 Represent Functions as Rules and Tables
Core Objects, Variables, Input, and Output
WEEK-2.
Assignment #3 Programming Language, Spring 2003
Knights and Knaves.
Semantic and Declarative Technologies AIT Budapest
Discrete Structures Prepositional Logic 2
Tell whether the relation below is a function.
DATA TYPES AND OPERATIONS
Algorithms CSCI 235, Spring 2019 Lecture 37 The Halting Problem
Presentation transcript:

Island of Logic Assignment #4 Programming Language, Spring 2003

Island of Logic Island –Three kind of inhabitants Divine beings Evil beings Human beings –Distinguish the three kinds of beings

Inhabitants –Rules Divine beings that always tell the truth Evil beings that always lie Human beings that are truthful during the day and lie at night Every inhabitant recognizes the type of every other inhabitant

Assignment Objectives –Find out What kind of beings the speakers are Whether it is day or night Requirements

Input Convention (1) Input file –Contains several descriptions of conversations –Each description starts with an integer n, the number of statements in the conversation –The following n lines each contain one statement by an inhabitant –The input is terminated by a test case starting with n = 0

Input Convention (2) Statements of Conversation –Every statement line begins with the speaker's name One of the capital letters A, B, C, D, E, followed by a colon ‘:' –Next is one of the following kinds of statements I am [not] ( divine | human | evil | lying ). X is [not] ( divine | human | evil | lying ). It is ( day | night ). –X stands for some name from A, B, C, D, E.

Input Convention (3) Statements of Conversation –Example 1 A: I am divine. 1 A: I am lying. 1 A: I am evil. 3 A: B is human. B: A is evil. A: B is evil. 0

Output Convention (1) Output file (1) –For each conversation, first output the number of the conversation Ex) Conversation #1 –Print ``This is impossible.'‘, if the conversation cannot happen according to the rules ``No facts are deducible.'', if no facts can be deduced Otherwise print all the facts that can be deduced

Output Convention (1) Output file (2) –Deduced facts should be printed using the following formats X is ( divine | human | evil ). It is ( day | night ). –X is to be replaced by a capital letter speaker name –Facts about inhabitants must be given first (in alphabetical order), then it may be stated whether it is day or night –The output for each conversation must be followed by a single blank line

Output Convention (3) Output Deduced facts –Example Conversation #1 No facts are deducible. Conversation #2 This is impossible. Conversation #3 A is human. It is night. Conversation #4 A is evil. B is divine.

Source Code island.pl –Input statements of conversation from file island.in –Output Deduced facts into file island.out

Spec. Assignment Spec. –System Unix –Language Prolog (GNU Prolog)