Copyright | (c) Jesper Kuiper 2021 Leander van Boven 2021 Ramon Meffert 2021 |
---|---|
License | BSD3 |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data Bdd
- bdd :: Bdd -> Bdd
- str :: Bdd -> String
- tex :: Bdd -> String
- type Assignment = [(Int, Bool)]
- type VarLabeller = Int -> String
- varl :: VarLabeller -> VarLabeller -> Int -> Bdd
- var :: Int -> Bdd
- top :: Bdd
- bot :: Bdd
- neg :: Bdd -> Bdd
- con :: Bdd -> Bdd -> Bdd
- dis :: Bdd -> Bdd -> Bdd
- imp :: Bdd -> Bdd -> Bdd
- equ :: Bdd -> Bdd -> Bdd
- xor :: Bdd -> Bdd -> Bdd
- conSet :: [Bdd] -> Bdd
- disSet :: [Bdd] -> Bdd
- xorSet :: [Bdd] -> Bdd
- foralll :: VarLabeller -> VarLabeller -> Int -> Bdd -> Bdd
- forall :: Int -> Bdd -> Bdd
- existsl :: VarLabeller -> VarLabeller -> Int -> Bdd -> Bdd
- exists :: Int -> Bdd -> Bdd
- forallSetl :: VarLabeller -> VarLabeller -> [Int] -> Bdd -> Bdd
- forallSet :: [Int] -> Bdd -> Bdd
- existsSetl :: VarLabeller -> VarLabeller -> [Int] -> Bdd -> Bdd
- existsSet :: [Int] -> Bdd -> Bdd
- substitl :: VarLabeller -> Int -> Bdd -> Bdd -> Bdd
- substit :: Int -> Bdd -> Bdd -> Bdd
- allVarsOf :: Bdd -> [Int]
- evaluate :: Bdd -> Assignment -> Maybe Bool
- evaluateFun :: Bdd -> (Int -> Bool) -> Bool
BDD type
Printable data wrapper for the Bdd
record.
BDD fields
Other types
type Assignment = [(Int, Bool)] Source #
An assignment is a valuation for a set of variables, i.e. a valuation as to whether a variable is true or false.
type VarLabeller = Int -> String Source #
The printable BDD can label their variables, instead of using integers. A VarLabeller type is a function that encodes a variable integer to its corresponding name.
Creating new BDDs
varl :: VarLabeller -> VarLabeller -> Int -> Bdd Source #
Encode a labelled integer as a BDD variable. Note that the first labeller is for text, the second for LaTeX. The variable is indexed by any integer from 0 to 1.000.000.
>>>
slabel n = "var" ++ (show n)
>>>
tlabel n = "p_" ++ (show n)
>>>
foo = varl slabel tlabel 0
>>>
foo
var0>>>
tex foo
p_0
Encode an unlabelled integer as a BDD variable. The variable is indexed by any integer from 0 to 1.000.000.
BDD Operators
Unary operator
Binary operators
equ :: Bdd -> Bdd -> Bdd Source #
Logical bi-implication or equivalence.
>>>
foo `equ` bar
(foo ⟷ bar)
N-ary operators
conSet :: [Bdd] -> Bdd Source #
Big (setwise) conjunction.
>>>
conSet [foo, bar, baz]
(foo ∧ bar ∧ baz)
disSet :: [Bdd] -> Bdd Source #
Big (setwise) disjunction.
>>>
disSet [foo, bar, baz]
(foo ∨ bar ∨ baz)
xorSet :: [Bdd] -> Bdd Source #
Big (setwise) exclusive disjunction.
>>>
xorSet [foo, bar, baz]
(foo ⊻ bar ⊻ baz)
Quantification
foralll :: VarLabeller -> VarLabeller -> Int -> Bdd -> Bdd Source #
Labelled binary universal quantification. Note that the first VarLabeller works for direct printing and the VarLabeller is for latex.
>>>
slabel n = "var" ++ (show n)
>>>
tlabel n = "p_" ++ (show n)
>>>
foo = foralll slabel tlabel 0 $ varl slabel tlabel 0 `imp` varl slabel tlabel 1
>>>
foo
∀var0(var0 ⟶ var1)>>>
tex foo
\\forall p_0 (p_0 \\rightarrow p_1)
forall :: Int -> Bdd -> Bdd Source #
Unlabelled binary universal quantification.
>>>
forall 0 foo
∀0(foo)
existsl :: VarLabeller -> VarLabeller -> Int -> Bdd -> Bdd Source #
Labelled binary existential quantification.
>>>
slabel n = "var" ++ (show n)
>>>
tlabel n = "p_" ++ (show n)
>>>
foo = existsl slabel tlabel 0 $ (varl slabel tlabel 0) `imp` (varl slabel tlabel 1)
>>>
foo
∃var0(var0 ⟶ var1)>>>
tex foo
\\exists (p_0 \\rightarrow p_1)
exists :: Int -> Bdd -> Bdd Source #
Unlabelled binary existential quantification
>>>
exists 0 foo
∃0(foo)
N-ary quantification
forallSetl :: VarLabeller -> VarLabeller -> [Int] -> Bdd -> Bdd Source #
Labelled big binary universal quanficition.
>>>
slabel n = "var" ++ (show n)
>>>
tlabel n = "p_" ++ (show n)
>>>
foo = forallSetl slabel tlabel [0, 1] $ (varl slabel tlabel 0) `imp` (varl slabel tlabel 1)
>>>
foo
∀{var0, var1}(var0 ⟶ var1)>>>
tex foo
\\forall \\left{ p_0, p_1 \\right} (p_0 \\rightarrow p_1)
forallSet :: [Int] -> Bdd -> Bdd Source #
Unlabelled big binary universal quantification.
>>>
forallSet [0,1,2] foo
∀{0,1,2}(foo)
existsSetl :: VarLabeller -> VarLabeller -> [Int] -> Bdd -> Bdd Source #
Labelled big binary existential quantification.
>>>
slabel n = "var" ++ (show n)
>>>
tlabel n = "p_" ++ (show n)
>>>
foo = existsSetl slabel tlabel [0, 1] $ (varl slabel tlabel 0) `imp` (varl slabel tlabel 1)
>>>
foo
∃{var0, var1}(var0 ⟶ var1)>>>
tex foo
\\exists \\left{ p_0, p_1 \\right} (p_0 \\rightarrow p_1)
existsSet :: [Int] -> Bdd -> Bdd Source #
Unlabelled big binary existential quantification.
>>>
existsSet [0,1,2] foo
∃{0,1,2}(foo)
Substitution
substitl :: VarLabeller -> Int -> Bdd -> Bdd -> Bdd Source #
Labelled substitution.
>>>
label n = "var" ++ n
>>>
subsitl label 0 top foo
[var0\⊤](foo)
Variable inspection
allVarsOf :: Bdd -> [Int] Source #
Returns all variables (without labels) that occur within the given BDD.
>>>
allVarsOf (var 0 `imp` (var 1 `dis` var 2))
[0,1,2]