Shared Flashcard Set

Details

Adprime
Weighted Contstraints applied to job shop scheduling
28
Computer Science
Professional
11/19/2006

Additional Computer Science Flashcards

 


 

Cards

Term
What does prolog stand for?
Definition
PROgramming in LOGic
Term
What does it mean for prolog to be a declarative language?
Definition
Rather than describing how to compute a solution, a program consists of a data base of facts and logical relationships (rules) which describe the relationships which hold for the given application. Rather then running a program to obtain a solution, the user asks a question. When asked a question, the run time system searches through the data base of facts and rules to determine (by logical deduction) the answer.
Term
What are some of the features of prolog?
Definition
logical variables meaning that they behave like mathematical variables, a powerful patten-matching facility (unification), a backtracking strategy to search for proofs, uniform data structures, and input and output are interchangeable.
Term
What happens if there are multiple solutions to a problem?
Definition
The run time system may backtrack to generate alternative solutions. Prolog is a weakly typesd language with dynamic type checking and static scope rules.
Term
What does a prolog program consist of?
Definition
A prolog program consists of a database of facts and rules, and queries (questions).

Fact: .
Rule: :-
Query: ?-

Variables: must begin with an upper case letter.

Constants: numbers, begin with lowercase letter, or enclosed in single quotes.
Term
What is interesting to understand about a prolog program?
Definition
A prolog program consists of a data base of facts and rules. There is no structure imposed on a prolog program, there is no main procedure, and there is no nesting of definitions. All facts and rules are global in scope and the scope of a variable is the fact or rule in which it appears. The readability of a Prolog program is left up to the programmer.
Term
How is a prolog program executed?
Definition
A prolog program is executed by asking a question. The question is called a query. Facts, rules, and queries are called clauses.
Term
What is a fact is in prolog?
Definition
A fact is just what it appears to be --- a fact. A fact in everyday language is often a proposition like "It is sunny" or "It is summer." In Prolog such facts could be represented as follows:

'It is sunny'.
'It is summer'.
Term
What is a query in prolog?
Definition
A query in prolog is the action of asking the program about information contained within its data base. Thus, queries usually occur in the interactive mode. After a program is loaded, you will receive the query prompt,

?-

at which time you can ask the run time system about information in the data base.
Term
What is an example of asking a question in prolog?
Definition
?- 'It is sunny'.

prolog will respond with:

Yes
?-
Term
What does a yes and no to a query in prolog mean?
Definition
A yes means that the information in the data base is consistent with the subject of the query. Another way to express this is that the program is capable of proving the query true with the available information in the data base. If a fact is not deducible from the data base the system replys with a no, which indicates that based on the information available (the closed world assumption) the fact is not deducible.
Term
What is an example of asking a question that would give a no?
Definition
If the data base does not contain sufficient information to answer a query, then it answers the query with a no.

?- 'It is cold'.
no

?-
Term
What are rules in prolog?
Definition
Rules extend the capabilities of a logic program. They are what give Prolog the ability to pursue its decision-making process.
Term
What is an example prolog program illustrating rules?
Definition
'It is sunny'.
'It is summer'.
'It is hot' :- 'It is summer', 'It is sunny'.
'It is cold' :- 'It is winter', 'It is snowing'.


The rule reads as follows:

"It is host if it is summer and it is sunny". The second rule is read as follows: "It is cold if it is winter and it is snowing".

The query,

?- 'It is hot'.

Yes
?-

is answered in the affirmative since both 'It is summer' and 'It is sunny' are in the data base while a query ''?-'It is cole.'" will produce a negative response.

This program is an example of propositional logic.
Term
What is predicate logic in prolog?
Definition
Facts and rules may be parameterized to produce programs in predicate logic. The parameters may be variables, atoms, numbers, or terms. Parameterization permits the definition of more complex relationships.
Term
What is an example of predicate logic in prolog?
Definition
female(amy).
female(johnette).

male(anthony).
male(bruce).
male(ogden).

parentof(amy, johnette).
parentof(amy, anthony).
parentof(amy, bruce).
parentof(ogden, johnette).
parentof(ogden, anthony).
parentof(ogden, bruce).

The above program contains the three simple predicates: female; male; and parentof. They are parameterized with what are called atoms.
Term
Using the predicate logic example, how would you alter/add to the program to find sibblings?
Definition
You first would ask, what does it mean to be a sibling? To be someone's sibling you must have the same parent. This last sentence can be written in Prolog as:

siblingof(X,Y) :-
parentof(Z,X),
parentof(Z,Y).

A translation of the above Prolog rule into English would be X is the sibling of Y provided that Z is a parent of X, and Z is a parent of Y. X, Y, and Z are variables. The rule however, also defines a child to be its own sibling. To correct this we must add that X and Y are not the same. The corrected version is:

siblingof(X,Y) :-
parentof(Z,X),
parentof(Z,Y),
X Y.

The relation brotherof is similar but adds the condition that X must be a male.

brotherof(X,Y) :-
parentof(Z,X),
male(X),
parentof(Z,Y),
X Y.
Term
What can be learned from the sibbling prolog examples?
Definition
From these examples we see how to construct facts, rules, and queries and that strings are enclosed in single quotes, variables begin with a capital letter, constants are either enclosed in single quotes or begin with a small letter.
Term
What are the types in prolog?
Definition
numbers, atoms, lists, tuples, and patterns.
Term
What are the types of objects that can be passed as arguments?
Definition
Type Values
boolean true, fail
integer integers
real floating point numbers
variable variables
atom character sequences
Term
What is important to understand about the type of objects that can be passed as arguments?
Definition
The boolean constants are not usually passed as parameters but are propositions. The constant fail is useful in forcing the generation of all solutions. Variables are character strings beginning with a capital letter. Atoms are either quoted character strings or unquoted strings beginning with a small letter.
Term
What is a great book on constraing programming using eclipse?
Definition
http://www.cambridge.org/us/catalogue/catalogue.asp?isbn=0521866286
Term
What is a great link to a prolog tutorial?
Definition
http://cs.wwc.edu/%7Ecs_dept/KU/PR/Prolog.html
Term
How did prolog originate?
Definition
Prolog originated from attempts to use logic to express grammar rules and formalize the parsing process.
Term
What are definite clause grammars?
Definition
DCG's are a generalization of context free grammars.
Term
What is a meta program?
Definition
Meta programs treat other programs as data. They analyze, transform, and simulate other programs. Prolog clauses may be passed as arguments, added and deleted from the Prolog data base, and may be constructed and then executed by a Prolog program. Implementations may require that the functor and arity of the clause be previously declared to be a dynamic type.
Term
What is arity?
Definition
The number of arguments a predicate taks.
Term
What is the difference between a caluse and a predicate?
Definition
clause are the single things ending with a .

predicate means all under the same name/arity

ex:

foo(1).
foo(2).
foo(3).

there are 3 clauses but one predicate foo/1
Supporting users have an ad free experience!