PProlog Assigment (writing set of facts, rules and queries)
Hello, I need your help on my prolog assigment.
Please use the basic logic (if, and…) as much as possible. This is the first assigment of prolog in my class.
I will post a quick sumary here, but please read the attachment for details:
I need your help to create two prolog files (***.pl): the first one will contain a set of facts and rules, and the second one will contain queries.
There is 4 rules and 10 queries that I need your help to define:
The first file will contain facts and rules:
Facts:
emp_name(SSN, NAME).
job_hist(SSN, TITLE, DATE, COMP). {DATE is the starting date.}
quit(SSN, DATE, COMP). {DATE is the departure date.}
supervisor(SSN1,SSN2). {SSN1 is above SSN2 in the current hierarchy}
Rules:
current_job(SSN, TITLE, COMP).
samelastname(SSN1, SSN2, COMP) meaning “Are there two people at the same company
with the same last name?”
worktogether(SSN1, SSN2) meaning “Did these two people work together at the
same company during the same year?”
above(SSN1, SSN2). “Is first above second in the hierarchy?”
The second file will contain 10 queries that you can define by yourself.
Please read the attachment for more details.
Prolog Programming Assignment
This assignment concerns facts and rules that might be part of a larger
(Prolog-style) database of an employee/employer information. We will require
that the company organization is hierarchical (that is, there are no cycles
in the organization chart), but it need not be a tree (for example, someone
may be supervised by, say, two vice-presidents).
We will use these types of data items:
SSN – a 3 digit ID number (unique for each employee)
NAME – a list of 2 or 3 items; [bob, smith] or [edgar, allan, poe]
TITLE – a job title; president, vice_president, department_head, worker, etc.
COMP – a company name; sysco, ibm, etc.
DATE – a four-digit year
FACTS: The only type of facts are listed here. You can assume that while someone
may change titles at one company, they are not rehired there after quitting.
emp_name(SSN, NAME).
job_hist(SSN, TITLE, DATE, COMP). {DATE is the starting date.}
quit(SSN, DATE, COMP).
{DATE is the departure date.}
supervisor(SSN1,SSN2).
{SSN1 is above SSN2 in the current
hierarchy}
RULES: You will write the following rules:
current_job(SSN, TITLE, COMP).
samelastname(SSN1, SSN2, COMP). Are there two people at the same company
with the same last name?
worktogether(SSN1, SSN2).
Did these two people work together at the
same company during the same year?
above(SSN1, SSN2).
Is first above second in the hierarchy?
You will probably want to add a few auxiliary rules of your own to the list.
SUBMISSION: You will submit two (ascii) files. The first has your program which
will include your rules and a set of facts. The data should have two companies with
at least 5 levels in the organization, and include a total of at least 10 people;
it should have enough complexity that every rule can be fully tested (preferably
in more than one way). You must write the four rules given above.
The second will contain 10 queries. The queries must varied and demonstrate
that you understand how to use queries creatively. For example you might query:
What is the first name of someone found with samelastname?
Who is neither at the top or bottom of the hierarchy?
Did a group of three people work together in pairs (ignoring dates)?
You second file should be readable, containing the queries on separate lines
from short explanations of what the “question” is in English.
We will test your program with your facts and queries; also with our facts.
Note that an important part of the assignment is designing the facts and queries.
Preparing: Study Appendix A of the text. Section A.2 has some practical
details. First try just starting and stopping (see table below). Then try
some of the built-in capabilities of Prolog like the list conventions and
the “=” operator for binding/matching; e.g., type this:
[X|Y] = [a,b,c].
Also try out the is operator to force evaluation of arithmetic
expressions, like this: X is 3+2. The relational arithmetic operators
work too, so 5>4 succeeds.
Files: Before entering a Prolog session, create a file (using any editor)
that contains the facts and rules you wish to test. Start with simple predicates.
Avoid blanks between the predicate and the left parenthesis
Start variable names with Capitals.
Start predicates, facts and data names with lower case letters.
Don’t forget the period at the end of facts and rules.
Starting: At the Unix prompt, type the Unix command prolog to start
interacting with the Prolog interpreter on the server. To load
your facts and/or rules from a file called file1 into the session, type
[file1]. ending with a period. If you entered Prolog while not in the
directory containing the file, give the full path, within single quotes:
[‘pro/file1’]. (You can also use the consult() command as described in the
text.) You can load two files at once, like this: [factfile, rulefile]. If
you unintentionally hit the key without the period, just type a
period and another . After loading your file(s), type in queries
and you will get the answers.
Stopping: Before you start anything, know how to stop it! To halt a Prolog
session, use halt. which is a Prolog predicate with no arguments, with the
side-effect of exiting Prolog. To stop an unresponsive Prolog process that
may be in an infinite loop, use a .
Tracing: For debugging, you can have the Prolog processor trace the steps
by which it reached its conclusions. This can get pretty complex, though,
so you may want to turn it off. To start the process type trace. and to
turn it off, use notrace.
This assignment concerns facts and rules that might be part of a larger
(Prolog-style) database of an employee/employer information. We will require
that the company organization is hierarchical (that is, there are no cycles
in the organization chart), but it need not be a tree (for example, someone
may be supervised by, say, two vice-presidents).
We will use these types of data items:
SSN – -a 3 digit ID number (unique for each employee)
NAME – a list of 2 or 3 items; [bob, smith] or [edgar, allan, poe]
TITLE – a job title; president, vice_president, department_head, worker, etc.
COMP – a company name; sysco, ibm, etc.
DATE – a four-digit year
FACTS: The only type of facts are listed here. You can assume that while someone
may change titles at one company, they are not rehired there after quitting.
emp_name(SSN, NAME).
job_hist(SSN, TITLE, DATE, COMP). {DATE is the starting date.}
quit(SSN, DATE, COMP).
{DATE is the departure date.}
supervisor(SSN1,SSN2).
{SSN1 is above SSN2 in the current
hierarchy}
RULES: You will write the following rules:
RULES: You will write the following rules:
current_job(SSN, TITLE, COMP).
samelastname(SSN1, SSN2, COMP). Are there two people at the same company
with the same last name?
worktogether(SSN1, SSN2).
Did these two people work together at the
same company during the same year?
above(SSN1, SSN2).
Is first above second in the hierarchy?
You will probably want to add a few auxiliary rules of your own to the list.
SUBMISSION: You will submit two (ascii) files. The first has your program which
will include your rules and a set of facts. The data should have two companies with
at least 5 levels in the organization, and include a total of at least 10 people;
it should have enough complexity that every rule can be fully tested (preferably
in more than one way). You must write the four rules given above.
The second will contain 10 queries. The queries must varied and demonstrate
that you understand how to use queries creatively. For example you might query:
What is the first name of someone found with samelastname?
Who is neither at the top or bottom of the hierarchy?
Did a group of three people work together in pairs (ignoring dates)?
You second file should be readable, containing the queries on separate lines
from short explanations of what the “question” is in English.
We will test your program with your facts and queries; also with our facts.
Note that an important part of the assignment is designing the facts and queries.
Top-quality papers guaranteed
100% original papers
We sell only unique pieces of writing completed according to your demands.
Confidential service
We use security encryption to keep your personal data protected.
Money-back guarantee
We can give your money back if something goes wrong with your order.
Enjoy the free features we offer to everyone
-
Title page
Get a free title page formatted according to the specifics of your particular style.
-
Custom formatting
Request us to use APA, MLA, Harvard, Chicago, or any other style for your essay.
-
Bibliography page
Don’t pay extra for a list of references that perfectly fits your academic needs.
-
24/7 support assistance
Ask us a question anytime you need to—we don’t charge extra for supporting you!
Calculate how much your essay costs
What we are popular for
- English 101
- History
- Business Studies
- Management
- Literature
- Composition
- Psychology
- Philosophy
- Marketing
- Economics