Hi Mark,
Good to see you back and great questions
On 1 Nov, 18:35, Mark Tarver <
dr.mtar...@ukonline.co.uk> wrote:
> Just dropped in; looked at the code for Shen. Interesting; some
> questions to reflect on though.
>
> 1. The 10X speedup sounds great but some details would be good. How
> is the speedup gained? What does the generated Lisp code look like?
i) I decided to manage the stack explicitly with a simple array,
ii) I decided to see the impact of an array of cons cells and
allocations of cons cells for
many operations that is done from this stack hence there is a lot
less consing going on
ii) I try to manage stack frames intelligently and make use of these
stack frames. I also keep
track of the changes and two changes (Iookup may reset value pointers
hence there might be many changes)
in one stack frame will result in just one resetting (the first one)
when we undo the stack frame.
iii) A variable is a fixnum e.g. an index in a variable stack, numbers
will be translated to other a special
object and managed internalle. Therefore there is a need to translate
data in and from this unifcation and
match environment, this has to be done either way because symbol is
not as well handled as in CL in other platforms
also integers have usually fast tests on all platforms and numbers is
not that common in the type declarations.
iv) The generated code for all part of the def is factorizing meaning
that the same prefix in the pattern matcher will mean
that the code share the prefix logic, actually this is used for
segments and Yacc like features as well, but then the sharing
have a semantic meaning as well e.g. more powerfull and faster but
more difficult because of possible buggs - this is a feature that we
need to discuss.
v) I stared at the generated ASSEMBLER for two weeks.
> 2. What is the declarative meaning of u? I guess it means 'unifies'.
yep (u X) means unify argument
> (define foo [X | Y] -> Y) can be interpreted equationally as forall
> X, Y foo(cons(X, Y)) = Y. This is important in formal methods since
> it provides (modulo ordering) a transcription of a Qi program into an
> axiomatic semantics (equations) for the program. But (define foo (u
> [X | Y]) C -> Y means forall X, Y foo (u (cons X Y)) C = Y meaning
> what? unification is a two place function not a 1 place.
You can skip (u) and segment parts. The reason not to separate a tool
for
segmentation, a tool for unification, a tool for yacc a tool for
define is that a lot
of logic carries over in one way or the other to the other parts and
you can
separate those part in the higher level routines. But logically you
should combine
them at the wizard level. By the way have you though about trying to
unify segmentation constructs?
> The u is really a *procedural* tag saying 'Do unification here' but
> its construction looks a little orthogonal to the rest of Qi. What is
> the declarative reading of this construction?
There is three modes of operation
- good old define world segmentation tiny yacc etc.
u unifies data in the unification world
m matches data in the unification world
so
(def (u U) (u [U|Y]) ....
will try to unify the first argument with the car of the second
argument.
> 3. How is this u construction to be type checked and how are the
> math'l proofs in FPQi to be extended to guarantee this construction?
Again you can perhaps in the final product separate out constructs
that are pure, But the
idea is to generate valid qi code that can to be type-checked in the
various modes. so I would
consider looking at the output qi code to decide on this.
Oh, please have a look at the reader.qi file in the BoopCore
directory, I did that code just as a
test.