Monday, May 26, 2008

repeating history

"We have learned, a little late no doubt, that for states as for
individuals real wealth consists not in acquiring or invading the
domains of others, but in developing one's own. We have learned that
all extensions of territory, all usurpations, by force or by fraud,
which have long been connected by prejudice with the idea of 'rank,'
of 'hegemony,' of 'political stability,' of 'superiority' in the order
of the Powers, are only the cruel jests of political lunacy, false
estimates of power, and that their real effect is to increase the
difficulty of administration and to diminish the happiness and
security of the governed for the passing interest or for the vanity of
those who govern..." Talleyrand 1754-1838

Saturday, May 17, 2008

Parsing first order logic

I'm translating some of John Harrison's textbook code
to Haskell. I thought I'd try Happy, Haskell's "yacc",
for parsing instead of Harrison's combinator parsers.

Since both formulas and terms can be parenthesized,
I ran into trouble with the following:

(P) meaning "the propositional variable P"
(c) meaning "the term constant c"

Then I have a reduce reduce conflict, eg. in the following cases

(P) /\ Q
(c) = 5 /\ Q

It occurred to me that even something as simple as the
following dumbed-down grammar is not LR(1) as far as I can tell:

T is "terms" and F is "Formulas"

T ::= var | ( T )
F ::= var | ( F ) | T = T

I can't think of a way to make this LR(1). In fact, it seems it's
not even LR(k), as (c) could just as easily be (f(1,2,3,...,n) = 5).
Thus I think my 'happy' experiment is a failure. Of course, with a backtracking
combinator parser this is easily remedied.

Tuesday, May 13, 2008

Nouns and Adjectives

Florian and Fulya were playing an interesting game today: name all
the words you can(excluding colors and homonyms) that are both adjectives and nouns. They got 10 in 30 minutes. It took me longer. Maybe being a native
speaker is a disadvantage...

Update: Emily thought of 8 in about 5 minutes. Maybe it's just me
who's bad at this game. Or maybe it's native speaking *men*...