What's New in Qi II


  1. Qi I Programs should run under Qi II with no bother. But there are quite a few things that have been improved.

    * A complete reimplementation of Qi from the ground up.
    * New license.
    * Type secure lazy evaluation on demand.
    * Improved programmable syntax.
    * 4 speed compiler which utilises type information.
    * Improved integration with CL.
    * Runs under LispWorks.
    * Common functions made polyadic.
    * Improved connection to Prolog.
    * Rule closures for embedding sequent reasoning into Qi functions.
    * Improved handling on dependent types.
    * Completely documented in 'Functional Programming in Qi (second edition)'.

    A Complete Reimplementation

    Qi II is a complete reimplementation of Qi. All of the code has been rewritten making extensive use of Qi YACC 7.0. Redesigning some old feaures, refactorising the old code and making use of Qi YACC technology has shortened the Qi source code from 160K to 100K of disk space. The new system is not only smaller, it is more powerful than the old one and should be easier to maintain. All the read-print routines in Qi II are driven by Qi YACC.

    New License

    The most unpopular feature of Qi has been the GPL license; so it has been dropped. In its place is a clear dual license that keeps Qi in open source and allows freedom for personal and educational use. Buying the book entitles the holder to a commercial license to produce closed source as long as the Qi open source is respected. Here is the personal license that comes with the software.

    This software is licensed only for personal and educational use and not for the production of commercial software. Modifications to this program are allowed but the resulting source must be annotated to indicate the nature of and the author of these changes. Any modified source is bound by this licence and must remain available as open source under the same conditions it was supplied and with this licence at the top.

    This software is supplied AS IS without any warranty. In no way shall ; Mark Tarver or Lambda Associates be held liable for any damages resulting from the use of this program. The terms of these conditions remain binding unless the individual holds a valid license to use Qi commercially. This license is found in the final page of 'Functional Programming in Qi'. In that event the terms of that license apply to the license holder.

    Here is the commercial license that comes with the book.


    The following license gives you a personal non-transferable right to produce closed source commercial Qi applications. It is activated by writing your name into the space provided. It remains valid as long as the license remains attached to an authorised copy of 'Functional Programming in Qi'. Note that xeroxed or electronically duplicated copies of this license are not valid. The license is personal to one individual person and is not transferable. I, the undersigned


    being the owner of this copy of 'Functional Programming in Qi' understand that I am free to produce commercial applications with the Qi programming system, to distribute them in source or binary form, and to charge monies for them as I see fit and in concordance with the laws of the land subject to the following conditions.

    1. Neither the names of Lambda Associates or Mark Tarver may be used to endorse or promote products built using Qi software without specific prior written permission from Mark Tarver.

    2. That this commercial license does not extend to Qi source code itself which must remain free for educational and personal use and in open source whether modified by me or not.

    3. That possession of this license does not confer on Mark Tarver or Lambda Associates any special contractual obligation towards me.

    4. That in no event shall Mark Tarver OR Lambda Associates be liable for any direct, indirect, incidental, special, exemplary or consequential damages (including but not limited to procurement of substitute goods or services, loss of use, data, or profits; or business interruption), however caused and on any theory of liability, whether in contract, strict liability or tort (including negligence) arising in any way out of the use of Qi, even if advised of the possibility of such damage.

    Lazy Evaluation

    Haskell is promoted on the basis of its ability to support lazy evaluation, which is sometimes useful. CL programmers have long been able to manage lazy evaluation througn closures. Qi II has the ability to call upon type secure lazy evaluation at will.

    Improved Programmable Syntax

    Qi II allows the user to create sugar functions that work directly on the read-print routines allowing you to develop your own syntax or produce internationalised versions of Qi. These functions can be ordered to work in any order and can be layered on top of each other. They effectively do what reader macros do for CL.

    4 Speed Merlin Compiler

    The Merlin compiler is the new compiler in Qi and has 4 speed settings from 0 (no optimisation) to 3 (fastest code). The top setting factorises overlapping patterns and inserts compiler directives into the Lisp code, substituting fast type secure tests for slow generic ones (e.g. CHAR-EQUAL for EQUAL).

    Improved Integration with CL

    Unlike Qi, Qi II maintains the standard CL read table apart from the case sensitivity. Hence ; etc. retain their standard interpretation. , : ; are read in as symbols by the Qi reader. Qi II allows the user to program how Qi treats CL macro calls embedded into Qi code.

    LispWorks is added

    Qi II will run under LispWorks adding it to CLisp, SBCL, Allegro and CMU as platforms for Qi.

    Common Functions Made Polyadic

    Certain bread and butter constructions are polyadic in Qi II. Thus (/. X Y X) is permitted shorthand for (l (l Y X)); (@p 1 2 3) for the tuple (@p 1 (@p 2 3)) (i.e. <1,2,3>); (append [1 2 3] [4 5 6] [7 8 9]), (and true false true); (or true false true) are all legal.

    Improved Connection to Prolog

    Qi II allows Prolog programs to be entered either in Edinburgh syntax (M level syntax) or as S-expressions (S level syntax). Qi II Prolog allows embedded function calls in the tails of Horn clauses and has a special prolog? macro for calling it from Qi or CL.

    Rule Closures

    Unlike Qi I, Qi II allows you to embed sequent rules within functions, evaluating them to closures. These rule closures are type checked and are permeable to having their variables lexically bound from outside the scope of the rule itself. These devices enable the student of computational logic to effortlessly code complex logical systems of all descriptions. Thus the rule

    let PTerm/X (replace-by X Term P)
    PTerm/X, (all X P) >> Q;
    (all X P) >> Q;

    allows universally quantified assumptions to be instantiated to new premises. This rule can be embedded into a Qi II function called all-left which does precisely this job. The rule is turned into a closure by the rule function which is then applied to the problem (list of sequents).

    (define all-left
    {term --> [sequent] --> [sequent]}
    Term S -> ((rule let PTerm/X (replace-by X Term P)
    PTerm/X, (all X P) >> Q;
    (all X P) >> Q;) S))

    FPQi devotes a hundred pages to the exploration of this powerful construction.

    Improved Handling of Dependent Types

    Qi II recognises dependences between the variables in a function and the variables in the type in a way that allows dependent types to be easily handled. Thus to create a function g that takes two numbers with the value of that number encoded in the type that returns a number that is the sum of these two numbers such that the type-system knows it is an addition; the correct definition is:

    (datatype num

    if (number? N)  
    N : (num N);

      M : (num M); N : (num N);
      (+ M N) : (num (M + N));)

    (define add
      {(num M) --> (num N) --> (num (M + N))}
       M N -> (+ M N))

    Completely Documented in 'Functional Programming in Qi'

    FPQi (second edition) completely documents the whole system and includes two new chapters and over 100 pages of material that have been rewritten around the rule closures approach. It is the first and currently the only definitive exposition that brings together in one place the design principles of the language. It includes hitherto unpublished or hard to find material on the compilation techniques used in Qi. Buy it and get a commercial license. Alternatively, buy a license and get the book free! ;)


    Copyright (c) 2008, Mark Tarver

FAQs on Qi II Code Studies Popular Essays Documentation Community Download Order Book & License