Re: General Form of Relationships?

From: Kaz Kylheku <kaz_at_ashi.footprints.net>
Date: 29 Dec 2002 09:43:51 -0800
Message-ID: <cf333042.0212290943.47b6f5c6_at_posting.google.com>


neo55592_at_hotmail.com (Neo) wrote in message news:<4b45d3ad.0212281437.3102c5f9_at_posting.google.com>...
> What is the general form of relationships? Is it
> 1) "t1 relator t2" or
> 2) "relator, t1, t2, ..."
>
> Can form 2 relationships always be broken down to multiple form 1's?
> Or are some relationships such that they cannot be broken down
> and thus form 2 is the more general.

You need to get a few clues.

Firstly, your examples are merely different in syntax: infix versus prefix. The actual relationship denoted by the syntax is a matter of semantics. It's possible to define a grammar together with semantic rules to interpret the syntax however you want. If you want deeper answers, you should turn to the study of programming languages. There is a newsgroup called comp.compilers which could be interesting.

Secondly, you need to learn to suppress the urge to initiate massively crossposted discussions.

> For example, either form works for "John like Mary"
> 1) "John like Mary"
> 2) "like, John, Mary"
>
> Next "John give Mary a ball" readily fits form 2
> "give, John, Mary, ball"
>
> But can it be broken down into multiple form 1's
> "John give ball1"
> "Mary receive ball2"
> "ball1 isSameAs ball2"

Not in general; the combined action of moving the object from one person to another cannot be factored into two independent actions. Suppose that in the same transaction, Mary compensates John for the ball with a kiss. That compensation can be hidden entirely in the semantics of ``give john mary ball''.

In computing languages, it's highly beneficial to have the simplicity of synthesized attributes. Synthesized attributes are semantics of an expression that are computed from its constituents only, not from any parents or siblings in the parse tree. Synthesized attributes can be computed in a straight bottom-up manner, starting at the leaves of the tree and working upward. Thus if you have the expression 'a * b * c', it means (a * b) * c, and the value is a synthesized attribute: first a and b are multiplied, to produce a value, and then that is multiplied by c. Both multiplications are independent, except that the output of one is an input to the other.

A prefix notation lets an operator be a function of any number of parameters, yet the simplicity of bottom-up evaluation is preserved. This is how it is in the language Lisp, whose newsgroup comp.lang.lisp you crossposted into. The * function of Lisp can take a large number of parameters, and it can take zero parameters as well.

You could write a translator such that the notation 'a * b * c * d ...' has the same meaning as (* a b c d) --- in other words, a single invocation of the operator with multiple arguments. But that translator could no longer treat evaluation as a simple synthesized attribute! It would have to recognize patterns spanning portions of the syntax tree, and reduce them.

In Lisp we could do this by writing an infix parser, and then by defining * symbol as a macro. The infix parser would take a * b * c * d and produce the nested list (* a (* b (* c d))). Then the macro * would take over, and analyze its arguments. Seeing that everything is multiplicative, it would produce the expression (* a b c d). So you see, it's possible to achieve whatever evaluation rules you want, if you are willing to do whole-tree analysis and transformation. But it's a heck of a lot less work to just parse and evaluate (* a b c d) in the first place, not to mention notationally clearer.

Returning to the John and Mary example, you could have functions YIELD and TAKE, such that you could write:

   (take mary (yield john ball))

Everything is nicely evaluated bottom up. First (yield john ball) liberates the ball object from john, and then that is passed to the take function together with the mary object, causing that object to accept the ball.

What if you wanted to keep that syntax, but add a complex two-way interaction between john and mary? Well, you can no longer do simple bottom-up evaluation. In the Lisp language, we could write TAKE as a macro. That macro could analyze the parameter expressions, to recognize the pattern:

   (take X (yield Y Z))

and translate the whole thing to the form:

   (take-yield X Y Z)

the TAKE-YIELD function would encapsulate the passing of Z from Y to X, as well as X kissing Y. So in other words, mary's posession of the ball is a synthesized attribute, and the kiss going to john is an inherited attribute. Received on Sun Dec 29 2002 - 18:43:51 CET

Original text of this message