Prolog Procedure si(A) Does not Exist

Viewed 360

This is the code

verificar(S) :-
    (si(S)
    ->  
    true ;
    (no(S)
    ->  
    fail ;
    preguntar(S))).

preguntar(Pregunta) :-
    write('Tiene los siguientes sintomas: '),
    write(Pregunta),
    write('?'),
    read(Respuesta),
    nl,
    ( (Respuesta == si)
    ->  
    assert(si(Pregunta));
    assert(no(Pregunta)), fail).

and the problem is

procedure `si(A)' does not exist
Reachable from:
      verificar(A)
      resfriado
      hipotesis(A)
      evaluar
    
2 Answers

The problem is for the first run, the program does not know what you mean with si(A) since there is no predicate or rule defined. Quickfix: Add dummy data like

si(nothing).
no(nothing).

which can be removed after the first "valid" entry in your knowledge base.

You have not written the predicate for si(). This is why you are getting the error:-

procedure `si(A)' does not exist
Related