| 1 | -- Try running the convex hull algorithm. |
|---|
| 2 | import Abs.Domain.SparsePolyhedra |
|---|
| 3 | import Abs.Domain.SparsePolyhedra.Constraints |
|---|
| 4 | import Abs.Domain.SparsePolyhedra.Types |
|---|
| 5 | import Abs.Domain.SparsePolyhedra.Simplex |
|---|
| 6 | import System.Environment (getArgs) |
|---|
| 7 | import Data.List (sort) |
|---|
| 8 | import Control.Monad (replicateM, replicateM_, liftM, unless) |
|---|
| 9 | |
|---|
| 10 | -- Domain variables. |
|---|
| 11 | |
|---|
| 12 | -- | Size of the buffer |
|---|
| 13 | s :: DomVar |
|---|
| 14 | |
|---|
| 15 | -- | The character read |
|---|
| 16 | c :: DomVar |
|---|
| 17 | |
|---|
| 18 | -- | The NUL position |
|---|
| 19 | sn :: DomVar |
|---|
| 20 | |
|---|
| 21 | -- | The pointer offset of u |
|---|
| 22 | u :: DomVar |
|---|
| 23 | |
|---|
| 24 | -- | The NUL position of v |
|---|
| 25 | vn :: DomVar |
|---|
| 26 | |
|---|
| 27 | -- | The NUL position of p |
|---|
| 28 | tn :: DomVar |
|---|
| 29 | |
|---|
| 30 | -- | A flag determining if sn = 4 or 6 |
|---|
| 31 | f :: DomVar |
|---|
| 32 | |
|---|
| 33 | -- | The pointer offset of p |
|---|
| 34 | p :: DomVar |
|---|
| 35 | |
|---|
| 36 | (s:c:sn:u:tn:p:f:vn:_) = [1..] :: [DomVar] |
|---|
| 37 | |
|---|
| 38 | main = do |
|---|
| 39 | let size = 8 |
|---|
| 40 | initial = set u 0 $ |
|---|
| 41 | top size |
|---|
| 42 | replicateM_ 1000 $ do |
|---|
| 43 | res1 <- fixpoint initial bottom bottom vn 1 |
|---|
| 44 | unless (res1 `subset` res1) $ putStrLn "something's wrong" |
|---|
| 45 | res2 <- fixpoint initial bottom bottom vn 1 |
|---|
| 46 | unless (res2 `subset` res2) $ putStrLn "something's wrong" |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | fixpoint :: Poly -> Poly -> Poly -> DomVar -> Integer -> IO Poly |
|---|
| 50 | fixpoint sU sT oldR sn fval = do |
|---|
| 51 | let sR = join sU sT |
|---|
| 52 | --putStrLn ("R:\n"++show sR) |
|---|
| 53 | let sV = meetAsym [Constraint (Terms [(1,u)]) 8] sR |
|---|
| 54 | if sR `subset` oldR then |
|---|
| 55 | return sV else do |
|---|
| 56 | let sT = assign 1 u (Constraint (Terms [(1,u)]) 1) sV |
|---|
| 57 | fixpoint sU sT sR sn fval |
|---|