I am new to start this language, there is a problem that cannot be solved.
There are two buttons: button a and button b.
and two lights: light p and light q.
Rule:
- pressing button a the light p will be on.
- pressing button b will interchanges p and q.
- initially, p and q are off.
- goal: p and q are on.
Use the Prolog language to solve this question.
Only use clauses of the form like this:
p(T+1) :- ...
q(T+1) :- ...
Using the following action names:
name: press_a, meaning: press button a
name: press_b, meaning: press button b
the rule T+1 instantiated by 1 and T instantiated by 0,
and the additional fact press_a(0).
the program should mention these six atoms:p(1),p(1),p(0),p(0),press_a(0),press_b(0).
The part of my code, but I am not sure if it is correct:
p(T+1) :- press_a(T),not p(T).
p(T+1) :- q(T), not p(T), press_b(T).
q(T+1) :- not q(T), p(T), press_b(T).
Hello,
I use Prolog programming daily in my regular employment.
I will create a Prolog solution to your posted problem. I will use SWI Prolog.
A milestone payment for the full budget for this project must be deposited with this site before your offer can be accepted.
Alan Idler
Chief Software Architect
Idleswell Software Creations