How to implement AND / OR logic

Young Park
  • Young Park

    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

    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:

        use P( )
            A( )
            B( )
        use P( )
            C( )
        use P( )
            D( )
            E( )


  • Young Park

    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

    You can do this by creating subgoals:

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



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks