Browse Source

Work on some packaging stuff, incl writing eqal for <expt>

Samuel W. Flint 5 years ago
parent
commit
e270d966d5
1 changed files with 97 additions and 76 deletions
  1. 97 76
      larcs.org

+ 97 - 76
larcs.org

@@ -248,6 +248,9 @@ This is where the common functions and constants are assembled into their own pa
 #+END_SRC
 
 * WORKING Expression Types [2/4]
+:PROPERTIES:
+:ID:       fe611e8f-db42-4fe0-8e77-9cfb55d2227c
+:END:
 
 All expressions are built from various ~<expression>~ objects.  These objects are specialized to contain only certain, specific information, relevant to a particular expression.  The most basic expressions (besides expression itself) are ~<atomic>~ (holding things like numbers or variables) and ~<compound>~ (holding things like multiplicatinos, divisions, exponents, trigonometric expressions, arithmetic expressions, /etc./).  All subtypes of ~<expression>~ must know if they are atomic, so we define a generic for this, they must also tell if they are ~eqal~ (a form of equality), and be able to perform substitution, evaluation, and simplification, however, the latter three are implemented elsewhere.  The organization of the various types may be found in Figure~[[fig:expression-types]].
 
@@ -256,10 +259,13 @@ Note, by default, ~eqal~ will handle ~type-error~ by trying to switch the order
 #+Caption: Basic Expressions Types
 #+Name: type-basic
 #+BEGIN_SRC lisp 
+  @export
   (defclass <expression> () ())
 
+  @export
   (defgeneric atomicp (expression))
 
+  @export
   (defgeneric eqal (expression-a expression-b))
 
   (defmethod eqal ((expression-a <expression>) (expression-b <expression>))
@@ -275,10 +281,13 @@ Note, by default, ~eqal~ will handle ~type-error~ by trying to switch the order
         (declare (ignore err))
         (eqal expression-b expression-a))))
 
+  @export
   (defgeneric substitute-expression (expression with in))
 
+  @export
   (defgeneric evaluate (expression &key substitutions-list resolve-constants-light-p resolve-constants-hard-p))
 
+  @export
   (defgeneric simplify (expression &key resolve-constans-light-p resolve-constants-hard-p))
 #+END_SRC
 
@@ -333,14 +342,19 @@ Note, by default, ~eqal~ will handle ~type-error~ by trying to switch the order
 
 
 ** DONE Atomic Types [3/3]
+:PROPERTIES:
+:ID:       9be57f5d-ed0e-4a7c-9c06-a4c647f6d56e
+:END:
 
 Of the various types, there are three atomic types, ~<number>~, ~<variable>~ and ~<constant>~  They are very similar, only differing on the ~:type~ their value slot has.  As all ~<atomic>~ subtypes are, in fact, atomic (save for some later blended types), we can simply return ~t~ for ~atomicp~.  Further, all ~<atomic>~ have a definite value, so we should be able to retrieve this.
 
 #+Caption: Atomic Type Definition
 #+Name: type-atomic
 #+BEGIN_SRC lisp 
+  @export
   (defclass <atomic> (<expression>) ())
 
+  @export
   (defgeneric value (expression &key resolve-constants))
 
   (defmethod atomicp ((expression <atomic>))
@@ -350,12 +364,16 @@ Of the various types, there are three atomic types, ~<number>~, ~<variable>~ and
 
 *** DONE Numbers
 CLOSED: [2019-01-05 Sat 09:56]
+:PROPERTIES:
+:ID:       f0314608-46d9-4cc0-a3e1-897481827ddf
+:END:
 
 As an ~<atomic>~, ~<number>~ is rather simple, having only one slot, ~value~, readable using the ~value~ method, and initialized with ~:value~.  This ~value~ must be of type ~number~.  Two ~<number>~ objects are equal, if their ~value~ is ~=~.
 
 #+Caption: Numbers
 #+Name: type-numbers
 #+BEGIN_SRC lisp 
+  @export
   (defclass <number> (<atomic>)
     ((value :initarg :value
             :type number)))
@@ -370,12 +388,16 @@ As an ~<atomic>~, ~<number>~ is rather simple, having only one slot, ~value~, re
 
 *** DONE Variables
 CLOSED: [2019-01-05 Sat 09:56]
+:PROPERTIES:
+:ID:       f5f656d0-6253-4c4c-8c50-6622d685eaa1
+:END:
 
 ~<variable>~ is similar to ~<number>~, with the only difference being ~name~ must be a ~symbol~ or ~keyword~.  Two ~<variable>~ objects are ~eqal~ if the ~name~ of each is ~equalp~.
 
 #+Caption: Variables
 #+Name: type-variables
 #+BEGIN_SRC lisp 
+  @export
   (defclass <variable> (<atomic>)
     ((name :initarg :name
            :type (or symbol keyword))))
@@ -391,6 +413,9 @@ CLOSED: [2019-01-05 Sat 09:56]
 
 *** DONE Constants
 CLOSED: [2019-01-05 Sat 12:07]
+:PROPERTIES:
+:ID:       806bbce0-ab52-411a-8178-29bda6bbb36a
+:END:
 
 ~<constant>~ is a bit different from the rest -- it has a name, as well as a number, and the value depends on whether or not you want to "resolve" the constant.  If the constant is to be resolved, the numeric value is returned, otherwise, the name is returned.
 
@@ -403,6 +428,7 @@ Equality of constants is a bit different, and is checked as follows:
 #+Caption: Constants
 #+Name: type-constants
 #+BEGIN_SRC lisp 
+  @export
   (defclass <constant> (<number> <variable>)
     ((name :initarg :name
            :type (or symbol keyword))
@@ -427,13 +453,17 @@ Equality of constants is a bit different, and is checked as follows:
        (slot-value expression-b 'value)))
 #+END_SRC
 
-** WORKING Compound Types [2/7]
+** WORKING Compound Types [3/7]
+:PROPERTIES:
+:ID:       a0d2eb19-8a1e-4dee-9b41-c454a49cacc4
+:END:
 
 Compound types are the majority of expressions.  An atom is well and good, but often says relatively little.  We use compound types to form equations from other expressions.  These are not, then, ~atomicp~.
 
 #+Caption: Compound Types
 #+Name: type-compound
 #+BEGIN_SRC lisp 
+  @export
   (defclass <compound> (<expression>) ())
 
   (defmethod atomicp ((expression <compound>))
@@ -443,12 +473,16 @@ Compound types are the majority of expressions.  An atom is well and good, but o
 
 *** DONE Multiplications
 CLOSED: [2019-01-05 Sat 12:17]
+:PROPERTIES:
+:ID:       0c601f5c-a614-4c30-9107-220a5d45a334
+:END:
 
 Multiplication is one of the more frequently used expression types, and is, surprisingly, simple.  A ~<multiplication>~ has only one slot, ~terms~, the various expressions to be multiplied.  Further, if two ~<multiplication>~ objects have the same number of terms, and there is no ~set-difference~ given ~eqal~ between the two lists of terms, the two ~<multiplication>~ objects are ~eqal~.
 
 #+Caption: Multiplications
 #+Name: type-multiplications
 #+BEGIN_SRC lisp 
+  @export
   (defclass <multiplication> (<compound>)
     ((terms :reader terms
             :initarg :terms
@@ -463,12 +497,16 @@ Multiplication is one of the more frequently used expression types, and is, surp
 
 *** DONE Divisions
 CLOSED: [2019-01-05 Sat 12:25]
+:PROPERTIES:
+:ID:       bcc56ff0-0a6f-4eb6-8185-2cab3eed99da
+:END:
 
 Division is similar to ~<multiplication>~, although instead of having ~terms~ it has ~numerator~ and ~denominator~.  A ~<division>~ is equal to another if the ~numerator~ of the first is ~eqal~ to the second and likewise for the denominator.
 
 #+Caption: Divisions
 #+Name: type-division
 #+BEGIN_SRC lisp 
+  @export
   (defclass <division> (<compound>)
     ((numerator :reader div-numerator
                 :initarg :numerator
@@ -477,20 +515,25 @@ Division is similar to ~<multiplication>~, although instead of having ~terms~ it
                   :initarg :denominator
                   :type <expression>)))
 
-  (defmethod eqal ((expression-a <division>) (expression-b <division>))
-    (and (eqal (div-numerator expression-a)
-             (div-numerator expression-b))
-       (eqal (div-denominator expression-a)
-             (div-denominator expression-b))))
+    (defmethod eqal ((expression-a <division>) (expression-b <division>))
+      (and (eqal (div-numerator expression-a)
+               (div-numerator expression-b))
+         (eqal (div-denominator expression-a)
+               (div-denominator expression-b))))
 #+END_SRC
 
-*** WORKING Exponentials
+*** DONE Exponentials
+CLOSED: [2019-01-05 Sat 15:28]
+:PROPERTIES:
+:ID:       d8c87457-5c3b-4263-ba60-53b9b9f5e816
+:END:
 
-There are two primary forms of exponential -- the natural (~exp~) and the general (~expt~).  Given this, there are two classes, with ~<exp>~ being a subclass of ~<expt>~, mirroring the generality of exponentials in general.
+There are two primary forms of exponential -- the natural (~exp~) and the general (~expt~).  Given this, there are two classes, with ~<exp>~ being a subclass of ~<expt>~, mirroring the generality of exponentials in general.  Two ~<expt>~ objects are ~eqal~ iff their ~base~ and ~exponent~ are ~eqal~. 
 
 #+Caption: Exponentials
 #+Name: type-exponentials
 #+BEGIN_SRC lisp 
+  @export
   (defclass <expt> (<compound>)
     ((base :reader base
            :initarg :base
@@ -499,6 +542,13 @@ There are two primary forms of exponential -- the natural (~exp~) and the genera
                :initarg :exponent
                :type <expression>)))
 
+  (defmethod eqal ((expression-a <expt>) (expression-b <expt>))
+    (and (eqal (base expression-a)
+             (base expression-b))
+       (eqal (exponent expression-a)
+             (exponent expression-b))))
+
+  @export
   (defclass <exp> (<expt>)
     ((exponent :reader exponent
                :initarg :exponent
@@ -520,12 +570,16 @@ There are two primary forms of exponential -- the natural (~exp~) and the genera
 
 ** DONE Blended Types -- Polynomial Terms
 CLOSED: [2019-01-05 Sat 09:46]
+:PROPERTIES:
+:ID:       a7258c20-bdd1-4565-9ada-41026ea5e1a0
+:END:
 
 The ~<polynomial-term>~ is one of the more interesting types.  It's a variable, a multiplication and an exponent, all rolled into one.  Therefore, it needs to implement all of the functionality of those.  So, while some of the generics are obvious, /i.e.,/ ~exponent~, others are less so.  Things like ~value~, ~base~ and ~terms~ must be written directly, and these can later be used, for instance, ~<polynomial-term>~ can easily be converted to ~<multiplication>~, and an example of this is provided.
 
 #+Caption: Polynomial Terms
 #+Name: type-poly-term
 #+BEGIN_SRC lisp 
+  @export
   (defclass <polynomial-term> (<multiplication> <expt> <variable>)
     ((coefficient :reader coefficient
                   :initarg :coefficient
@@ -1895,7 +1949,7 @@ The final assembly of this portion of the system is as simple as the rest, resol
 
 LARCS is primarily a library, and as such, the formal interface for the library, and a way to load it must be provided.  This is done here by defining packages centrally and defining an ASDF system to load the library quickly and easily.
 
-** WORKING Package Definitions [0/6]
+** WORKING Package Definitions [0/1]
 :PROPERTIES:
 :CREATED:  <2016-06-13 Mon 15:00>
 :ID:       573a8352-8cbe-408c-8c27-3cf0b66da885
@@ -1906,85 +1960,43 @@ As all of the packages are defined centrally, this makes resolving inter-package
 #+Caption: LARCS Packages
 #+Name: larcs-packages
 #+BEGIN_SRC lisp :tangle "larcs-packages.lisp"
-  
-#+END_SRC
-
-*** TODO Common
-:PROPERTIES:
-:CREATED:  <2016-08-05 Fri 22:07>
-:ID:       84845974-c272-4007-a490-6bc328a8d22d
-:END:
-
-This defines the common package, which keeps a few macros and variables that are used by all other packages.  It exports a function to generate arguments lists, a list of special symbols to TeX sequences and a list of constant names.
-
-#+Caption: Common Package Definition
-#+Name: common-package-def
-#+BEGIN_SRC lisp
+  <<types-package-def>>
 #+END_SRC
 
-*** TODO Classification
+*** TODO Types
 :PROPERTIES:
-:CREATED:  <2016-08-05 Fri 22:07>
-:ID:       f68d9d69-3cca-4767-8204-8077ae8ac2b2
+:ID:       8f14e64c-23a8-461b-9b81-f977deac87ee
 :END:
 
-Classification is another system that is used by just as many packages as the common packages.  In this case, it exports two functions (one to get classification and one to check whether something is classified as a given classification) and a macro (the case pattern for classification).
-
-#+Caption: Classification Package Definition
-#+Name: classification-package-def
-#+BEGIN_SRC lisp
-#+END_SRC
-
-*** TODO Polynomial Functions
-:PROPERTIES:
-:CREATED:  <2016-08-21 Sun 10:58>
-:ID:       c97b187c-22c8-4332-902e-3be2247b277e
-:END:
-
-Polynomial Functions are used in several of the other packages, and provide a way of comparing and retrieving information about specific terms, or providing a way to collect information about variables.
-
-#+Caption: Polynomial Package Definition
-#+Name: polynomial-package-def
+#+Caption: Types Package
+#+Name: types-package-def
 #+BEGIN_SRC lisp 
+  (defpackage #:larcs.types
+    (:use #:cl)
+    (:import-from #:annot
+                  #:enable-annot-syntax)
+    (:nicknames #:types))
 #+END_SRC
 
-*** TODO Manipulation
-:PROPERTIES:
-:CREATED:  <2016-08-05 Fri 22:07>
-:ID:       07a9d8fc-5bdc-4c03-9df3-3e3d46d1b704
-:END:
-
-This package provides for a method to manipulate and perform algebra symbolically.  In a way, this is the core of the library, upon which nearly everything else is built.
-
-#+Caption: Manipulation Package Definition
-#+Name: manipulation-package-def
-#+BEGIN_SRC lisp
-#+END_SRC
-
-*** TODO Differentiation
-:PROPERTIES:
-:CREATED:  <2016-08-05 Fri 22:07>
-:ID:       53a94c2e-3fb1-4cc1-9b3a-0e53657c3b91
-:END:
+#+Caption: Types File
+#+Name: types-file-main
+#+BEGIN_SRC lisp :tangle "larcs-types-basic.lisp"
+  (in-package #:larcs.types)
+  (enable-annot-syntax)
 
-This is a rather simple package, providing a way to differentiate equations for use in a variety of functions.
+  <<type-basic>>
 
-#+Caption: Differentiation Package Definition
-#+Name: differentiation-package-def
-#+BEGIN_SRC lisp
-#+END_SRC
-
-*** TODO Typesetting
-:PROPERTIES:
-:CREATED:  <2016-08-05 Fri 22:07>
-:ID:       f3ae4f48-7fc9-4f4c-a128-642cd3babaf1
-:END:
+  <<type-atomic>>
+  <<type-numbers>>
+  <<type-variables>>
+  <<type-constants>>
 
-Again, this is a relatively simple package definition, providing a way to convert symbolic equations to a form that can be more easily read by most humans.
+  <<type-compound>>
+  <<type-multiplications>>
+  <<type-division>>
+  <<type-exponentials>>
 
-#+Caption: Typesetting Package Definition
-#+Name: typesetting-package-def
-#+BEGIN_SRC lisp
+  <<type-poly-term>>
 #+END_SRC
 
 ** TODO System Definition
@@ -1998,6 +2010,15 @@ This defines the LARCS Library system, allowing the functionality to be loaded b
 #+Caption: Library System Definition
 #+Name: library-system-definition
 #+BEGIN_SRC lisp :tangle "larcs-lib.asd"
+  (asdf:defsystem #:larcs-lib
+    :description "A CAS Library for use within Lisp software."
+    :author "Samuel W. Flint <swflint@flintfam.org>"
+    :licence "GNU GPLv3 or later"
+    :depends-on (#:alexandria
+                 #:cl-annot)
+    :serial t
+    :components ((:file "larcs-packages")
+                 (:file "larcs-types-basic")))
 #+END_SRC
 
 * Push to bottom                                                     :ignore: