[<<][meta][>>][..]
Fri Aug 26 10:10:50 CEST 2011

Next: make abstract interpretation work.

Given a SigOp, we need to observe:
  - initial state
  - representation of recurrence relation

So, for each domain there should be an unfold or eval function.

TODO: print int

data Expr = I String
          | Add Expr Expr
          deriving (Eq)
instance Show Expr where                   
  show (I v) = v
  show (Add a b) = concat ["(",show a," + ",show b,")"]

instance Num Expr where
  (+) = Add
  (*) = undefined
  abs = undefined
  signum = undefined
  fromInteger = I . show


*Main> cg (I "in") int
"(((in + 0),(in + 0)),0)"
*Main> cg (I "in") (int . int)
"(((((in + 0) + 0),(in + 0)),((in + 0) + 0)),(0,0))"
*Main> cg (I "in") (int . int . int)
"((((((in + 0) + 0) + 0),(((in + 0) + 0),(in + 0))),(((in + 0) + 0) + 0)),(0,(0,0)))"


This is almost correct, except that I don't have a way to name: this
isn't the generic update equation, this is an expression for the first
output from the initial state, "parameterized" over the input.

I.e. (cg int) works for:

  cg (SigOp u s0) = show (u (s0, I "i"), s0) 

but not for

  cg (SigOp u s0) = show (u ("s", I "i"), s0)

We need some kind of test function that goes between the initial state
and what is actually fed into the function, or how that function is
unrolled or otherwise transformed for that matter..

This comes back to placing the unroll function in a type class.

Hmm.. Using some horrible hack I can do this:


cg (SigOp u s0) = show (u (sigOpInit s0, I "i"), s0) 

instance SigOpInit Expr where
  sigOpInit s = I "s"

-- Stream unfolding.
class Show s => (SigOpInit s) where
  sigOpInit :: s -> s
  sigOpInit x = x
  
-- Distribute over pairs, lists and void
instance (SigOpInit a, SigOpInit b) => SigOpInit(a,b) where
         sigOpInit (a,b) = (sigOpInit a, sigOpInit b)
instance SigOpInit a => SigOpInit [a]
         sigOpInit = map sigOpInit
instance SigOpInit ()


*Main> cg int
"(((i + s),(i + s)),0)"

Trouble with that of course is uniqueness, i.e. variable name
generation:

*Main> cg $ int . int
"(((((i + s) + s),(i + s)),((i + s) + s)),(0,0))"

Not simple..  Where to put all that functionality?


Start again.  What's the main problem?  The following seem not
compatible.

  1.  Bundling initial state with processors.

  2.  Getting a representation of an opened-up function.


Instead of using some foefelare, is it possible to build that
intensional representation together with everything else?  The trouble
seems to be that at some point the content of tuples needs to be
named.

Yes.  s needs to support some kind of labeling function that needs to
be threaded at composition time.








[Reply][About]
[<<][meta][>>][..]