Laszlo Nemeth | 4 Jan 2006 13:05
Picon
Favicon

takewhile questionmark(s)

Hi,

I've been staring at this takewhile.epi (in examples/) for some time and 
while epigram turns it green I remain mostly yellow about it.

If I am correct it is supposed to demostrate that one can have more than 
one index on a datatype (also that we can establish invariants not just 
preserve them)

------------------------------------------------------------------------------
     ( as : List A        !        ( as : List 
A                            !
     !                    !        
!                                        !
     ! P : all a : A => * !        ! p : Prefix as asbs ;  q : ListAll P 
as !
data !--------------------!  where 
!----------------------------------------!
     ! Takewhile as P : * )        !      tw as p q : Takewhile asbs 
P      )
------------------------------------------------------------------------------

ie takewhile can have a much more informative type than it has in 
Haskell: the predicate P holds for all elements of the prefix. The 
definition of Prefix however is puzzling:

------------------------------------------------------------------------------
                                              ( as, asbs : List 
A           !
     ( as, asbs  !                            
(Continue reading)

peter morris | 5 Jan 2006 12:49
Picon

Re: takewhile questionmark(s)

Hi!

pnil : Prefix nil bs 

What is bs doing in the pnil case? nil is a prefix of any list?

I don't see why this is an absurd suggestion; if I had a function to calculate all possible prefixes of a given list I would expect the empty prefix to appear each time i ran it. In epigram that function might well return elements of this 'Prefix xs xsys' type, each saying 'xs' is a prefix of the list 'xsys' which is the list you gave. If we were feeling more adventurous we might build a 'Concat xs ys xsys' relation which would pack the remainder of the list after the prefix it may well have the constructor:

nilconc : Concat nil ys ys

I changed it to 'as' just to see what happens and everything remained green!

Of course, 'as' is more general than 'pnil' so the new construtor will work in more cases not less, in no way are we exploiting the information contained in proofs of prefixivity so we can't see how this new definition fails to capture the right meaning. It is absurd however to claim that [4] is a prefix of [1,2,3].


        takewhileaux asbs (yes a) (tw as p q) => tw ? (pcons p ?) (lcons a q)


The confusion arose when I tried to fill in the question marks in the
definition of takewhileaux. VFL says you can use ? if Epigram can figure
out what goes there...but I couldn't!

Yes you could, this is almost the right answer: 

Tried
1. (pcons p a) from the typing of (pcons): its yellow

But Epigram has twarted you by calling the proof that the head of the target list satisfies the predicate 'a' when you'd rather that the head itself was called 'a' and the proof something else entirely. Fix? You need to get the code in emacs and replace that line with:

takewhileaux asbs _ P _ a (yes Pa) (tw as p q) => tw (cons a as) (pcons p a) (lcons Pa q) 
 
This explicity tells the system that you want the head of the list to be called 'a' and the proof 'Pa', it's a horrible thing to have to do, we know.

and I concluded that ?s should not remain after elaboration!

Yup, it's on the list, I think there should be two kinds of question mark one that Epigram replaces with the right term and one that behaves as now
 

Is there
any way of convincing epigram to spit back the term it found appropriate
instead of the ??

No, unfortunately not (unless you count this list :)
 

And could I please have an example which demonstrates
it works: inspect takewhile ?????.


Certainly, I'm not sure which version of this you have so forgive me if i call things by the wrong name but if you define IsZero like this:

------------------------------------------------------------------------------
     ( p : zero = (suc n) !
let  !---------------------!
     !   kill p : False    )
                           
     kill p <= case p      
------------------------------------------------------------------------------
     (          n : Nat           !
let  !----------------------------!
     ! IsZero n : Dec (zero = n) )
                                   
     IsZero n <= case n            
     { IsZero zero => yes refl
       IsZero (suc n) => no kill   
     }                             
------------------------------------------------------------------------------
(That is to say IsZero is a proof that we can decide whether a given Nat is zero or not)

We can then ask the system:

inspect takewhile IsZero (cons zero (cons zero (cons zero (cons (suc zero) nil))))

A more useful thing would be 'takewhile IsNotZero':
------------------------------------------------------------------------------
     (      dp : Dec P      !         
let  !----------------------!         
     ! Opp dp : Dec (Not P) )         
                                      
     Opp dp <= case dp                
     { Opp (yes a) => no (lam f => f a)
       Opp (no f) => yes f            
     }                                
------------------------------------------------------------------------------
(If I can decide whether something is true I can also decide whether it is false :)

inspect takewhile (lam n : Nat => Opp (IsZero n))
         (cons (suc zero) (cons (suc (suc zero)) (cons zero (cons (suc zero) nil))))

I won't spoil the suprise as to the answer to these inspects

Cheers

Peter
nick thomas | 6 Jan 2006 05:18
Picon

Hi!

My name is Nick Thomas, and I've been following your work on Epigram for a few weeks. I've been reading the Epigram notes and some of the background material, on and off; I grok some of it, but it's pretty heavy for me in places (everywhere, actually). Having seen some of the things that you can do with dependent types, I'm really excited about the technology, and I'd like to contribute to the project. One thing I'd like to do is to write a GUI editor, and get Epigram out of XEmacs.

Cyril | 6 Jan 2006 10:23
Picon

RE: Hi!

Hi Nick!
 
Maybe it will be useful for you to take a look at JetBrains MPS http://www.jetbrains.com/mps/ . Maybe it will help you somehow to develop your editor.
Here is my own humble attempt to use MPS for developing Epigram editor: http://www.jetbrains.net/confluence/display/MPS/Epigram . It runs, but unfortunately it isn't complete and currently I don't think I'll develop it further :(
 
Cheers,
Cyril.
 

From: owner-epigram <at> durham.ac.uk [mailto:owner-epigram <at> durham.ac.uk] On Behalf Of nick thomas
Sent: Friday, January 06, 2006 7:19 AM
To: Epigram
Subject: [Epigram] Hi!

My name is Nick Thomas, and I've been following your work on Epigram for a few weeks. I've been reading the Epigram notes and some of the background material, on and off; I grok some of it, but it's pretty heavy for me in places (everywhere, actually). Having seen some of the things that you can do with dependent types, I'm really excited about the technology, and I'd like to contribute to the project. One thing I'd like to do is to write a GUI editor, and get Epigram out of XEmacs.
Thorsten Altenkirch | 6 Jan 2006 10:47
Picon
Gravatar

Re: Hi!

Hi Nick,

good to see that you are interested in Epigram.

> My name is Nick Thomas, and I've been following your work on Epigram for a
> few weeks. I've been reading the Epigram notes and some of the background
> material, on and off; I grok some of it, but it's pretty heavy for me in
> places (everywhere, actually). 

Feel free to ask questions on the mailing list, please.

	Having seen some of the things that you can
> do with dependent types, I'm really excited about the technology, and I'd
> like to contribute to the project. One thing I'd like to do is to write a
> GUI editor, and get Epigram out of XEmacs.

Great! Having a better GUI is an important issue and we would 
certainly appreciate any contribution on this front. You may either 
use a Haskell GUI library like wxHaskell (especially if you have 
experience in Haskell) or use an external toolkit like Eclipse or MPS, 
which Cyril suggests, to built one.

Jeffrey (jdl02u <at> Cs.Nott.AC.UK), one of my project students here at 
Nottingham is working on this topic for his final year project - you 
may want to talk to him. However, this shouldn't discourage you to do 
something similar (or different).

Cheers,
Thorsten

P.S. Just out of couriosity: where are you based?

--

-- 
Dr. Thorsten Altenkirch		   phone : (+44) (0)115 84 66516
Lecturer			   http://www.cs.nott.ac.uk/~txa/
School of Computer Science & IT	   University of Nottingham

This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

nick thomas | 6 Jan 2006 20:06
Picon

Re: Hi!

Thanks for the tips, everyone! My previous plan of attack was to hook up a wxPython process to some form of Haskell wrapper for the Concrete type (even Show would probably work). This would still work as a last resort, but your other suggestions are more appealing.

I've been interested in wxHaskell before, but it's got a strange API, and I've never been able to get it to run on my machine. I might give it another shot, though, the next time I get a chance. It looks like a very pleasant GUI toolkit to work with; if my machine and I can get to grips with it, I'll probably write the GUI with it.

MPS looks very cool. Depending on my luck with wxHaskell, I'll probably give it a try; if nothing else, programming with it would be more interesting than using Python. Even if I succeed with wxHaskell, it's definitely worth playing with sometime! If I take this approach, I'll probably pick up on Cyril's project, rather than start from scratch.

> P.S. Just out of couriosity: where are you based?
I live in Ann Arbor, MI.

-- Nick

nick thomas | 7 Jan 2006 20:46
Picon

CVS?

How do I get at Epigram CVS, to check out the current version? I
haven't found any mention of this on the website.

peter morris | 8 Jan 2006 01:46
Picon

Re: CVS?

Hi

Sadly there is (and will be) no anonymous access to the Epigram repository as it stands, this is not necessarily a bad thing for us right at this moment.

If you are looking for the latest Epigram1 code, then you are in luck, it's on the website and there's something of moratorium on that version. If you are looking for Epigram2 code, then you probably have to cut us some slack as we move from CVS to darcs at which point it will be (under whatever GPL compatible license we eventually choose) freely available.

Peter

On 08/01/06, nick thomas <jesuswaffle <at> gmail.com> wrote:
How do I get at Epigram CVS, to check out the current version? I
haven't found any mention of this on the website.


nick thomas | 8 Jan 2006 01:56
Picon

Re: CVS?

Well, that brings me to my next question. I'd like to start writing an editor, as I said I would. Will Epigram2's editor/elaborator interface be completely different from Epigram1's? More to the point, would it be wasted effort to start hacking on Epigram1? If so, is the editor/elaborator interface for Epigram2 relatively fleshed out by now? Or, more to the point, would it be wasted effort to start hacking on Epigram2?

On 1/7/06, peter morris <morrispwj <at> gmail.com> wrote:
Hi

Sadly there is (and will be) no anonymous access to the Epigram repository as it stands, this is not necessarily a bad thing for us right at this moment.

If you are looking for the latest Epigram1 code, then you are in luck, it's on the website and there's something of moratorium on that version. If you are looking for Epigram2 code, then you probably have to cut us some slack as we move from CVS to darcs at which point it will be (under whatever GPL compatible license we eventually choose) freely available.

Peter


On 08/01/06, nick thomas < jesuswaffle <at> gmail.com> wrote:
How do I get at Epigram CVS, to check out the current version? I
haven't found any mention of this on the website.



Conor McBride | 8 Jan 2006 12:23
Picon

Re: CVS?

Hi Nick

nick thomas wrote:

> Well, that brings me to my next question. I'd like to start writing an 
> editor, as I said I would. Will Epigram2's editor/elaborator interface 
> be completely different from Epigram1's?

Yes. For a start, there'll be one! In Epigram 1, the editor just 
provides a rendering of the elaborator state. The elaborator is 
responsible for knowing where your cursor sits in a shed and other such 
details, a world away from typechecking: it was very cheap and it 
sort-of works, but it's very hard to build on. In fact, that's a fairly 
reasonable summary of the state of Epigram 1, more generally.

> More to the point, would it be wasted effort to start hacking on Epigram1?

For all but the very cheapest experiments or tweaks, yes. Epigram 1 is 
inching towards the scrap heap.

> If so, is the editor/elaborator interface for Epigram2 relatively 
> fleshed out by now? Or, more to the point, would it be wasted effort 
> to start hacking on Epigram2?

The basic shape is there, but it isn't very documented. Here's where to 
start looking:

  http://sneezy.cs.nott.ac.uk/epigram/current/doc/index.html

The basic picture is that Editor and Elaborator live in different 
threads and have a communication format based on the concrete syntax. 
The shared state is a big lump of concrete syntax with uniquely labelled 
nodes. The basic Editor-Elaborator message is 'replace node x with this 
piece of concrete syntax'. The basic Elaborator-Editor message is 'node 
x has been replaced by this piece of node-labelled concrete syntax'. The 
process kicks off with the Elaborator issuing the Editor with its root 
node. We don't fix any style of interaction: it could be batch-mode 
(replace root with whole program) or some fab asynchronous thing.

That said, the concrete syntax is already quite an evolved 
representation in the life of a program, so lots of 'front end' stuff 
has to happen in the Editor. However, we have a hierarchy of tools which 
refine input all the way from strings to tokens to 2D documents to 
syntax to syntax-with-resolved-scope (the Elaborator is never told the 
user's name choices!), which leaves it up to the Editor-author to choose 
what to trade in. An editor written in something other than Haskell 
would require a suitable Haskell stub.

Now, we're currently refactoring the guts of Epigram 2 as we shift over 
from cvs to darcs. House style is now to write lhs2TeX source, which 
should at least encourage better documentation. This effort should 
deliver a dummy elaborator fairly soon---one which communicates sensibly 
with an editor but doesn't actually typecheck anything. The real thing 
will take a bit longer. I wish I knew how long, but it's very hard to 
predict how much hacking we'll manage to fit in around everything else 
that's going on.

So, Epigram 2 would be the target to go for; the general set-up is 
already sketched out, so you could at least start planning; once the 
current move to is complete, we'll have better documentation; shortly 
after that, we'll have a thing (albeit a dummy) you can actually link to.

Thank you for your enthusiasm!

All the best

Conor


Gmane