{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}
module Constrained.Examples.CheatSheet where
import Constrained.API
import Constrained.Properties (forAllSpec)
import Data.Set (Set)
import Data.Set qualified as Set
import GHC.Generics
import Test.QuickCheck (Property, label)
specInt :: Specification Int
specInt :: Specification Int
specInt = (Term Int -> [PredD Deps]) -> Specification Int
forall a p.
(IsPred p, HasSpec a) =>
(Term a -> p) -> Specification a
constrained ((Term Int -> [PredD Deps]) -> Specification Int)
-> (Term Int -> [PredD Deps]) -> Specification Int
forall a b. (a -> b) -> a -> b
$ \Term Int
i ->
[ Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term Int
i Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
10
, Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term Int
0 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
i
]
specInt' :: Specification Int
specInt' :: Specification Int
specInt' = (Term Int -> [Term Bool]) -> Specification Int
forall a p.
(IsPred p, HasSpec a) =>
(Term a -> p) -> Specification a
constrained ((Term Int -> [Term Bool]) -> Specification Int)
-> (Term Int -> [Term Bool]) -> Specification Int
forall a b. (a -> b) -> a -> b
$ \Term Int
i ->
[ Term Int
i Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
10
, Term Int
0 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
i
]
specProd :: Specification (Int, Int)
specProd :: Specification (Int, Int)
specProd = (Term (Int, Int) -> [Term Bool]) -> Specification (Int, Int)
forall a p.
(IsPred p, HasSpec a) =>
(Term a -> p) -> Specification a
constrained ((Term (Int, Int) -> [Term Bool]) -> Specification (Int, Int))
-> (Term (Int, Int) -> [Term Bool]) -> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \Term (Int, Int)
p ->
[ Term (Int, Int) -> Term Int
forall x y. (HasSpec x, HasSpec y) => Term (x, y) -> Term x
fst_ Term (Int, Int)
p Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
10
, Term (Int, Int) -> Term Int
forall x y. (HasSpec x, HasSpec y) => Term (x, y) -> Term y
snd_ Term (Int, Int)
p Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
100
]
specProd0 :: Specification (Int, Int)
specProd0 :: Specification (Int, Int)
specProd0 = (Term (Int, Int) -> PredD Deps) -> Specification (Int, Int)
forall a p.
(IsPred p, HasSpec a) =>
(Term a -> p) -> Specification a
constrained ((Term (Int, Int) -> PredD Deps) -> Specification (Int, Int))
-> (Term (Int, Int) -> PredD Deps) -> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \Term (Int, Int)
p -> Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term (Int, Int) -> Term Int
forall x y. (HasSpec x, HasSpec y) => Term (x, y) -> Term x
fst_ Term (Int, Int)
p Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term (Int, Int) -> Term Int
forall x y. (HasSpec x, HasSpec y) => Term (x, y) -> Term y
snd_ Term (Int, Int)
p
specProd1 :: Specification (Int, Int)
specProd1 :: Specification (Int, Int)
specProd1 = (Term (Int, Int) -> PredD Deps) -> Specification (Int, Int)
forall a p.
(IsPred p, HasSpec a) =>
(Term a -> p) -> Specification a
constrained ((Term (Int, Int) -> PredD Deps) -> Specification (Int, Int))
-> (Term (Int, Int) -> PredD Deps) -> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \Term (Int, Int)
p ->
Term (Int, Int)
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (Term Bool)
-> PredD Deps
forall p a.
(IsProductType a, IsPred p, GenericRequires a,
ProdAsListComputes a) =>
Term a -> FunTy (MapList Term (ProductAsList a)) p -> PredD Deps
match Term (Int, Int)
p (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (Term Bool)
-> PredD Deps)
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (Term Bool)
-> PredD Deps
forall a b. (a -> b) -> a -> b
$ \Term Int
x Term Int
y ->
Term Int
x Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
y
nested :: Specification ((Int, Int), (Int, Int))
nested :: Specification ((Int, Int), (Int, Int))
nested =
(Term ((Int, Int), (Int, Int)) -> PredD Deps)
-> Specification ((Int, Int), (Int, Int))
forall a p.
(IsPred p, HasSpec a) =>
(Term a -> p) -> Specification a
constrained ((Term ((Int, Int), (Int, Int)) -> PredD Deps)
-> Specification ((Int, Int), (Int, Int)))
-> (Term ((Int, Int), (Int, Int)) -> PredD Deps)
-> Specification ((Int, Int), (Int, Int))
forall a b. (a -> b) -> a -> b
$ \Term ((Int, Int), (Int, Int))
pp ->
Term ((Int, Int), (Int, Int))
-> FunTy
(MapList Term (Args (SimpleRep ((Int, Int), (Int, Int)))))
(PredD Deps)
-> PredD Deps
forall p a.
(IsProductType a, IsPred p, GenericRequires a,
ProdAsListComputes a) =>
Term a -> FunTy (MapList Term (ProductAsList a)) p -> PredD Deps
match Term ((Int, Int), (Int, Int))
pp (FunTy
(MapList Term (Args (SimpleRep ((Int, Int), (Int, Int)))))
(PredD Deps)
-> PredD Deps)
-> FunTy
(MapList Term (Args (SimpleRep ((Int, Int), (Int, Int)))))
(PredD Deps)
-> PredD Deps
forall a b. (a -> b) -> a -> b
$ \Term (Int, Int)
p1 Term (Int, Int)
p2 ->
Term (Int, Int)
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> PredD Deps
forall p a.
(IsProductType a, IsPred p, GenericRequires a,
ProdAsListComputes a) =>
Term a -> FunTy (MapList Term (ProductAsList a)) p -> PredD Deps
match Term (Int, Int)
p1 (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> PredD Deps)
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> PredD Deps
forall a b. (a -> b) -> a -> b
$ \Term Int
x1 Term Int
y1 ->
Term (Int, Int)
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> PredD Deps
forall p a.
(IsProductType a, IsPred p, GenericRequires a,
ProdAsListComputes a) =>
Term a -> FunTy (MapList Term (ProductAsList a)) p -> PredD Deps
match Term (Int, Int)
p2 (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> PredD Deps)
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> PredD Deps
forall a b. (a -> b) -> a -> b
$ \Term Int
x2 Term Int
y2 ->
[Term Int
x1 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<=. Term Int
y1, Term Int
y1 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<=. Term Int
x2, Term Int
x2 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<=. Term Int
y2]
specProd2 :: Specification (Int, Int)
specProd2 :: Specification (Int, Int)
specProd2 = FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (Term Bool)
-> Specification (Int, Int)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (Term Bool)
-> Specification (Int, Int))
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (Term Bool)
-> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \Term Int
x Term Int
y -> Term Int
x Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
y
solverOrder :: Specification (Int, Int)
solverOrder :: Specification (Int, Int)
solverOrder = FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int))
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \Term Int
x Term Int
y ->
[ Term Int
x Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
y
, Term Int
y Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
10
]
solverOrder' :: Specification (Int, Int)
solverOrder' :: Specification (Int, Int)
solverOrder' = FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int))
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \ Term Int
[var|x|] Term Int
[var|y|] ->
[ Term Int
x Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
y
, Term Int
y Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
10
]
tightFit0 :: Specification (Int, Int)
tightFit0 :: Specification (Int, Int)
tightFit0 = FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int))
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \Term Int
x Term Int
y ->
[ Term Int
0 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
x
, Term Int
x Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
y
]
tightFit1 :: Specification (Int, Int)
tightFit1 :: Specification (Int, Int)
tightFit1 = FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [PredD Deps]
-> Specification (Int, Int)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [PredD Deps]
-> Specification (Int, Int))
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [PredD Deps]
-> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \Term Int
x Term Int
y ->
[ Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term Int
0 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
x
, Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term Int
x Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
y
, Term Int
y Term Int -> Term Int -> PredD Deps
forall a b.
(HasSpec a, HasSpec b) =>
Term a -> Term b -> PredD Deps
`dependsOn` Term Int
x
]
booleanExample :: Specification (Int, Int)
booleanExample :: Specification (Int, Int)
booleanExample = FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> Specification (Int, Int)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> Specification (Int, Int))
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \Term Int
x Term Int
y ->
Term Bool -> Term Bool -> Term Bool -> PredD Deps
forall p q.
(IsPred p, IsPred q) =>
Term Bool -> p -> q -> PredD Deps
ifElse
(Term Int
0 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
x)
(Term Int
y Term Int -> Term Int -> Term Bool
forall a. HasSpec a => Term a -> Term a -> Term Bool
==. Term Int
10)
(Term Int
y Term Int -> Term Int -> Term Bool
forall a. HasSpec a => Term a -> Term a -> Term Bool
==. Term Int
20)
validPVPVersion :: Specification (Int, Int)
validPVPVersion :: Specification (Int, Int)
validPVPVersion = FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int))
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [Term Bool]
-> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \Term Int
ma Term Int
mi -> [Term Int
0 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<=. Term Int
ma, Term Int
0 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<=. Term Int
mi]
canFollowExample :: Specification ((Int, Int), (Int, Int))
canFollowExample :: Specification ((Int, Int), (Int, Int))
canFollowExample = FunTy
(MapList Term (Args (SimpleRep ((Int, Int), (Int, Int)))))
[PredD Deps]
-> Specification ((Int, Int), (Int, Int))
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy
(MapList Term (Args (SimpleRep ((Int, Int), (Int, Int)))))
[PredD Deps]
-> Specification ((Int, Int), (Int, Int)))
-> FunTy
(MapList Term (Args (SimpleRep ((Int, Int), (Int, Int)))))
[PredD Deps]
-> Specification ((Int, Int), (Int, Int))
forall a b. (a -> b) -> a -> b
$ \Term (Int, Int)
p Term (Int, Int)
q ->
[ Term (Int, Int)
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> PredD Deps
forall p a.
(IsProductType a, IsPred p, GenericRequires a,
ProdAsListComputes a) =>
Term a -> FunTy (MapList Term (ProductAsList a)) p -> PredD Deps
match Term (Int, Int)
p (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> PredD Deps)
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> PredD Deps
forall a b. (a -> b) -> a -> b
$ \Term Int
ma Term Int
mi ->
Term (Int, Int)
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [PredD Deps]
-> PredD Deps
forall p a.
(IsProductType a, IsPred p, GenericRequires a,
ProdAsListComputes a) =>
Term a -> FunTy (MapList Term (ProductAsList a)) p -> PredD Deps
match Term (Int, Int)
q (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [PredD Deps]
-> PredD Deps)
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [PredD Deps]
-> PredD Deps
forall a b. (a -> b) -> a -> b
$ \Term Int
ma' Term Int
mi' ->
[ Term Bool -> Term Bool -> Term Bool -> PredD Deps
forall p q.
(IsPred p, IsPred q) =>
Term Bool -> p -> q -> PredD Deps
ifElse
(Term Int
ma' Term Int -> Term Int -> Term Bool
forall a. HasSpec a => Term a -> Term a -> Term Bool
==. Term Int
ma)
(Term Int
mi' Term Int -> Term Int -> Term Bool
forall a. HasSpec a => Term a -> Term a -> Term Bool
==. Term Int
mi Term Int -> Term Int -> Term Int
forall a. Num a => a -> a -> a
+ Term Int
1)
(Term Int
mi' Term Int -> Term Int -> Term Bool
forall a. HasSpec a => Term a -> Term a -> Term Bool
==. Term Int
0)
,
Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term Int
ma' Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<=. Term Int
ma Term Int -> Term Int -> Term Int
forall a. Num a => a -> a -> a
+ Term Int
1
, Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term Int
ma Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<=. Term Int
ma'
,
Term Int
ma' Term Int -> Term Int -> PredD Deps
forall a b.
(HasSpec a, HasSpec b) =>
Term a -> Term b -> PredD Deps
`dependsOn` Term Int
ma
]
, Term (Int, Int)
p Term (Int, Int) -> Specification (Int, Int) -> PredD Deps
forall a. HasSpec a => Term a -> Specification a -> PredD Deps
`satisfies` Specification (Int, Int)
validPVPVersion
, Term (Int, Int)
q Term (Int, Int) -> Specification (Int, Int) -> PredD Deps
forall a. HasSpec a => Term a -> Specification a -> PredD Deps
`satisfies` Specification (Int, Int)
validPVPVersion
]
sumExample :: Specification (Either Int Bool)
sumExample :: Specification (Either Int Bool)
sumExample = (Term (Either Int Bool) -> PredD Deps)
-> Specification (Either Int Bool)
forall a p.
(IsPred p, HasSpec a) =>
(Term a -> p) -> Specification a
constrained ((Term (Either Int Bool) -> PredD Deps)
-> Specification (Either Int Bool))
-> (Term (Either Int Bool) -> PredD Deps)
-> Specification (Either Int Bool)
forall a b. (a -> b) -> a -> b
$ \Term (Either Int Bool)
e ->
(Term (Either Int Bool)
-> FunTy
(MapList
(Weighted (BinderD Deps)) (Cases (SimpleRep (Either Int Bool))))
(PredD Deps)
forall a.
(GenericRequires a, SimpleRep a ~ SumOver (Cases (SimpleRep a)),
TypeList (Cases (SimpleRep a))) =>
Term a
-> FunTy
(MapList (Weighted (BinderD Deps)) (Cases (SimpleRep a)))
(PredD Deps)
caseOn Term (Either Int Bool)
e)
(FunTy (MapList Term (Args Int)) (Term Bool)
-> Weighted (BinderD Deps) Int
forall p a.
(HasSpec a, All HasSpec (Args a), IsPred p, IsProd a) =>
FunTy (MapList Term (Args a)) p -> Weighted (BinderD Deps) a
branch (FunTy (MapList Term (Args Int)) (Term Bool)
-> Weighted (BinderD Deps) Int)
-> FunTy (MapList Term (Args Int)) (Term Bool)
-> Weighted (BinderD Deps) Int
forall a b. (a -> b) -> a -> b
$ \Term Int
i -> Term Int
i Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
0)
(FunTy (MapList Term (Args Bool)) (Term Bool)
-> Weighted (BinderD Deps) Bool
forall p a.
(HasSpec a, All HasSpec (Args a), IsPred p, IsProd a) =>
FunTy (MapList Term (Args a)) p -> Weighted (BinderD Deps) a
branch (FunTy (MapList Term (Args Bool)) (Term Bool)
-> Weighted (BinderD Deps) Bool)
-> FunTy (MapList Term (Args Bool)) (Term Bool)
-> Weighted (BinderD Deps) Bool
forall a b. (a -> b) -> a -> b
$ \Term Bool
b -> Term Bool -> Term Bool
not_ Term Bool
b)
sumExampleTwo :: Specification (Int, Either Int Bool)
sumExampleTwo :: Specification (Int, Either Int Bool)
sumExampleTwo = FunTy
(MapList Term (Args (SimpleRep (Int, Either Int Bool))))
[PredD Deps]
-> Specification (Int, Either Int Bool)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy
(MapList Term (Args (SimpleRep (Int, Either Int Bool))))
[PredD Deps]
-> Specification (Int, Either Int Bool))
-> FunTy
(MapList Term (Args (SimpleRep (Int, Either Int Bool))))
[PredD Deps]
-> Specification (Int, Either Int Bool)
forall a b. (a -> b) -> a -> b
$ \Term Int
i Term (Either Int Bool)
e ->
[ Term (Either Int Bool)
-> FunTy
(MapList
(Weighted (BinderD Deps)) (Cases (SimpleRep (Either Int Bool))))
(PredD Deps)
forall a.
(GenericRequires a, SimpleRep a ~ SumOver (Cases (SimpleRep a)),
TypeList (Cases (SimpleRep a))) =>
Term a
-> FunTy
(MapList (Weighted (BinderD Deps)) (Cases (SimpleRep a)))
(PredD Deps)
caseOn
Term (Either Int Bool)
e
(FunTy (MapList Term (Args Int)) (Term Bool)
-> Weighted (BinderD Deps) Int
forall p a.
(HasSpec a, All HasSpec (Args a), IsPred p, IsProd a) =>
FunTy (MapList Term (Args a)) p -> Weighted (BinderD Deps) a
branch (FunTy (MapList Term (Args Int)) (Term Bool)
-> Weighted (BinderD Deps) Int)
-> FunTy (MapList Term (Args Int)) (Term Bool)
-> Weighted (BinderD Deps) Int
forall a b. (a -> b) -> a -> b
$ \Term Int
j -> Term Int
i Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
j)
(FunTy (MapList Term (Args Bool)) (Term Bool)
-> Weighted (BinderD Deps) Bool
forall p a.
(HasSpec a, All HasSpec (Args a), IsPred p, IsProd a) =>
FunTy (MapList Term (Args a)) p -> Weighted (BinderD Deps) a
branch (FunTy (MapList Term (Args Bool)) (Term Bool)
-> Weighted (BinderD Deps) Bool)
-> FunTy (MapList Term (Args Bool)) (Term Bool)
-> Weighted (BinderD Deps) Bool
forall a b. (a -> b) -> a -> b
$ \Term Bool
b -> Term Bool -> Term Bool
not_ Term Bool
b)
, Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term Int
20 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
i
]
setExample :: Specification (Set Int, Set Int, Set Int)
setExample :: Specification (Set Int, Set Int, Set Int)
setExample = FunTy
(MapList Term (Args (SimpleRep (Set Int, Set Int, Set Int))))
[Term Bool]
-> Specification (Set Int, Set Int, Set Int)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy
(MapList Term (Args (SimpleRep (Set Int, Set Int, Set Int))))
[Term Bool]
-> Specification (Set Int, Set Int, Set Int))
-> FunTy
(MapList Term (Args (SimpleRep (Set Int, Set Int, Set Int))))
[Term Bool]
-> Specification (Set Int, Set Int, Set Int)
forall a b. (a -> b) -> a -> b
$ \Term (Set Int)
xs Term (Set Int)
ys Term (Set Int)
zs ->
[ Term (Set Int)
xs Term (Set Int) -> Term (Set Int) -> Term Bool
forall a.
(Ord a, HasSpec a) =>
Term (Set a) -> Term (Set a) -> Term Bool
`subset_` (Term (Set Int)
ys Term (Set Int) -> Term (Set Int) -> Term (Set Int)
forall a. Semigroup a => a -> a -> a
<> Term (Set Int)
zs)
, Term (Set Int) -> Term Integer
forall a. (HasSpec a, Sized a) => Term a -> Term Integer
sizeOf_ Term (Set Int)
ys Term Integer -> Term Integer -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<=. Term Integer
10
]
forAllFollow0 :: Specification ((Int, Int), Set (Int, Int))
forAllFollow0 :: Specification ((Int, Int), Set (Int, Int))
forAllFollow0 = FunTy
(MapList Term (Args (SimpleRep ((Int, Int), Set (Int, Int)))))
[PredD Deps]
-> Specification ((Int, Int), Set (Int, Int))
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy
(MapList Term (Args (SimpleRep ((Int, Int), Set (Int, Int)))))
[PredD Deps]
-> Specification ((Int, Int), Set (Int, Int)))
-> FunTy
(MapList Term (Args (SimpleRep ((Int, Int), Set (Int, Int)))))
[PredD Deps]
-> Specification ((Int, Int), Set (Int, Int))
forall a b. (a -> b) -> a -> b
$ \Term (Int, Int)
p Term (Set (Int, Int))
qs ->
[ Term (Set (Int, Int))
-> (Term (Int, Int) -> PredD Deps) -> PredD Deps
forall t a p.
(Forallable t a, HasSpec t, HasSpec a, IsPred p) =>
Term t -> (Term a -> p) -> PredD Deps
forAll Term (Set (Int, Int))
qs ((Term (Int, Int) -> PredD Deps) -> PredD Deps)
-> (Term (Int, Int) -> PredD Deps) -> PredD Deps
forall a b. (a -> b) -> a -> b
$ \Term (Int, Int)
q -> Term (Int, Int) -> Term (Int, Int) -> Term ((Int, Int), (Int, Int))
forall a b.
(HasSpec a, HasSpec b, IsNormalType a, IsNormalType b) =>
Term a -> Term b -> Term (a, b)
pair_ Term (Int, Int)
p Term (Int, Int)
q Term ((Int, Int), (Int, Int))
-> Specification ((Int, Int), (Int, Int)) -> PredD Deps
forall a. HasSpec a => Term a -> Specification a -> PredD Deps
`satisfies` Specification ((Int, Int), (Int, Int))
canFollowExample
]
forAllFollow :: Specification ((Int, Int), Set (Int, Int))
forAllFollow :: Specification ((Int, Int), Set (Int, Int))
forAllFollow = FunTy
(MapList Term (Args (SimpleRep ((Int, Int), Set (Int, Int)))))
[PredD Deps]
-> Specification ((Int, Int), Set (Int, Int))
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy
(MapList Term (Args (SimpleRep ((Int, Int), Set (Int, Int)))))
[PredD Deps]
-> Specification ((Int, Int), Set (Int, Int)))
-> FunTy
(MapList Term (Args (SimpleRep ((Int, Int), Set (Int, Int)))))
[PredD Deps]
-> Specification ((Int, Int), Set (Int, Int))
forall a b. (a -> b) -> a -> b
$ \Term (Int, Int)
p Term (Set (Int, Int))
qs ->
[ Term (Set (Int, Int))
-> (Term (Int, Int) -> PredD Deps) -> PredD Deps
forall t a p.
(Forallable t a, HasSpec t, HasSpec a, IsPred p) =>
Term t -> (Term a -> p) -> PredD Deps
forAll Term (Set (Int, Int))
qs ((Term (Int, Int) -> PredD Deps) -> PredD Deps)
-> (Term (Int, Int) -> PredD Deps) -> PredD Deps
forall a b. (a -> b) -> a -> b
$ \Term (Int, Int)
q -> Term (Int, Int) -> Term (Int, Int) -> Term ((Int, Int), (Int, Int))
forall a b.
(HasSpec a, HasSpec b, IsNormalType a, IsNormalType b) =>
Term a -> Term b -> Term (a, b)
pair_ Term (Int, Int)
p Term (Int, Int)
q Term ((Int, Int), (Int, Int))
-> Specification ((Int, Int), (Int, Int)) -> PredD Deps
forall a. HasSpec a => Term a -> Specification a -> PredD Deps
`satisfies` Specification ((Int, Int), (Int, Int))
canFollowExample
, Term (Int, Int)
p Term (Int, Int) -> Specification (Int, Int) -> PredD Deps
forall a. HasSpec a => Term a -> Specification a -> PredD Deps
`satisfies` Specification (Int, Int)
validPVPVersion
]
existentials :: Specification (Set Int, Set Int)
existentials :: Specification (Set Int, Set Int)
existentials = FunTy
(MapList Term (Args (SimpleRep (Set Int, Set Int)))) (PredD Deps)
-> Specification (Set Int, Set Int)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy
(MapList Term (Args (SimpleRep (Set Int, Set Int)))) (PredD Deps)
-> Specification (Set Int, Set Int))
-> FunTy
(MapList Term (Args (SimpleRep (Set Int, Set Int)))) (PredD Deps)
-> Specification (Set Int, Set Int)
forall a b. (a -> b) -> a -> b
$ \Term (Set Int)
xs Term (Set Int)
ys ->
((forall b. Term b -> b) -> GE (Set Int))
-> (Term (Set Int) -> [PredD Deps]) -> PredD Deps
forall a p.
(HasSpec a, IsPred p) =>
((forall b. Term b -> b) -> GE a) -> (Term a -> p) -> PredD Deps
exists (\forall b. Term b -> b
eval -> Set Int -> GE (Set Int)
forall a. a -> GE a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Set Int -> GE (Set Int)) -> Set Int -> GE (Set Int)
forall a b. (a -> b) -> a -> b
$ Set Int -> Set Int -> Set Int
forall a. Ord a => Set a -> Set a -> Set a
Set.intersection (Term (Set Int) -> Set Int
forall b. Term b -> b
eval Term (Set Int)
xs) (Term (Set Int) -> Set Int
forall b. Term b -> b
eval Term (Set Int)
ys)) ((Term (Set Int) -> [PredD Deps]) -> PredD Deps)
-> (Term (Set Int) -> [PredD Deps]) -> PredD Deps
forall a b. (a -> b) -> a -> b
$ \Term (Set Int)
zs ->
[ Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term Bool -> Term Bool
not_ (Term Bool -> Term Bool) -> Term Bool -> Term Bool
forall a b. (a -> b) -> a -> b
$ Term (Set Int) -> Term Bool
forall a. (HasSpec a, Sized a) => Term a -> Term Bool
null_ Term (Set Int)
zs
, Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term (Set Int)
zs Term (Set Int) -> Term (Set Int) -> Term Bool
forall a.
(Ord a, HasSpec a) =>
Term (Set a) -> Term (Set a) -> Term Bool
`subset_` Term (Set Int)
xs
, Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term (Set Int)
zs Term (Set Int) -> Term (Set Int) -> Term Bool
forall a.
(Ord a, HasSpec a) =>
Term (Set a) -> Term (Set a) -> Term Bool
`subset_` Term (Set Int)
ys
, Term (Set Int)
xs Term (Set Int) -> Term (Set Int) -> PredD Deps
forall a b.
(HasSpec a, HasSpec b) =>
Term a -> Term b -> PredD Deps
`dependsOn` Term (Set Int)
zs
, Term (Set Int)
ys Term (Set Int) -> Term (Set Int) -> PredD Deps
forall a b.
(HasSpec a, HasSpec b) =>
Term a -> Term b -> PredD Deps
`dependsOn` Term (Set Int)
zs
]
data FooBarBaz = Foo Int Int | Bar Bool | Baz deriving (FooBarBaz -> FooBarBaz -> Bool
(FooBarBaz -> FooBarBaz -> Bool)
-> (FooBarBaz -> FooBarBaz -> Bool) -> Eq FooBarBaz
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FooBarBaz -> FooBarBaz -> Bool
== :: FooBarBaz -> FooBarBaz -> Bool
$c/= :: FooBarBaz -> FooBarBaz -> Bool
/= :: FooBarBaz -> FooBarBaz -> Bool
Eq, Int -> FooBarBaz -> ShowS
[FooBarBaz] -> ShowS
FooBarBaz -> String
(Int -> FooBarBaz -> ShowS)
-> (FooBarBaz -> String)
-> ([FooBarBaz] -> ShowS)
-> Show FooBarBaz
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FooBarBaz -> ShowS
showsPrec :: Int -> FooBarBaz -> ShowS
$cshow :: FooBarBaz -> String
show :: FooBarBaz -> String
$cshowList :: [FooBarBaz] -> ShowS
showList :: [FooBarBaz] -> ShowS
Show, (forall x. FooBarBaz -> Rep FooBarBaz x)
-> (forall x. Rep FooBarBaz x -> FooBarBaz) -> Generic FooBarBaz
forall x. Rep FooBarBaz x -> FooBarBaz
forall x. FooBarBaz -> Rep FooBarBaz x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FooBarBaz -> Rep FooBarBaz x
from :: forall x. FooBarBaz -> Rep FooBarBaz x
$cto :: forall x. Rep FooBarBaz x -> FooBarBaz
to :: forall x. Rep FooBarBaz x -> FooBarBaz
Generic)
instance HasSimpleRep FooBarBaz
instance HasSpec FooBarBaz
fooBarBaz :: Specification FooBarBaz
fooBarBaz :: Specification FooBarBaz
fooBarBaz = (Term FooBarBaz -> PredD Deps) -> Specification FooBarBaz
forall a p.
(IsPred p, HasSpec a) =>
(Term a -> p) -> Specification a
constrained ((Term FooBarBaz -> PredD Deps) -> Specification FooBarBaz)
-> (Term FooBarBaz -> PredD Deps) -> Specification FooBarBaz
forall a b. (a -> b) -> a -> b
$ \Term FooBarBaz
fbb ->
Term FooBarBaz
-> FunTy
(MapList (Weighted (BinderD Deps)) (Cases (SimpleRep FooBarBaz)))
(PredD Deps)
forall a.
(GenericRequires a, SimpleRep a ~ SumOver (Cases (SimpleRep a)),
TypeList (Cases (SimpleRep a))) =>
Term a
-> FunTy
(MapList (Weighted (BinderD Deps)) (Cases (SimpleRep a)))
(PredD Deps)
caseOn
Term FooBarBaz
fbb
(FunTy (MapList Term (Args (Prod Int Int))) (Term Bool)
-> Weighted (BinderD Deps) (Prod Int Int)
forall p a.
(HasSpec a, All HasSpec (Args a), IsPred p, IsProd a) =>
FunTy (MapList Term (Args a)) p -> Weighted (BinderD Deps) a
branch (FunTy (MapList Term (Args (Prod Int Int))) (Term Bool)
-> Weighted (BinderD Deps) (Prod Int Int))
-> FunTy (MapList Term (Args (Prod Int Int))) (Term Bool)
-> Weighted (BinderD Deps) (Prod Int Int)
forall a b. (a -> b) -> a -> b
$ \Term Int
i Term Int
j -> Term Int
i Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
j)
(FunTy (MapList Term (Args Bool)) (Term Bool)
-> Weighted (BinderD Deps) Bool
forall p a.
(HasSpec a, All HasSpec (Args a), IsPred p, IsProd a) =>
FunTy (MapList Term (Args a)) p -> Weighted (BinderD Deps) a
branch (FunTy (MapList Term (Args Bool)) (Term Bool)
-> Weighted (BinderD Deps) Bool)
-> FunTy (MapList Term (Args Bool)) (Term Bool)
-> Weighted (BinderD Deps) Bool
forall a b. (a -> b) -> a -> b
$ \Term Bool
b -> Term Bool -> Term Bool
not_ Term Bool
b)
(FunTy (MapList Term (Args ())) Bool -> Weighted (BinderD Deps) ()
forall p a.
(HasSpec a, All HasSpec (Args a), IsPred p, IsProd a) =>
FunTy (MapList Term (Args a)) p -> Weighted (BinderD Deps) a
branch (FunTy (MapList Term (Args ())) Bool -> Weighted (BinderD Deps) ())
-> FunTy (MapList Term (Args ())) Bool
-> Weighted (BinderD Deps) ()
forall a b. (a -> b) -> a -> b
$ \TermD Deps ()
_ -> Bool
False)
reifyExample :: Specification (Int, Int)
reifyExample :: Specification (Int, Int)
reifyExample = FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> Specification (Int, Int)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> Specification (Int, Int))
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) (PredD Deps)
-> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \ Term Int
[var|a|] Term Int
[var|b|] ->
Term Int -> Term Int -> (Int -> Int) -> PredD Deps
forall a b.
(HasSpec a, HasSpec b) =>
Term b -> Term a -> (a -> b) -> PredD Deps
reifies Term Int
b Term Int
a ((Int -> Int) -> PredD Deps) -> (Int -> Int) -> PredD Deps
forall a b. (a -> b) -> a -> b
$ \Int
x -> Int -> Int -> Int
forall a. Integral a => a -> a -> a
mod Int
x Int
10
reifyExample' :: Specification (Int, Int)
reifyExample' :: Specification (Int, Int)
reifyExample' = FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [PredD Deps]
-> Specification (Int, Int)
forall a p.
(Cases (SimpleRep a) ~ '[SimpleRep a],
TypeSpec a ~ TypeSpec (SimpleRep a), HasSpec (SimpleRep a),
HasSimpleRep a, All HasSpec (Args (SimpleRep a)),
IsProd (SimpleRep a), HasSpec a, IsProductType a, IsPred p,
GenericRequires a, ProdAsListComputes a) =>
FunTy (MapList Term (Args (SimpleRep a))) p -> Specification a
constrained' (FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [PredD Deps]
-> Specification (Int, Int))
-> FunTy (MapList Term (Args (SimpleRep (Int, Int)))) [PredD Deps]
-> Specification (Int, Int)
forall a b. (a -> b) -> a -> b
$ \Term Int
a Term Int
b ->
[ Term Bool -> PredD Deps
forall p. IsPred p => p -> PredD Deps
assert (Term Bool -> PredD Deps) -> Term Bool -> PredD Deps
forall a b. (a -> b) -> a -> b
$ Term Int
b Term Int -> Term Int -> Term Bool
forall a. HasSpec a => Term a -> Term a -> Term Bool
==. Term Int -> Term Int -> Term Int
mod_ Term Int
a Term Int
10
, Term Int
b Term Int -> Term Int -> PredD Deps
forall a b.
(HasSpec a, HasSpec b) =>
Term a -> Term b -> PredD Deps
`dependsOn` Term Int
a
]
where
mod_ :: Term Int -> Term Int -> Term Int
mod_ :: Term Int -> Term Int -> Term Int
mod_ = String -> Term Int -> Term Int -> Term Int
forall a. HasCallStack => String -> a
error String
"This doesn't exist"
monitorExample :: Specification (Either Int Int)
monitorExample :: Specification (Either Int Int)
monitorExample = (Term (Either Int Int) -> PredD Deps)
-> Specification (Either Int Int)
forall a p.
(IsPred p, HasSpec a) =>
(Term a -> p) -> Specification a
constrained ((Term (Either Int Int) -> PredD Deps)
-> Specification (Either Int Int))
-> (Term (Either Int Int) -> PredD Deps)
-> Specification (Either Int Int)
forall a b. (a -> b) -> a -> b
$ \Term (Either Int Int)
e ->
Term (Either Int Int)
-> FunTy
(MapList
(Weighted (BinderD Deps)) (Cases (SimpleRep (Either Int Int))))
(PredD Deps)
forall a.
(GenericRequires a, SimpleRep a ~ SumOver (Cases (SimpleRep a)),
TypeList (Cases (SimpleRep a))) =>
Term a
-> FunTy
(MapList (Weighted (BinderD Deps)) (Cases (SimpleRep a)))
(PredD Deps)
caseOn
Term (Either Int Int)
e
(Int
-> FunTy (MapList Term (Args Int)) (PredD Deps)
-> Weighted (BinderD Deps) Int
forall p a.
(HasSpec a, All HasSpec (Args a), IsPred p, IsProd a) =>
Int -> FunTy (MapList Term (Args a)) p -> Weighted (BinderD Deps) a
branchW Int
1 (FunTy (MapList Term (Args Int)) (PredD Deps)
-> Weighted (BinderD Deps) Int)
-> FunTy (MapList Term (Args Int)) (PredD Deps)
-> Weighted (BinderD Deps) Int
forall a b. (a -> b) -> a -> b
$ \Term Int
_ -> ((forall b. Term b -> b) -> Property -> Property) -> PredD Deps
monitor (((forall b. Term b -> b) -> Property -> Property) -> PredD Deps)
-> ((forall b. Term b -> b) -> Property -> Property) -> PredD Deps
forall a b. (a -> b) -> a -> b
$ \forall b. Term b -> b
_ -> String -> Property -> Property
forall prop. Testable prop => String -> prop -> Property
label String
"Left")
(Int
-> FunTy (MapList Term (Args Int)) (PredD Deps)
-> Weighted (BinderD Deps) Int
forall p a.
(HasSpec a, All HasSpec (Args a), IsPred p, IsProd a) =>
Int -> FunTy (MapList Term (Args a)) p -> Weighted (BinderD Deps) a
branchW Int
2 (FunTy (MapList Term (Args Int)) (PredD Deps)
-> Weighted (BinderD Deps) Int)
-> FunTy (MapList Term (Args Int)) (PredD Deps)
-> Weighted (BinderD Deps) Int
forall a b. (a -> b) -> a -> b
$ \Term Int
_ -> ((forall b. Term b -> b) -> Property -> Property) -> PredD Deps
monitor (((forall b. Term b -> b) -> Property -> Property) -> PredD Deps)
-> ((forall b. Term b -> b) -> Property -> Property) -> PredD Deps
forall a b. (a -> b) -> a -> b
$ \forall b. Term b -> b
_ -> String -> Property -> Property
forall prop. Testable prop => String -> prop -> Property
label String
"Right")
prop_monitoring :: Property
prop_monitoring :: Property
prop_monitoring = Specification (Either Int Int)
-> (Either Int Int -> Bool) -> Property
forall a p.
(HasSpec a, Testable p) =>
Specification a -> (a -> p) -> Property
forAllSpec Specification (Either Int Int)
monitorExample ((Either Int Int -> Bool) -> Property)
-> (Either Int Int -> Bool) -> Property
forall a b. (a -> b) -> a -> b
$ \Either Int Int
_ -> Bool
True
chooseSpecExample :: Specification Int
chooseSpecExample :: Specification Int
chooseSpecExample =
(Int, Specification Int)
-> (Int, Specification Int) -> Specification Int
forall a.
HasSpec a =>
(Int, Specification a) -> (Int, Specification a) -> Specification a
chooseSpec
(Int
1, (Term Int -> Term Bool) -> Specification Int
forall a p.
(IsPred p, HasSpec a) =>
(Term a -> p) -> Specification a
constrained ((Term Int -> Term Bool) -> Specification Int)
-> (Term Int -> Term Bool) -> Specification Int
forall a b. (a -> b) -> a -> b
$ \Term Int
i -> Term Int
i Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
0)
(Int
2, (Term Int -> Term Bool) -> Specification Int
forall a p.
(IsPred p, HasSpec a) =>
(Term a -> p) -> Specification a
constrained ((Term Int -> Term Bool) -> Specification Int)
-> (Term Int -> Term Bool) -> Specification Int
forall a b. (a -> b) -> a -> b
$ \Term Int
i -> Term Int
0 Term Int -> Term Int -> Term Bool
forall a. OrdLike a => Term a -> Term a -> Term Bool
<. Term Int
i)
prop_chooseSpec :: Property
prop_chooseSpec :: Property
prop_chooseSpec = Specification Int -> (Int -> Property) -> Property
forall a p.
(HasSpec a, Testable p) =>
Specification a -> (a -> p) -> Property
forAllSpec Specification Int
chooseSpecExample ((Int -> Property) -> Property) -> (Int -> Property) -> Property
forall a b. (a -> b) -> a -> b
$ \Int
i ->
String -> Bool -> Property
forall prop. Testable prop => String -> prop -> Property
label (Int -> String
forall a. Show a => a -> String
show (Int -> String) -> Int -> String
forall a b. (a -> b) -> a -> b
$ Int -> Int
forall a. Num a => a -> a
signum Int
i) Bool
True