From: Daniel al-Autistiqui
Subject: Dansrules.lsip
Date: 
Message-ID: <0blg125o081ln9egda621bj1o3pov9hkd8@4ax.com>
;;; 'Dansrules' begins here.

(setf *rules* 'empty-stream)

(remember-rule '(modus-ponens
                  (implies (? papa) (? quebec))
                  (? papa)
                  (? quebec)))

(remember-rule '(modus-tollens
                  (implies (? papa) (? quebec))
                  (not (? quebec))
                  (not (? papa))))

(remember-rule '(hypothetical-syllogism
                  (implies (? papa) (? quebec))
                  (implies (? quebec) (? romeo))
                  (implies (? papa) (? romeo))))

(remember-rule '(disjunctive-syllogism
                  (or (? papa) (? quebec))
                  (not (? papa))
                  (? quebec)))

(remember-rule '(constructive-dilemma
                  (and (implies (? papa) (? quebec))
                       (implies (? romeo) (? sierra)))
                  (or (? papa) (? romeo))
                  (or (? quebec) (? sierra))))

(remember-rule '(absorption
                  (implies (? papa) (? quebec))
                  (implies (? papa) (and (? papa) (? quebec)))))

(remember-rule '(simplification
                  (and (? papa) (? quebec))
                  (? papa)))

(remember-rule '(conjunction
                  (? papa)
                  (? quebec)
                  (and (? papa) (? quebec))))

(remember-rule '(addition
                  (? papa)
                  (or (? papa) (? quebec))))

;;; 'Dansrules' ends here.

daniel mcgrath
-- 
Daniel Gerard McGrath, a/k/a "Govende":
for e-mail replace "invalid" with "com"

Developmentally disabled;
has Autism (Pervasive Developmental Disorder),
    Obsessive-Compulsive Disorder,
    & periodic bouts of depression.
[This signature is under construction.]

From: Kaz Kylheku
Subject: Re: Dansrules.lsip
Date: 
Message-ID: <1142452929.612435.110400@u72g2000cwu.googlegroups.com>
Daniel al-Autistiqui wrote:
> ;;; 'Dansrules' begins here.
>
> (setf *rules* 'empty-stream)
>
> (remember-rule '(modus-ponens
>                   (implies (? papa) (? quebec))
>                   (? papa)
>                   (? quebec)))
>
> (remember-rule '(modus-tollens
>                   (implies (? papa) (? quebec))
>                   (not (? quebec))
>                   (not (? papa))))
>
> (remember-rule '(hypothetical-syllogism
>                   (implies (? papa) (? quebec))
>                   (implies (? quebec) (? romeo))
>                   (implies (? papa) (? romeo))))

Your notation has the syntactic drawback that there is a variable
number of clauses which precede the conclusion. A procedure which wants
to extract just the conclusion from this syntax has parse through the
list to find the last element.

Consider a syntax which is like this:

  <rule> ::= (<name> <premises> <conclusion>)

  <name> := <symbol>

  <premises> := ( <expression> * )

  <conclusion := <expression>

Or, you could put the conclusion /first/ followed by the premises. This
is Lisp! We don't have to stick to conventional orders where they don't
work for us, right? Others put operators in the middle, we put them on
the left.

  <rule> := (<name> <conclusion> <premises> + )

I like the (? <symbol>) notation for meta-variables. Logic programming
systems over Lisp sometimes condense that with lexical tricks. For
instance, any symbol whose name begins with a question mark is a
variable.

Another approach is to require the variables to be declared. This is
exactly what quantifiers do in predicate logic, and what LAMBDA does in
Lisp programming or lambda calculus.

 (for-all (x y) y (or x y) (not x))

"For all X and for all Y,  the conclusion  Y   is implied by   X or Y
and not X".

With quantifiers in the rules, you know what is a bound variable and
what is a free variable.
From: Daniel al-Autistiqui
Subject: Re: Dansrules.lsip
Date: 
Message-ID: <fg9j12tgsog1lcei5kbh4ekql4786k57es@4ax.com>
On 15 Mar 2006 12:02:09 -0800, "Kaz Kylheku" <········@gmail.com>
wrote:

>
>Daniel al-Autistiqui wrote:
>> ;;; 'Dansrules' begins here.
>>
>> (setf *rules* 'empty-stream)
>>
>> (remember-rule '(modus-ponens
>>                   (implies (? papa) (? quebec))
>>                   (? papa)
>>                   (? quebec)))
>>
>> (remember-rule '(modus-tollens
>>                   (implies (? papa) (? quebec))
>>                   (not (? quebec))
>>                   (not (? papa))))
>>
>> (remember-rule '(hypothetical-syllogism
>>                   (implies (? papa) (? quebec))
>>                   (implies (? quebec) (? romeo))
>>                   (implies (? papa) (? romeo))))
>
>Your notation has the syntactic drawback that there is a variable
>number of clauses which precede the conclusion. A procedure which wants
>to extract just the conclusion from this syntax has parse through the
>list to find the last element.
>
Have you read _LISP_ (3rd ed.) by Patrick Henry Winston and Berthold
Klaus Paul Horn -- chapter 26 in particular?  In that book, rules are
stored in LISP exactly like this (lots of premises, then a
conclusion).  I don't know why they needed to put the premises first,
but I wanted to be consistent with the book.

The following DEFUNs are taken straight from the middle of page 381 of
Winston & Horn's book: (What a coincidence -- same page number at
which the proverb vocabulary appears in Irving Copi's book!)

    (defun rule-name (rule) (first rule))

    (defun rule-ifs (rule) (butlast (rest rule)))

    (defun rule-then (rule) (first (last rule)))

[...]
>I like the (? <symbol>) notation for meta-variables. Logic programming
>systems over Lisp sometimes condense that with lexical tricks. For
>instance, any symbol whose name begins with a question mark is a
>variable.
>
My use of the question-mark atom was, again, taken directly from W&H's
book; that notation is recognized by a function from chapter 24 called
MATCH.  On the other hand, I came up with the idea of the "military
alphabet" (PAPA, QUEBEC, ROMEO, etc.) all by myself.

This kind of code was meant to be only semi-genuine anyway, and the
idea of "efficiency" may not always matter.  In fact, I couldn't even
get myself to type "Dansrules.lisp", spelled exactly like that.

daniel mcgrath
-- 
Daniel Gerard McGrath, a/k/a "Govende":
for e-mail replace "invalid" with "com"

Developmentally disabled;
has Autism (Pervasive Developmental Disorder),
    Obsessive-Compulsive Disorder,
    & periodic bouts of depression.
[This signature is under construction.]