| 1 | (* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh |
| 2 | * Jagannathan, and Stephen Weeks. |
| 3 | * |
| 4 | * MLton is released under a BSD-style license. |
| 5 | * See the file MLton-LICENSE for details. |
| 6 | *) |
| 7 | |
| 8 | signature ALPHA_BETA_STRUCTS = |
| 9 | sig |
| 10 | structure Value: |
| 11 | sig |
| 12 | include ORDER |
| 13 | |
| 14 | val largest: t |
| 15 | val smallest: t |
| 16 | val move: t -> t |
| 17 | val unmove: t -> t |
| 18 | end |
| 19 | |
| 20 | structure State: |
| 21 | sig |
| 22 | type t |
| 23 | |
| 24 | val succ: t -> t list |
| 25 | datatype value = |
| 26 | Leaf of Value.t |
| 27 | | NonLeaf of {lower: Value.t, upper: Value.t} |
| 28 | val evaluate: t -> value |
| 29 | val layout: t -> Layout.t |
| 30 | end |
| 31 | |
| 32 | structure Cache: |
| 33 | sig |
| 34 | type 'a t |
| 35 | |
| 36 | val peek: 'a t * State.t -> {value: 'a option, |
| 37 | update: 'a -> unit} |
| 38 | end |
| 39 | end |
| 40 | |
| 41 | signature ALPHA_BETA = |
| 42 | sig |
| 43 | include ALPHA_BETA_STRUCTS |
| 44 | |
| 45 | (* return v s.t. a <= v <= b |
| 46 | * andalso |v - v'| is minimal, where v' is maximum value. |
| 47 | *) |
| 48 | val alphaBeta: State.t * Value.t * Value.t -> Value.t |
| 49 | |
| 50 | structure Interval: |
| 51 | sig |
| 52 | type t |
| 53 | |
| 54 | val make: {lower: Value.t, upper: Value.t} -> t |
| 55 | val all: t |
| 56 | val point: Value.t -> t |
| 57 | val isPoint: t -> bool |
| 58 | val lower: t -> Value.t |
| 59 | val upper: t -> Value.t |
| 60 | val layout: t -> Layout.t |
| 61 | end |
| 62 | |
| 63 | (* Return closest value in interval to maximum value. *) |
| 64 | (* May modify the cache. *) |
| 65 | val alphaBetaCache: State.t * Interval.t * Interval.t Cache.t -> Value.t |
| 66 | end |