(0) Obligation:
JBC Problem based on JBC Program:
Manifest-Version: 1.0
Created-By: 1.6.0_16 (Sun Microsystems Inc.)
Main-Class: List
/**
* A set of functions over objects.
*
* All calls terminate.
*
* Julia + BinTerm prove that all calls terminate
*
* Note that cyclicity is introduced by the statement
* <tt>l2.tail.tail = l2</tt>. However, this is not enough to induce
* non-termination in the program. If you instead uncomment the line
* <tt>l1.tail.tail = l1</tt>, most of the calls cannot be proved to terminate
* anymore.
*
* @author <A HREF="mailto:fausto.spoto@univr.it">Fausto Spoto</A>
*/
public class List {
private Object head;
private List tail;
public static void main(String[] args) {
List l1 = new List(new Object(),new List(new Object(),null));
List l2 = new List(new Object(),new List(new Object(),null));
l1.alternate(l2);
l2.tail.tail = l2;
//l1.tail.tail = l1;
l1.append(l2);
l1.iter();
l1.reverseAcc(null);
l1.reverse();
}
public List(Object head, List tail) {
this.head = head;
this.tail = tail;
}
private void iter() {
if (tail != null) tail.iter();
}
private List append(List other) {
if (tail == null) return new List(head,other);
else return new List(head,tail.append(other));
}
private List reverseAcc(List acc) {
if (tail == null) return new List(head,acc);
else return tail.reverseAcc(new List(head,acc));
}
private List reverse() {
if (tail == null) return this;
else return tail.reverse().append(new List(head,null));
}
private List alternate(List other) {
if (other == null) return this;
else return new List(head,other.alternate(tail));
}
}