On Fri, Sep 03, 2004 at 05:10:53PM +0100, Jules Bean wrote:
> The other cases are the same problem as ilccons: how to provide proofs
> to epigram that the evaluation of contains (...) will be true.
I don't think this answers your question directly, but just for the sake of
discussion I've just done it a different way without using 'So'. Instead,
have a predicate "Contains" which is a proof that a list contains a given
element either at the first element (cfirst) or somewhere later (clater).
Then a List Containing a Given Element is just a list which carries around
this proof.
Anyway, cons is easy to write in this setting. It ought to be fairly
straightforward to do other listy things too... (sorry, I know, I called it
EListCont instead of IListCont. Oops.)
Edwin.
--
Edwin Brady - Computer Science PhD Student, University of Durham.
WWW: http://www.dur.ac.uk/e.c.brady/
------------------------------------------------------------------------------
( n : Nat !
data (---------! where (------------! ; !-------------!
! Nat : * ) ! zero : Nat ) ! suc n : Nat )
------------------------------------------------------------------------------
data (----------! where true : Bool ; false : Bool
! Bool : * )
------------------------------------------------------------------------------
( X : * ! ( x : X ; xs : List X !
data !------------! where (--------------! ; !----------------------!
! List X : * ) ! nil : List X ) ! cons x xs : List X )
------------------------------------------------------------------------------
( x : X ; xs : List X !
data !----------------------!
! Contains x xs : * )
( y : X ; p : Contains x xs !
where (--------------------------! ; !----------------------------!
! cfirst : ! ! clater y p : !
! Contains x (cons x xs) ) ! Contains x (cons y xs) )
------------------------------------------------------------------------------
( X : * ; x : X ! ( x : X ; xs : List X ; p : Contains x xs !
data !-----------------! where !-------------------------------------------!
! EListCont X x : ! ! here x xs p : EListCont X x )
! * )
------------------------------------------------------------------------------
( x : X ; xs : EListCont X y !
let !-----------------------------!
! econs x xs : EListCont X y )
econs x xs <= case xs
{ econs x' (here x xs p) => here x (cons x' xs) (clater x' p)
}
------------------------------------------------------------------------------
( x : X !
let !-------------------------!
! einit x : EListCont X x )
einit x => here x (cons x nil) cfirst
------------------------------------------------------------------------------