src/HOL/NanoJava/Example.thy
changeset 32960 69916a850301
parent 21020 9af9ceb16d58
child 35102 cc7a0b9f938c
equal deleted inserted replaced
32959:23a8c5ac35f8 32960:69916a850301
     1 (*  Title:      HOL/NanoJava/Example.thy
     1 (*  Title:      HOL/NanoJava/Example.thy
     2     ID:         $Id$
       
     3     Author:     David von Oheimb
     2     Author:     David von Oheimb
     4     Copyright   2001 Technische Universitaet Muenchen
     3     Copyright   2001 Technische Universitaet Muenchen
     5 *)
     4 *)
     6 
     5 
     7 header "Example"
     6 header "Example"
    28   Nat add(Nat n)
    27   Nat add(Nat n)
    29     { if (this.pred != null) return this.pred.add(n.suc()); else return n; }
    28     { if (this.pred != null) return this.pred.add(n.suc()); else return n; }
    30 
    29 
    31   public static void main(String[] args) // test x+1=1+x
    30   public static void main(String[] args) // test x+1=1+x
    32     {
    31     {
    33 	Nat one = new Nat().suc();
    32         Nat one = new Nat().suc();
    34 	Nat x   = new Nat().suc().suc().suc().suc();
    33         Nat x   = new Nat().suc().suc().suc().suc();
    35 	Nat ok = x.suc().eq(x.add(one));
    34         Nat ok = x.suc().eq(x.add(one));
    36         System.out.println(ok != null);
    35         System.out.println(ok != null);
    37     }
    36     }
    38 }
    37 }
    39 \end{verbatim}
    38 \end{verbatim}
    40 
    39