public class Scope extends Object implements Scopable
An immutable mapping from Clafers to their scope. Also contains the scope of integers for solving, like the bit-width in Alloy, but more flexible because the lowest and highest integers can be set independently and does not have to be a power of 2.
 The scope is built through the constructor or ScopeBuilder, whichever
 is mort convenient.
 
Example 1:
Map<AstClafer, Integer> map = new HashMap<AstClafer, Integer>(); map.put(claferA, 3); map.put(claferB, 2); Scope scope = new Scope(map, 3, -16, 16);
Example 2:
Scope scope = Scope.set(claferA, 3).set(claferB).defaultScope(3).intLow(-16).intHigh(16).toScope();
Both examples construct the same scope.
What is scope? Because of the expressiveness of Clafer, reasoning is too difficult in general. The scope is a limitation of the solver so that reasoning feasible.
Example 1:
A : int B : int C : int [A * A * A + B * B * B = C * C * C]
Example 2:
A * B * C * [#A * #A * #A + #B * #B * #B = #C * #C * #C]Both examples are attempting to prove/disprove Fermat's last theorem for k=3, although this easily generalizes for any k. Unfortunately this is too difficult, so the solver only attempts to prove/disprove upto a certain scope. In example 1, a scope of
Scope.intLow(-16).intHigh(16).toScope() would only attempt the proof
 for integers between negative and positive 16. In example 2, a scope of
 Scope.defaultScope(16).toScope() would only attempt the proof for
 integers between 0 and positive 16 (the example uses encodes integers using
 cardinality).ScopeBuilder| Constructor and Description | 
|---|
Scope(Map<AstClafer,Integer> scopes,
          int defaultScope,
          int intLow,
          int intHigh)
Construct a new scope. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
static ScopeBuilder | 
builder()
Construct the scope using the builder pattern. 
 | 
static ScopeBuilder | 
defaultScope(int defaultScope)
Equivalent to  
builder().defaultScope(defaultScope). | 
int | 
getDefaultScope()
The scope for unspecified Clafers. 
 | 
int | 
getIntHigh()
Returns the highest (inclusive) integer used for solving. 
 | 
int | 
getIntLow()
Returns the lowest (inclusive) integer used for solving. 
 | 
int | 
getScope(AstClafer clafer)
Returns the scope of the Clafer. 
 | 
Set<AstClafer> | 
getScoped()
Returns the set of Clafers that have an explicit scope. 
 | 
static ScopeBuilder | 
intHigh(int intHigh)
Equivalent to  
builder().intHigh(intHigh). | 
static ScopeBuilder | 
intLow(int intLow)
Equivalent to  
builder().intLow(intLow). | 
static ScopeBuilder | 
setScope(AstClafer clafer,
                int scope)
Equivalent to  
builder().setScope(clafer, scope). | 
ScopeBuilder | 
toBuilder()  | 
Scope | 
toScope()
Convert to scope. 
 | 
String | 
toString() | 
public Scope(Map<AstClafer,Integer> scopes, int defaultScope, int intLow, int intHigh)
scopes - a map of Clafers to their scopesdefaultScope - the scope for unspecified ClafersintLow - the lowest (inclusive) integer used for solvingintHigh - the highest (inclusive) integer used for solvingpublic Set<AstClafer> getScoped()
public int getScope(AstClafer clafer)
clafer - the Claferpublic int getDefaultScope()
public int getIntLow()
public int getIntHigh()
public static ScopeBuilder builder()
ScopeBuilderpublic static ScopeBuilder setScope(AstClafer clafer, int scope)
builder().setScope(clafer, scope).clafer - the Claferscope - the scope of the claferpublic static ScopeBuilder defaultScope(int defaultScope)
builder().defaultScope(defaultScope).defaultScope - the default scopepublic static ScopeBuilder intLow(int intLow)
builder().intLow(intLow).intLow - the lowest integerpublic static ScopeBuilder intHigh(int intHigh)
builder().intHigh(intHigh).intHigh - the highest integerpublic ScopeBuilder toBuilder()
Copyright © 2013. All Rights Reserved.