Commit 4a2a5c34 authored by AVANZINI Martin's avatar AVANZINI Martin
Browse files

remove some commented code

parent 16a60407
......@@ -136,16 +136,6 @@ instance Substitutable BExp where
| e1 :>=: e2 <- S.toList cs ]
| Conj cs <- conjs b]
-- Constraints
----------------------------------------------------------------------
-- data Constraint = BExp :=>: BLit
-- (.=>) :: BExp -> BLit -> Constraint
-- (.=>) = (:=>:)
-- ite :: BExp -> BExp -> BLit -> BLit -> [Constraint]
-- ite i b t e = (i .&& b) .=> t ++ (i .&& neg b) .=> e
-- pretty
----------------------------------------------------------------------
......@@ -154,12 +144,6 @@ instance (PP.Pretty p, PP.Pretty q) => PP.Pretty (Literal p q) where
pretty (e1 :>=: e2) =
PP.nest 2 (PP.group (PP.pretty e1 PP.<$> PP.nest 2 (PP.group (PP.text "≥" PP.<$> PP.pretty e2))))
-- instance PP.Pretty Constraint where
-- pretty cmd = PP.group (pp cmd) where
-- pp (Top :=>: c) = PP.pretty c
-- pp (cs :=>: c) =
-- PP.nest 2 ( PP.pretty cs PP.<+> PP.text "⇒" PP.<$> PP.pretty c ) where
instance PP.Pretty l => PP.Pretty (DNF l) where
pretty Top = PP.text "⊤"
pretty Bot = PP.text "⊥"
......
......@@ -118,7 +118,7 @@ instance (Num c, Eq c) => CostExpression (NormPolyFrac c) where
normalise (n :% d) =
case P.factoriseMono [n',d'] of
Just (_,[n'',d'']) -> n'' :% d''
Nothing -> n' :% d'
_ -> n' :% d'
where
n' = normalise n
d' = normalise d
......
......@@ -52,12 +52,6 @@ instance Substitutable Exp where
substitute v e = P.substitute s where
s v' | v == v' = e
| otherwise = P.variable v'
-- substitute v s e@(V v') | v == v' = s
-- | otherwise = e
-- substitute _ _ e@Const{} = e
-- substitute v s (Neg e) = negate (substitute v s e)
-- substitute v s (Add e1 e2) = substitute v s e1 + substitute v s e2
-- substitute v s (Mul e1 e2) = substitute v s e1 * substitute v s e2
constant :: Int -> Exp
......@@ -83,20 +77,6 @@ variable = P.variable
variables :: Exp -> [Var]
variables = P.variables
-- variables (V v) = [v]
-- variables Const{} = []
-- variables (Neg e) = variables e
-- variables (Add e1 e2) = variables e1 ++ variables e2
-- variables (Mul e1 e2) = variables e1 ++ variables e2
-- suprema :: [Exp] -> [Exp]
-- suprema [] = []
-- suprema (e:es) = ins e (suprema es) where
-- ins f [] = [f]
-- ins f1 (f2:fs) | f1 `leq` f2 = f2:fs
-- | f2 `leq` f1 = f1:fs
-- | otherwise = f2:ins f1 fs
-- (P.toMonoMap -> m1) `leq` (P.toMonoMap -> m2) = M.isSubmapOfBy (<=) m1 m2
-- distributions
----------------------------------------------------------------------
......@@ -109,21 +89,6 @@ deriving instance Data Exp
newtype Lam = Lam Exp deriving (Data, Eq, Ord, Read, Show)
-- data Frac a = a :% a deriving (Data, Eq, Ord, Read, Show, Functor, Foldable, Traversable)
-- instance (Num a) => Num (Frac a) where
-- fromInteger a = fromInteger a :% 1
-- (a1 :% b1) + (a2 :% b2) = (a1 * b2 + a2 * b1) :% (b1 * b2)
-- (a1 :% b1) * (a2 :% b2) = (a1 * a2) :% (b1 * b2)
-- signum _ = error "Frac.signum: not defined"
-- negate (a :% b) = negate a :% b
-- abs (a :% b) = abs a :% abs b
-- instance (Num a) => Fractional (Frac a) where
-- (x:%y) / (x':%y') = (x*y') :% (y*x')
-- recip (x:%y) = y :% x
-- fromRational r = fromInteger (numerator r) :% fromInteger (denominator r)
data Dist e
= Discrete [(Exp,e)]
| Rand e
......
......@@ -4,7 +4,6 @@ module PWhile.Testbed.Examples where
import Prelude
import Data.String
import qualified Text.PrettyPrint.ANSI.Leijen as PP
import PWhile.Testbed.DSL
......@@ -1231,6 +1230,20 @@ tarjan = do
ifp p c1 c2 = choice [(p, c1), (100 - p, c2)]
qb' :: Program
qb' = do
l1 <- var "l1"; l2 <- var "l2"; n <- var "n"
if l1 .>= 1 then l1 .= l1 - 1 else skip
-- ifp 98 skip $
-- ifp 20 (l1 .= l1 + 3)
-- (ifp 50 (l2 .= l2 + 2)
-- (do
-- l1 .= l1 + 2
-- l2 .= l2 + 1))
nondet [consume l1, consume l2]
-- if l1 .>= l2 then consume l1 else consume l2
-- Wang et al. 2019, Cost Analysis of Nondeterministic Probabilistic Programs
qb :: Program
qb = do
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment