0
votes

So basically i have this afirmations and rules and somehow the compiler is saying that the clauses are not in the source file and i dont get why, like the program is well written i think?

Program:

forne(f001,zé_dos_parafusos,fabricante,carregado).
forne(f002,branquinho,fabricante,lisboa).
forne(f003,lar_ideal,fabricante,lisboa).

tipo_prod(p001,parafuso).
tipo_prod(p002,broca).
tipo_prod(p003,lavatório).
tipo_prod(p004,sabonete).
tipo_prod(p005,detergente).

og_prod(f001,p001,30000).
og_prod(f001,p002,500).
og_prod(f002,p003,25).
og_prod(f002,p004,50000).
og_prod(f002,p005,50000).
og_prod(f003,p001,1000).
og_prod(f003,p002,50).
og_prod(f003,p003,5).
og_prod(f003,p005,500).

tipo_prod(X, _) :- og_prod(X, _, _).

og_prod(X, Y, _) :- tipo_prod(Y, _), forne(X, _, _, _).

Warnings:

Clauses of tipo_prod/2 are not together in the source-file
Clauses of og_prod/3 are not together in the source-file 
Earlier definition at ex1 cap7.pl:11
          Current predicate: tipo_prod/2
          Use :- discontiguous og_prod/3. to suppress this message

If someone could explain to me whats wrong in this program i would appreciate it a lot.

1
These _ in the two rules' heads strike me as odd. Are you sure you want that tipo is for any product? Otherwise reorder the clauses accordingly - false
The thing is i want to associate a parameter in forne like Lisboa and i want for example the an X associated with Lisboa and is p001. But i cant find a good link between both informations. - Martim Correia

1 Answers

1
votes

Prolog doesn't care whether the clauses are facts or rules -- they're all just clauses (facts simply don't have a ":- ..." part; but you can also think of them as having :- true).

You have rules for tipo_prod/2 and og_prod/3 separate from the facts for those predicates. So, you're getting a warning, as that's often the indication of a typo.

BTW, your code probably won't do what you think it's doing. My guess is that you want to use different names for the rules tipo_prod/2 and og_prod/3 that's different from the names for the facts.