On Sat, 4 Jan 2025 17:46:55 +0000, minforth wrote:
Thank you for sharing your outstanding work here!
>
I don't think I understand the details of your program
but it seems to me way simpler than the famous Warren
Abstract Machine. IMHO your concept is very well suited
for teaching students how to approach problemss from
the ground up.
Thanks,
It works also under minforth MF348 (64 bit).
I had not Warren abstract machine in mind when I wrote it. I just
denfined facts, rules, forward chaining, backward chaining and some
words to interface it to set inference modes, display rules and facts.
Facts are structures with fields : name, use, true/flase, action and
text
name: in order to recognize the fact appearing in rules,
use : true if already used in the process of inference (false if
not), in
order to not repeat the test if it is true or false (true/false
field).
action: the fact can execute words if it is true,
text: additional field for comments, other actions, ...
Rules have the form :
goal_fact :- condition_fact1 , condition_fact2 , ... ,
condition_factn .;
... stands for other condition_facts
:-
,
.; are forth words
These three words are like defered words implemented with variables and
@ execute (first, I used defered words but that didn't give the good
results for iForth and vfxForth).
These words change their behavior for 3 phases:
- forward mode
- backward mode:
- verify facts: the operator (user) respond by yes/no, (yes and no
are
defined as forth words) when prompted by:
verify factname <---
- update facts: perform the actions in the facts (action field)
if the fact
is true (true/false field)
- use facts: perform the infernce
In forward mode, the user asserts the facts that he knows they are true
then invoke the forth word ->? to launch the inference process and with
result forth word he can display the result of the inference.
He can also use .facts forth word to see the facts that are true.
In backward mode, the user can launch the process of inference using the
forth word <-? . The infernce launched this way ask the user to verify
certain facts (that appear in the condition part of the rules) and the
user respond with yes or no, and an empty response is considered as no,
and a response other than yes/no/empty will stop the process of
inference with an error ( undefined word).
During this inference process, the system can guess the result and
perhaps display 'Apparently: ....' followed bye a result and after some
steps it stops by 'Finally: ...' and display the result if found and if
not it displays 'No results".
The user can ask the system to give the condition facts that are
necessary to get a goal_fact true. the forth word :-? is used for that.
The user can see the rules using the forth word : .rules or for a
specific rule:
n .rule where n is the number of the rule.
For the moment, the infernce process pass through the rules one after
another in that order. Perhaps, if time permits, I'll change that using
the action field of some facts used to change the flow of the inference.
Notice here:
<-? backward chaining, the arrow <- in <-? is towards the left
->? forward cahining, the arrow -> in ->? is towards the right
:-? asking for condition facts to get a goal fact true, used
like this:
penguin :-?
The user can use :
.mode : to display the current mode used (forward or backward)
forward_mode : to set the forward mode
backward_mode : to set the backward mode
The words <-? and ->? set the mode automatically to backward or forward
respectively.
The work is under development, and possible ideas will be used.
Ahmed
--