Re: Fwd: MIU in Curry

From: Michael Hanus <mh_at_informatik.uni-kiel.de>
Date: Fri, 20 Jun 2014 10:49:05 +0200

Hallo Sebastian,

danke fuer dein Feedback. In der Tat, ich stimme dir zu,
dass eine nur noch sequentielle Lesweise der Regeln
manchmal auch nicht so schoen ist, gerade im Bereich
wirklich regelorientierter Programmierung (z.B. wissensbasierte
Systeme, Constraint-Programmierung o.ae.).
Da die Interpretation sequentiell/ungeordnet letztendlich
allein durch das Frontend bestimmt werden kann, wuerde
ich dafuer plaedieren, dies durch ein Pragma zu steuern.
Solche Pragmas waren ja schon oefters drin, z.B. am Anfang
zur Auswahl des Pattern Matching (optimal oder Haskell-like
von links nach rechts), des Matching-Status (flexibel oder rigide),
wobei dann die Entwicklung und Anwendung gezeigt hat, dass man diese
Auswahl letztendlich nicht benoetigt. Hier waere es aber
schon sinnvoll.

Viele Gruesse

Michael


On 06/19/2014 10:14 PM, Sebastian Fischer wrote:
> Hallo Michael,
>
> ich hab mich gerade an ein wieteres Programm erinnert, das durch
> top-down pattern-matching schwieriger zu schreiben wäre. Wolfgang
> Jeltsch hatte mal ein Programm für das MIU Puzzle auf der Mailingliste
> geschickt, dass ich so umgeschrieben hatte:
>
> rewrite :: String -> String
> rewrite (x ++ "I") = x ++ "IU"
> rewrite ("M" ++ x) = "M" ++ x ++ x
> rewrite (x ++ "III" ++ y) = x ++ "U" ++ y
> rewrite (x ++ "UU" ++ y) = x ++ y
>
> Ich denke im Allgemeinen wird die Umsetzung von formalen
> Spezifikationen (Grammatiken oder anderen Ersetzungssystemen)
> schwieriger, weil da die Regeln unabhängig voneinander gelesen werden.
> Parserkombinatoren sind vermutlich ein weiteres Beispiel, wo man dann
> wohl wie in Haskell einen Auswahloperator (oder (?)) braucht, statt
> mehrere Regeln schreiben zu können.
>
> Grüße,
> Sebastian
>
> ---------- Forwarded message ----------
> From: Sebastian Fischer <sebf_at_informatik.uni-kiel.de>
> Date: Wed, Apr 24, 2013 at 10:17 AM
> Subject: Re: MIU in Curry
> To: Wolfgang Jeltsch <wolfgang_at_cs.ioc.ee>
> Cc: curry_at_lists.rwth-aachen.de
>
>
> Hi Wolfgang,
>
> I also wrote a Curry-verision, after reading your post ;) Here it is:
>
> rewrite :: String -> String
> rewrite (x ++ "I") = x ++ "IU"
> rewrite ("M" ++ x) = "M" ++ x ++ x
> rewrite (x ++ "III" ++ y) = x ++ "U" ++ y
> rewrite (x ++ "UU" ++ y) = x ++ y
>
> test :: Int -> [String]
> test n = filter (=="MIU") . take n $ iterate rewrite "MI"
>
> It just uses predefined functions take and iterate to limit the search
> depth but I expect you could also use breadth first search in KiCS2 to
> avoid an explicit limit.
>
> Best,
> Sebastian
>
> On Tue, Apr 23, 2013 at 7:48 PM, Wolfgang Jeltsch <wolfgang_at_cs.ioc.ee> wrote:
>> Hi,
>>
>> I have recently implemented a derivation engine for the MIU system from
>> Douglas Hofstadter’s book “Gödel, Escher, Bach” in Haskell. See my blog
>> post:
>>
>> <http://jeltsch.wordpress.com/2013/04/18/miu-in-haskell/>
>>
>> Now I wanted to implement the same thing in Curry, since this could
>> dramatically simplify the code. I wrote an implementation, which I have
>> attached to this e-mail.
>>
>> Unfortunately when I try out this implementation, it prints at most one
>> solution and then causes heavy use of the swap partition. So if anyone
>> would be interested in looking at the code and giving me hints for
>> improving it, I would be very thankful.
>>
>> Best wishes,
>> Wolfgang
>>
>> _______________________________________________
>> curry mailing list
>> curry_at_lists.RWTH-Aachen.DE
>> http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
>>
>
Received on Fr Jun 20 2014 - 10:49:33 CEST

This archive was generated by hypermail 2.3.0 : Fr Mär 29 2024 - 07:15:12 CET