{"id":21469709,"url":"https://github.com/fjwright/emacs-reduce","last_synced_at":"2026-01-03T15:33:04.091Z","repository":{"id":198308589,"uuid":"578294973","full_name":"fjwright/Emacs-REDUCE","owner":"fjwright","description":"REDUCE on Emacs Lisp","archived":false,"fork":false,"pushed_at":"2022-12-21T17:30:59.000Z","size":117,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T16:11:46.446Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fjwright.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-12-14T18:02:12.000Z","updated_at":"2022-12-16T17:16:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"378b2497-f07f-432a-ad71-7d7aca84a512","html_url":"https://github.com/fjwright/Emacs-REDUCE","commit_stats":null,"previous_names":["fjwright/emacs-reduce"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjwright%2FEmacs-REDUCE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjwright%2FEmacs-REDUCE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjwright%2FEmacs-REDUCE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjwright%2FEmacs-REDUCE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fjwright","download_url":"https://codeload.github.com/fjwright/Emacs-REDUCE/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243986880,"owners_count":20379424,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-23T09:17:28.749Z","updated_at":"2026-01-03T15:33:04.031Z","avatar_url":"https://github.com/fjwright.png","language":"Emacs Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Emacs REDUCE\n**The REDUCE Computer Algebra System running on Emacs Lisp in an Emacs buffer**\n\n**[Francis Wright](https://sites.google.com/site/fjwcentaur)**, December 2022\n\n---\n\nSomewhat to my amazement, the Emacs REDUCE that I built in October 2018 using whatever was the current release of Emacs still appears to run on Emacs 28 in December 2022 without any modification!\n\n---\n\n## Introduction\n\n**This project is strictly for amusement only!  It may crash Emacs and I strongly recommend running it alone in an instance of Emacs that you are not also using for anything important.**\n\nFor simplicity and stability during initial development, I am currently using the [REDUCE 3.8 source files](https://sourceforge.net/p/reduce-algebra/code/HEAD/tree/historical/r38).\n\n[REDUCE](https://reduce-algebra.sourceforge.io/) is a Computer Algebra System written in Standard Lisp that normally runs on PSL (Portable Standard Lisp) or CSL (Codemist Standard Lisp).  Both PSL and CSL were essentially developed to run REDUCE.\n\nThe aim of this project is to provide an emulation of Standard Lisp and modified versions of some of the files in the REDUCE source directories `util` and `packages/support` in order to build REDUCE in Emacs, running on Emacs Lisp.  The file `esl.el` provides a partial emulation of Standard Lisp (enough to run REDUCE) and forms the main interface between REDUCE and Emacs.  I refer to this emulation as Emacs Standard Lisp or ESL.  To avoid name clashes between Emacs Lisp and Standard Lisp, ESL uses primarily upper-case, although this is invisible to normal REDUCE users because the REDUCE UI translates case as necessary.\n\nThe file `boot.el` is the ESL version of the REDUCE file `boot.sl`, which I have edited to use upper case and replace `%` with `;` and `!`  with `\\` where necessary so that Emacs Lisp can read it.  However, it retains `lambda`, `nil`, `quote` and `t` as lower-case symbols.\n\nFiles with names of the form `eslxxxx.red` are ESL versions of the REDUCE files `cslxxxx.red`, `pslxxxx.red` or `xxxx.red`.  Currently Emacs REDUCE assumes that all required Emacs Lisp (`.el`) and REDUCE (`.red`) files and directories are in the current directory.\n\n## Building Emacs REDUCE\n\nThe primary repository for this project is on [GitHub](https://github.com/fjwright/Emacs-REDUCE) but every so often I will upload what I regard as a reasonably stable and usefully improved snapshot to the secondary repository on [SourceForge](https://sourceforge.net/p/reduce-algebra/code/HEAD/tree/trunk/generic/emacs/REDUCE).\n\nDownload the files in this repository (or clone it) to some directory, which I will call `REDUCE`, but its name is not significant.  Download the directory\n\nhttps://sourceforge.net/p/reduce-algebra/code/HEAD/tree/historical/r38/packages\n\nand the file\n\nhttps://sourceforge.net/p/reduce-algebra/code/HEAD/tree/historical/r38/package.red\n\nto `REDUCE`.  Alternatively, download\n\nhttps://sourceforge.net/p/reduce-algebra/code/HEAD/tree/historical/r38\n\nsomewhere and regard this directory as the directory `REDUCE` (which will then include a lot of files that are not required for this build), or link the directory `packages` and/or file `package.red` to `REDUCE`.\n\nOpen a (Unix-style) command shell and execute\n\n```sh\n. build-core-reduce.sh\n```\nand then\n\n```sh\n. remake-all-packages.sh\n```\n\nThis build should take about 10 minutes.\n\n## Running Emacs REDUCE\n\nTo run Emacs REDUCE for the first time in an Emacs session, load the file `reduce.el` (or compile it first and load `reduce.elc`).  This should give you a fairly standard REDUCE session with input via the minibuffer.  Emacs REDUCE accepts input in either lower or upper case and currently outputs in lower case by default (except that strings retain their input case).\n\nIf you terminate Emacs REDUCE (or it is terminated by Emacs), it is really only suspended unless you terminate Emacs and you can re-enter where you left it by running the Emacs command `M-x esl-reduce` (unless REDUCE was terminated by a catastrophic error).  Don't reload `reduce.el(c)`.  You can exit (i.e. suspend) Emacs REDUCE in the conventional way (using the REDUCE command bye or quit) or you can use the Emacs keyboard-quit signal `C-g`.\n\nClosing Emacs is the only reliably way to completely stop Emacs REDUCE, so the only way to restart it cleanly is to restart Emacs!\n\nYou can interact with an Emacs REDUCE session using normal Emacs Lisp facilities (in ways that are not possible or convenient using conventional REDUCE facilities), but it is normally best to suspend REDUCE first.  Otherwise, Emacs will probably suspend REDUCE; for example, if you do something that needs to use the minibuffer.\n\nWhen interacting with an Emacs REDUCE session via Emacs Lisp, remember that ESL is an upper-case Lisp and that you are using Emacs Lisp syntax, so omit any `!` escapes that would be required in REDUCE or Standard LISP.  For example, the REDUCE symbolic-mode input\n\n`foo!-bar x;`  [or `foo!-bar(x);`]\n\nwould be (assuming `foo!-bar` has no special processing rules)\n\n```lisp\n(FOO-BAR X)\n```\n\nin Emacs Lisp.\n\n### Print output\n\nThe ESL print functions support the Standard LISP escape convention and down-casing of identifiers (when `!*LOWER` is non-nil).\n\n## Current status of Emacs REDUCE\n\nThe build process builds (almost) all REDUCE 3.8 packages, apparently successfully.\n\n### Test files\n\nEmacs REDUCE currently runs all of `alg/alg.tst` correctly but about 20 times slower than the time shown in `alg.rlg`.\n\n#### Poly package\n\n`poly/polydiv.tst` now runs correctly.\n\n`poly/poly.tst` now also runs correctly provided I replace the `d` in the products in the gcd tests with `\u003c\u003cd\u003e\u003e` to force an extra evaluation.  I can't find the cause of this problem.\n\n#### Arith package\n\nThe REDUCE 3.8 file `smlbflot.red` contains are error that must be corrected as in later REDUCE versions.  The file `rdelem.red` uses the smacro `incprec!:` defined in `smlbflot.red`, but it is not being applied.  I have added\n\n```text\nload!-package 'smlbflot;\n```\n\nwhich seems to fix the problem.  I think either this change, or perhaps better moving the smacro definitions for `incprec!:` and `decprec!:` into `arith.red`, should probably be applied to the generic source code if this has not already been done post REDUCE 3.8.\n\nWith the above two changes, `arith/arith.tst` appears to run correctly.  There are a lot of rounding differences, but nothing serious and sometimes Emacs REDUCE is more accurate!  Probably OK for now.  Eventually, I should probably use the Elisp transcendental functions, which are implemented in C, rather than those in `arith/math.red`.\n\n#### Factor package\n\n`factor/factor.tst` runs completely correctly, although it's a bit slow.  There is probably scope for optimizing the ESL arithmetic used in the factorizer.\n\n#### Int package\n\n`int/int.tst` runs to completion, but it's about 20 times slower than the time shown in `int.rlg` (which is consistent with running `alg.tst`).  However, at one point Emacs appears to be about to enter the debugger but then it doesn't and `int(x**7/(x**12+1),x)` evaluates only on a later subsequent attempt.  The problem appears to be that it involves extremely large numbers.  The Calc functions used to process them (in particular, `math-div-bignum-big`) are written recursively and they run out of stack space, but only by a small margin.  This triggers the debugger, which increases the stack space by enough that Emacs can continue and the integral can later be evaluated, although the error seems to change the sort order of the result.  Increasing `max-specpdl-size` from the default of 1300 to 2000 before running the test file allows it to complete correctly.  However, the best solution might be to re-implement big integers taking care to avoid recursion, which is in hand!\n\n### Known problems\n\n* `tmprint` build: too Lisp-specific and irrelevant at present\n* `atensor`, `ncpoly` and `xcolor` tests: variable binding depth\n* `crack` suite test: various obscure problems\n* The sort order in the `cali` and `fide` tests differs from the reference `.rlg` files, but not from the results of running the tests in PSL REDUCE, so I think these differences can be ignored as quirks in REDUCE 3.8.\n* `rlfi` clears the raise switch, which mangles Emacs REDUCE, and in batch mode the test file reads `EOF` ad infinitum!\n* The `specfn` test uses too much resource at present, probably due to recursive functions and the recursive code in the Calc package.\n* The `cgb`, `eds`, `mathml`, `mathmlom`, `redlog`, `susy2` tests all display errors.\n\n## To do\n\n* Optimization.\n* Better support for big integers: revert from using Calc to native integers and require Emacs 27 or later; see `NEWS.27`.\n* Better user interface.\n* Switch to the current version of REDUCE.\n* Use lexical binding for REDUCE where possible.  This **appears** to work for the `rlisp` package without any modification to the REDUCE source code, but it needs to be automated and tested more generally.  Free (undeclared) variables **appear** to be bound appropriately.  Need to save the compile logs when generating fasl files.\n* The Lisp `READ` function is used in a few places in REDUCE and so needs to be implemented better than at present.\n* Investigate rounding of floats, which seems to differ from the exemplary test logs.  This may just be because the REDUCE 3.8 logs are nearly 20 years old.  If current Lisps all use essentially the same C libraries then the rounding should be the same in all REDUCE implementations (maybe).\n* Native compilation; requires Emacs 28 or later.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjwright%2Femacs-reduce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffjwright%2Femacs-reduce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjwright%2Femacs-reduce/lists"}