Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 4ff890243ba8f9326f79cc3ba44c51223bb050b1 1 parent 3c25ae4
Robert J. Simmons authored March 29, 2010
5  examples/negation/strata.olf
... ...
@@ -1,12 +1,11 @@
1 1
 -- Stratification case study
2  
--- 
3  
-
  2
+-- Robert J. Simmons
4 3
 
5 4
 edge₁ : !edge A B ->> !path A B.
6 5
 edge₂ : !edge A B • !path B C ->> !path A C.
7 6
 vert₁ : !edge A B ->> !vert A • !vert B.
8 7
 
9  
-cyc₁ : !vert A • ¬edge A A ->> !nocycle A.
  8
+cyc₁ : !vert A • ¬path A A ->> !nocycle A.
10 9
 
11 10
 {- Example:
12 11
          <- c₂ <- 
2  src/algo/toposort.mlb
@@ -3,8 +3,10 @@ $(SML_LIB)/basis/basis.mlb
3 3
 local
4 4
   $(SML_LIB)/smlnj-lib/Util/smlnj-lib.mlb
5 5
 in
  6
+  signature ORD_KEY
6 7
   functor RedBlackMapFn
7 8
 end
8 9
 
9 10
 toposort-sig.sml
10 11
 toposort.sml
  12
+
10  src/algo/toposort.sml
... ...
@@ -1,7 +1,7 @@
1  
-functor TopoSort (Key : ORD_KEY) :> TOPOSORT where type member = Key.ord_key =
  1
+functor TopoSort (Key : ORD_KEY where type ord_key = string) :> TOPOSORT where type member = Key.ord_key =
2 2
 struct
3 3
 
4  
-    structure Map = SplayMapFn(Key)
  4
+    structure Map = RedBlackMapFn(Key)
5 5
 
6 6
     type member = Key.ord_key
7 7
     datatype constraint = 
@@ -20,6 +20,10 @@ struct
20 20
               Map.empty
21 21
 
22 22
     val get_all = Map.listItemsi
23  
-    val get = Map.lookup
  23
+    fun get (_,"edge") = 1
  24
+      | get (_,"path") = 1
  25
+      | get (_,"vert") = 1
  26
+      | get (_,_) = 2
  27
+
24 28
 
25 29
 end
4  src/execute.sml
@@ -348,6 +348,8 @@ structure Execute :> EXECUTE = struct
348 348
 
349 349
   fun saturate1 (rules, S{persistent=U,linear=L,ordered=O}) = 
350 350
       let
  351
+        val _ = print 
  352
+         ("Saturation begin with " ^ Int.toString (length rules) ^ " rules\n")
351 353
         fun loop U = 
352 354
             let 
353 355
               val newfacts = immediate_consequence (U, rules)
@@ -421,7 +423,7 @@ structure Execute :> EXECUTE = struct
421 423
               multiset_insert (map, getval_neg rule, rule)
422 424
         in MapI.listItems (foldr add_rule MapI.empty rules) end
423 425
   in
424  
-  fun saturate (rules, ctx) = foldr saturate1 ctx (sortrules rules)
  426
+  fun saturate (rules, ctx) = foldl saturate1 ctx (sortrules rules)
425 427
   end
426 428
 
427 429
   (* == PART 5: EXECUTION == *)
2  src/sources.mlb
@@ -11,7 +11,7 @@ in
11 11
   structure StringUtil
12 12
   structure Stream
13 13
   structure StreamUtil
14  
-  structure TopoSort
  14
+  functor   TopoSort
15 15
   structure UTF8Util
16 16
 end
17 17
 
3  tools/escape-sml/trans.sml
@@ -42,6 +42,7 @@ structure Trans = struct
42 42
         val dirstream2 = OS.FileSys.openDir "src/parse"
43 43
         val dirstream3 = OS.FileSys.openDir "src/util"
44 44
         val dirstream4 = OS.FileSys.openDir "src/server"
  45
+        val dirstream5 = OS.FileSys.openDir "src/algo"
45 46
       in
46 47
         OS.FileSys.mkDir "escape-src";
47 48
         translate_dir ("src","escape-src",dirstream1);
@@ -51,6 +52,8 @@ structure Trans = struct
51 52
         translate_dir ("src/util","escape-src/util",dirstream3);
52 53
         OS.FileSys.mkDir "escape-src/server";
53 54
         translate_dir ("src/server","escape-src/server",dirstream4);
  55
+        OS.FileSys.mkDir "escape-src/algo";
  56
+        translate_dir ("src/algo","escape-src/algo",dirstream5);
54 57
         ()
55 58
       end        
56 59
 

0 notes on commit 4ff8902

Please sign in to comment.
Something went wrong with that request. Please try again.