Nat subject = (Nat) atermSubject; if(subject.isPlus()) { Nat arg1 = subject.getArg1(); Nat arg2 = subject.getArg2(); if(arg2.isZero()) { return arg1; } else if(arg2.isSuc()) { Nat y = arg2.getPred(); return factory.makeNat_Suc(factory.makeNat_Plus(arg1,y)); } } else if(subject.isFib()) { Nat t = subject.getArg1(); if(t.isZero()) { return factory.makeNat_Suc(t); } else if (t.isSuc() && t.getPred().isZero()) { return t.getPred(); } else { Nat pred1 = t.getPred(); Nat pred2 = pred1.getPred(); return factory.makeNat_Plus( factory.makeNat_Fib(pred2), factory.makeNat_Fib(pred1)); } } return null; }
Nat subject = (Nat) atermSubject; if (subject.isPlus()) { Nat arg1 = subject.getArg1(); Nat arg2 = subject.getArg2(); if (arg2.isZero()) { return arg1; } else if (arg2.isSuc()) { Nat y = arg2.getPred(); return getPeanoFactory().makeNat_Suc(getPeanoFactory().makeNat_Plus(arg1, y)); } } else if (subject.isFib()) { Nat t = subject.getArg1(); if (t.isZero()) { return getPeanoFactory().makeNat_Suc(t); } else if (t.isSuc() && t.getPred().isZero()) { return t.getPred(); } else { Nat pred1 = t.getPred(); Nat pred2 = pred1.getPred(); return getPeanoFactory().makeNat_Plus( getPeanoFactory().makeNat_Fib(pred2), getPeanoFactory().makeNat_Fib(pred1)); } } return null; }
        public ATerm apply(ATerm atermSubject) {          Nat subject = (Nat) atermSubject;          if(subject.isPlus()) {            Nat arg1 = subject.getArg1();            Nat arg2 = subject.getArg2();            if(arg2.isZero()) {              return arg1;            } else if(arg2.isSuc()) {              Nat y = arg2.getPred();              return factory.makeNat_Suc(factory.makeNat_Plus(arg1,y));            }          } else if(subject.isFib()) {            Nat t = subject.getArg1();            if(t.isZero()) {              return factory.makeNat_Suc(t);            } else if (t.isSuc() && t.getPred().isZero()) {              return t.getPred();            } else {              Nat pred1 = t.getPred();              Nat pred2 = pred1.getPred();              return factory.makeNat_Plus(                factory.makeNat_Fib(pred2),                factory.makeNat_Fib(pred1));            }          }          return null;        }