Page 1 of 1

Family tree simple project

Posted: 7 Dec 2013 15:26
by hadiranji
hi
i am new in visual prolog and i read some book about it but i can't define fact and rule in visual prolog
this is my program :

%fact
parent( pam, bob).
parent( bob, liz).

%rule
grandparent(X,Z):-parent( X, Y),parent( Y, Z).

%goal
edit3_ctl:setText=grandparent( edit1_ctl:getText(), edit2_ctl:getText()).

any body can give me this project in visual polog for helping me to start learning visual prolog ?

thanks

Family example of the Visual Prolog 5.2

Posted: 10 Dec 2013 10:10
by Ferenc Nagy
Hi,

The attached archive is the family example of the earlier version of Prolog.

Code: Select all

Here I quote the main code: /*****************************************************************************                   Copyright (c) 1984 - 2000 Prolog Development Center A/S    Project:  FAMILY  FileName: FAMILY.PRO  Purpose: No description  Written by: Visual Prolog  Comments: ******************************************************************************/     database - tmp   son(STRING,STRING)   sister(STRING,STRING)   brother(STRING,STRING)   married(STRING,STRING)   clauses   son("John","Dan").   sister("Mary","Suzan").   brother("Harold","Larry").   married("John","Mary").   married("Larry","Sue").   predicates   father(STRING father,STRING child)   grandfather(STRING grandfather,STRING grandchild)   sister_in_law(STRING,STRING)   clauses   father(A,B):-         son(B,A).     grandfather(A,B):-         father(A,C),         father(C,B).     sister_in_law(A,B):-         married(A,C),         sister(C,B).   sister_in_law(A,B):-         brother(A,C),         married(C,B).   goal   sister_in_law("John",Z),   format(Msg,"sister_in_law(\"John\",%)",Z),   write(Msg). %goal % sister_in_law("Harold",Z).
You can use in an Easywin project or add the "let us blind the peasant" MDI user interface.
You may continue like

predicates
cousin(string, string).
clauses
cousin(A,B) :-
grandfather(G,A),grandfather(G,B).

Posted: 11 Dec 2013 19:53
by Thomas Linder Puls
In the IDE: Help -> Install Examples... will install examples.

In the installed examples folder you will find the project _tutorial\family\family1\family1.prj6.

It contains the code corresponding to the tutorial: Fundamental Visual Prolog.