pure-lang-users Mailing List for Pure (Page 16)
Status: Beta
Brought to you by:
agraef
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
(31) |
May
(422) |
Jun
(241) |
Jul
(268) |
Aug
(281) |
Sep
(109) |
Oct
(1) |
Nov
|
Dec
|
---|
From: Albert G. <Dr....@t-...> - 2008-08-10 08:40:40
|
Jiri Spitz wrote: > The code compiles much faster now. However, your latest changes made the > execution memory eager and my favourite test 'set (1..1000000)' caused > my PC swap to death. It seems the code isn't tail recursive anymore. Fixed (r459). -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: David B. <dh...@gm...> - 2008-08-09 22:28:39
|
On Sat, Aug 9, 2008 at 2:48 PM, Albert Graef <Dr....@t-...> wrote: >> David Baird wrote: >> 3. (maybe something else goes in the middle here?) > > Something like... code generation? :) Doh! I thought that was somewhere around step 5 :-P I'll have to rethink this. Thank you for all your generous feedback. -David |
From: Albert G. <Dr....@t-...> - 2008-08-09 20:48:28
|
David Baird wrote: > Well, not a CAS exactly but probably very related. I'll definitely > keep checking out Q. Note that Q will eventually be replaced by Pure, so it's a good idea to already check out the latter, even if it's still a bit rough around the edges here and there. I hope that the forthcoming 0.5 release will be bug-free and feature-complete enough to be useful for some real programming. (Thanks also to the work of other people here who already started porting modules from Q to Pure.) > I originally tried cracking open the source code > to Maxima and then realized that was going to be more than just an > hour of effort (partly because I don't have enough Lisp experience > yet). LOL. Yeah, CAS's are big monsters. :) > 2. Term rewriting for doing AST manipulation (Q seemed a good match > here). Mostly, I was interested in taking an expression and > normalizing it to a sum-of-products format. There's a software named Stratego specifically designed for that purpose (http://www.program-transformation.org/Stratego/). It uses some kind of programmed rewriting systems which look like they are quite a bit more complicated to program than Pure/Q. Probably worth a look, though. > 3. (maybe something else goes in the middle here?) Something like... code generation? :) > 4. Optimization to try to ensure that pipelines in a CPU are kept full > or that processing latency is minimized (using Prolog, integer linear > programming, ...) For items 3 and 4, LLVM (which Pure uses as its backend) is definitely worth a look. It's a C++ framework, though. It would be nice to have LLVM bindings for Pure. Then we could write compiler backends directly in Pure, which also provides an easy path to make Pure self-hosting at some point. > I'm actually > kinda confused about why people insist on using C to write compilers > when there are such great higher level tools available? C/C++ is what most programmers know, and has a huge amount of libraries available. Also, besides the usual problems to break away from the imperative mindset, languages like ML, Haskell and even Lisp are often perceived as requiring at lot of esoteric math/cs knowledge to be able to use them successfully. That's not completely undeserved. I think that there's a need for a functional language which is as easy to use as, say, Python. Obviously, Pure tries to fill that niche, but we're not quite there yet. ;-) > The idea is that I can then layer term rewriters on top of this (this > is how I discovered Q in the first place), and also be able to provide > nearly seamless integration between Python and constrained > optimization tools (like CVXOPT, GLPK, LP_SOLVE), and probably other > tools too (like ODE solvers?). There are plans to add interfaces to the GNU Scientific Library and some other solvers to Pure, so these kinds of applications will hopefully be well supported in the future. Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: David B. <dh...@gm...> - 2008-08-09 16:50:06
|
On Sat, Aug 9, 2008 at 5:11 AM, Albert Graef <Dr....@t-...> wrote: > David Baird wrote: >> Excellent, thanks! I finally got your suggestion to work in Pure. > > Great. :) Are you writing a CAS in Pure? There's already some nice stuff > by Rob Hubbard to deal with rationals and polynomials, it only needs to > be ported over (currently it's written in Q). Well, not a CAS exactly but probably very related. I'll definitely keep checking out Q. I originally tried cracking open the source code to Maxima and then realized that was going to be more than just an hour of effort (partly because I don't have enough Lisp experience yet). Then I discovered Q and was very impressed by the conciseness of Q (and then discovered Pure). What I'm kinda playing around with is compilers and also just systems integration in general. As far as compilers though, I've mentally broken them down like this: 1. Parsing 2. Term rewriting for doing AST manipulation (Q seemed a good match here). Mostly, I was interested in taking an expression and normalizing it to a sum-of-products format. 3. (maybe something else goes in the middle here?) 4. Optimization to try to ensure that pipelines in a CPU are kept full or that processing latency is minimized (using Prolog, integer linear programming, ...) 5. Writing out the results I'm trying to use declarative tools to achieve these goals. Also, I don't really have much experience with compilers so I am just goofing around really. Some of my coworkers have also been doing great work by using high level tools such as OCaml and Prolog. I'm actually kinda confused about why people insist on using C to write compilers when there are such great higher level tools available? I'm also investigating the possibility of implementing an expression representation system (probably a thin layer around sexps) in Python. The idea is that I can then layer term rewriters on top of this (this is how I discovered Q in the first place), and also be able to provide nearly seamless integration between Python and constrained optimization tools (like CVXOPT, GLPK, LP_SOLVE), and probably other tools too (like ODE solvers?). *phew* Hope that description wasn't too long. Sometimes I enjoy talking too much. -David |
From: Albert G. <Dr....@t-...> - 2008-08-09 11:16:53
|
Albert Graef wrote: > E.g., the following will give x^3+2*x: > > (foo x with foo x = x^3 end) + (foo x with foo x = 2*x end); > > At least it should. As I just discovered, in reality it gives x^3+x^3 > instead. Oh well, that's a bug that I need to fix. ;-) This was quite a bit more work than expected, but I fixed it now. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Albert G. <Dr....@t-...> - 2008-08-09 11:10:59
|
David Baird wrote: > Excellent, thanks! I finally got your suggestion to work in Pure. Great. :) Are you writing a CAS in Pure? There's already some nice stuff by Rob Hubbard to deal with rationals and polynomials, it only needs to be ported over (currently it's written in Q). > (Took awhile because I had to work around having multiple versions of > LLVM installed though so that pure-0.4 would build). Yeah, I really have to get Pure 0.5 out of the door soon. I just fixed one showstopper, two more bugs to go. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: David B. <dh...@gm...> - 2008-08-09 06:28:49
|
On Fri, Aug 8, 2008 at 3:30 AM, Albert Graef <Dr....@t-...> wrote: > So something like this should do the job in Pure: > > a*b::int = b*a if varp a; > x*a*b::int = x*b*a if varp a; > > (In addition, you'll probably need some associativity rules to make this > work in the general case.) Excellent, thanks! I finally got your suggestion to work in Pure. (Took awhile because I had to work around having multiple versions of LLVM installed though so that pure-0.4 would build). I also got it to work in Q: A * B:Int = B * A if isvar A; X * A * B:Int = X * B * A if isvar A; A * (B * C) = A * B * C; Then, I can ask it to reduce an expression like: ==> 3 * ((A * 2) * 4) and I get: 24*A -David |
From: Albert G. <Dr....@t-...> - 2008-08-08 09:30:05
|
Hi David, David Baird wrote: > So, I thought maybe I could create a rule like this: > > A:Symbol * B:Integer = B * A; > // and maybe some more rules for associativity/commutivity There's not type for symbols in either Pure or Q, and in Q the type of integers is named Int (section 8.2 of the manual), int and bigint in Pure. To check for free variable symbols, there's the isvar predicate, described in Section 10.8 of the manual (varp in Pure, see primitives.pure). So something like this should do the job in Pure: a*b::int = b*a if varp a; x*a*b::int = x*b*a if varp a; (In addition, you'll probably need some associativity rules to make this work in the general case.) HTH, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: David B. <dh...@gm...> - 2008-08-08 08:04:28
|
Hi, I'm new to Q/Pure, and I've searched the archives a little and the "Q in a Nutshell" doc a lot, but maybe I missed something. I have been just using Q up until now (because I only just found out about Pure). I would like rewrite an expression like: 4 * a * 3 to this: 12 * a So, I thought maybe I could create a rule like this: A:Symbol * B:Integer = B * A; // and maybe some more rules for associativity/commutivity but, like I guessed, I get an undeclared type error for Symbol and Integer (I think the type guards have to be algebraic types, not simple expressions). Is there a way to achieve this in Q or Pure? Thanks, -David |
From: Ryan S. <rya...@us...> - 2008-08-02 23:43:05
|
On Aug 2, 2008, at 07:42, Albert Graef wrote: > Right, LD_LIBRARY_PATH is used in the Makefile right now for > exactly the > same reason under Linux. I should be able to patch this up as well so > that DYLD_LIBRARY_PATH gets used on OSX instead. That would be great! > Is DYLD_LIBRARY_PATH=. sufficient for that purpose, or does > DYLD_LIBRARY_PATH require an absolute path? Looks like "DYLD_LIBRARY_PATH=." is fine! I never thought about trying that. |
From: Albert G. <Dr....@t-...> - 2008-08-02 12:41:58
|
Ryan Schmidt wrote: >> But does setting DYLD_LIBRARY_PATH still work even if the library path >> is hardcoded into the binary? > > Yes, it does. Many ports employ this technique to get the tests to > work without installation. Right, LD_LIBRARY_PATH is used in the Makefile right now for exactly the same reason under Linux. I should be able to patch this up as well so that DYLD_LIBRARY_PATH gets used on OSX instead. Is DYLD_LIBRARY_PATH=. sufficient for that purpose, or does DYLD_LIBRARY_PATH require an absolute path? Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Ryan S. <rya...@us...> - 2008-08-02 07:58:03
|
On Aug 2, 2008, at 02:21, Albert Graef wrote: > Ryan Schmidt wrote: > >> This does break make check, but we're used to working around that by >> setting DYLD_LIBRARY_PATH during the check so that's fine. > > But does setting DYLD_LIBRARY_PATH still work even if the library path > is hardcoded into the binary? Yes, it does. Many ports employ this technique to get the tests to work without installation. |
From: Albert G. <Dr....@t-...> - 2008-08-02 07:21:20
|
Ryan Schmidt wrote: > This does break make check, but we're used to working around that by > setting DYLD_LIBRARY_PATH during the check so that's fine. But does setting DYLD_LIBRARY_PATH still work even if the library path is hardcoded into the binary? Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Ryan S. <rya...@us...> - 2008-08-02 00:21:07
|
On Aug 1, 2008, at 15:07, Albert Graef wrote: > Ryan Schmidt wrote: > >>> Well, that probably means that you have to hardcode the install path >>> into the binaries, so maybe adding something like -install_name >>> /mp/lib/libpure-0.4.dylib to the link line for libpure-0.4.dylib >>> helps. >> >> That could help, but I'm not clear on what to add where to test this. > > I guess that for Pure 0.5 the following should do the trick: > > make shared="-dynamiclib -install_name $(prefix)/lib/ > libpure-0.5.dylib" > > Replace $(prefix) with your installation prefix, presumably /mp > from the > examples you've shown. (You can also edit the generated Makefile, of > course, the rule for building the runtime library starts out with > '$(libpure): $(OBJECT)' and is at line 131 in the Makefile.) Adding "-install_name $(prefix)/lib/libpure-0.5.dylib" to the line after that did the trick, thanks! http://trac.macports.org/changeset/38884 > Don't know if this works, I'm referring to information I found on the > Fink project pages > (http://www.finkproject.org/doc/porting/shared.php?phpLang=en). This > seems to indicate that linking against the shared lib thus created > will > hardcode the absolute path of the library (as given by -install_name) > into the executable. Note that this might well break 'make check' > if you > don't do a 'make install' beforehand. This does break make check, but we're used to working around that by setting DYLD_LIBRARY_PATH during the check so that's fine. > Please let me know whether this works, then I'll try to figure out > a way > to include the -install_name option in the configury so that it's > added > to the link line automatically. |
From: Albert G. <Dr....@t-...> - 2008-08-01 20:06:37
|
Ryan Schmidt wrote: >> Well, that probably means that you have to hardcode the install path >> into the binaries, so maybe adding something like -install_name >> /mp/lib/libpure-0.4.dylib to the link line for libpure-0.4.dylib >> helps. > > That could help, but I'm not clear on what to add where to test this. I guess that for Pure 0.5 the following should do the trick: make shared="-dynamiclib -install_name $(prefix)/lib/libpure-0.5.dylib" Replace $(prefix) with your installation prefix, presumably /mp from the examples you've shown. (You can also edit the generated Makefile, of course, the rule for building the runtime library starts out with '$(libpure): $(OBJECT)' and is at line 131 in the Makefile.) Don't know if this works, I'm referring to information I found on the Fink project pages (http://www.finkproject.org/doc/porting/shared.php?phpLang=en). This seems to indicate that linking against the shared lib thus created will hardcode the absolute path of the library (as given by -install_name) into the executable. Note that this might well break 'make check' if you don't do a 'make install' beforehand. Please let me know whether this works, then I'll try to figure out a way to include the -install_name option in the configury so that it's added to the link line automatically. Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Ryan S. <rya...@us...> - 2008-08-01 07:37:25
|
On Jul 30, 2008, at 09:04, Albert Graef wrote: > Ryan Schmidt wrote: > >> And the reason looks to be that pure is linking with libpure without >> specifying the directory it's located in: > > Well, that probably means that you have to hardcode the install path > into the binaries, so maybe adding something like -install_name > /mp/lib/libpure-0.4.dylib to the link line for libpure-0.4.dylib > helps. That could help, but I'm not clear on what to add where to test this. > Does MacPorts have any recommendendations concerning the linking of > shared libs? I don't think so... it's outside the scope of what MacPorts does. MacPorts takes software which can be compiled and run on Mac OS X and packages it for easy installation. MacPorts does not "port" software in the sense of rewriting software in order to make it compile on Mac OS X. >> Finally, "libpure-0.5.dylib" is a peculiar name; I would have >> expected something more like "libpure.0.5.dylib". > > Peculiar, but not unheard of. :) You're right... I see I have libraries installed with names like libglib-2.0.dylib, libapr-1.0.3.2.dylib... I guess you're in good company. :) I retract my objection. > The reason is that I want to make sure > that the interpreter always picks up the libpure which *exactly* > matches > the version number of the interpreter. This allows different > versions of > the interpreter to be installed on the same system. Using some > major/minor/age versioning scheme will make sense as soon as the > runtime > library begins to stabilize, but we're not there yet. |
From: Albert G. <Dr....@t-...> - 2008-07-30 21:18:44
|
John Cowan wrote: > The new entity definition file is at > http://www.w3.org/2003/entities/2007/w3centities-f.ent . > > Q and Pure should be updated accordingly; TagSoup will be. Done, thanks. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Eddie R. <er...@bm...> - 2008-07-30 20:38:42
|
On Wed, 2008-07-30 at 22:19 +0200, Albert Graef wrote: > Eddie Rucker wrote: > > When I tried to test a script I had written using notepad on my Linux > > box I got the following errors. > > > > erucker@erucker:~/Desktop$ pure -i test.pure > > 'est.pure:4.8: invalid character ' > > test.pure:4.8: syntax error, unexpected invalid character > > This should be fixed now (\r is now treated as a whitespace character, > as are \f and \v). > > Albert > Thanks. That will make life much easier when moving files between windows and linux. e.r. |
From: Albert G. <Dr....@t-...> - 2008-07-30 20:19:55
|
Eddie Rucker wrote: > When I tried to test a script I had written using notepad on my Linux > box I got the following errors. > > erucker@erucker:~/Desktop$ pure -i test.pure > 'est.pure:4.8: invalid character ' > test.pure:4.8: syntax error, unexpected invalid character This should be fixed now (\r is now treated as a whitespace character, as are \f and \v). Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Eddie R. <er...@bm...> - 2008-07-30 20:06:54
|
On Wed, 2008-07-30 at 22:04 +0200, Albert Graef wrote: > >> Yes, ViewVC seems to be disabled for now, apparently some overhaul of > >> the SVN infrastructure is in progress. More info on the (new) site > >> status page at http://sourceforge.net/sitestatus. We can also > >> joyfully look forward to a pending migration and major update of the shell/web > >> services which probably means that this will soon be broken, too. :( > > > > Major bummer :-( > > It's been up again for a few days, but a new downtime is scheduled for > today. > > Albert > Wonderful! e.r. |
From: Albert G. <Dr....@t-...> - 2008-07-30 20:04:42
|
>> Yes, ViewVC seems to be disabled for now, apparently some overhaul of >> the SVN infrastructure is in progress. More info on the (new) site >> status page at http://sourceforge.net/sitestatus. We can also >> joyfully look forward to a pending migration and major update of the shell/web >> services which probably means that this will soon be broken, too. :( > > Major bummer :-( It's been up again for a few days, but a new downtime is scheduled for today. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Albert G. <Dr....@t-...> - 2008-07-30 14:03:51
|
Ryan Schmidt wrote: > And the reason looks to be that pure is linking with libpure without > specifying the directory it's located in: Well, that probably means that you have to hardcode the install path into the binaries, so maybe adding something like -install_name /mp/lib/libpure-0.4.dylib to the link line for libpure-0.4.dylib helps. Does MacPorts have any recommendendations concerning the linking of shared libs? > Finally, "libpure-0.5.dylib" is a peculiar name; I would have > expected something more like "libpure.0.5.dylib". Peculiar, but not unheard of. :) The reason is that I want to make sure that the interpreter always picks up the libpure which *exactly* matches the version number of the interpreter. This allows different versions of the interpreter to be installed on the same system. Using some major/minor/age versioning scheme will make sense as soon as the runtime library begins to stabilize, but we're not there yet. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Ryan S. <rya...@us...> - 2008-07-30 09:02:11
|
I noticed that pure doesn't actually run on Mac OS X anymore because it can't find libpure. This occurs with pure 0.4 and also with the version of pure 0.5 in trunk @438. I tested on Mac OS X 10.4.11 and 10.5.4, both on Intel. Here is the error that occurs with 0.4: $ pure dyld: Library not loaded: libpure-0.4.dylib Referenced from: /mp/bin/pure Reason: image not found Trace/BPT trap $ And the reason looks to be that pure is linking with libpure without specifying the directory it's located in: $ otool -L /mp/bin/pure /mp/bin/pure: libpure-0.4.dylib (compatibility version 0.0.0, current version 0.0.0) /mp/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0) /mp/lib/libreadline.5.2.dylib (compatibility version 5.0.0, current version 5.2.0) /mp/lib/libgmp.3.dylib (compatibility version 8.0.0, current version 8.2.0) /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0) /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.10) $ It works if I tell it where the libraries are when I run pure: $ DYLD_LIBRARY_PATH=/mp/lib pure Pure 0.4 (i386-apple-darwin8.11.1) Copyright (c) 2008 by Albert Graef This program is free software distributed under the GNU Public License (GPL V3 or later). Please see the COPYING file for details. Loaded prelude from /mp/lib/pure-0.4/prelude.pure. > quit $ But obviously you don't want users to have to give DYLD_LIBRARY_PATH every time they want to use pure. Finally, "libpure-0.5.dylib" is a peculiar name; I would have expected something more like "libpure.0.5.dylib". |
From: Eddie R. <er...@bm...> - 2008-07-26 10:54:29
|
On Sat 26/07/08 2:49 AM , Albert Graef Dr....@t-... sent: > Because that rule doesn't apply. Note that x^2+3*x+4*x+12 === > (x^2+3*x)+4*x+12 !== x^2+(3*x+4*x)+12. Pure doesn't do any rewriting > modulo AC (associativity+commutativity). Neither does Q, it will return > exactly the same result with your equations. > > What you can do to make this example work is add the following rule: > > x+(a*b)+(c*d) = x+(a+c)*b if b === d; Ah! Ok, the reason why I was getting the answer in Q is because I also had the associative rules of multiplication and addition. (a+b)+c = a+(b+c); It works but x^2+(7x+12) is kind of annoying to look at. The rule you give above makes the answer look nice. Thanks, e.r. |
From: Albert G. <Dr....@t-...> - 2008-07-26 07:49:46
|
Eddie Rucker wrote: > Ok. I've figured I need to do stuff like > > (a*b)+(c*d) = (a+c)*b if b === d; > a*b=a^2 if a===b; Yeah, that's exactly how to do it. (In fact, the Q interpreter does exactly the same for non-linearities, it's only done automatically behind the scenes.) > (a+b)*(c+d) = a*c+a*d+b*c+b*d; > a*b = b*a if numberp b; > > Then > > (x+4)*(x+3) > x^2+3*x+4*x+12 > > Why doesn't the rule '(a*b)+(c*d) = (a+c)*b if b === d;' reduce it > further to > > x^2+7x+12 Because that rule doesn't apply. Note that x^2+3*x+4*x+12 === (x^2+3*x)+4*x+12 !== x^2+(3*x+4*x)+12. Pure doesn't do any rewriting modulo AC (associativity+commutativity). Neither does Q, it will return exactly the same result with your equations. What you can do to make this example work is add the following rule: x+(a*b)+(c*d) = x+(a+c)*b if b === d; Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |