Permalink
Browse files

Toposort works with a hard-coded example. Obviously this is bogus.

git-svn-id: https://svn.concert.cs.cmu.edu/lollibot/trunk@118 88e30042-7354-0410-bf5e-e4d69759226d
  • Loading branch information...
robsimmons committed Mar 29, 2010
1 parent 3c25ae4 commit 4ff890243ba8f9326f79cc3ba44c51223bb050b1
Showing with 18 additions and 8 deletions.
  1. +2 −3 examples/negation/strata.olf
  2. +2 −0 src/algo/toposort.mlb
  3. +7 −3 src/algo/toposort.sml
  4. +3 −1 src/execute.sml
  5. +1 −1 src/sources.mlb
  6. +3 −0 tools/escape-sml/trans.sml
@@ -1,12 +1,11 @@
-- Stratification case study
---
-
+-- Robert J. Simmons
edge₁ : !edge A B ->> !path A B.
edge₂ : !edge A B • !path B C ->> !path A C.
vert₁ : !edge A B ->> !vert A • !vert B.
-cyc₁ : !vert A • ¬edge A A ->> !nocycle A.
+cyc₁ : !vert A • ¬path A A ->> !nocycle A.
{- Example:
<- c₂ <-
View
@@ -3,8 +3,10 @@ $(SML_LIB)/basis/basis.mlb
local
$(SML_LIB)/smlnj-lib/Util/smlnj-lib.mlb
in
+ signature ORD_KEY
functor RedBlackMapFn
end
toposort-sig.sml
toposort.sml
+
View
@@ -1,7 +1,7 @@
-functor TopoSort (Key : ORD_KEY) :> TOPOSORT where type member = Key.ord_key =
+functor TopoSort (Key : ORD_KEY where type ord_key = string) :> TOPOSORT where type member = Key.ord_key =
struct
- structure Map = SplayMapFn(Key)
+ structure Map = RedBlackMapFn(Key)
type member = Key.ord_key
datatype constraint =
@@ -20,6 +20,10 @@ struct
Map.empty
val get_all = Map.listItemsi
- val get = Map.lookup
+ fun get (_,"edge") = 1
+ | get (_,"path") = 1
+ | get (_,"vert") = 1
+ | get (_,_) = 2
+
end
View
@@ -348,6 +348,8 @@ structure Execute :> EXECUTE = struct
fun saturate1 (rules, S{persistent=U,linear=L,ordered=O}) =
let
+ val _ = print
+ ("Saturation begin with " ^ Int.toString (length rules) ^ " rules\n")
fun loop U =
let
val newfacts = immediate_consequence (U, rules)
@@ -421,7 +423,7 @@ structure Execute :> EXECUTE = struct
multiset_insert (map, getval_neg rule, rule)
in MapI.listItems (foldr add_rule MapI.empty rules) end
in
- fun saturate (rules, ctx) = foldr saturate1 ctx (sortrules rules)
+ fun saturate (rules, ctx) = foldl saturate1 ctx (sortrules rules)
end
(* == PART 5: EXECUTION == *)
View
@@ -11,7 +11,7 @@ in
structure StringUtil
structure Stream
structure StreamUtil
- structure TopoSort
+ functor TopoSort
structure UTF8Util
end
@@ -42,6 +42,7 @@ structure Trans = struct
val dirstream2 = OS.FileSys.openDir "src/parse"
val dirstream3 = OS.FileSys.openDir "src/util"
val dirstream4 = OS.FileSys.openDir "src/server"
+ val dirstream5 = OS.FileSys.openDir "src/algo"
in
OS.FileSys.mkDir "escape-src";
translate_dir ("src","escape-src",dirstream1);
@@ -51,6 +52,8 @@ structure Trans = struct
translate_dir ("src/util","escape-src/util",dirstream3);
OS.FileSys.mkDir "escape-src/server";
translate_dir ("src/server","escape-src/server",dirstream4);
+ OS.FileSys.mkDir "escape-src/algo";
+ translate_dir ("src/algo","escape-src/algo",dirstream5);
()
end

0 comments on commit 4ff8902

Please sign in to comment.