b V c In English, it will be a implies that b or c (o...">

How to write "a implies b or c" in Prolog

How can I write the following in Prolog?

a -> b V c 

In English, it will be a implies that b or c (or both)

+7
source share
3 answers

Sentence

 a => (b ; c) % ';' means 'or' 

is not a Horn proposal and therefore cannot be represented in a (pure) Prolog (see, for example, Wikipedia ). On the other hand, (b ; c) => a is a Horn proposal and can obviously be represented by two Prolog rules.

+6
source

I'm not quite sure what you want to do with this implies a statement. But I would have thought that it would be enough (remember that this is SICStus not swi, but at this low level I think it is all the same).

 predicate(a, b). predicate(a, c). ?- predicate(a, Then). Then = b ; Then = c ; no ?- predicate(x, Then). no 

You can do more complex checks to make sure that it is never an unrelated value (to prevent predicate(If, b) . True), but if you are not building a huge application, I am sure that good documentation will be enough.

+1
source

Logically, "b or c" is the same as "b or c (or both)"

Here you can read about the logical operators in Prolog: http://rigaux.org/language-study/syntax-across-languages-per-language/Prolog.html

Can you explain a little more what you are trying to do with β€œimplies”?

0
source

All Articles