## How to implement AND / OR logic document.SUBSCRIPTION_OPTIONS = { "thing": "thread", "subscribed": false, "url": "subscribe", "icon": { "css": "fa fa-envelope-o" } };

Help
Young Park
2010-03-08
2013-05-17
• Young Park - 2010-03-08

I am a newbee in PyKE, went over the tutorial, installed, ran examples.
Now I am writing rulebase of my own, and encountered a missing hole.

Suppose that I made a fact base consisting of simple facts.
Then made rulebase of FC and BC rules composing from the elementary facts.
How can i make rules of AND and OR conditions?
For example, (A and B) or C or (D and E) in Prolog would be something like this:
P :- (A, B); C; (D, E)

I would appreciate much for such initial help.

• Young Park

• Bruce Frederiksen - 2010-03-10

Facts are AND-ed be default in Pyke when you list more than one of them in a rule.

Pyke does not have OR-ing within a rule.  Instead, you would use multiple rules.  Using your Prolog example:

```P :- A, B.
P :- C.
P :- D, E.
```

or, in Pyke:

```rule1
use P( )
when
A( )
B( )
rule2
use P( )
when
C( )
rule3
use P( )
when
D( )
E( )
```

-Bruce

• Young Park - 2010-03-10

Thank you Bruce.
Then how to implement rules like the following?
P :- A, (B; C), (D; E).
i.e. A and (B or C) and (D or E).

Thank you in advance for your help.

• Young Park

• Bruce Frederiksen - 2010-03-10

You can do this by creating subgoals:

P :- A, P2, P3.
P2 :- B.
P2 :- C.
P3 :- D.
P3 :- E.

-Bruce