Commit 430f9c2e authored by Philipp Meyer's avatar Philipp Meyer

Rename yes and no states to true and false states

parent 4cdc7a42
population protocol "Broadcast Protocol" { population protocol "Broadcast Protocol" {
states { true false} states { _true _false }
transitions { x_false_true } transitions { x_false_true }
arcs { arcs {
{ false, true } -> x_false_true -> { true, true } { _false, _true } -> x_false_true -> { _true, _true }
} }
initial { true false } initial { _true _false }
yes { true } true { _true }
no { false } false { _false }
} }
...@@ -8,6 +8,6 @@ population protocol "Majority Protocol" { ...@@ -8,6 +8,6 @@ population protocol "Majority Protocol" {
{ neutral, mildlybad } -> x_neutral_mildlybad -> { mildlybad, mildlybad } { neutral, mildlybad } -> x_neutral_mildlybad -> { mildlybad, mildlybad }
} }
initial { good bad } initial { good bad }
yes { good neutral } true { good neutral }
no { bad mildlybad } false { bad mildlybad }
} }
This diff is collapsed.
...@@ -38,8 +38,8 @@ structuralAnalysis pp = do ...@@ -38,8 +38,8 @@ structuralAnalysis pp = do
verbosePut 0 $ "States : " ++ show (length (states pp)) verbosePut 0 $ "States : " ++ show (length (states pp))
verbosePut 0 $ "Transitions : " ++ show (length (transitions pp)) verbosePut 0 $ "Transitions : " ++ show (length (transitions pp))
verbosePut 0 $ "Initial states : " ++ show (length (initialStates pp)) verbosePut 0 $ "Initial states : " ++ show (length (initialStates pp))
verbosePut 0 $ "Yes states : " ++ show (length (yesStates pp)) verbosePut 0 $ "Yes states : " ++ show (length (trueStates pp))
verbosePut 0 $ "No states : " ++ show (length (noStates pp)) verbosePut 0 $ "No states : " ++ show (length (falseStates pp))
checkFile :: String -> OptIO PropResult checkFile :: String -> OptIO PropResult
checkFile file = do checkFile file = do
......
...@@ -77,11 +77,11 @@ transitions = reserved "transitions" *> identList ...@@ -77,11 +77,11 @@ transitions = reserved "transitions" *> identList
initial :: Parser [String] initial :: Parser [String]
initial = reserved "initial" *> identList initial = reserved "initial" *> identList
yesStates :: Parser [String] trueStates :: Parser [String]
yesStates = reserved "yes" *> identList trueStates = reserved "true" *> identList
noStates :: Parser [String] falseStates :: Parser [String]
noStates = reserved "no" *> identList falseStates = reserved "false" *> identList
arc :: Parser [(String,String,Integer)] arc :: Parser [(String,String,Integer)]
arc = do arc = do
...@@ -105,8 +105,8 @@ arcs = do ...@@ -105,8 +105,8 @@ arcs = do
data Statement = States [String] data Statement = States [String]
| Transitions [String] | Transitions [String]
| Initial [String] | Initial [String]
| YesStatement [String] | TrueStatement [String]
| NoStatement [String] | FalseStatement [String]
| Arcs [(String,String,Integer)] | Arcs [(String,String,Integer)]
statement :: Parser Statement statement :: Parser Statement
...@@ -114,8 +114,8 @@ statement = States <$> states <|> ...@@ -114,8 +114,8 @@ statement = States <$> states <|>
Transitions <$> transitions <|> Transitions <$> transitions <|>
Arcs <$> arcs <|> Arcs <$> arcs <|>
Initial <$> initial <|> Initial <$> initial <|>
YesStatement <$> yesStates <|> TrueStatement <$> trueStates <|>
NoStatement <$> noStates FalseStatement <$> falseStates
populationProtocol :: Parser PopulationProtocol populationProtocol :: Parser PopulationProtocol
populationProtocol = do populationProtocol = do
...@@ -123,16 +123,16 @@ populationProtocol = do ...@@ -123,16 +123,16 @@ populationProtocol = do
reserved "protocol" reserved "protocol"
name <- option "" ident name <- option "" ident
statements <- braces (many statement) statements <- braces (many statement)
let (qs,ts,is,ys,ns,as) = foldl splitStatement ([],[],[],[],[],[]) statements let (qs,ts,qinitial,qtrue,qfalse,as) = foldl splitStatement ([],[],[],[],[],[]) statements
return $ makePopulationProtocolFromStrings name qs ts is ys ns as return $ makePopulationProtocolFromStrings name qs ts qinitial qtrue qfalse as
where where
splitStatement (qs,ts,is,ys,ns,as) stmnt = case stmnt of splitStatement (qs,ts,qinitial,qtrue,qfalse,as) stmnt = case stmnt of
States q -> (q ++ qs,ts,is,ys,ns,as) States q -> (q ++ qs,ts,qinitial,qtrue,qfalse,as)
Transitions t -> (qs,t ++ ts,is,ys,ns,as) Transitions t -> (qs,t ++ ts,qinitial,qtrue,qfalse,as)
Initial i -> (qs,ts,i ++ is,ys,ns,as) Initial q -> (qs,ts,q ++ qinitial,qtrue,qfalse,as)
YesStatement y -> (qs,ts,is,y ++ ys,ns,as) TrueStatement q -> (qs,ts,qinitial,q ++ qtrue,qfalse,as)
NoStatement n -> (qs,ts,is,ys,n ++ ns,as) FalseStatement q -> (qs,ts,qinitial,qtrue,q ++ qfalse,as)
Arcs a -> (qs,ts,is,ys,ns,a ++ as) Arcs a -> (qs,ts,qinitial,qtrue,qfalse,a ++ as)
binary :: String -> (a -> a -> a) -> Assoc -> Operator String () Identity a binary :: String -> (a -> a -> a) -> Assoc -> Operator String () Identity a
binary name fun = Infix ( reservedOp name *> return fun ) binary name fun = Infix ( reservedOp name *> return fun )
......
...@@ -5,7 +5,7 @@ module PopulationProtocol ...@@ -5,7 +5,7 @@ module PopulationProtocol
(PopulationProtocol,State(..),Transition(..), (PopulationProtocol,State(..),Transition(..),
Configuration,FlowVector,RConfiguration,RFlowVector, Configuration,FlowVector,RConfiguration,RFlowVector,
renameState,renameTransition,renameStatesAndTransitions, renameState,renameTransition,renameStatesAndTransitions,
name,showNetName,states,transitions,initialStates,yesStates,noStates, name,showNetName,states,transitions,initialStates,trueStates,falseStates,
pre,lpre,post,lpost,mpre,mpost,context, pre,lpre,post,lpost,mpre,mpost,context,
makePopulationProtocol,makePopulationProtocolWithTrans, makePopulationProtocol,makePopulationProtocolWithTrans,
makePopulationProtocolFromStrings,makePopulationProtocolWithTransFromStrings, makePopulationProtocolFromStrings,makePopulationProtocolWithTransFromStrings,
...@@ -72,8 +72,8 @@ data PopulationProtocol = PopulationProtocol { ...@@ -72,8 +72,8 @@ data PopulationProtocol = PopulationProtocol {
states :: [State], states :: [State],
transitions :: [Transition], transitions :: [Transition],
initialStates :: [State], initialStates :: [State],
yesStates :: [State], trueStates :: [State],
noStates :: [State], falseStates :: [State],
adjacencyQ :: M.Map State ([(Transition,Integer)], [(Transition,Integer)]), adjacencyQ :: M.Map State ([(Transition,Integer)], [(Transition,Integer)]),
adjacencyT :: M.Map Transition ([(State,Integer)], [(State,Integer)]) adjacencyT :: M.Map Transition ([(State,Integer)], [(State,Integer)])
} }
...@@ -84,12 +84,12 @@ showNetName pp = "Population protocol" ++ ...@@ -84,12 +84,12 @@ showNetName pp = "Population protocol" ++
instance Show PopulationProtocol where instance Show PopulationProtocol where
show pp = showNetName pp ++ show pp = showNetName pp ++
"\nStates: " ++ show (states pp) ++ "\nStates : " ++ show (states pp) ++
"\nTransitions: " ++ show (transitions pp) ++ "\nTransitions : " ++ show (transitions pp) ++
"\nInitial states: " ++ show (initialStates pp) ++ "\nInitial states : " ++ show (initialStates pp) ++
"\nYes states: " ++ show (yesStates pp) ++ "\nTrue states : " ++ show (trueStates pp) ++
"\nNo states: " ++ show (noStates pp) ++ "\nFalse states : " ++ show (falseStates pp) ++
"\nState arcs:\n" ++ unlines "\nState arcs :\n" ++ unlines
(map showContext (M.toList (adjacencyQ pp))) ++ (map showContext (M.toList (adjacencyQ pp))) ++
"\nTransition arcs:\n" ++ unlines "\nTransition arcs:\n" ++ unlines
(map showContext (M.toList (adjacencyT pp))) (map showContext (M.toList (adjacencyT pp)))
...@@ -112,10 +112,10 @@ renameStatesAndTransitions f pp = ...@@ -112,10 +112,10 @@ renameStatesAndTransitions f pp =
listSet $ map (renameTransition f) $ transitions pp, listSet $ map (renameTransition f) $ transitions pp,
initialStates = initialStates =
listSet $ map (renameState f) $ initialStates pp, listSet $ map (renameState f) $ initialStates pp,
yesStates = trueStates =
listSet $ map (renameState f) $ yesStates pp, listSet $ map (renameState f) $ trueStates pp,
noStates = falseStates =
listSet $ map (renameState f) $ noStates pp, listSet $ map (renameState f) $ falseStates pp,
adjacencyQ = mapAdjacency (renameState f) (renameTransition f) $ adjacencyQ = mapAdjacency (renameState f) (renameTransition f) $
adjacencyQ pp, adjacencyQ pp,
adjacencyT = mapAdjacency (renameTransition f) (renameState f) $ adjacencyT = mapAdjacency (renameTransition f) (renameState f) $
...@@ -129,14 +129,14 @@ makePopulationProtocol :: String -> [State] -> [Transition] -> ...@@ -129,14 +129,14 @@ makePopulationProtocol :: String -> [State] -> [Transition] ->
[State] -> [State] -> [State] -> [State] -> [State] -> [State] ->
[Either (Transition, State, Integer) (State, Transition, Integer)] -> [Either (Transition, State, Integer) (State, Transition, Integer)] ->
PopulationProtocol PopulationProtocol
makePopulationProtocol name states transitions initialStates yesStates noStates arcs = makePopulationProtocol name states transitions initialStates trueStates falseStates arcs =
PopulationProtocol { PopulationProtocol {
name = name, name = name,
states = listSet states, states = listSet states,
transitions = listSet transitions, transitions = listSet transitions,
initialStates = listSet initialStates, initialStates = listSet initialStates,
yesStates = listSet yesStates, trueStates = listSet trueStates,
noStates = listSet noStates, falseStates = listSet falseStates,
adjacencyQ = M.map (listMap *** listMap) adQ, adjacencyQ = M.map (listMap *** listMap) adQ,
adjacencyT = M.map (listMap *** listMap) adT adjacencyT = M.map (listMap *** listMap) adT
} }
...@@ -160,14 +160,14 @@ makePopulationProtocol name states transitions initialStates yesStates noStates ...@@ -160,14 +160,14 @@ makePopulationProtocol name states transitions initialStates yesStates noStates
makePopulationProtocolFromStrings :: String -> [String] -> [String] -> [String] -> [String] -> [String] -> makePopulationProtocolFromStrings :: String -> [String] -> [String] -> [String] -> [String] -> [String] ->
[(String, String, Integer)] -> PopulationProtocol [(String, String, Integer)] -> PopulationProtocol
makePopulationProtocolFromStrings name states transitions initialStates yesStates noStates arcs = makePopulationProtocolFromStrings name states transitions initialStates trueStates falseStates arcs =
makePopulationProtocol makePopulationProtocol
name name
(map State (S.toAscList stateSet)) (map State (S.toAscList stateSet))
(map Transition (S.toAscList transitionSet)) (map Transition (S.toAscList transitionSet))
(map State initialStates) (map State initialStates)
(map State yesStates) (map State trueStates)
(map State noStates) (map State falseStates)
(map toEitherArc arcs) (map toEitherArc arcs)
where where
stateSet = S.fromList states stateSet = S.fromList states
...@@ -194,8 +194,8 @@ makePopulationProtocolFromStrings name states transitions initialStates yesState ...@@ -194,8 +194,8 @@ makePopulationProtocolFromStrings name states transitions initialStates yesState
makePopulationProtocolWithTrans :: String -> [State] -> [State] -> [State] -> [State] -> makePopulationProtocolWithTrans :: String -> [State] -> [State] -> [State] -> [State] ->
[(Transition, ([(State, Integer)], [(State, Integer)]))] -> [(Transition, ([(State, Integer)], [(State, Integer)]))] ->
PopulationProtocol PopulationProtocol
makePopulationProtocolWithTrans name states initialStates yesStates noStates ts = makePopulationProtocolWithTrans name states initialStates trueStates falseStates ts =
makePopulationProtocol name states (map fst ts) initialStates yesStates noStates arcs makePopulationProtocol name states (map fst ts) initialStates trueStates falseStates arcs
where where
arcs = [ Right (q,t,w) | (t,(is,_)) <- ts, (q,w) <- is ] ++ arcs = [ Right (q,t,w) | (t,(is,_)) <- ts, (q,w) <- is ] ++
[ Left (t,q,w) | (t,(_,os)) <- ts, (q,w) <- os ] [ Left (t,q,w) | (t,(_,os)) <- ts, (q,w) <- os ]
...@@ -203,13 +203,13 @@ makePopulationProtocolWithTrans name states initialStates yesStates noStates ts ...@@ -203,13 +203,13 @@ makePopulationProtocolWithTrans name states initialStates yesStates noStates ts
makePopulationProtocolWithTransFromStrings :: String -> [String] -> [String] -> [String] -> [String] -> makePopulationProtocolWithTransFromStrings :: String -> [String] -> [String] -> [String] -> [String] ->
[(String, ([(String, Integer)], [(String, Integer)]))] -> [(String, ([(String, Integer)], [(String, Integer)]))] ->
PopulationProtocol PopulationProtocol
makePopulationProtocolWithTransFromStrings name states initialStates yesStates noStates arcs = makePopulationProtocolWithTransFromStrings name states initialStates trueStates falseStates arcs =
makePopulationProtocolWithTrans makePopulationProtocolWithTrans
name name
(map State states) (map State states)
(map State initialStates) (map State initialStates)
(map State yesStates) (map State trueStates)
(map State noStates) (map State falseStates)
(map toTArc arcs) (map toTArc arcs)
where where
toTArc (t, (iq, oq)) = toTArc (t, (iq, oq)) =
......
...@@ -49,7 +49,7 @@ initialConfiguration pp m0 = ...@@ -49,7 +49,7 @@ initialConfiguration pp m0 =
differentConsensusConstraints :: PopulationProtocol -> SIMap State -> SIMap State -> SBool differentConsensusConstraints :: PopulationProtocol -> SIMap State -> SIMap State -> SBool
differentConsensusConstraints pp m1 m2 = differentConsensusConstraints pp m1 m2 =
(sum (mval m1 (yesStates pp)) .> 0 &&& sum (mval m2 (noStates pp)) .> 0) (sum (mval m1 (trueStates pp)) .> 0 &&& sum (mval m2 (falseStates pp)) .> 0)
unmarkedByConfiguration :: [State] -> SIMap State -> SBool unmarkedByConfiguration :: [State] -> SIMap State -> SBool
unmarkedByConfiguration r m = sum (mval m r) .== 0 unmarkedByConfiguration r m = sum (mval m r) .== 0
......
Markdown is supported
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