-- | \"Sieves\" by Iannis Xenakis and John Rahn
-- /Perspectives of New Music/
-- Vol. 28, No. 1 (Winter, 1990), pp. 58-78
module Music.Theory.Xenakis.Sieve where

import qualified Data.List as L
import Music.Theory.List

-- | A Sieve.
data Sieve = Empty -- ^ 'Empty' 'Sieve'
           | L (Integer, Integer) -- ^ Primitive 'Sieve' of /modulo/ and /index/
           | Union Sieve Sieve -- ^ 'Union' of two 'Sieve's
           | Intersection Sieve Sieve -- ^ 'Intersection' of two 'Sieve's
           | Complement Sieve -- ^ 'Complement' of a 'Sieve'
             deriving (Sieve -> Sieve -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Sieve -> Sieve -> Bool
$c/= :: Sieve -> Sieve -> Bool
== :: Sieve -> Sieve -> Bool
$c== :: Sieve -> Sieve -> Bool
Eq,Int -> Sieve -> ShowS
[Sieve] -> ShowS
Sieve -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Sieve] -> ShowS
$cshowList :: [Sieve] -> ShowS
show :: Sieve -> String
$cshow :: Sieve -> String
showsPrec :: Int -> Sieve -> ShowS
$cshowsPrec :: Int -> Sieve -> ShowS
Show)

-- | The 'Union' of a list of 'Sieve's, ie. 'foldl1' 'Union'.
union :: [Sieve] -> Sieve
union :: [Sieve] -> Sieve
union = forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldl1 Sieve -> Sieve -> Sieve
Union

-- | The 'Intersection' of a list of 'Sieve's, ie. 'foldl1' 'Intersection'.
intersection :: [Sieve] -> Sieve
intersection :: [Sieve] -> Sieve
intersection = forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldl1 Sieve -> Sieve -> Sieve
Intersection

-- | Unicode synonym for 'Union'.
(∪) :: Sieve -> Sieve -> Sieve
∪ :: Sieve -> Sieve -> Sieve
(∪) = Sieve -> Sieve -> Sieve
Union

-- | Unicode synonym for 'Intersection'.
(∩) :: Sieve -> Sieve -> Sieve
∩ :: Sieve -> Sieve -> Sieve
(∩) = Sieve -> Sieve -> Sieve
Intersection

-- | Synonym for 'Complement'.
c :: Sieve -> Sieve
c :: Sieve -> Sieve
c = Sieve -> Sieve
Complement

-- | Pretty-print sieve.  Fully parenthesised.
sieve_pp :: Sieve -> String
sieve_pp :: Sieve -> String
sieve_pp Sieve
s =
    case Sieve
s of
      Sieve
Empty -> String
"∅"
      L (Integer
p,Integer
q) -> forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [forall a. Show a => a -> String
show Integer
p,String
".",forall a. Show a => a -> String
show Integer
q]
      Union Sieve
p Sieve
q -> forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String
"(",Sieve -> String
sieve_pp Sieve
p,String
" ∪ ",Sieve -> String
sieve_pp Sieve
q,String
")"]
      Intersection Sieve
p Sieve
q -> forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String
"(",Sieve -> String
sieve_pp Sieve
p,String
" ∩ ",Sieve -> String
sieve_pp Sieve
q,String
")"]
      Complement Sieve
p -> forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String
"(∁ ",Sieve -> String
sieve_pp Sieve
p,String
")"]

-- | Variant of 'L', ie. 'curry' 'L'.
--
-- > l 15 19 == L (15,19)
l :: Integer -> Integer -> Sieve
l :: Integer -> Integer -> Sieve
l = forall a b c. ((a, b) -> c) -> a -> b -> c
curry (Integer, Integer) -> Sieve
L

-- | unicode synonym for 'l'.
(⋄) :: Integer -> Integer -> Sieve
⋄ :: Integer -> Integer -> Sieve
(⋄) = Integer -> Integer -> Sieve
l

infixl 3 
infixl 4 
infixl 5 

{- | In a /normal/ 'Sieve' /m/ is '>' /i/.

> normalise (L (15,19)) == L (15,4)
> normalise (L (11,13)) == L (11,2)
-}
normalise :: Sieve -> Sieve
normalise :: Sieve -> Sieve
normalise Sieve
s =
    case Sieve
s of
      Sieve
Empty -> Sieve
Empty
      L (Integer
m,Integer
i) -> (Integer, Integer) -> Sieve
L (Integer
m,Integer
i forall a. Integral a => a -> a -> a
`mod` Integer
m)
      Union Sieve
s0 Sieve
s1 -> Sieve -> Sieve -> Sieve
Union (Sieve -> Sieve
normalise Sieve
s0) (Sieve -> Sieve
normalise Sieve
s1)
      Intersection Sieve
s0 Sieve
s1 -> Sieve -> Sieve -> Sieve
Intersection (Sieve -> Sieve
normalise Sieve
s0) (Sieve -> Sieve
normalise Sieve
s1)
      Complement Sieve
s' -> Sieve -> Sieve
Complement (Sieve -> Sieve
normalise Sieve
s')

{- | Predicate to test if a 'Sieve' is /normal/.

> is_normal (L (15,4)) == True
> is_normal (L (11,13)) == False
-}
is_normal :: Sieve -> Bool
is_normal :: Sieve -> Bool
is_normal Sieve
s = Sieve
s forall a. Eq a => a -> a -> Bool
== Sieve -> Sieve
normalise Sieve
s

{- | Predicate to determine if an 'I' is an element of the 'Sieve'.

> map (element (L (3,1))) [1..4] == [True,False,False,True]
> map (element (L (15,4))) [4,19 .. 49] == [True,True,True,True]
-}
element :: Sieve -> Integer -> Bool
element :: Sieve -> Integer -> Bool
element Sieve
s Integer
n =
    case Sieve
s of
      Sieve
Empty -> Bool
False
      L (Integer
m,Integer
i) -> Integer
n forall a. Integral a => a -> a -> a
`mod` Integer
m forall a. Eq a => a -> a -> Bool
== Integer
i forall a. Integral a => a -> a -> a
`mod` Integer
m Bool -> Bool -> Bool
&& Integer
n forall a. Ord a => a -> a -> Bool
>= Integer
i
      Union Sieve
s0 Sieve
s1 -> Sieve -> Integer -> Bool
element Sieve
s0 Integer
n Bool -> Bool -> Bool
|| Sieve -> Integer -> Bool
element Sieve
s1 Integer
n
      Intersection Sieve
s0 Sieve
s1 -> Sieve -> Integer -> Bool
element Sieve
s0 Integer
n Bool -> Bool -> Bool
&& Sieve -> Integer -> Bool
element Sieve
s1 Integer
n
      Complement Sieve
s' -> Bool -> Bool
not (Sieve -> Integer -> Bool
element Sieve
s' Integer
n)

{- | 'I' not in set.

> take 9 (i_complement [1,3..]) == [0,2..16]
-}
i_complement :: [Integer] -> [Integer]
i_complement :: [Integer] -> [Integer]
i_complement =
    let f :: t -> [t] -> [t]
f t
x [t]
s = case [t]
s of
                [] -> [t
x ..]
                t
e:[t]
s' -> case forall a. Ord a => a -> a -> Ordering
compare t
x t
e of
                          Ordering
LT -> t
x forall a. a -> [a] -> [a]
: t -> [t] -> [t]
f (t
x forall a. Num a => a -> a -> a
+ t
1) [t]
s
                          Ordering
EQ -> t -> [t] -> [t]
f (t
x forall a. Num a => a -> a -> a
+ t
1) [t]
s'
                          Ordering
GT -> forall a. HasCallStack => String -> a
error String
"i_complement"
    in forall {t}. (Enum t, Ord t, Num t) => t -> [t] -> [t]
f Integer
0

{- | Construct the sequence defined by a 'Sieve'.  Note that building
     a sieve that contains an intersection clause that has no elements
     gives @_|_@.

> let d = [0,2,4,5,7,9,11]
> let r = d ++ map (+ 12) d
> take 14 (build (union (map (l 12) d))) == r
-}
build :: Sieve -> [Integer]
build :: Sieve -> [Integer]
build Sieve
s =
    let u_f :: [Integer] -> [Integer]
u_f = forall a b. (a -> b) -> [a] -> [b]
map forall a. [a] -> a
head forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [[a]]
L.group
        i_f :: [Integer] -> [Integer]
i_f = let g :: [a] -> [a]
g [a
x,a
_] = [a
x]
                  g [a]
_ = []
              in forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall {a}. [a] -> [a]
g forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [[a]]
L.group
    in case Sieve
s of
         Sieve
Empty -> []
         L (Integer
m,Integer
i) -> [Integer
i, Integer
iforall a. Num a => a -> a -> a
+Integer
m ..]
         Union Sieve
s0 Sieve
s1 -> [Integer] -> [Integer]
u_f (forall a. Ord a => [a] -> [a] -> [a]
merge (Sieve -> [Integer]
build Sieve
s0) (Sieve -> [Integer]
build Sieve
s1))
         Intersection Sieve
s0 Sieve
s1 -> [Integer] -> [Integer]
i_f (forall a. Ord a => [a] -> [a] -> [a]
merge (Sieve -> [Integer]
build Sieve
s0) (Sieve -> [Integer]
build Sieve
s1))
         Complement Sieve
s' -> [Integer] -> [Integer]
i_complement (Sieve -> [Integer]
build Sieve
s')

{- | Variant of 'build' that gives the first /n/ places of the 'reduce' of 'Sieve'.

> buildn 6 (union (map (l 8) [0,3,6])) == [0,3,6,8,11,14]
> buildn 12 (L (3,2)) == [2,5,8,11,14,17,20,23,26,29,32,35]
> buildn 9 (L (8,0)) == [0,8,16,24,32,40,48,56,64]
> buildn 3 (L (3,2) ∩ L (8,0)) == [8,32,56]
> buildn 12 (L (3,1) ∪ L (4,0)) == [0,1,4,7,8,10,12,13,16,19,20,22]
> buildn 14 (5⋄4 ∪ 3⋄2 ∪ 7⋄3) == [2,3,4,5,8,9,10,11,14,17,19,20,23,24]
> buildn 6 (3⋄0 ∪ 4⋄0) == [0,3,4,6,8,9]
> buildn 8 (5⋄2 ∩ 2⋄0 ∪ 7⋄3) == [2,3,10,12,17,22,24,31]
> buildn 12 (5⋄1 ∪ 7⋄2) == [1,2,6,9,11,16,21,23,26,30,31,36]
> buildn 19 (L (3,2) ∪ L (7, 1)) == [1, 2, 5, 8, 11, 14, 15, 17, 20, 22, 23, 26, 29, 32, 35, 36, 38, 41, 43]
> buildn 19 (3⋄0 ∪ 7⋄0) == [0, 3, 6, 7, 9, 12, 14, 15, 18, 21, 24, 27, 28, 30, 33, 35, 36, 39, 42]

> buildn 10 (3⋄2 ∩ 4⋄7 ∪ 6⋄9 ∩ 15⋄18) == [3,11,23,33,35,47,59,63,71,83]

> let s = 3⋄2∩4⋄7∩6⋄11∩8⋄7 ∪ 6⋄9∩15⋄18 ∪ 13⋄5∩8⋄6∩4⋄2 ∪ 6⋄9∩15⋄19
> let s' = 24⋄23 ∪ 30⋄3 ∪ 104⋄70
> buildn 16 s == buildn 16 s'

> buildn 10 (24⋄23 ∪ 30⋄3 ∪ 104⋄70) == [3,23,33,47,63,70,71,93,95,119]

> let r = [2,3,4,5,8,9,10,11,14,17,19,20,23,24,26,29,31]
> buildn 17 (5⋄4 ∪ 3⋄2 ∪ 7⋄3) == r

> let r = [0,1,3,6,9,10,11,12,15,16,17,18,21,24,26,27,30]
> buildn 17 (5⋄1 ∪ 3⋄0 ∪ 7⋄3) == r

> let r = [0,2,3,4,6,7,9,11,12,15,17,18,21,22,24,25,27,30,32]
> buildn 19 (5⋄2 ∪ 3⋄0 ∪ 7⋄4) == r

Agon et. al. p.155

> let a = c (13⋄3 ∪ 13⋄5 ∪ 13⋄7 ∪ 13⋄9)
> let b = 11⋄2
> let c' = c (11⋄4 ∪ 11⋄8)
> let d = 13⋄9
> let e = 13⋄0 ∪ 13⋄1 ∪ 13⋄6
> let f = (a ∩ b) ∪ (c' ∩ d) ∪ e
> buildn 13 f == [0,1,2,6,9,13,14,19,22,24,26,27,32]

> differentiate [0,1,2,6,9,13,14,19,22,24,26,27,32] == [1,1,4,3,4,1,5,3,2,2,1,5]

> import Music.Theory.Pitch {- hmt -}

> let n = [0,1,2,6,9,13,14,19,22,24,26,27,32]
> let r = "C C𝄲 C♯ D♯ E𝄲 F𝄰 G A𝄲 B C C♯ C𝄰 E"
> unwords (map (pitch_class_pp . pc24et_to_pitch . (`mod` 24)) n) == r

Jonchaies

> let s = map (17⋄) [0,1,4,5,7,11,12,16]
> let r = [1,3,1,2,4,1,4,1,1,3,1,2,4,1,4,1,1,3,1,2,4,1,4,1]
> differentiate (buildn 25 (union s)) == r
> let a2 = octpc_to_midi (2,9)
> let m = scanl (+) a2 r
> import Music.Theory.Pitch.Spelling.Table {- hmt -}
> let p = "A2 A#2 C#3 D3 E3 G#3 A3 C#4 D4 D#4 F#4 G4 A4 C#5 D5 F#5 G5 G#5 B5 C6 D6 F#6 G6 B6 C7"
> unwords (map (pitch_pp_iso . midi_to_pitch pc_spell_sharp) m) == p

Nekuïa

> let s = [24⋄0,14⋄2,22⋄3,31⋄4,28⋄7,29⋄9,19⋄10,25⋄13,24⋄14,26⋄17,23⋄21,24⋄10,30⋄9,35⋄17,29⋄24,32⋄25,30⋄29,26⋄21,30⋄17,31⋄16]
> let r = [2,1,1,3,2,1,3,1,2,1,4,3,1,4,1,4,1,3,1,4,1,3,1,4,1,4,1,1,3,1,3,1,2,3,1,4,1,4,4,1]
> differentiate (buildn 41 (union s)) == r
> let a0 = octpc_to_midi (0,9)
> let m = scanl (+) a0 r
> import Music.Theory.Pitch.Spelling.Table {- hmt -}
> let p = "A0 B0 C1 C#1 E1 F#1 G1 A#1 B1 C#2 D2 F#2 A2 A#2 D3 D#3 G3 G#3 B3 C4 E4 F4 G#4 A4 C#5 D5 F#5 G5 G#5 B5 C6 D#6 E6 F#6 A6 A#6 D7 D#7 G7 B7 C8"
> unwords (map (pitch_pp_iso . midi_to_pitch pc_spell_sharp) m) == p

> let s = [8⋄0∩3⋄0,2⋄0∩7⋄2,2⋄1∩11⋄3,31⋄4,4⋄3∩7⋄0,29⋄9,19⋄10,25⋄13,8⋄6∩3⋄2,2⋄1∩13⋄4,23⋄21,8⋄2∩3⋄1,2⋄1∩3⋄0∩5⋄4,5⋄2∩7⋄3,29⋄24,32⋄25,2⋄1∩3⋄2∩5⋄4,2⋄1∩13⋄8,2⋄1∩3⋄2∩5⋄2,31⋄16]
> differentiate (buildn 41 (union s)) == r

Major scale:

> let s = (c(3⋄2) ∩ 4⋄0) ∪ (c(3⋄1) ∩ 4⋄1) ∪ (3⋄2 ∩ 4⋄2) ∪ (c(3⋄0) ∩ 4⋄3)
> buildn 7 s == [0,2,4,5,7,9,11]

Nomos Alpha:

let s = (c (13⋄3 ∪ 13⋄5 ∪ 13⋄7 ∪ 13⋄9) ∩ 11⋄2) ∪ (c (11⋄4 ∪ 11⋄8) ∩ 13⋄9) ∪ (13⋄0 ∪ 13⋄1 ∪ 13⋄6)
let r = [0,1,2,6,9,13,14,19,22,24,26,27,32,35,39,40,45,52,53,58,61,65,66,71,78,79,84,87,90,91,92,97]
buildn 32 s == r

-}
buildn :: Int -> Sieve -> [Integer]
buildn :: Int -> Sieve -> [Integer]
buildn Int
n = forall a. Int -> [a] -> [a]
take Int
n forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sieve -> [Integer]
build forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sieve -> Sieve
reduce

{- | Standard differentiation function.

> differentiate [1,3,6,10] == [2,3,4]
> differentiate [0,2,4,5,7,9,11,12] == [2,2,1,2,2,2,1]
-}
differentiate :: (Num a) => [a] -> [a]
differentiate :: forall a. Num a => [a] -> [a]
differentiate [a]
x = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (-) (forall {a}. [a] -> [a]
tail [a]
x) [a]
x

{- | Euclid's algorithm for computing the greatest common divisor.

> euclid 1989 867 == 51
-}
euclid :: (Integral a) => a -> a -> a
euclid :: forall a. Integral a => a -> a -> a
euclid a
i a
j =
    let k :: a
k = a
i forall a. Integral a => a -> a -> a
`mod` a
j
    in if a
k forall a. Eq a => a -> a -> Bool
== a
0 then a
j else forall a. Integral a => a -> a -> a
euclid a
j a
k

{- | Bachet De Méziriac's algorithm.

> de_meziriac 15 4 == 3 && euclid 15 4 == 1
-}
de_meziriac :: (Integral a) => a -> a -> a
de_meziriac :: forall a. Integral a => a -> a -> a
de_meziriac a
i a
j =
    let f :: a -> a
f a
t = if (a
t forall a. Num a => a -> a -> a
* a
i) forall a. Integral a => a -> a -> a
`mod` a
j forall a. Eq a => a -> a -> Bool
/= a
1
              then a -> a
f (a
t forall a. Num a => a -> a -> a
+ a
1)
              else a
t
    in if a
j forall a. Eq a => a -> a -> Bool
== a
1 then a
1 else a -> a
f a
1

{- | Attempt to reduce the 'Intersection' of two 'L' nodes to a singular 'L' node.

> reduce_intersection (3,2) (4,7) == Just (12,11)
> reduce_intersection (12,11) (6,11) == Just (12,11)
> reduce_intersection (12,11) (8,7) == Just (24,23)
-}
reduce_intersection :: (Integral t) => (t,t) -> (t,t) -> Maybe (t,t)
reduce_intersection :: forall t. Integral t => (t, t) -> (t, t) -> Maybe (t, t)
reduce_intersection (t
m1,t
i1) (t
m2,t
i2) =
    let d :: t
d = forall a. Integral a => a -> a -> a
euclid t
m1 t
m2
        i1' :: t
i1' = t
i1 forall a. Integral a => a -> a -> a
`mod` t
m1
        i2' :: t
i2' = t
i2 forall a. Integral a => a -> a -> a
`mod` t
m2
        c1 :: t
c1 = t
m1 forall a. Integral a => a -> a -> a
`div` t
d
        c2 :: t
c2 = t
m2 forall a. Integral a => a -> a -> a
`div` t
d
        m3 :: t
m3 = t
d forall a. Num a => a -> a -> a
* t
c1 forall a. Num a => a -> a -> a
* t
c2
        t :: t
t = forall a. Integral a => a -> a -> a
de_meziriac t
c1 t
c2
        i3 :: t
i3 = (t
i1' forall a. Num a => a -> a -> a
+ t
t forall a. Num a => a -> a -> a
* (t
i2' forall a. Num a => a -> a -> a
- t
i1') forall a. Num a => a -> a -> a
* t
c1) forall a. Integral a => a -> a -> a
`mod` t
m3
    in if t
d forall a. Eq a => a -> a -> Bool
/= t
1 Bool -> Bool -> Bool
&& (t
i1' forall a. Num a => a -> a -> a
- t
i2') forall a. Integral a => a -> a -> a
`mod` t
d forall a. Eq a => a -> a -> Bool
/= t
0
       then forall a. Maybe a
Nothing
       else forall a. a -> Maybe a
Just (t
m3,t
i3)

{- | Reduce the number of nodes at a 'Sieve'.

> reduce (L (3,2) ∪ Empty) == L (3,2)
> reduce (L (3,2) ∩ Empty) == L (3,2)
> reduce (L (3,2) ∩ L (4,7)) == L (12,11)
> reduce (L (6,9) ∩ L (15,18)) == L (30,3)

> let s = 3⋄2∩4⋄7∩6⋄11∩8⋄7 ∪ 6⋄9∩15⋄18 ∪ 13⋄5∩8⋄6∩4⋄2 ∪ 6⋄9∩15⋄19
> reduce s == (24⋄23 ∪ 30⋄3 ∪ 104⋄70)

> putStrLn $ sieve_pp (reduce s)

> let s = 3⋄2∩4⋄7∩6⋄11∩8⋄7 ∪ 6⋄9∩15⋄18 ∪ 13⋄5∩8⋄6∩4⋄2 ∪ 6⋄9∩15⋄19
> reduce s == (24⋄23 ∪ 30⋄3 ∪ 104⋄70)
-}
reduce :: Sieve -> Sieve
reduce :: Sieve -> Sieve
reduce Sieve
s =
    let f :: (Sieve -> Sieve -> Sieve) -> Sieve -> Sieve -> Sieve
f Sieve -> Sieve -> Sieve
g Sieve
s1 Sieve
s2 =
            let s1' :: Sieve
s1' = Sieve -> Sieve
reduce Sieve
s1
                s2' :: Sieve
s2' = Sieve -> Sieve
reduce Sieve
s2
                s' :: Sieve
s' = Sieve -> Sieve -> Sieve
g Sieve
s1' Sieve
s2'
            in if Sieve
s1 forall a. Eq a => a -> a -> Bool
== Sieve
s1' Bool -> Bool -> Bool
&& Sieve
s2 forall a. Eq a => a -> a -> Bool
== Sieve
s2'
               then Sieve
s'
               else Sieve -> Sieve
reduce Sieve
s'
    in case Sieve
s of
         Sieve
Empty -> Sieve
Empty
         L (Integer, Integer)
_ -> Sieve
s
         Union Sieve
s1 Sieve
Empty -> Sieve
s1
         Union Sieve
s1 Sieve
s2 -> (Sieve -> Sieve -> Sieve) -> Sieve -> Sieve -> Sieve
f Sieve -> Sieve -> Sieve
Union Sieve
s1 Sieve
s2
         Intersection Sieve
s1 Sieve
Empty -> Sieve
s1
         Intersection (L (Integer, Integer)
p) (L (Integer, Integer)
q) -> forall b a. b -> (a -> b) -> Maybe a -> b
maybe Sieve
Empty (Integer, Integer) -> Sieve
L (forall t. Integral t => (t, t) -> (t, t) -> Maybe (t, t)
reduce_intersection (Integer, Integer)
p (Integer, Integer)
q)
         Intersection Sieve
s1 Sieve
s2 -> (Sieve -> Sieve -> Sieve) -> Sieve -> Sieve -> Sieve
f Sieve -> Sieve -> Sieve
Intersection Sieve
s1 Sieve
s2
         Complement Sieve
s' -> Sieve -> Sieve
Complement (Sieve -> Sieve
reduce Sieve
s')

-- * Literature

psappha_flint_c :: [Sieve]
psappha_flint_c :: [Sieve]
psappha_flint_c =
  let s0 :: Sieve
s0 = (Integer
8Integer -> Integer -> Sieve
Integer
0Sieve -> Sieve -> Sieve
Integer
8Integer -> Integer -> Sieve
Integer
1Sieve -> Sieve -> Sieve
Integer
8Integer -> Integer -> Sieve
Integer
7)Sieve -> Sieve -> Sieve
(Integer
5Integer -> Integer -> Sieve
Integer
1Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
3)
      s1 :: Sieve
s1 = (Integer
8Integer -> Integer -> Sieve
Integer
0Sieve -> Sieve -> Sieve
Integer
8Integer -> Integer -> Sieve
Integer
1Sieve -> Sieve -> Sieve
Integer
8Integer -> Integer -> Sieve
Integer
2)Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
0
      s2 :: Sieve
s2 = Integer
8Integer -> Integer -> Sieve
Integer
3Sieve -> Sieve -> Sieve
(Integer
5Integer -> Integer -> Sieve
Integer
0Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
1Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
2Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
3Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
4)
      s3 :: Sieve
s3 = Integer
8Integer -> Integer -> Sieve
Integer
4Sieve -> Sieve -> Sieve
(Integer
5Integer -> Integer -> Sieve
Integer
0Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
1Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
2Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
3Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
4)
      s4 :: Sieve
s4 = (Integer
8Integer -> Integer -> Sieve
Integer
5Sieve -> Sieve -> Sieve
Integer
8Integer -> Integer -> Sieve
Integer
6)Sieve -> Sieve -> Sieve
(Integer
5Integer -> Integer -> Sieve
Integer
2Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
3Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
4)
      s5 :: Sieve
s5 = Integer
8Integer -> Integer -> Sieve
Integer
1Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
2
      s6 :: Sieve
s6 = Integer
8Integer -> Integer -> Sieve
Integer
6Sieve -> Sieve -> Sieve
Integer
5Integer -> Integer -> Sieve
Integer
1
  in [Sieve
s0, Sieve
s1, Sieve
s2, Sieve
s3, Sieve
s4, Sieve
s5, Sieve
s6]

{- | /Psappha/ (Flint)

> let r = [0,1,3,4,6,8,10,11,12,13,14,16,17,19,20,22,23,25,27,28,29,31,33,35,36,37,38]
> buildn 27 psappha_flint == r
-}
psappha_flint :: Sieve
psappha_flint :: Sieve
psappha_flint = [Sieve] -> Sieve
union [Sieve]
psappha_flint_c

a_r_squibbs_c :: [Sieve]
a_r_squibbs_c :: [Sieve]
a_r_squibbs_c =
  [Integer
8Integer -> Integer -> Sieve
Integer
0Sieve -> Sieve -> Sieve
(Integer
11Integer -> Integer -> Sieve
Integer
0Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
4Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
5Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
6Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
10)
  ,Integer
8Integer -> Integer -> Sieve
Integer
1Sieve -> Sieve -> Sieve
(Integer
11Integer -> Integer -> Sieve
Integer
2Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
3Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
6Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
7Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
9)
  ,Integer
8Integer -> Integer -> Sieve
Integer
2Sieve -> Sieve -> Sieve
(Integer
11Integer -> Integer -> Sieve
Integer
0Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
1Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
2Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
3Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
5Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
10)
  ,Integer
8Integer -> Integer -> Sieve
Integer
3Sieve -> Sieve -> Sieve
(Integer
11Integer -> Integer -> Sieve
Integer
1Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
2Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
3Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
4Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
10)
  ,Integer
8Integer -> Integer -> Sieve
Integer
4Sieve -> Sieve -> Sieve
(Integer
11Integer -> Integer -> Sieve
Integer
0Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
4Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
8)
  ,Integer
8Integer -> Integer -> Sieve
Integer
5Sieve -> Sieve -> Sieve
(Integer
11Integer -> Integer -> Sieve
Integer
0Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
2Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
3Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
7Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
9Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
10)
  ,Integer
8Integer -> Integer -> Sieve
Integer
6Sieve -> Sieve -> Sieve
(Integer
11Integer -> Integer -> Sieve
Integer
1Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
3Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
5Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
7Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
8Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
9)
  ,Integer
8Integer -> Integer -> Sieve
Integer
7Sieve -> Sieve -> Sieve
(Integer
11Integer -> Integer -> Sieve
Integer
1Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
3Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
6Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
7Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
8Sieve -> Sieve -> Sieve
Integer
11Integer -> Integer -> Sieve
Integer
10)]

{- | À R. (Hommage à Maurice Ravel) (Squibbs, 1996)

let r = [0,2,3,4,7,9,10,13,14,16,17,21,23,25,29,30,32,34,35,38,39,43,44,47,48,52,53,57,58,59,62,63,66,67,69,72,73,77,78,82,86,87]
buildn 42 a_r_squibbs == r
-}
a_r_squibbs :: Sieve
a_r_squibbs :: Sieve
a_r_squibbs = [Sieve] -> Sieve
union [Sieve]
a_r_squibbs_c