Verify Basic Algebra Properties

From: Neo <neo55592_at_hotmail.com>
Date: 13 Jan 2007 14:13:08 -0800
Message-ID: <1168726386.548695.17830_at_a75g2000cwd.googlegroups.com>



Apparently the following four algebraic properties (or something similar) are considered important, possibly showing an approach is well-grounded in mathematics.

Commutative: A and B = B and A

                      A or B = B or A
Associative:    A and (B and C) = (A and B) and C
                     A or (B or C) = (A or B) or C
Idempotent:    A and A = A
                     A or A = A
Absorbtive:    (A and B) or B = B
                    (A or B) and B = B

...where A, B and C can be sets of anything?

How is the above implemented/demonstrated in RMDBs, Prolog, LISP, etc? Below I show how to verify it in dbd for the following data set:

A has john, mary and apple.
B has john, mary and orange.
C has mary, apple and orange.

And each thing in A, B and C has different classifications and attributes. See script below for details.

(new 'gender)
(new 'build)
(new 'color)
(new 'flavor)
(new 'like 'verb)

(new 'apple 'fruit)
(set+ apple color 'red)

(new 'orange 'fruit)
(set+ orange flavor 'tart)
(set+ orange color 'orange)

(new 'mary 'person 'student)
(set+ mary build 'tall)
(set+ mary build 'thin)
(set mary like orange)
(set mary like apple)

(new 'john 'person 'engineer)
(set+ john gender 'male)
(set john like mary)

(new 'A 'group)
(new 'B 'group)
(new 'C 'group)

(set A has john)
(set A has mary)
(set A has apple)

(set B has john)
(set B has mary)
(set B has orange)

(set C has mary)
(set C has apple)
(set C has orange)

(; **************************************)
(; Verify COMMUTATIVE: (= (& A B)

                                          (& B A))       )

(; Gets john and mary)
(= (& (get A has *) (get B has *))

    (& (get B has *) (get A has *)))

(; Verify COMMUTATIVE: (= (| A B)

                                          (| B A))       )

(; Gets john, mary, apple,
john, mary, orange)

(= (| (get A has *) (get B has *))

    (| (get B has *) (get A has *)))

(; **************************************)
(; Demo ASSOCIATIVE: (= (& A (& B C))

                                        (& (& A B) C))   )

(; Gets mary)
(= (& (get A has *) (& (get B has *) (get C has *)))

    (& (& (get A has *) (get B has *)) (get C has *)))

(; Demo ASSOCIATIVE: (= (| A (| B C))

                                        (| (| A B) C))   )

(; Gets john, mary, apple,
john, mary, orange, mary, apple, orange)

(= (| (get A has *) (| (get B has *) (get C has *)))

    (| (| (get A has *) (get B has *)) (get C has *)))

(; **************************************)
(; Verify IDEMPOTENT: (= (& A A)

  1. )
    (; Gets john, mary, apple)
    (= (& (get A has *) (get A has *))
    (get A has *))

(; Verify IDEMPOTENT: (= (| A A)

  1. )
    (; Gets john, mary, apple
    john, mary, apple)
    (= (| (get A has *) (get A has *))
    (get A has *))

(; **************************************)
(; Verify ABSORBTIVE: (= (| (& A B) B)

                                       B)              )

(; Gets john, mary
john, mary, orange)

(= (| (& (get A has *) (get B has *)) (get B has *))

    (get B has *))

(; Verify ABSORBTIVE: (= (& (| A B) B)

                                       B)              )

(; Gets john, mary
john, mary, orange)

(= (& (| (get A has *) (get B has *)) (get B has *))

    (get B has *))

More details at www.dbfordummies.com/example Received on Sat Jan 13 2007 - 23:13:08 CET

Original text of this message