Changeset 3919
- Timestamp:
- 07/03/09 00:18:48 (5 months ago)
- Location:
- trunk/Library
- Files:
-
- 2 modified
-
Generator22D.fsi (modified) (1 diff)
-
Generator22D.fss (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Library/Generator22D.fsi
r3917 r3919 79 79 rects[\ E, nat b0, nat s0, nat b1, nat s1 \](g : Array2[\E, b0, s0, b1, s1\]) : Rects[\E, b0, s0, b1, s1\] 80 80 81 trait AbideWith[\T\] end 82 83 trait SomeMSS2DTuple[\T\] end 84 85 mssBody[\T\](v:T) : SomeMSS2DTuple[\T\] 86 87 object MSS2DReductionAbove[\T\](op, ot) extends { AssociativeReduction[\SomeMSS2DTuple[\T\]\], AbideWith[\MSS2DReductionBeside[\T\]\] } 88 getter asString(): String 89 simpleJoin(x: SomeMSS2DTuple[\T\], y: SomeMSS2DTuple[\T\]): SomeMSS2DTuple[\T\] 81 90 end 91 92 object MSS2DReductionBeside[\T\](op, ot) extends { AssociativeReduction[\SomeMSS2DTuple[\T\]\], AbideWith[\MSS2DReductionAbove[\T\]\] } 93 getter asString(): String 94 simpleJoin(x: SomeMSS2DTuple[\T\], y: SomeMSS2DTuple[\T\]): SomeMSS2DTuple[\T\] 95 end 96 97 end -
trunk/Library/Generator22D.fss
r3917 r3919 68 68 rowsImpl[\ E \](g).generate[\ R \](r, body) 69 69 end 70 71 theorems[\R, L1, L2\]() = 72 <|[\((ActualReduction[\ R, L1 \], ActualReduction[\ R, L2 \], E -> R)->Boolean, (ActualReduction[\ R, L1 \], ActualReduction[\ R, L2 \], E -> R)->R)\] 73 (fn (r, q, f) => conditionAbiding[\ R, L1, L2 \](r, q, f), fn (r, q, f) => efficientImplAbiding[\ R, L1, L2 \](r, q, f)) 74 |> 75 76 (*--- conditions ---*) 77 conditionAbiding[\ R, L1, L2 \](q : ActualReduction[\ R, L1 \], r : ActualReduction[\ R, L2 \], f : E -> R) : Boolean = abiding(q, r) 78 79 (*--- implementation using the abide-tree reduction *) 80 efficientImplAbiding[\ R, L1, L2 \](q : ActualReduction[\ R, L1 \], r : ActualReduction[\ R, L2 \], f : E -> R) = do 81 82 (* println("Abide!") *) 83 84 (* we assume that two operators have the same lifting, i.e., L1 = L2 *) 85 r.unlift(GeneratorATWrapper(seed()).generateAT[\L1\](q, r, fn a => r.lift(f(a)))) 86 end 87 70 88 end 71 89 … … 93 111 colsImpl[\ E \](g).generate[\ R \](r, body) 94 112 end 113 114 theorems[\R, L1, L2\]() = 115 <|[\((ActualReduction[\ R, L1 \], ActualReduction[\ R, L2 \], E -> R)->Boolean, (ActualReduction[\ R, L1 \], ActualReduction[\ R, L2 \], E -> R)->R)\] 116 (fn (r, q, f) => conditionAbiding[\ R, L1, L2 \](r, q, f), fn (r, q, f) => efficientImplAbiding[\ R, L1, L2 \](r, q, f)) 117 |> 118 119 (*--- conditions ---*) 120 conditionAbiding[\ R, L1, L2 \](q : ActualReduction[\ R, L1 \], r : ActualReduction[\ R, L2 \], f : E -> R) : Boolean = abiding(q, r) 121 122 (*--- implementation using the abide-tree reduction *) 123 efficientImplAbiding[\ R, L1, L2 \](q : ActualReduction[\ R, L1 \], r : ActualReduction[\ R, L2 \], f : E -> R) = do 124 125 (* println("Abide!") *) 126 127 (* we assume that two operators have the same lifting, i.e., L1 = L2 *) 128 r.unlift(GeneratorATWrapper(seed()).generateAT[\L1\](r, q, fn a => r.lift(f(a)))) 129 end 130 95 131 end 96 132 … … 330 366 ) : SomeMSS2DTuple[\T\] = MSS2DTuple[\T, s0, s1\](b, n, s, e, w, ne, nw, se, nw, c, r) 331 367 332 object MSS2DReductionAbove[\T\](op, ot) extends { AssociativeReduction[\SomeMSS2DTuple[\T\]\] } 368 (* annotation for operators with the `abide' property*) 369 trait AbideWith[\T\] end 370 371 abiding[\R, Q\]( r : R, q : Q ) = 372 typecase(r, q) of 373 (R, AbideWith[\R\]) => true 374 else => false 375 end 376 377 object MSS2DReductionAbove[\T\](op, ot) extends { AssociativeReduction[\SomeMSS2DTuple[\T\]\], AbideWith[\MSS2DReductionBeside[\T\]\] } 333 378 getter asString(): String = "MSS2DReductionAbove" 334 379 simpleJoin(x: SomeMSS2DTuple[\T\], y: SomeMSS2DTuple[\T\]): SomeMSS2DTuple[\T\] = … … 357 402 end 358 403 359 object MSS2DReductionBeside[\T\](op, ot) extends { AssociativeReduction[\SomeMSS2DTuple[\T\]\] }404 object MSS2DReductionBeside[\T\](op, ot) extends { AssociativeReduction[\SomeMSS2DTuple[\T\]\], AbideWith[\MSS2DReductionAbove[\T\]\] } 360 405 getter asString(): String = "MSS2DReductionBeside" 361 406 simpleJoin(x: SomeMSS2DTuple[\T\], y: SomeMSS2DTuple[\T\]): SomeMSS2DTuple[\T\] =

