src/HOL/Tools/Quickcheck/PNF_Narrowing_Engine.hs
author bulwahn
Fri, 02 Mar 2012 09:35:35 +0100
changeset 46758 4106258260b3
parent 46408 2520cd337056
child 47090 6b53d954255b
permissions -rw-r--r--
choosing longer constant names in Quickcheck_Narrowing to reduce the chances of name clashes in Quickcheck-Narrowing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
     1
{-
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
     2
A narrowing-based Evaluator for Formulas in Prefix Normal Form based on the compilation technique of LazySmallCheck
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
     3
-}
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
     4
module Narrowing_Engine where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
     5
46408
2520cd337056 using fully qualified module names in Haskell source, which seems to be required by GHC 7.0.4 (also cf. 0fd9ab902b5a)
bulwahn
parents: 45760
diff changeset
     6
import Control.Monad
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
     7
import Control.Exception
46408
2520cd337056 using fully qualified module names in Haskell source, which seems to be required by GHC 7.0.4 (also cf. 0fd9ab902b5a)
bulwahn
parents: 45760
diff changeset
     8
import System.IO
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
     9
import System.Exit
46408
2520cd337056 using fully qualified module names in Haskell source, which seems to be required by GHC 7.0.4 (also cf. 0fd9ab902b5a)
bulwahn
parents: 45760
diff changeset
    10
import Data.Maybe
2520cd337056 using fully qualified module names in Haskell source, which seems to be required by GHC 7.0.4 (also cf. 0fd9ab902b5a)
bulwahn
parents: 45760
diff changeset
    11
import Data.List (partition, findIndex)
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
    12
import qualified Generated_Code
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    13
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    14
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    15
type Pos = [Int]
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    16
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    17
-- Term refinement
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    18
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    19
-- Operation: termOf
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    20
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    21
posOf :: Edge -> Pos
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    22
posOf (VN pos _) = pos
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    23
posOf (CtrB pos _) = pos
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    24
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    25
tailPosEdge :: Edge -> Edge
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    26
tailPosEdge (VN pos ty) = VN (tail pos) ty
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    27
tailPosEdge (CtrB pos ts) = CtrB (tail pos) ts
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    28
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
    29
termOf :: Pos -> Path -> Generated_Code.Narrowing_term
46758
4106258260b3 choosing longer constant names in Quickcheck_Narrowing to reduce the chances of name clashes in Quickcheck-Narrowing
bulwahn
parents: 46408
diff changeset
    30
termOf pos (CtrB [] i : es) = Generated_Code.Narrowing_constructor i (termListOf pos es)
4106258260b3 choosing longer constant names in Quickcheck_Narrowing to reduce the chances of name clashes in Quickcheck-Narrowing
bulwahn
parents: 46408
diff changeset
    31
termOf pos [VN [] ty] = Generated_Code.Narrowing_variable pos ty
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    32
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
    33
termListOf :: Pos -> Path -> [Generated_Code.Narrowing_term]
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    34
termListOf pos es = termListOf' 0 es
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    35
  where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    36
    termListOf' i [] = []
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    37
    termListOf' i (e : es) =
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    38
      let 
46408
2520cd337056 using fully qualified module names in Haskell source, which seems to be required by GHC 7.0.4 (also cf. 0fd9ab902b5a)
bulwahn
parents: 45760
diff changeset
    39
        (ts, rs) = Data.List.partition (\e -> head (posOf e) == i) (e : es)
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    40
        t = termOf (pos ++ [i]) (map tailPosEdge ts)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    41
      in
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    42
        (t : termListOf' (i + 1) rs) 
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    43
{-
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    44
conv :: [[Term] -> a] -> Term -> a
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    45
conv cs (Var p _) = error ('\0':map toEnum p)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    46
conv cs (Ctr i xs) = (cs !! i) xs
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    47
-}
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    48
-- Answers
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    49
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    50
data Answer = Known Bool | Unknown Pos deriving Show;
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    51
45003
7591039fb6b4 catch PatternMatchFail exceptions in narrowing-based quickcheck
bulwahn
parents: 44751
diff changeset
    52
answeri :: a -> (a -> IO b) -> (Pos -> IO b) -> IO b;
7591039fb6b4 catch PatternMatchFail exceptions in narrowing-based quickcheck
bulwahn
parents: 44751
diff changeset
    53
answeri a known unknown =
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    54
  do res <- try (evaluate a)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    55
     case res of
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    56
       Right b -> known b
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    57
       Left (ErrorCall ('\0':p)) -> unknown (map fromEnum p)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    58
       Left e -> throw e
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    59
45685
e2e928af750b quickcheck narrowing also shows potential counterexamples
bulwahn
parents: 45081
diff changeset
    60
answer :: Bool -> Bool -> (Bool -> IO b) -> (Pos -> IO b) -> IO b;
45760
3b5a735897c3 inverted flag potential to genuine_only in the quickcheck narrowing Haskell code
bulwahn
parents: 45685
diff changeset
    61
answer genuine_only a known unknown =
45003
7591039fb6b4 catch PatternMatchFail exceptions in narrowing-based quickcheck
bulwahn
parents: 44751
diff changeset
    62
  Control.Exception.catch (answeri a known unknown) 
45760
3b5a735897c3 inverted flag potential to genuine_only in the quickcheck narrowing Haskell code
bulwahn
parents: 45685
diff changeset
    63
    (\ (PatternMatchFail _) -> known genuine_only)
45003
7591039fb6b4 catch PatternMatchFail exceptions in narrowing-based quickcheck
bulwahn
parents: 44751
diff changeset
    64
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    65
--  Proofs and Refutation
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    66
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    67
data Quantifier = ExistentialQ | UniversalQ
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    68
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    69
data EvaluationResult = Eval Bool | UnknownValue Bool deriving Eq
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    70
{-
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    71
instance Show EvaluationResult where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    72
  show (Eval True) = "T"
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    73
  show (Eval False) = "F"
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    74
  show (UnknownValue False) = "U"
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    75
  show (UnknownValue True) = "X"
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    76
-}
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    77
uneval = UnknownValue True
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    78
unknown = UnknownValue False
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    79
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    80
andOp :: EvaluationResult -> EvaluationResult -> EvaluationResult
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    81
andOp (Eval b1) (Eval b2) = Eval (b1 && b2)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    82
andOp (Eval True) (UnknownValue b) = UnknownValue b
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    83
andOp (Eval False) (UnknownValue _) = Eval False
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    84
andOp (UnknownValue b) (Eval True) = UnknownValue b
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    85
andOp (UnknownValue _) (Eval False) = Eval False
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    86
andOp (UnknownValue b1) (UnknownValue b2) = UnknownValue (b1 || b2)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    87
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    88
orOp :: EvaluationResult -> EvaluationResult -> EvaluationResult
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    89
orOp (Eval b1) (Eval b2) = Eval (b1 || b2)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    90
orOp (Eval False) (UnknownValue b) = UnknownValue b
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    91
orOp (Eval True) (UnknownValue _) = Eval True
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    92
orOp (UnknownValue b) (Eval False) = UnknownValue b
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    93
orOp (UnknownValue _) (Eval True) = Eval True
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    94
orOp (UnknownValue b1) (UnknownValue b2) = UnknownValue (b1 && b2)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    95
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    96
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
    97
data Edge = VN Pos Generated_Code.Narrowing_type | CtrB Pos Int
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    98
type Path = [Edge]
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
    99
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   100
data QuantTree = Node EvaluationResult
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   101
  | VarNode Quantifier EvaluationResult Pos Generated_Code.Narrowing_type QuantTree
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   102
  | CtrBranch Quantifier EvaluationResult Pos [QuantTree]
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   103
{-
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   104
instance Show QuantTree where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   105
  show (Node r) = "Node " ++ show r
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   106
  show (VarNode q r p _ t) = "VarNode " ++ show q ++ " " ++ show r ++ " " ++ show p ++ " " ++ show t
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   107
  show (CtrBranch q r p ts) = "CtrBranch " ++ show q ++ show r ++ show p ++ show ts
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   108
-}
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   109
evalOf :: QuantTree -> EvaluationResult
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   110
evalOf (Node r) = r
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   111
evalOf (VarNode _ r _ _ _) = r
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   112
evalOf (CtrBranch _ r _ _) = r
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   113
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   114
-- Operation find: finds first relevant unevaluated node and returns its path
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   115
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   116
find :: QuantTree -> Path
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   117
find (Node (UnknownValue True)) = []
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   118
find (VarNode _ _ pos ty t) = VN pos ty : (find t)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   119
find (CtrBranch _ _ pos ts) = CtrB pos i : find (ts !! i)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   120
  where  
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   121
    Just i = findIndex (\t -> evalOf t == uneval) ts
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   122
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   123
-- Operation: updateNode ( and simplify)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   124
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   125
{- updates the Node and the stored evaluation results along the upper nodes -}
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   126
updateNode :: Path -> EvaluationResult -> QuantTree -> QuantTree
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   127
updateNode [] v (Node _) = Node v
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   128
updateNode (VN _ _ : es) v (VarNode q r p ty t) = VarNode q (evalOf t') p ty t'
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   129
  where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   130
    t' = updateNode es v t    
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   131
updateNode (CtrB _ i : es) v (CtrBranch q r pos ts) = CtrBranch q r' pos ts' 
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   132
  where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   133
    (xs, y : ys) = splitAt i ts
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   134
    y' = updateNode es v y
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   135
    ts' = xs ++ (y' : ys)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   136
    r' = foldl (\s t -> oper s (evalOf t)) neutral ts'
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   137
    (neutral, oper) = case q of { UniversalQ -> (Eval True, andOp); ExistentialQ -> (Eval False, orOp)}
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   138
 
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   139
-- Operation: refineTree
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   140
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   141
updateTree :: (QuantTree -> QuantTree) -> Path -> QuantTree -> QuantTree
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   142
updateTree f [] t = (f t)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   143
updateTree f (VN _ _ : es) (VarNode q r pos ty t) = VarNode q r pos ty (updateTree f es t)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   144
updateTree f (CtrB _ i : es) (CtrBranch q r pos ts) = CtrBranch q r pos (xs ++ (updateTree f es y : ys))
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   145
   where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   146
     (xs, y : ys) = splitAt i ts
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   147
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   148
refineTree :: [Edge] -> Pos -> QuantTree -> QuantTree
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   149
refineTree es p t = updateTree refine (pathPrefix p es) t
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   150
  where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   151
    pathPrefix p es = takeWhile (\e -> posOf e /= p) es  
46758
4106258260b3 choosing longer constant names in Quickcheck_Narrowing to reduce the chances of name clashes in Quickcheck-Narrowing
bulwahn
parents: 46408
diff changeset
   152
    refine (VarNode q r p (Generated_Code.Narrowing_sum_of_products ps) t) =
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   153
      CtrBranch q r p [ foldr (\(i,ty) t -> VarNode q r (p++[i]) ty t) t (zip [0..] ts) | ts <- ps ]
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   154
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   155
-- refute
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   156
45685
e2e928af750b quickcheck narrowing also shows potential counterexamples
bulwahn
parents: 45081
diff changeset
   157
refute :: ([Generated_Code.Narrowing_term] -> Bool) -> Bool -> Int -> QuantTree -> IO QuantTree
45760
3b5a735897c3 inverted flag potential to genuine_only in the quickcheck narrowing Haskell code
bulwahn
parents: 45685
diff changeset
   158
refute exec genuine_only d t = ref t
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   159
  where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   160
    ref t =
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   161
      let path = find t in
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   162
        do
45760
3b5a735897c3 inverted flag potential to genuine_only in the quickcheck narrowing Haskell code
bulwahn
parents: 45685
diff changeset
   163
          t' <- answer genuine_only (exec (termListOf [] path)) (\b -> return (updateNode path (Eval b) t))
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   164
            (\p -> return (if length p < d then refineTree path p t else updateNode path unknown t));
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   165
          case evalOf t' of
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   166
            UnknownValue True -> ref t'
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   167
            _ -> return t'
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   168
45685
e2e928af750b quickcheck narrowing also shows potential counterexamples
bulwahn
parents: 45081
diff changeset
   169
depthCheck :: Bool -> Int -> Generated_Code.Property -> IO ()
45760
3b5a735897c3 inverted flag potential to genuine_only in the quickcheck narrowing Haskell code
bulwahn
parents: 45685
diff changeset
   170
depthCheck genuine_only d p = refute (checkOf p) genuine_only d (treeOf 0 p) >>= (\t -> 
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   171
  case evalOf t of
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   172
   Eval False -> putStrLn ("SOME (" ++ show (counterexampleOf (reifysOf p) (exampleOf 0 t)) ++ ")")  
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   173
   _ -> putStrLn ("NONE"))
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   174
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   175
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   176
-- presentation of counterexample
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   177
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   178
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   179
instance Show Generated_Code.Typerep where {
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   180
  show (Generated_Code.Typerep c ts) = "Type (\"" ++ c ++ "\", " ++ show ts ++ ")";
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   181
};
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   182
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   183
instance Show Generated_Code.Term where {
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   184
  show (Generated_Code.Const c t) = "Const (\"" ++ c ++ "\", " ++ show t ++ ")";
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   185
  show (Generated_Code.App s t) = "(" ++ show s ++ ") $ (" ++ show t ++ ")";
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   186
  show (Generated_Code.Abs s ty t) = "Abs (\"" ++ s ++ "\", " ++ show ty ++ ", " ++ show t ++ ")";
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   187
  show (Generated_Code.Free s ty) = "Free (\"" ++ s ++  "\", " ++ show ty ++ ")";
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   188
};
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   189
{-
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   190
posOf :: Edge -> Pos
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   191
posOf (VN pos _) = pos
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   192
posOf (CtrB pos _) = pos
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   193
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   194
tailPosEdge :: Edge -> Edge
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   195
tailPosEdge (VN pos ty) = VN (tail pos) ty
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   196
tailPosEdge (CtrB pos ts) = CtrB (tail pos) ts
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   197
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   198
termOf :: Pos -> Tree -> (Narrowing_term, Tree)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   199
termOf pos = if Ctr i (termListOf (pos ++ [i]) )
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   200
termOf pos [VN [] ty] = Var pos ty
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   201
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   202
termListOf :: Pos -> [Narrowing_term]
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   203
termListOf pos es = termListOf' 0 es
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   204
  where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   205
    termListOf' i [] = []
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   206
    termListOf' i (e : es) =
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   207
      let
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   208
        (ts, rs) = List.partition (\e -> head (posOf e) == i) (e : es)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   209
        t = termOf (pos ++ [i]) (map tailPosEdge ts)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   210
      in
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   211
        (t : termListOf' (i + 1) rs) 
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   212
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   213
termlist_of :: Pos -> QuantTree -> ([Term], QuantTree)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   214
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   215
termlist_of p' (Node r)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   216
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   217
term_of p' (VarNode _ _ p ty t) = if p == p' then
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   218
    (Some (Var ty), t)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   219
  else
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   220
    (None, t)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   221
term_of p' (CtrBranch q _ p ts) =
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   222
  if p == p' then
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   223
    let
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   224
      i = findindex (\t -> evalOf t == Eval False)        
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   225
    in
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   226
      Ctr i (termlist_of (p ++ [i])  (ts ! i) [])
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   227
  else
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   228
    error ""
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   229
-}
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   230
termlist_of :: Pos -> ([Generated_Code.Narrowing_term], QuantTree) -> ([Generated_Code.Narrowing_term], QuantTree)
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   231
termlist_of p' (terms, Node b) = (terms, Node b) 
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   232
termlist_of p' (terms, VarNode q r p ty t) = if p' == take (length p') p then
46758
4106258260b3 choosing longer constant names in Quickcheck_Narrowing to reduce the chances of name clashes in Quickcheck-Narrowing
bulwahn
parents: 46408
diff changeset
   233
    termlist_of p' (terms ++ [Generated_Code.Narrowing_variable p ty], t)
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   234
  else
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   235
    (terms, VarNode q r p ty t)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   236
termlist_of p' (terms, CtrBranch q r p ts) = if p' == take (length p') p then
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   237
    let
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   238
      Just i = findIndex (\t -> evalOf t == Eval False) ts
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   239
      (subterms, t') = fixp (\j -> termlist_of (p ++ [j])) 0 ([], ts !! i)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   240
    in
46758
4106258260b3 choosing longer constant names in Quickcheck_Narrowing to reduce the chances of name clashes in Quickcheck-Narrowing
bulwahn
parents: 46408
diff changeset
   241
      (terms ++ [Generated_Code.Narrowing_constructor i subterms], t')
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   242
  else
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   243
    (terms, CtrBranch q r p ts)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   244
  where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   245
    fixp f j s = if length (fst (f j s)) == length (fst s) then s else fixp f (j + 1) (f j s)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   246
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   247
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   248
alltermlist_of :: Pos -> ([Generated_Code.Narrowing_term], QuantTree) -> [([Generated_Code.Narrowing_term], QuantTree)]
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   249
alltermlist_of p' (terms, Node b) = [(terms, Node b)] 
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   250
alltermlist_of p' (terms, VarNode q r p ty t) = if p' == take (length p') p then
46758
4106258260b3 choosing longer constant names in Quickcheck_Narrowing to reduce the chances of name clashes in Quickcheck-Narrowing
bulwahn
parents: 46408
diff changeset
   251
    alltermlist_of p' (terms ++ [Generated_Code.Narrowing_variable p ty], t)
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   252
  else
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   253
    [(terms, VarNode q r p ty t)]
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   254
alltermlist_of p' (terms, CtrBranch q r p ts) =
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   255
  if p' == take (length p') p then
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   256
    let
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   257
      its = filter (\(i, t) -> evalOf t == Eval False) (zip [0..] ts)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   258
    in
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   259
      concatMap
46758
4106258260b3 choosing longer constant names in Quickcheck_Narrowing to reduce the chances of name clashes in Quickcheck-Narrowing
bulwahn
parents: 46408
diff changeset
   260
        (\(i, t) -> map (\(subterms, t') -> (terms ++ [Generated_Code.Narrowing_constructor i subterms], t'))
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   261
           (fixp (\j -> alltermlist_of (p ++ [j])) 0 ([], t))) its
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   262
  else
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   263
    [(terms, CtrBranch q r p ts)]
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   264
  where
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   265
    fixp f j s = case (f j s) of
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   266
      [s'] -> if length (fst s') == length (fst s) then [s'] else concatMap (fixp f (j + 1)) (f j s)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   267
      _ -> concatMap (fixp f (j + 1)) (f j s)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   268
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   269
data Example = UnivExample Generated_Code.Narrowing_term Example | ExExample [(Generated_Code.Narrowing_term, Example)] | EmptyExample
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   270
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   271
quantifierOf (VarNode q _ _ _ _) = q
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   272
quantifierOf (CtrBranch q _ _ _) = q
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   273
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   274
exampleOf :: Int -> QuantTree -> Example
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   275
exampleOf _ (Node _) = EmptyExample
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   276
exampleOf p t =
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   277
   case quantifierOf t of
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   278
     UniversalQ ->
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   279
       let
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   280
         ([term], rt) = termlist_of [p] ([], t)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   281
       in UnivExample term (exampleOf (p + 1) rt)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   282
     ExistentialQ ->
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   283
       ExExample (map (\([term], rt) -> (term, exampleOf (p + 1) rt)) (alltermlist_of [p] ([], t)))
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   284
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   285
data Counterexample = Universal_Counterexample (Generated_Code.Term, Counterexample)
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   286
  | Existential_Counterexample [(Generated_Code.Term, Counterexample)] | Empty_Assignment
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   287
  
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   288
instance Show Counterexample where {
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   289
show Empty_Assignment = "Narrowing_Generators.Empty_Assignment";
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   290
show (Universal_Counterexample x) = "Narrowing_Generators.Universal_Counterexample" ++ show x;
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   291
show (Existential_Counterexample x) = "Narrowing_Generators.Existential_Counterexample" ++ show x;
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   292
};
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   293
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   294
counterexampleOf :: [Generated_Code.Narrowing_term -> Generated_Code.Term] -> Example -> Counterexample
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   295
counterexampleOf [] EmptyExample = Empty_Assignment
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   296
counterexampleOf (reify : reifys) (UnivExample t ex) = Universal_Counterexample (reify t, counterexampleOf reifys ex)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   297
counterexampleOf (reify : reifys) (ExExample exs) = Existential_Counterexample (map (\(t, ex) -> (reify t, counterexampleOf reifys ex)) exs)
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   298
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   299
checkOf :: Generated_Code.Property -> [Generated_Code.Narrowing_term] -> Bool
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   300
checkOf (Generated_Code.Property b) = (\[] -> b)
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   301
checkOf (Generated_Code.Universal _ f _) = (\(t : ts) -> checkOf (f t) ts)
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   302
checkOf (Generated_Code.Existential _ f _) = (\(t : ts) -> checkOf (f t) ts)
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   303
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   304
dummy = Generated_Code.Var [] (Generated_Code.SumOfProd [[]])
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   305
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   306
treeOf :: Int -> Generated_Code.Property -> QuantTree
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   307
treeOf n (Generated_Code.Property _) = Node uneval
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   308
treeOf n (Generated_Code.Universal ty f _)  = VarNode UniversalQ uneval [n] ty (treeOf (n + 1) (f dummy)) 
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   309
treeOf n (Generated_Code.Existential ty f _) = VarNode ExistentialQ uneval [n] ty (treeOf (n + 1) (f dummy))
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   310
45081
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   311
reifysOf :: Generated_Code.Property -> [Generated_Code.Narrowing_term -> Generated_Code.Term]
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   312
reifysOf (Generated_Code.Property _) = []
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   313
reifysOf (Generated_Code.Universal _ f r)  = (r : (reifysOf (f dummy)))
f00e52acbd42 importing the Generated_Code module qualified to reduce the probability of name clashes between the static code and the generated code in the narrowing-based Quickcheck
bulwahn
parents: 45003
diff changeset
   314
reifysOf (Generated_Code.Existential _ f r) = (r : (reifysOf (f dummy)))
43313
d3c34987863b adding narrowing engine for existentials
bulwahn
parents:
diff changeset
   315