We've got this assignment and you can write it in any language you want...it's got rules and predicates all ready in it so i was thinking of trying out prolog for it. Anyone know a good prolog compiler as well as a good tutorial on prolog?
Prologextra credit assignment
Page 1 of 1
6 Replies - 1601 Views - Last Post: 21 April 2007 - 05:50 AM
Replies To: Prolog
#2
Re: Prolog
Posted 26 March 2007 - 02:55 PM
I've used SWI-Prolog with no real problems.
The tutorials I found were through a google search.
The tutorials I found were through a google search.
#3
Re: Prolog
Posted 26 March 2007 - 06:28 PM
im a little confused on how to begin...nothing seems to explicitly tell you how to use simple statements like a -> b (though i may be looking it over)
#4
Re: Prolog
Posted 26 March 2007 - 07:36 PM
how do you meant a->b?
prolog is programming logic, it is not object oriented and it is not your average language at all. It is a very recursive intense language and you must order your cases correctly as well as including the proper number of variables.
Here is a basic code which compares based on "enjoys", the first line enjoys.robert->baseball could be a meaning of this that it's implied that robert enjoys baseball. The last case of enjoys allows the item to be a list of 2 items, thus both items need to be shared, this can be extended easily with recursion.
I think the common method is straight forward, X and Y are people and Z is an activity. Hope this gives a basic start on teh structure. ! was my favorite thing in prolog.
prolog is programming logic, it is not object oriented and it is not your average language at all. It is a very recursive intense language and you must order your cases correctly as well as including the proper number of variables.
Here is a basic code which compares based on "enjoys", the first line enjoys.robert->baseball could be a meaning of this that it's implied that robert enjoys baseball. The last case of enjoys allows the item to be a list of 2 items, thus both items need to be shared, this can be extended easily with recursion.
I think the common method is straight forward, X and Y are people and Z is an activity. Hope this gives a basic start on teh structure. ! was my favorite thing in prolog.
enjoys(robert, baseball). enjoys(robert, swimming). enjoys(robert, basketball). enjoys(robert, jogging). enjoys(margaret, baseball). enjoys(margaret, gardening). enjoys(margaret, soccer). enjoys(ronald, football). enjoys(ronald, tv). enjoys(ronald, baseball). enjoys(X,[Y,Z]) :- enjoys(X,Y), enjoys(X,Z). common(X, Y, Z) :- enjoys(X, Z), enjoys(Y, Z). /*returns the common activity */
#5
Re: Prolog
Posted 26 March 2007 - 07:41 PM
maybe I can elaborate on my question:
For the assignment we were given a set of rules used to derive certain implications
a -> b
b ^ c -> d
b -> e
e ^ f -> g
c ^ e ^ f -> h
Also we were given two facts a and f to be considered true.
you input a statement such as 'g' and it prints out the steps involved in proving that 'g' is true
a is true a->b
b is true b->e
e is true e ^ f -> g
as a counter example
you could not prove statement d to be true because c is not defined as true
For the assignment we were given a set of rules used to derive certain implications
a -> b
b ^ c -> d
b -> e
e ^ f -> g
c ^ e ^ f -> h
Also we were given two facts a and f to be considered true.
you input a statement such as 'g' and it prints out the steps involved in proving that 'g' is true
a is true a->b
b is true b->e
e is true e ^ f -> g
as a counter example
you could not prove statement d to be true because c is not defined as true
#6
Re: Prolog
Posted 12 April 2007 - 03:31 PM
mattman059, on 26 Mar, 2007 - 07:41 PM, said:
maybe I can elaborate on my question:
For the assignment we were given a set of rules used to derive certain implications
a -> b
b ^ c -> d
b -> e
e ^ f -> g
c ^ e ^ f -> h
Also we were given two facts a and f to be considered true.
you input a statement such as 'g' and it prints out the steps involved in proving that 'g' is true
a is true a->b
b is true b->e
e is true e ^ f -> g
as a counter example
you could not prove statement d to be true because c is not defined as true
For the assignment we were given a set of rules used to derive certain implications
a -> b
b ^ c -> d
b -> e
e ^ f -> g
c ^ e ^ f -> h
Also we were given two facts a and f to be considered true.
you input a statement such as 'g' and it prints out the steps involved in proving that 'g' is true
a is true a->b
b is true b->e
e is true e ^ f -> g
as a counter example
you could not prove statement d to be true because c is not defined as true
hi, prolog is all about facts, rules, and query.
swi prolog is an excellent compiler. the first thing you sre going to notice is a prompt in the way of ?, at that point enter "consult(user)." without the quotes, and press enter. you now should have a prompt in the way of a - , at this point declare a predicate, and give it parameters. this is setting facts. example: "true(a,
now to compile the program "end_of_file." again no quotes. make sure that you are ending all statements with periods. after the program compiles, you will again have the question mark prompt. at this point enter your query.
you should be able to get started with this much. i am just learning prolog myself, so good luck, and have fun.
#7
Re: Prolog
Posted 21 April 2007 - 05:50 AM
Hi!
SOS! I need somebody to help in prolog and/or sml. I'm not strong at programming:(
I have a stringlist ts = [t0, t1, ..., tz-1] z>=0 is the length of the list and k>0 is the max superimposition between the words. All words are different.
2 words are in n superposition when the last n letter= first n letter
example:
| ?- max_k_atfedok(2, [asztalos,alma,apu,utas,anyu,satu,malom], L1).
L1 = [alma-[1-anyu,1-apu,1-asztalos,2-malom],anyu-[1-utas],apu-[1-utas],
asztalos-[1-satu],satu-[1-utas],utas-[1-satu,2-asztalos]] ? ;
I have to creat this program in prolog and sml too.
Thx for help!
ps: I have a program about simple n superposition
SOS! I need somebody to help in prolog and/or sml. I'm not strong at programming:(
I have a stringlist ts = [t0, t1, ..., tz-1] z>=0 is the length of the list and k>0 is the max superimposition between the words. All words are different.
2 words are in n superposition when the last n letter= first n letter
example:
| ?- max_k_atfedok(2, [asztalos,alma,apu,utas,anyu,satu,malom], L1).
L1 = [alma-[1-anyu,1-apu,1-asztalos,2-malom],anyu-[1-utas],apu-[1-utas],
asztalos-[1-satu],satu-[1-utas],utas-[1-satu,2-asztalos]] ? ;
I have to creat this program in prolog and sml too.
Thx for help!
ps: I have a program about simple n superposition
Attached File(s)
-
prolog.txt (1.5K)
Number of downloads: 102
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|