# Declarations

decl_type: formula
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 55 2 65 88
body:
    HHGGLEM: LEMMA FORALL (k:nat):
      (k<=n-m AND i<=n-m) IMPLIES
      (GG(k,n,0,i,R,T)=1 AND
      (n-m>=0 IMPLIES GG(k,n,m,n-m,R,T)=1) AND
      (k<=n-m AND k>i IMPLIES GG(k,n,m,1+i,R,T)=GG(k,n,m,i,R,T)) AND
      HH(k,n,0,i,R,T)=1 AND
      (n-m>=0 IMPLIES HH(k,n,m,n-m,R,T)=1) AND
      (m/=0 IMPLIES HH(i+m,n,m,1+i,R,T)+1=GG(i,n,m,i,R,T)) AND
      (m/=0 AND k<i IMPLIES HH(k,n,m,i,R,T) = HH(k,n,m,1+i,R,T)+1) AND
      (m/=0 AND k>=i AND k<i+m IMPLIES (HH(k,n,m,i,R,T)=HH(k,n,m,1+i,R,T)+1 AND 
        HH(i+m,n,m,1+i,R,T)+1=HH(k,n,m,i,R,T) AND HH(i+m,n,m,1+i,R,T)=HH(k,n,m,1+i,R,T))))


decl_type: formula
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 67 2 80 138
body:
    pseudo_div_def: LEMMA
      h(m)/=0 AND
      (FORALL (ii:nat): ii>n IMPLIES g(ii)=0) AND
      (FORALL (ii:nat): ii>m IMPLIES h(ii)=0) IMPLIES
      LET psd = pseudo_div(g,n)(h,m)(i),
          pd  = poly_divide(g,n)(h,m)(i),
          qlength = length(psd`quotl),
          rlength = length(psd`reml)
      IN  pd`quot = (LAMBDA (k:nat): (1/h(m))^GG(k,n,m,i,R,T))
                      *(LAMBDA (k:nat): IF k<=pd`qdeg AND 
                                     k>=pd`qdeg-qlength+1 
                                     THEN nth(psd`quotl,k-(pd`qdeg-qlength+1))      %n-m-pd`qdeg+j)
                                     ELSE 0 ENDIF) AND
          pd`rem  = (LAMBDA (k:nat): (1/h(m))^HH(k,n,m,i,R,T))*(LAMBDA (k:nat): IF k<=pd`rdeg AND (i>n-m OR m>0) THEN nth(psd`reml,k) ELSE 0 ENDIF)


decl_type: formula
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 82 2 90 110
body:
    poly_pseudo_remainder_def: LEMMA
      h(m)/=0 AND n>=m AND
      (FORALL (ii:nat): ii>n IMPLIES g(ii)=0) AND
      (FORALL (ii:nat): ii>m IMPLIES h(ii)=0) IMPLIES
      LET psd = pseudo_div(g,n)(h,m)(0),
          pd  = poly_divide(g,n)(h,m)(0),
          qlength = length(psd`quotl),
          rlength = length(psd`reml)
      IN pd`rem = (1/h(m))^(n-m+1) * (LAMBDA (k:nat): IF k<=psd`rdegl AND m>0 THEN nth(psd`reml,k) ELSE 0 ENDIF)


decl_type: formula
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 98 2 109 24
body:
    adjusted_remainder_def: LEMMA
        h(m)/=0 AND
        (FORALL (ii:nat): ii>n IMPLIES g(ii)=0) AND
        (FORALL (ii:nat): ii>m IMPLIES h(ii)=0)
      IMPLIES
        LET thisrem  = adjusted_remainder(g,n)(h,m),
            pd       = poly_divide(g,n)(h,m)(0),
            thisdeg  = length[int](thisrem)-1,
            thispoly = (LAMBDA (i:nat): IF i<=thisdeg THEN nth(thisrem,i) ELSE 0 ENDIF)
        IN thisdeg>=0 IMPLIES ((EXISTS (cp:posreal):
          polynomial(thispoly,thisdeg) = polynomial(-cp*pd`rem,pd`rdeg)) AND
          thispoly(thisdeg) /= 0)


decl_type: formula
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 111 2 114 19
body:
    adjusted_remainder_length: LEMMA
      h(m)/=0 IMPLIES
      LET pr = adjusted_remainder(g,n)(h,m) IN
        length(pr)<=m


decl_type: formula
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 116 2 119 21
body:
    adjusted_remainder_length2: LEMMA
      h(m)/=0 IMPLIES
      LET pr = adjusted_remainder(g,n)(h,m) IN
        length(pr)<=n+1


decl_type: formula
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 121 2 128 44
body:
    adjusted_remainder_empty: LEMMA
      (FORALL (i:nat): i>n IMPLIES g(i)=0) AND
      (FORALL (i:nat): i>m IMPLIES h(i)=0) AND
      h(m)/=0 AND
      length(adjusted_remainder(g,n)(h,m))=0
      IMPLIES
      FORALL (j:nat): j<=poly_divide(g,n)(h,m)(0)`rdeg IMPLIES
             poly_divide(g,n)(h,m)(0)`rem(j)=0


decl_type: formula
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 130 2 137 64
body:
    adjusted_remainder_test: LEMMA
      LET g = (LAMBDA (i:nat): IF i=0 THEN 1 ELSIF i=1 THEN 2
                               ELSIF i=2 THEN 2 ELSIF i=3 THEN 5
                               ELSIF i=5 THEN 2 ELSIF i=6 THEN -7 ELSE 0 ENDIF),
          h = (LAMBDA (i:nat): IF i=0 THEN -4 ELSIF i=1 THEN -4
                               ELSIF i=2 THEN 2 ELSIF i=3 THEN 5
                               ELSIF i=4 THEN -2 ELSE 0 ENDIF)
      IN adjusted_remainder(g,6)(h,4) = (: -740, -996, -10, 887 :)


decl_type: type
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 12 2 13 40
body:
    DivListType : TYPE = [# quotl: list[int],qdegl:nat,
                        reml : list[int],rdegl :nat #]


decl_type: function
theory: polynomial_pseudo_divide
library: Sturm
location: 19 2 35 25
signature:
  [d1: [[nat -> int], nat] ->
          [d: [h: [nat -> int], {m | h(m) /= 0}] ->
             [i: nat ->
                {DT: DivListType |
                         (d`2 > d1`2 OR
                           i > d1`2 - d`2 AND
                            length(DT`reml) = 1 + d1`2 AND
                             DT`rdegl = d1`2)
                          OR
                          (d`2 = 0 AND
                            length(DT`reml) = 0 AND DT`rdegl = 0)
                           OR
                           (d`2 > 0 AND
                             length(DT`reml) = i + d`2 AND
                              length(DT`reml) = 1 + DT`rdegl)}]]]

body:
    pseudo_div(g,n)(h,(m|h(m)/=0))(i): RECURSIVE {DT: DivListType |
                                                      (m>n OR i>n-m AND length(DT`reml)=n+1 AND DT`rdegl = n) OR
                                                      (m=0 AND length(DT`reml)=0 AND DT`rdegl=0) OR 
                                                      (m>0 AND length(DT`reml)=m+i AND length(DT`reml)=DT`rdegl+1)}=
      IF m>n OR i>n-m THEN make_divlisttype((::),0,array2list(n+1)(g),n)
      ELSIF m = 0 THEN make_divlisttype(array2list(n+1)(g),n,(::),0)
      ELSE
        LET ldt = IF i=n-m THEN make_divlisttype((::),n-m,array2list(n+1)(g),n)
                    ELSE pseudo_div(g,n)(h,m)(i+1) ENDIF,
            thisterm = nth(ldt`reml,ldt`rdegl)
        IN  make_divlisttype(cons(thisterm,ldt`quotl),
                         n-m,array2list(m+i)(LAMBDA (j:nat):
                               IF j>m+i THEN 0
                               ELSIF j<i THEN h(m)*nth(ldt`reml,j)
                               ELSE h(m)*nth(ldt`reml,j)-thisterm*h(j-i) ENDIF),m+i-1)
      ENDIF
     MEASURE max(n-m-i+1,0)


decl_type: function
theory: polynomial_pseudo_divide
library: Sturm
signature: [[nat, nat, nat, nat, nat, nat] -> int]
location: 51 2 51 102
body:
    GG(k:nat,n,m,i,R,T): int = IF i>n-m THEN 0 ELSIF m=0 OR i = n-m OR k<i THEN 1 ELSE (1+(n-m-k)) ENDIF


decl_type: function
theory: polynomial_pseudo_divide
library: Sturm
signature: [[nat, nat, nat, nat, nat, nat] -> int]
location: 53 2 53 102
body:
    HH(k:nat,n,m,i,R,T): int =  IF i>n-m THEN 0 ELSIF m=0 OR i=n-m OR k>=i+m THEN 1 ELSE 1+(n-m-i) ENDIF


decl_type: function
theory: polynomial_pseudo_divide
library: Sturm
signature:
  [[[nat -> int], nat] ->
  [[h: [nat -> int], {m | h(m) /= 0}] -> list[int]]]

location: 92 2 96 77
body:
    adjusted_remainder(g,n)(h,(m|h(m)/=0)): list[int] =
      LET ppd = pseudo_div(g,n)(h,m)(0),
          thisrem = ppd`reml,
          pseudosign:nzint = IF h(m)>0 OR mod(n-m+1,2)=0 OR m>n THEN 1 ELSE -1 ENDIF
      IN descalarize_list(nonzero_version(primitize_list(thisrem)),-pseudosign)


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 144 0 148 999
body:
  % Subtype TCC generated (at line 35, column 11) for  max(n - m - i + 1, 0)
      % expected type  naturalnumber
  pseudo_div_TCC1: OBLIGATION
    FORALL (n: nat, h: [nat -> int], (m: nat | h(m) /= 0), i: nat):
      max(n - m - i + 1, 0) >= 0;


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 150 0 195 999
body:
  % Subtype TCC generated (at line 23, column 25) for
      % make_divlisttype((: :), 0, array2list(n + 1)(g), n)
      % expected type  {DT: DivListType |
                     %          (m > n OR
                     %            i > n - m AND
                     %             length(DT`reml) = 1 + n AND DT`rdegl = n)
                     %           OR
                     %           (m = 0 AND
                     %             length(DT`reml) = 0 AND DT`rdegl = 0)
                     %            OR
                     %            (m > 0 AND
                     %              length(DT`reml) = i + m AND
                     %               length(DT`reml) = 1 + DT`rdegl)}
  pseudo_div_TCC2: OBLIGATION
    FORALL (g: [nat -> int], n: nat, h: [nat -> int], (m: nat | h(m) /= 0),
            i: nat):
      m > n OR i > n - m IMPLIES
       (m > n OR
         i > n - m AND
          length[int]
              (make_divlisttype((: :), 0, array2list[int](n + 1)(g), n)`reml)
           = 1 + n
           AND
           make_divlisttype((: :), 0, array2list[int](n + 1)(g), n)`rdegl =
            n)
        OR
        (m = 0 AND
          length[int]
              (make_divlisttype((: :), 0, array2list[int](n + 1)(g), n)`reml)
           = 0
           AND
           make_divlisttype((: :), 0, array2list[int](n + 1)(g), n)`rdegl =
            0)
         OR
         (m > 0 AND
           length[int]
               (make_divlisttype((: :), 0, array2list[int](n + 1)(g),
                                 n)`reml)
            = i + m
            AND
            length[int]
                (make_divlisttype((: :), 0, array2list[int](n + 1)(g),
                                  n)`reml)
             =
             1 +
              make_divlisttype((: :), 0, array2list[int](n + 1)(g), n)`rdegl);


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 197 0 242 999
body:
  % Subtype TCC generated (at line 24, column 21) for
      % make_divlisttype(array2list(n + 1)(g), n, (: :), 0)
      % expected type  {DT: DivListType |
                     %          (m > n OR
                     %            i > n - m AND
                     %             length(DT`reml) = 1 + n AND DT`rdegl = n)
                     %           OR
                     %           (m = 0 AND
                     %             length(DT`reml) = 0 AND DT`rdegl = 0)
                     %            OR
                     %            (m > 0 AND
                     %              length(DT`reml) = i + m AND
                     %               length(DT`reml) = 1 + DT`rdegl)}
  pseudo_div_TCC3: OBLIGATION
    FORALL (g: [nat -> int], n: nat, h: [nat -> int], (m: nat | h(m) /= 0),
            i: nat):
      m = 0 AND NOT m > n AND NOT i > n - m IMPLIES
       (m > n OR
         i > n - m AND
          length[int]
              (make_divlisttype(array2list[int](n + 1)(g), n, (: :), 0)`reml)
           = 1 + n
           AND
           make_divlisttype(array2list[int](n + 1)(g), n, (: :), 0)`rdegl =
            n)
        OR
        (m = 0 AND
          length[int]
              (make_divlisttype(array2list[int](n + 1)(g), n, (: :), 0)`reml)
           = 0
           AND
           make_divlisttype(array2list[int](n + 1)(g), n, (: :), 0)`rdegl =
            0)
         OR
         (m > 0 AND
           length[int]
               (make_divlisttype(array2list[int](n + 1)(g), n, (: :),
                                 0)`reml)
            = i + m
            AND
            length[int]
                (make_divlisttype(array2list[int](n + 1)(g), n, (: :),
                                  0)`reml)
             =
             1 +
              make_divlisttype(array2list[int](n + 1)(g), n, (: :), 0)`rdegl);


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 244 0 275 999
body:
  % Subtype TCC generated (at line 28, column 31) for  ldt`rdegl
      % expected type  below[length(ldt`reml)]
  pseudo_div_TCC4: OBLIGATION
    FORALL (g: [nat -> int], n: nat, h: [nat -> int], (m: nat | h(m) /= 0),
            i: nat,
            v:
              [d11: [[nat -> int], nat] ->
                 [d1: [h: [nat -> int], {m | h(m) /= 0}] ->
                    [i1:
                       {z: nat |
                                max(1 - z - d1`2 + d11`2, 0) <
                                 max(1 + n - i - m, 0)} ->
                       {DT: DivListType |
                                (d1`2 > d11`2 OR
                                  i1 > d11`2 - d1`2 AND
                                   length(DT`reml) = 1 + d11`2 AND
                                    DT`rdegl = d11`2)
                                 OR
                                 (d1`2 = 0 AND
                                   length(DT`reml) = 0 AND DT`rdegl = 0)
                                  OR
                                  (d1`2 > 0 AND
                                    length(DT`reml) = i1 + d1`2 AND
                                     length(DT`reml) = 1 + DT`rdegl)}]]]):
      NOT m = 0 AND NOT m > n AND NOT i > n - m IMPLIES
       (FORALL (ldt: DivListType):
          ldt =
           IF i = n - m
             THEN make_divlisttype((: :), n - m, array2list(n + 1)(g), n)
           ELSE v(g, n)(h, m)(i + 1)
           ENDIF
           IMPLIES ldt`rdegl < length[int](ldt`reml));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 277 0 310 999
body:
  % Subtype TCC generated (at line 30, column 18) for  n - m
      % expected type  nat
  pseudo_div_TCC5: OBLIGATION
    FORALL (g: [nat -> int], n: nat, h: [nat -> int], (m: nat | h(m) /= 0),
            i: nat,
            v:
              [d11: [[nat -> int], nat] ->
                 [d1: [h: [nat -> int], {m | h(m) /= 0}] ->
                    [i1:
                       {z: nat |
                                max(1 - z - d1`2 + d11`2, 0) <
                                 max(1 + n - i - m, 0)} ->
                       {DT: DivListType |
                                (d1`2 > d11`2 OR
                                  i1 > d11`2 - d1`2 AND
                                   length(DT`reml) = 1 + d11`2 AND
                                    DT`rdegl = d11`2)
                                 OR
                                 (d1`2 = 0 AND
                                   length(DT`reml) = 0 AND DT`rdegl = 0)
                                  OR
                                  (d1`2 > 0 AND
                                    length(DT`reml) = i1 + d1`2 AND
                                     length(DT`reml) = 1 + DT`rdegl)}]]]):
      NOT m = 0 AND NOT m > n AND NOT i > n - m IMPLIES
       (FORALL (ldt: DivListType):
          ldt =
           IF i = n - m
             THEN make_divlisttype((: :), n - m, array2list(n + 1)(g), n)
           ELSE v(g, n)(h, m)(i + 1)
           ENDIF
           IMPLIES
           (FORALL (thisterm: int):
              thisterm = nth(ldt`reml, ldt`rdegl) IMPLIES n - m >= 0));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 312 0 348 999
body:
  % Subtype TCC generated (at line 32, column 43) for  j
      % expected type  below[length(ldt`reml)]
  pseudo_div_TCC6: OBLIGATION
    FORALL (g: [nat -> int], n: nat, h: [nat -> int], (m: nat | h(m) /= 0),
            i: nat,
            v:
              [d11: [[nat -> int], nat] ->
                 [d1: [h: [nat -> int], {m | h(m) /= 0}] ->
                    [i1:
                       {z: nat |
                                max(1 - z - d1`2 + d11`2, 0) <
                                 max(1 + n - i - m, 0)} ->
                       {DT: DivListType |
                                (d1`2 > d11`2 OR
                                  i1 > d11`2 - d1`2 AND
                                   length(DT`reml) = 1 + d11`2 AND
                                    DT`rdegl = d11`2)
                                 OR
                                 (d1`2 = 0 AND
                                   length(DT`reml) = 0 AND DT`rdegl = 0)
                                  OR
                                  (d1`2 > 0 AND
                                    length(DT`reml) = i1 + d1`2 AND
                                     length(DT`reml) = 1 + DT`rdegl)}]]]):
      NOT m = 0 AND NOT m > n AND NOT i > n - m IMPLIES
       (FORALL (ldt: DivListType):
          ldt =
           IF i = n - m
             THEN make_divlisttype((: :), n - m, array2list(n + 1)(g), n)
           ELSE v(g, n)(h, m)(i + 1)
           ENDIF
           IMPLIES
           (FORALL (thisterm: int):
              thisterm = nth(ldt`reml, ldt`rdegl) IMPLIES
               (FORALL (j: nat):
                  j < i AND NOT j > m + i IMPLIES
                   j < length[int](ldt`reml))));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 350 0 386 999
body:
  % Subtype TCC generated (at line 33, column 33) for  j
      % expected type  below[length(ldt`reml)]
  pseudo_div_TCC7: OBLIGATION
    FORALL (g: [nat -> int], n: nat, h: [nat -> int], (m: nat | h(m) /= 0),
            i: nat,
            v:
              [d11: [[nat -> int], nat] ->
                 [d1: [h: [nat -> int], {m | h(m) /= 0}] ->
                    [i1:
                       {z: nat |
                                max(1 - z - d1`2 + d11`2, 0) <
                                 max(1 + n - i - m, 0)} ->
                       {DT: DivListType |
                                (d1`2 > d11`2 OR
                                  i1 > d11`2 - d1`2 AND
                                   length(DT`reml) = 1 + d11`2 AND
                                    DT`rdegl = d11`2)
                                 OR
                                 (d1`2 = 0 AND
                                   length(DT`reml) = 0 AND DT`rdegl = 0)
                                  OR
                                  (d1`2 > 0 AND
                                    length(DT`reml) = i1 + d1`2 AND
                                     length(DT`reml) = 1 + DT`rdegl)}]]]):
      NOT m = 0 AND NOT m > n AND NOT i > n - m IMPLIES
       (FORALL (ldt: DivListType):
          ldt =
           IF i = n - m
             THEN make_divlisttype((: :), n - m, array2list(n + 1)(g), n)
           ELSE v(g, n)(h, m)(i + 1)
           ENDIF
           IMPLIES
           (FORALL (thisterm: int):
              thisterm = nth(ldt`reml, ldt`rdegl) IMPLIES
               (FORALL (j: nat):
                  NOT j < i AND NOT j > m + i IMPLIES
                   j < length[int](ldt`reml))));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 388 0 423 999
body:
  % Subtype TCC generated (at line 33, column 47) for  j - i
      % expected type  nat
  pseudo_div_TCC8: OBLIGATION
    FORALL (g: [nat -> int], n: nat, h: [nat -> int], (m: nat | h(m) /= 0),
            i: nat,
            v:
              [d11: [[nat -> int], nat] ->
                 [d1: [h: [nat -> int], {m | h(m) /= 0}] ->
                    [i1:
                       {z: nat |
                                max(1 - z - d1`2 + d11`2, 0) <
                                 max(1 + n - i - m, 0)} ->
                       {DT: DivListType |
                                (d1`2 > d11`2 OR
                                  i1 > d11`2 - d1`2 AND
                                   length(DT`reml) = 1 + d11`2 AND
                                    DT`rdegl = d11`2)
                                 OR
                                 (d1`2 = 0 AND
                                   length(DT`reml) = 0 AND DT`rdegl = 0)
                                  OR
                                  (d1`2 > 0 AND
                                    length(DT`reml) = i1 + d1`2 AND
                                     length(DT`reml) = 1 + DT`rdegl)}]]]):
      NOT m = 0 AND NOT m > n AND NOT i > n - m IMPLIES
       (FORALL (ldt: DivListType):
          ldt =
           IF i = n - m
             THEN make_divlisttype((: :), n - m, array2list(n + 1)(g), n)
           ELSE v(g, n)(h, m)(i + 1)
           ENDIF
           IMPLIES
           (FORALL (thisterm: int):
              thisterm = nth(ldt`reml, ldt`rdegl) IMPLIES
               (FORALL (j: nat):
                  NOT j < i AND NOT j > m + i IMPLIES j - i >= 0)));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 425 0 458 999
body:
  % Subtype TCC generated (at line 33, column 59) for  m + i - 1
      % expected type  nat
  pseudo_div_TCC9: OBLIGATION
    FORALL (g: [nat -> int], n: nat, h: [nat -> int], (m: nat | h(m) /= 0),
            i: nat,
            v:
              [d11: [[nat -> int], nat] ->
                 [d1: [h: [nat -> int], {m | h(m) /= 0}] ->
                    [i1:
                       {z: nat |
                                max(1 - z - d1`2 + d11`2, 0) <
                                 max(1 + n - i - m, 0)} ->
                       {DT: DivListType |
                                (d1`2 > d11`2 OR
                                  i1 > d11`2 - d1`2 AND
                                   length(DT`reml) = 1 + d11`2 AND
                                    DT`rdegl = d11`2)
                                 OR
                                 (d1`2 = 0 AND
                                   length(DT`reml) = 0 AND DT`rdegl = 0)
                                  OR
                                  (d1`2 > 0 AND
                                    length(DT`reml) = i1 + d1`2 AND
                                     length(DT`reml) = 1 + DT`rdegl)}]]]):
      NOT m = 0 AND NOT m > n AND NOT i > n - m IMPLIES
       (FORALL (ldt: DivListType):
          ldt =
           IF i = n - m
             THEN make_divlisttype((: :), n - m, array2list(n + 1)(g), n)
           ELSE v(g, n)(h, m)(i + 1)
           ENDIF
           IMPLIES
           (FORALL (thisterm: int):
              thisterm = nth(ldt`reml, ldt`rdegl) IMPLIES m + i - 1 >= 0));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 460 0 638 999
body:
  % Subtype TCC generated (at line 29, column 10) for
      % make_divlisttype(cons(thisterm, ldt`quotl), n - m,
      %                  array2list(m + i)
      %                            (LAMBDA (j: nat):
      %                               IF j > m + i
      %                               THEN 0
      %                               ELSIF j < i
      %                               THEN h(m) * nth(ldt`reml, j)
      %                               ELSE h(m) * nth(ldt`reml, j)
      %                                    -
      %                                    thisterm * h(j - i)
      %                               ENDIF),
      %                  m + i - 1)
      % expected type  {DT: DivListType |
                     %          (m > n OR
                     %            i > n - m AND
                     %             length(DT`reml) = 1 + n AND DT`rdegl = n)
                     %           OR
                     %           (m = 0 AND
                     %             length(DT`reml) = 0 AND DT`rdegl = 0)
                     %            OR
                     %            (m > 0 AND
                     %              length(DT`reml) = i + m AND
                     %               length(DT`reml) = 1 + DT`rdegl)}
  pseudo_div_TCC10: OBLIGATION
    FORALL (g: [nat -> int], n: nat, h: [nat -> int], (m: nat | h(m) /= 0),
            i: nat,
            v:
              [d11: [[nat -> int], nat] ->
                 [d1: [h: [nat -> int], {m | h(m) /= 0}] ->
                    [i1:
                       {z: nat |
                                max(1 - z - d1`2 + d11`2, 0) <
                                 max(1 + n - i - m, 0)} ->
                       {DT: DivListType |
                                (d1`2 > d11`2 OR
                                  i1 > d11`2 - d1`2 AND
                                   length(DT`reml) = 1 + d11`2 AND
                                    DT`rdegl = d11`2)
                                 OR
                                 (d1`2 = 0 AND
                                   length(DT`reml) = 0 AND DT`rdegl = 0)
                                  OR
                                  (d1`2 > 0 AND
                                    length(DT`reml) = i1 + d1`2 AND
                                     length(DT`reml) = 1 + DT`rdegl)}]]]):
      NOT m = 0 AND NOT m > n AND NOT i > n - m IMPLIES
       (FORALL (ldt: DivListType):
          ldt =
           IF i = n - m
             THEN make_divlisttype((: :), n - m, array2list(n + 1)(g), n)
           ELSE v(g, n)(h, m)(i + 1)
           ENDIF
           IMPLIES
           (FORALL (thisterm: int):
              thisterm = nth(ldt`reml, ldt`rdegl) IMPLIES
               (m > n OR
                 i > n - m AND
                  length[int]
                      (make_divlisttype(cons[int](thisterm, ldt`quotl),
                                        n - m,
                                        array2list[int]
                                        (m + i)
                                        (LAMBDA
                                         (j: nat):
                                         IF j > m + i
                                         THEN 0
                                         ELSIF j < i
                                         THEN h(m) * nth[int](ldt`reml, j)
                                         ELSE h(m) * nth[int](ldt`reml, j)
                                              -
                                              thisterm * h(j - i)
                                         ENDIF),
                                        m + i - 1)`reml)
                   = 1 + n
                   AND
                   make_divlisttype(cons[int](thisterm, ldt`quotl), n - m,
                                    array2list[int]
                                        (m + i)
                                        (LAMBDA
                                         (j: nat):
                                         IF j > m + i
                                         THEN 0
                                         ELSIF j < i
                                         THEN h(m) * nth[int](ldt`reml, j)
                                         ELSE h(m) * nth[int](ldt`reml, j)
                                              -
                                              thisterm * h(j - i)
                                         ENDIF),
                                    m + i - 1)`rdegl
                    = n)
                OR
                (m = 0 AND
                  length[int]
                      (make_divlisttype(cons[int](thisterm, ldt`quotl),
                                        n - m,
                                        array2list[int]
                                        (m + i)
                                        (LAMBDA
                                         (j: nat):
                                         IF j > m + i
                                         THEN 0
                                         ELSIF j < i
                                         THEN h(m) * nth[int](ldt`reml, j)
                                         ELSE h(m) * nth[int](ldt`reml, j)
                                              -
                                              thisterm * h(j - i)
                                         ENDIF),
                                        m + i - 1)`reml)
                   = 0
                   AND
                   make_divlisttype(cons[int](thisterm, ldt`quotl), n - m,
                                    array2list[int]
                                        (m + i)
                                        (LAMBDA
                                         (j: nat):
                                         IF j > m + i
                                         THEN 0
                                         ELSIF j < i
                                         THEN h(m) * nth[int](ldt`reml, j)
                                         ELSE h(m) * nth[int](ldt`reml, j)
                                              -
                                              thisterm * h(j - i)
                                         ENDIF),
                                    m + i - 1)`rdegl
                    = 0)
                 OR
                 (m > 0 AND
                   length[int]
                       (make_divlisttype(cons[int](thisterm, ldt`quotl),
                                         n - m,
                                         array2list[int]
                                         (m + i)
                                         (LAMBDA
                                          (j: nat):
                                          IF j > m + i
                                          THEN 0
                                          ELSIF j < i
                                          THEN h(m) * nth[int](ldt`reml, j)
                                          ELSE h(m) * nth[int](ldt`reml, j)
                                               -
                                               thisterm * h(j - i)
                                          ENDIF),
                                         m + i - 1)`reml)
                    = i + m
                    AND
                    length[int]
                        (make_divlisttype(cons[int](thisterm, ldt`quotl),
                                          n - m,
                                          array2list[int]
                                          (m + i)
                                          (LAMBDA
                                           (j: nat):
                                           IF j > m + i
                                           THEN 0
                                           ELSIF j < i
                                           THEN h(m) * nth[int](ldt`reml, j)
                                           ELSE h(m) * nth[int](ldt`reml, j)
                                                -
                                                thisterm * h(j - i)
                                           ENDIF),
                                          m + i - 1)`reml)
                     =
                     1 +
                      make_divlisttype(cons[int](thisterm, ldt`quotl),
                                       n - m,
                                       array2list[int]
                                       (m + i)
                                       (LAMBDA
                                        (j: nat):
                                        IF j > m + i
                                        THEN 0
                                        ELSIF j < i
                                        THEN h(m) * nth[int](ldt`reml, j)
                                        ELSE h(m) * nth[int](ldt`reml, j)
                                             -
                                             thisterm * h(j - i)
                                        ENDIF),
                                       m + i - 1)`rdegl)));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 640 0 645 999
body:
  % Subtype TCC generated (at line 26, column 52) for  n - m
      % expected type  nat
  pseudo_div_TCC11: OBLIGATION
    FORALL (n: nat, h: [nat -> int], (m: nat | h(m) /= 0), i: nat):
      i = n - m AND NOT m = 0 AND NOT m > n AND NOT i > n - m IMPLIES
       n - m >= 0;


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 647 0 652 999
body:
  % Termination TCC generated (at line 27, column 20) for
      % pseudo_div(g, n)(h, m)(i + 1)
  pseudo_div_TCC12: OBLIGATION
    FORALL (n: nat, h: [nat -> int], (m: nat | h(m) /= 0), i: nat):
      NOT i = n - m AND NOT m = 0 AND NOT m > n AND NOT i > n - m IMPLIES
       max(n - m - (i + 1) + 1, 0) < max(n - m - i + 1, 0);


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 654 0 685 999
body:
  % Subtype TCC generated (at line 78, column 26) for
      % k - (pd`qdeg - qlength + 1)
      % expected type  below[length(psd`quotl)]
  pseudo_div_def_TCC1: OBLIGATION
    FORALL (g, h: [nat -> int], i, m, n: nat):
      (FORALL (ii: nat): ii > m IMPLIES h(ii) = 0) AND
       (FORALL (ii: nat): ii > n IMPLIES g(ii) = 0) AND h(m) /= 0
       IMPLIES
       (FORALL (psd:
                  {DT: DivListType |
                           (m > n OR
                             i > n - m AND
                              length[int](DT`reml) = 1 + n AND DT`rdegl = n)
                            OR
                            (m = 0 AND
                              length[int](DT`reml) = 0 AND DT`rdegl = 0)
                             OR
                             (m > 0 AND
                               length[int](DT`reml) = i + m AND
                                length[int](DT`reml) = 1 + DT`rdegl)}):
          psd = pseudo_div(g, n)(h, m)(i) IMPLIES
           (FORALL (pd: DivType):
              pd = poly_divide(g, n)(h, m)(i) IMPLIES
               (FORALL (qlength: nat):
                  qlength = length(psd`quotl) IMPLIES
                   (FORALL (rlength: nat):
                      rlength = length(psd`reml) IMPLIES
                       (FORALL (k: nat):
                          k <= pd`qdeg AND k >= pd`qdeg - qlength + 1 IMPLIES
                           k - (pd`qdeg - qlength + 1) >= 0 AND
                            k - (pd`qdeg - qlength + 1) <
                             length[int](psd`quotl))))));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 687 0 725 999
body:
  % Subtype TCC generated (at line 80, column 122) for  k
      % expected type  below[length(psd`reml)]
  pseudo_div_def_TCC2: OBLIGATION
    FORALL (R, T: nat, g, h: [nat -> int], i, m, n: nat):
      (FORALL (ii: nat): ii > m IMPLIES h(ii) = 0) AND
       (FORALL (ii: nat): ii > n IMPLIES g(ii) = 0) AND h(m) /= 0
       IMPLIES
       (FORALL (psd:
                  {DT: DivListType |
                           (m > n OR
                             i > n - m AND
                              length[int](DT`reml) = 1 + n AND DT`rdegl = n)
                            OR
                            (m = 0 AND
                              length[int](DT`reml) = 0 AND DT`rdegl = 0)
                             OR
                             (m > 0 AND
                               length[int](DT`reml) = i + m AND
                                length[int](DT`reml) = 1 + DT`rdegl)}):
          psd = pseudo_div(g, n)(h, m)(i) IMPLIES
           (FORALL (pd: DivType):
              pd = poly_divide(g, n)(h, m)(i) IMPLIES
               (FORALL (qlength: nat):
                  qlength = length(psd`quotl) IMPLIES
                   (FORALL (rlength: nat):
                      (pd`quot =
                        (LAMBDA (k: nat): (1 / h(m)) ^ GG(k, n, m, i, R, T))
                         *
                         (LAMBDA (k: nat):
                            IF k <= pd`qdeg AND k >= pd`qdeg - qlength + 1
                              THEN nth(psd`quotl,
                                       k - (pd`qdeg - qlength + 1))
                            ELSE 0
                            ENDIF))
                       AND rlength = length(psd`reml)
                       IMPLIES
                       (FORALL (k1: nat):
                          k1 <= pd`rdeg AND (i > n - m OR m > 0) IMPLIES
                           k1 < length[int](psd`reml))))));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 727 0 755 999
body:
  % Subtype TCC generated (at line 90, column 94) for  k
      % expected type  below[length(psd`reml)]
  poly_pseudo_remainder_def_TCC1: OBLIGATION
    FORALL (g, h: [nat -> int], m, n: nat):
      (FORALL (ii: nat): ii > m IMPLIES h(ii) = 0) AND
       (FORALL (ii: nat): ii > n IMPLIES g(ii) = 0) AND n >= m AND h(m) /= 0
       IMPLIES
       (FORALL (psd:
                  {DT: DivListType |
                           (m > n OR
                             0 > n - m AND
                              length[int](DT`reml) = 1 + n AND DT`rdegl = n)
                            OR
                            (m = 0 AND
                              length[int](DT`reml) = 0 AND DT`rdegl = 0)
                             OR
                             (m > 0 AND
                               length[int](DT`reml) = m AND
                                length[int](DT`reml) = 1 + DT`rdegl)}):
          psd = pseudo_div(g, n)(h, m)(0) IMPLIES
           (FORALL (pd: DivType):
              pd = poly_divide(g, n)(h, m)(0) IMPLIES
               (FORALL (qlength: nat):
                  qlength = length(psd`quotl) IMPLIES
                   (FORALL (rlength: nat):
                      rlength = length(psd`reml) IMPLIES
                       (FORALL (k: nat):
                          k <= psd`rdegl AND m > 0 IMPLIES
                           k < length[int](psd`reml))))));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 757 0 798 999
body:
  % Subtype TCC generated (at line 96, column 65) for  -pseudosign
      % expected type  {k: nzint |
                     %          FORALL (ii: nat):
                     %            ii <
                     %             length[int]
                     %                 (nonzero_version
                     %                  (primitize_list(thisrem)))
                     %             IMPLIES
                     %             divides(k,
                     %                     nth[int]
                     %                     (nonzero_version
                     %                      (primitize_list(thisrem)),
                     %                      ii))}
  adjusted_remainder_TCC1: OBLIGATION
    FORALL (g: [nat -> int], n: nat, h: [nat -> int], (m: nat | h(m) /= 0),
            ppd:
              {DT: DivListType |
                       (m > n OR
                         0 > n - m AND
                          length[int](DT`reml) = 1 + n AND DT`rdegl = n)
                        OR
                        (m = 0 AND length[int](DT`reml) = 0 AND DT`rdegl = 0)
                         OR
                         (m > 0 AND
                           length[int](DT`reml) = m AND
                            length[int](DT`reml) = 1 + DT`rdegl)}):
      ppd = pseudo_div(g, n)(h, m)(0) IMPLIES
       (FORALL (thisrem: list[int]):
          thisrem = ppd`reml IMPLIES
           (FORALL (pseudosign: nzint):
              pseudosign =
               IF h(m) > 0 OR mod(n - m + 1, 2) = 0 OR m > n THEN 1
               ELSE -1
               ENDIF
               IMPLIES
               (FORALL (ii: nat):
                  ii < length[int](nonzero_version(primitize_list(thisrem)))
                   IMPLIES
                   divides(-pseudosign,
                           nth[int]
                               (nonzero_version(primitize_list(thisrem)),
                                ii)))));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 800 0 814 999
body:
  % Subtype TCC generated (at line 106, column 62) for  i
      % expected type  below[length(thisrem)]
  adjusted_remainder_def_TCC1: OBLIGATION
    FORALL (g, h: [nat -> int], m, n: nat):
      (FORALL (ii: nat): ii > m IMPLIES h(ii) = 0) AND
       (FORALL (ii: nat): ii > n IMPLIES g(ii) = 0) AND h(m) /= 0
       IMPLIES
       (FORALL (thisrem: list[int]):
          thisrem = adjusted_remainder(g, n)(h, m) IMPLIES
           (FORALL (pd: DivType):
              pd = poly_divide(g, n)(h, m)(0) IMPLIES
               (FORALL (thisdeg: int):
                  thisdeg = length[int](thisrem) - 1 IMPLIES
                   (FORALL (i: nat):
                      i <= thisdeg IMPLIES i < length[int](thisrem)))));


decl_type: tcc
theory: polynomial_pseudo_divide
library: Sturm
signature: nil
location: 816 0 841 999
body:
  % Subtype TCC generated (at line 137, column 33) for  4
      % expected type  {m | h(m) /= 0}
  adjusted_remainder_test_TCC1: OBLIGATION
    FORALL (g: [nat -> int]):
      g =
       (LAMBDA (i: nat):
          IF i = 0 THEN 1
          ELSIF i = 1 THEN 2
          ELSIF i = 2 THEN 2
          ELSIF i = 3 THEN 5
          ELSIF i = 5 THEN 2
          ELSIF i = 6 THEN -7
          ELSE 0
          ENDIF)
       IMPLIES
       (FORALL (h: [nat -> int]):
          h =
           (LAMBDA (i: nat):
              IF i = 0 THEN -4
              ELSIF i = 1 THEN -4
              ELSIF i = 2 THEN 2
              ELSIF i = 3 THEN 5
              ELSIF i = 4 THEN -2
              ELSE 0
              ENDIF)
           IMPLIES h(4) /= 0);


decl_type: formula
theory: remainder_sequence
library: Sturm
signature: nil
location: 59 2 65 53
body:
    remainder_seq_test: LEMMA
      LET g=(LAMBDA (i:nat): IF i<=3 THEN 2 ELSIF i<=6 
                             THEN -3 ELSE 0 ENDIF)
      IN sturm_chain(g,6) =
        (:(::),(:-1:),(:-579,-608:),(:2,4,55:),
          (:126,140,105,120:),(:-70,-56,-42,-48,21:),
           (:2,4,6,-12,-15,-18:),(:2,2,2,2,-3,-3,-3:):)


decl_type: function
theory: remainder_sequence
library: Sturm
location: 13 2 26 71
signature:
  [[g: [nat -> int], {n | g(n) /= 0}, h: [nat -> int],
         {m | h(m) /= 0}] ->
          [list[list[int]] -> bool]]

body:
    is_neg_remainder_list?(g,(n|g(n)/=0),h,(m|h(m)/=0))(curr): bool =
      (FORALL (icurr,jcurr:nat):icurr<jcurr AND jcurr<length(curr)-1 
                     IMPLIES
                          length(nth(curr,icurr)) < length(nth(curr,jcurr))) AND
      (FORALL (icurr:nat): icurr<length(curr) IMPLIES LET thiscurr = nth(curr,icurr) IN
                          length(thiscurr)>0 IMPLIES nth(thiscurr,length(thiscurr)-1)/=0) AND
      (length(curr)>0 IMPLIES nth(curr,length(curr)-1) = array2list[int](n+1)(g)) AND
      (length(curr)>1 IMPLIES nth(curr,length(curr)-2) = array2list[int](m+1)(h)) AND
      (FORALL (j:nat): j<length(curr)-2 IMPLIES 
        LET pbig = list2array[int](0)(nth(curr,j+2)),
            nbig = length(nth(curr,j+2))-1,
            plittle = list2array[int](0)(nth(curr,j+1)),
            nlittle:nat = length(nth(curr,j+1))-1
        IN  nth(curr,j) = adjusted_remainder(pbig,nbig)(plittle,nlittle))


decl_type: function
theory: remainder_sequence
library: Sturm
location: 29 2 50 73
signature:
  [d:
          [g: [nat -> int], {n | g(n) /= 0}, h: [nat -> int],
           {m | h(m) /= 0}] ->
          [(is_neg_remainder_list?(d`1, d`2, d`3, d`4)) ->
             {crem: (is_neg_remainder_list?(d`1, d`2, d`3, d`4)) |
                      length(crem) > 1 AND length(nth(crem, 0)) = 0}]]

body:
    compute_remainder_seq(g,(n|g(n)/=0),h,(m|h(m)/=0))
      (curr:(is_neg_remainder_list?(g,n,h,m))):
      RECURSIVE {crem:(is_neg_remainder_list?(g,n,h,m))|length(crem)>1 AND length(nth(crem,0))=0} =
      LET currlength = length(curr) IN
        IF currlength = 0 THEN 
            compute_remainder_seq(g,n,h,m)(cons[list[int]](array2list[int](m+1)(h),
                        cons[list[int]](array2list[int](n+1)(g),curr)))
        ELSIF currlength = 1 THEN 
            compute_remainder_seq(g,n,h,m)(cons[list[int]](array2list[int](m+1)(h),
                        curr))
        ELSIF length(nth(curr,0))=0 THEN curr
        ELSE
          LET csplittle  = nth(curr,0),
              cspbig     = nth(curr,1),
              newg       = list2array[int](0)(cspbig),
              newn       = length(cspbig)-1,
              newh       = list2array[int](0)(csplittle),
              newm       = length(csplittle)-1,
              newlist    = adjusted_remainder(newg,newn)(newh,newm)
          IN  compute_remainder_seq(g,n,h,m)(cons(newlist,curr))
        ENDIF MEASURE IF null?(curr) THEN m+n+4 ELSIF length(curr)=1 THEN m+n+3
              ELSIF length(curr)=2 THEN m+n+2 ELSE length(nth(curr,0)) ENDIF


decl_type: function
theory: remainder_sequence
library: Sturm
location: 52 2 54 51
signature:
  [d:
          [g: [nat -> int], {n | g(n) /= 0}, h: [nat -> int],
           {m | h(m) /= 0}] ->
          {crem: (is_neg_remainder_list?(d`1, d`2, d`3, d`4)) |
                   length(crem) > 1 AND length(nth(crem, 0)) = 0}]

body:
    remainder_seq(g,(n|g(n)/=0),h,(m|h(m)/=0)):
      {crem:(is_neg_remainder_list?(g,n,h,m))|length(crem)>1 AND length(nth(crem,0))=0} =
      compute_remainder_seq(g,n,h,m)(null[list[int]])


decl_type: function
theory: remainder_sequence
library: Sturm
signature: [[g: [nat -> int], {pn | g(pn) /= 0}] -> list[list[int]]]
location: 56 2 57 42
body:
    sturm_chain(g,(pn|g(pn)/=0)) : MACRO list[list[int]] = 
      remainder_seq(g,pn,poly_deriv(g),pn-1)


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 72 0 78 999
body:
  % Subtype TCC generated (at line 16, column 19) for  icurr
      % expected type  below[length[list[int]](curr)]
  is_neg_remainder_list?_TCC1: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: list[list[int]], icurr, jcurr: nat):
      icurr < jcurr AND jcurr < length(curr) - 1 IMPLIES
       icurr < length[list[int]](curr);


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 80 0 86 999
body:
  % Subtype TCC generated (at line 16, column 45) for  jcurr
      % expected type  below[length[list[int]](curr)]
  is_neg_remainder_list?_TCC2: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: list[list[int]], icurr, jcurr: nat):
      icurr < jcurr AND jcurr < length(curr) - 1 IMPLIES
       jcurr < length[list[int]](curr);


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 88 0 102 999
body:
  % Subtype TCC generated (at line 18, column 43) for  length(thiscurr) - 1
      % expected type  below[length(thiscurr)]
  is_neg_remainder_list?_TCC3: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: list[list[int]]):
      (FORALL (icurr, jcurr: nat):
         icurr < jcurr AND jcurr < length(curr) - 1 IMPLIES
          length(nth(curr, icurr)) < length(nth(curr, jcurr)))
       IMPLIES
       (FORALL (icurr1: nat):
          icurr1 < length(curr) IMPLIES
           (FORALL (thiscurr: list[int]):
              length(thiscurr) > 0 AND thiscurr = nth(curr, icurr1) IMPLIES
               length[int](thiscurr) - 1 >= 0 AND
                length[int](thiscurr) - 1 < length[int](thiscurr)));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 104 0 121 999
body:
  % Subtype TCC generated (at line 19, column 37) for  length(curr) - 1
      % expected type  below[length[list[int]](curr)]
  is_neg_remainder_list?_TCC4: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: list[list[int]]):
      (length(curr) > 0 AND
        (FORALL (icurr: nat):
           icurr < length(curr) IMPLIES
            LET thiscurr = nth(curr, icurr) IN
              length(thiscurr) > 0 IMPLIES
               nth(thiscurr, length(thiscurr) - 1) /= 0)
         AND
         (FORALL (icurr, jcurr: nat):
            icurr < jcurr AND jcurr < length(curr) - 1 IMPLIES
             length(nth(curr, icurr)) < length(nth(curr, jcurr))))
       IMPLIES
       length[list[int]](curr) - 1 >= 0 AND
        length[list[int]](curr) - 1 < length[list[int]](curr);


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 123 0 143 999
body:
  % Subtype TCC generated (at line 20, column 37) for  length(curr) - 2
      % expected type  below[length[list[int]](curr)]
  is_neg_remainder_list?_TCC5: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: list[list[int]]):
      (length(curr) > 1 AND
        (length(curr) > 0 IMPLIES
          nth(curr, length(curr) - 1) = array2list[int](n + 1)(g))
         AND
         (FORALL (icurr: nat):
            icurr < length(curr) IMPLIES
             LET thiscurr = nth(curr, icurr) IN
               length(thiscurr) > 0 IMPLIES
                nth(thiscurr, length(thiscurr) - 1) /= 0)
          AND
          (FORALL (icurr, jcurr: nat):
             icurr < jcurr AND jcurr < length(curr) - 1 IMPLIES
              length(nth(curr, icurr)) < length(nth(curr, jcurr))))
       IMPLIES
       length[list[int]](curr) - 2 >= 0 AND
        length[list[int]](curr) - 2 < length[list[int]](curr);


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 145 0 167 999
body:
  % Subtype TCC generated (at line 22, column 45) for  j + 2
      % expected type  below[length[list[int]](curr)]
  is_neg_remainder_list?_TCC6: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: list[list[int]]):
      ((length(curr) > 1 IMPLIES
         nth(curr, length(curr) - 2) = array2list[int](m + 1)(h))
        AND
        (length(curr) > 0 IMPLIES
          nth(curr, length(curr) - 1) = array2list[int](n + 1)(g))
         AND
         (FORALL (icurr: nat):
            icurr < length(curr) IMPLIES
             LET thiscurr = nth(curr, icurr) IN
               length(thiscurr) > 0 IMPLIES
                nth(thiscurr, length(thiscurr) - 1) /= 0)
          AND
          (FORALL (icurr, jcurr: nat):
             icurr < jcurr AND jcurr < length(curr) - 1 IMPLIES
              length(nth(curr, icurr)) < length(nth(curr, jcurr))))
       IMPLIES
       (FORALL (j: nat):
          j < length(curr) - 2 IMPLIES j + 2 < length[list[int]](curr));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 169 0 196 999
body:
  % Subtype TCC generated (at line 24, column 41) for  j + 1
      % expected type  below[length[list[int]](curr)]
  is_neg_remainder_list?_TCC7: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: list[list[int]]):
      ((length(curr) > 1 IMPLIES
         nth(curr, length(curr) - 2) = array2list[int](m + 1)(h))
        AND
        (length(curr) > 0 IMPLIES
          nth(curr, length(curr) - 1) = array2list[int](n + 1)(g))
         AND
         (FORALL (icurr: nat):
            icurr < length(curr) IMPLIES
             LET thiscurr = nth(curr, icurr) IN
               length(thiscurr) > 0 IMPLIES
                nth(thiscurr, length(thiscurr) - 1) /= 0)
          AND
          (FORALL (icurr, jcurr: nat):
             icurr < jcurr AND jcurr < length(curr) - 1 IMPLIES
              length(nth(curr, icurr)) < length(nth(curr, jcurr))))
       IMPLIES
       (FORALL (j: nat):
          j < length(curr) - 2 IMPLIES
           (FORALL (pbig: [nat -> int]):
              pbig = list2array[int](0)(nth(curr, j + 2)) IMPLIES
               (FORALL (nbig: int):
                  nbig = length(nth(curr, j + 2)) - 1 IMPLIES
                   j + 1 < length[list[int]](curr))));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 198 0 228 999
body:
  % Subtype TCC generated (at line 25, column 17) for
      % length(nth(curr, j + 1)) - 1
      % expected type  nat
  is_neg_remainder_list?_TCC8: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: list[list[int]]):
      ((length(curr) > 1 IMPLIES
         nth(curr, length(curr) - 2) = array2list[int](m + 1)(h))
        AND
        (length(curr) > 0 IMPLIES
          nth(curr, length(curr) - 1) = array2list[int](n + 1)(g))
         AND
         (FORALL (icurr: nat):
            icurr < length(curr) IMPLIES
             LET thiscurr = nth(curr, icurr) IN
               length(thiscurr) > 0 IMPLIES
                nth(thiscurr, length(thiscurr) - 1) /= 0)
          AND
          (FORALL (icurr, jcurr: nat):
             icurr < jcurr AND jcurr < length(curr) - 1 IMPLIES
              length(nth(curr, icurr)) < length(nth(curr, jcurr))))
       IMPLIES
       (FORALL (j: nat):
          j < length(curr) - 2 IMPLIES
           (FORALL (pbig: [nat -> int]):
              pbig = list2array[int](0)(nth(curr, j + 2)) IMPLIES
               (FORALL (nbig: int):
                  nbig = length(nth(curr, j + 2)) - 1 IMPLIES
                   (FORALL (plittle: [nat -> int]):
                      plittle = list2array[int](0)(nth(curr, j + 1)) IMPLIES
                       length[int](nth[list[int]](curr, j + 1)) - 1 >= 0))));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 230 0 261 999
body:
  % Subtype TCC generated (at line 26, column 19) for  j
      % expected type  below[length[list[int]](curr)]
  is_neg_remainder_list?_TCC9: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: list[list[int]]):
      ((length(curr) > 1 IMPLIES
         nth(curr, length(curr) - 2) = array2list[int](m + 1)(h))
        AND
        (length(curr) > 0 IMPLIES
          nth(curr, length(curr) - 1) = array2list[int](n + 1)(g))
         AND
         (FORALL (icurr: nat):
            icurr < length(curr) IMPLIES
             LET thiscurr = nth(curr, icurr) IN
               length(thiscurr) > 0 IMPLIES
                nth(thiscurr, length(thiscurr) - 1) /= 0)
          AND
          (FORALL (icurr, jcurr: nat):
             icurr < jcurr AND jcurr < length(curr) - 1 IMPLIES
              length(nth(curr, icurr)) < length(nth(curr, jcurr))))
       IMPLIES
       (FORALL (j: nat):
          j < length(curr) - 2 IMPLIES
           (FORALL (pbig: [nat -> int]):
              pbig = list2array[int](0)(nth(curr, j + 2)) IMPLIES
               (FORALL (nbig: int):
                  nbig = length(nth(curr, j + 2)) - 1 IMPLIES
                   (FORALL (plittle: [nat -> int]):
                      plittle = list2array[int](0)(nth(curr, j + 1)) IMPLIES
                       (FORALL (nlittle: nat):
                          nlittle = length(nth(curr, j + 1)) - 1 IMPLIES
                           j < length[list[int]](curr))))));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 263 0 294 999
body:
  % Subtype TCC generated (at line 26, column 62) for  nlittle
      % expected type  {m | plittle(m) /= 0}
  is_neg_remainder_list?_TCC10: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: list[list[int]]):
      ((length(curr) > 1 IMPLIES
         nth(curr, length(curr) - 2) = array2list[int](m + 1)(h))
        AND
        (length(curr) > 0 IMPLIES
          nth(curr, length(curr) - 1) = array2list[int](n + 1)(g))
         AND
         (FORALL (icurr: nat):
            icurr < length(curr) IMPLIES
             LET thiscurr = nth(curr, icurr) IN
               length(thiscurr) > 0 IMPLIES
                nth(thiscurr, length(thiscurr) - 1) /= 0)
          AND
          (FORALL (icurr, jcurr: nat):
             icurr < jcurr AND jcurr < length(curr) - 1 IMPLIES
              length(nth(curr, icurr)) < length(nth(curr, jcurr))))
       IMPLIES
       (FORALL (j: nat):
          j < length(curr) - 2 IMPLIES
           (FORALL (pbig: [nat -> int]):
              pbig = list2array[int](0)(nth(curr, j + 2)) IMPLIES
               (FORALL (nbig: int):
                  nbig = length(nth(curr, j + 2)) - 1 IMPLIES
                   (FORALL (plittle: [nat -> int]):
                      plittle = list2array[int](0)(nth(curr, j + 1)) IMPLIES
                       (FORALL (nlittle: nat):
                          nlittle = length(nth(curr, j + 1)) - 1 IMPLIES
                           plittle(nlittle) /= 0)))));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 296 0 327 999
body:
  % Subtype TCC generated (at line 26, column 48) for  nbig
      % expected type  nat
  is_neg_remainder_list?_TCC11: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: list[list[int]]):
      ((length(curr) > 1 IMPLIES
         nth(curr, length(curr) - 2) = array2list[int](m + 1)(h))
        AND
        (length(curr) > 0 IMPLIES
          nth(curr, length(curr) - 1) = array2list[int](n + 1)(g))
         AND
         (FORALL (icurr: nat):
            icurr < length(curr) IMPLIES
             LET thiscurr = nth(curr, icurr) IN
               length(thiscurr) > 0 IMPLIES
                nth(thiscurr, length(thiscurr) - 1) /= 0)
          AND
          (FORALL (icurr, jcurr: nat):
             icurr < jcurr AND jcurr < length(curr) - 1 IMPLIES
              length(nth(curr, icurr)) < length(nth(curr, jcurr))))
       IMPLIES
       (FORALL (j: nat):
          j < length(curr) - 2 IMPLIES
           (FORALL (pbig: [nat -> int]):
              pbig = list2array[int](0)(nth(curr, j + 2)) IMPLIES
               (FORALL (nbig: int):
                  nbig = length(nth(curr, j + 2)) - 1 IMPLIES
                   (FORALL (plittle: [nat -> int]):
                      plittle = list2array[int](0)(nth(curr, j + 1)) IMPLIES
                       (FORALL (nlittle: nat):
                          nlittle = length(nth(curr, j + 1)) - 1 IMPLIES
                           nbig >= 0)))));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 329 0 334 999
body:
  % Subtype TCC generated (at line 31, column 89) for  0
      % expected type  below[length[list[int]](crem)]
  compute_remainder_seq_TCC1: OBLIGATION
    FORALL (g, h, (m: nat | h(m) /= 0), (n: nat | g(n) /= 0),
            crem: (is_neg_remainder_list?(g, n, h, m))):
      length(crem) > 1 IMPLIES 0 < length[list[int]](crem);


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 336 0 343 999
body:
  % Subtype TCC generated (at line 50, column 64) for  0
      % expected type  below[length[list[int]](curr)]
  compute_remainder_seq_TCC2: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0),
            curr: (is_neg_remainder_list?(g, n, h, m))):
      NOT length(curr) = 2 AND NOT length(curr) = 1 AND NOT null?(curr)
       IMPLIES 0 < length[list[int]](curr);


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 345 0 353 999
body:
  % Subtype TCC generated (at line 50, column 64) for  0
      % expected type  below[length[list[int]](z)]
  compute_remainder_seq_TCC3: OBLIGATION
    FORALL (d1:
              [g: [nat -> int], {n | g(n) /= 0}, h: [nat -> int],
               {m | h(m) /= 0}],
            z: (is_neg_remainder_list?(d1`1, d1`2, d1`3, d1`4))):
      NOT null?(z) AND NOT length(z) = 1 AND NOT length(z) = 2 IMPLIES
       0 < length[list[int]](z);


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 355 0 369 999
body:
  % Subtype TCC generated (at line 34, column 41) for
      % cons[list[int]]
      %     (array2list[int](m + 1)(h),
      %      cons[list[int]](array2list[int](n + 1)(g), curr))
      % expected type  (is_neg_remainder_list?(g, n, h, m))
  compute_remainder_seq_TCC4: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: (is_neg_remainder_list?(g, n, h, m)),
            currlength: nat):
      currlength = 0 AND currlength = length(curr) IMPLIES
       is_neg_remainder_list?(g, n, h, m)
                             (cons[list[int]]
                                  (array2list[int](m + 1)(h),
                                   cons[list[int]]
                                       (array2list[int](n + 1)(g), curr)));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 371 0 405 999
body:
  % Termination TCC generated (at line 34, column 10) for
      % compute_remainder_seq(g, n, h, m)
      %                      (cons[list[int]]
      %                           (array2list[int](m + 1)(h),
      %                            cons[list[int]]
      %                                (array2list[int](n + 1)(g), curr)))
  compute_remainder_seq_TCC5: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: (is_neg_remainder_list?(g, n, h, m)),
            currlength: nat):
      currlength = 0 AND currlength = length(curr) IMPLIES
       IF length[list[int]]
              (cons[list[int]]
                   (array2list[int](m + 1)(h),
                    cons[list[int]](array2list[int](n + 1)(g), curr)))
           = 1
         THEN m + n + 3
       ELSIF length[list[int]]
                 (cons[list[int]]
                      (array2list[int](m + 1)(h),
                       cons[list[int]](array2list[int](n + 1)(g), curr)))
              = 2
         THEN m + n + 2
       ELSE length[int]
                (nth[list[int]]
                     (cons[list[int]]
                          (array2list[int](m + 1)(h),
                           cons[list[int]](array2list[int](n + 1)(g), curr)),
                      0)) ENDIF
        <
        IF null?[list[int]](curr) THEN m + n + 4
        ELSIF length[list[int]](curr) = 1 THEN m + n + 3
        ELSIF length[list[int]](curr) = 2 THEN m + n + 2
        ELSE length[int](nth[list[int]](curr, 0))
        ENDIF;


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 407 0 418 999
body:
  % Subtype TCC generated (at line 37, column 41) for
      % cons[list[int]](array2list[int](m + 1)(h), curr)
      % expected type  (is_neg_remainder_list?(g, n, h, m))
  compute_remainder_seq_TCC6: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: (is_neg_remainder_list?(g, n, h, m)),
            currlength: nat):
      currlength = 1 AND NOT currlength = 0 AND currlength = length(curr)
       IMPLIES
       is_neg_remainder_list?(g, n, h, m)
                             (cons[list[int]]
                                  (array2list[int](m + 1)(h), curr));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 420 0 446 999
body:
  % Termination TCC generated (at line 37, column 10) for
      % compute_remainder_seq(g, n, h, m)
      %                      (cons[list[int]]
      %                           (array2list[int](m + 1)(h), curr))
  compute_remainder_seq_TCC7: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: (is_neg_remainder_list?(g, n, h, m)),
            currlength: nat):
      currlength = 1 AND NOT currlength = 0 AND currlength = length(curr)
       IMPLIES
       IF length[list[int]](cons[list[int]](array2list[int](m + 1)(h), curr))
           = 1
         THEN m + n + 3
       ELSIF length[list[int]]
                 (cons[list[int]](array2list[int](m + 1)(h), curr))
              = 2
         THEN m + n + 2
       ELSE length[int]
                (nth[list[int]]
                     (cons[list[int]](array2list[int](m + 1)(h), curr),
                      0)) ENDIF
        <
        IF null?[list[int]](curr) THEN m + n + 4
        ELSIF length[list[int]](curr) = 1 THEN m + n + 3
        ELSIF length[list[int]](curr) = 2 THEN m + n + 2
        ELSE length[int](nth[list[int]](curr, 0))
        ENDIF;


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 448 0 455 999
body:
  % Subtype TCC generated (at line 39, column 28) for  0
      % expected type  below[length[list[int]](curr)]
  compute_remainder_seq_TCC8: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: (is_neg_remainder_list?(g, n, h, m)),
            currlength: nat):
      NOT currlength = 1 AND NOT currlength = 0 AND currlength = length(curr)
       IMPLIES 0 < length[list[int]](curr);


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 457 0 469 999
body:
  % Subtype TCC generated (at line 39, column 39) for  curr
      % expected type  {crem: (is_neg_remainder_list?(g, n, h, m)) |
                     %          length(crem) > 1 AND length(nth(crem, 0)) = 0}
  compute_remainder_seq_TCC9: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: (is_neg_remainder_list?(g, n, h, m)),
            currlength: nat):
      length(nth(curr, 0)) = 0 AND
       NOT currlength = 1 AND
        NOT currlength = 0 AND currlength = length(curr)
       IMPLIES
       length[list[int]](curr) > 1 AND
        length[int](nth[list[int]](curr, 0)) = 0;


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 471 0 482 999
body:
  % Subtype TCC generated (at line 42, column 27) for  1
      % expected type  below[length[list[int]](curr)]
  compute_remainder_seq_TCC10: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: (is_neg_remainder_list?(g, n, h, m)),
            currlength: nat):
      NOT length(nth(curr, 0)) = 0 AND
       NOT currlength = 1 AND
        NOT currlength = 0 AND currlength = length(curr)
       IMPLIES
       (FORALL (csplittle: list[int]):
          csplittle = nth(curr, 0) IMPLIES 1 < length[list[int]](curr));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 484 0 506 999
body:
  % Subtype TCC generated (at line 47, column 53) for  newm
      % expected type  {m | newh(m) /= 0}
  compute_remainder_seq_TCC11: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: (is_neg_remainder_list?(g, n, h, m)),
            currlength: nat):
      NOT length(nth(curr, 0)) = 0 AND
       NOT currlength = 1 AND
        NOT currlength = 0 AND currlength = length(curr)
       IMPLIES
       (FORALL (csplittle: list[int]):
          csplittle = nth(curr, 0) IMPLIES
           (FORALL (cspbig: list[int]):
              cspbig = nth(curr, 1) IMPLIES
               (FORALL (newg: [nat -> int]):
                  newg = list2array[int](0)(cspbig) IMPLIES
                   (FORALL (newn: int):
                      newn = length(cspbig) - 1 IMPLIES
                       (FORALL (newh: [nat -> int]):
                          newh = list2array[int](0)(csplittle) IMPLIES
                           (FORALL (newm: int):
                              newm = length(csplittle) - 1 IMPLIES
                               newm >= 0 AND newh(newm) /= 0))))));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 508 0 530 999
body:
  % Subtype TCC generated (at line 47, column 42) for  newn
      % expected type  nat
  compute_remainder_seq_TCC12: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: (is_neg_remainder_list?(g, n, h, m)),
            currlength: nat):
      NOT length(nth(curr, 0)) = 0 AND
       NOT currlength = 1 AND
        NOT currlength = 0 AND currlength = length(curr)
       IMPLIES
       (FORALL (csplittle: list[int]):
          csplittle = nth(curr, 0) IMPLIES
           (FORALL (cspbig: list[int]):
              cspbig = nth(curr, 1) IMPLIES
               (FORALL (newg: [nat -> int]):
                  newg = list2array[int](0)(cspbig) IMPLIES
                   (FORALL (newn: int):
                      newn = length(cspbig) - 1 IMPLIES
                       (FORALL (newh: [nat -> int]):
                          newh = list2array[int](0)(csplittle) IMPLIES
                           (FORALL (newm: int):
                              newm = length(csplittle) - 1 IMPLIES
                               newn >= 0))))));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 532 0 561 999
body:
  % Subtype TCC generated (at line 48, column 43) for  cons(newlist, curr)
      % expected type  (is_neg_remainder_list?(g, n, h, m))
  compute_remainder_seq_TCC13: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: (is_neg_remainder_list?(g, n, h, m)),
            currlength: nat):
      NOT length(nth(curr, 0)) = 0 AND
       NOT currlength = 1 AND
        NOT currlength = 0 AND currlength = length(curr)
       IMPLIES
       (FORALL (csplittle: list[int]):
          csplittle = nth(curr, 0) IMPLIES
           (FORALL (cspbig: list[int]):
              cspbig = nth(curr, 1) IMPLIES
               (FORALL (newg: [nat -> int]):
                  newg = list2array[int](0)(cspbig) IMPLIES
                   (FORALL (newn: int):
                      newn = length(cspbig) - 1 IMPLIES
                       (FORALL (newh: [nat -> int]):
                          newh = list2array[int](0)(csplittle) IMPLIES
                           (FORALL (newm: int):
                              newm = length(csplittle) - 1 IMPLIES
                               (FORALL (newlist: list[int]):
                                  newlist =
                                   adjusted_remainder(newg, newn)(newh, newm)
                                   IMPLIES
                                   is_neg_remainder_list?(g, n, h, m)
                                                         (cons[list[int]]
                                                          (newlist,
                                                           curr)))))))));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 563 0 610 999
body:
  % Termination TCC generated (at line 48, column 12) for
      % compute_remainder_seq(g, n, h, m)(cons(newlist, curr))
  compute_remainder_seq_TCC14: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0), curr: (is_neg_remainder_list?(g, n, h, m)),
            currlength: nat):
      NOT length(nth(curr, 0)) = 0 AND
       NOT currlength = 1 AND
        NOT currlength = 0 AND currlength = length(curr)
       IMPLIES
       (FORALL (csplittle: list[int]):
          csplittle = nth(curr, 0) IMPLIES
           (FORALL (cspbig: list[int]):
              cspbig = nth(curr, 1) IMPLIES
               (FORALL (newg: [nat -> int]):
                  newg = list2array[int](0)(cspbig) IMPLIES
                   (FORALL (newn: int):
                      newn = length(cspbig) - 1 IMPLIES
                       (FORALL (newh: [nat -> int]):
                          newh = list2array[int](0)(csplittle) IMPLIES
                           (FORALL (newm: int):
                              newm = length(csplittle) - 1 IMPLIES
                               (FORALL (newlist: list[int]):
                                  newlist =
                                   adjusted_remainder(newg, newn)(newh, newm)
                                   IMPLIES
                                   IF length[list[int]]
                                      (cons[list[int]](newlist, curr))
                                      =
                                      1
                                     THEN m + n + 3
                                   ELSIF length[list[int]]
                                         (cons[list[int]](newlist, curr))
                                         =
                                         2
                                     THEN m + n + 2
                                   ELSE length[int]
                                        (nth[list[int]]
                                         (cons[list[int]](newlist, curr),
                                          0)) ENDIF
                                    <
                                    IF null?[list[int]](curr) THEN m + n + 4
                                    ELSIF length[list[int]](curr) = 1
                                      THEN m + n + 3
                                    ELSIF length[list[int]](curr) = 2
                                      THEN m + n + 2
                                    ELSE length[int](nth[list[int]](curr, 0))
                                    ENDIF)))))));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 612 0 617 999
body:
  % Subtype TCC generated (at line 54, column 35) for  null[list[int]]
      % expected type  (is_neg_remainder_list?(g, n, h, m))
  remainder_seq_TCC1: OBLIGATION
    FORALL (g: [nat -> int], (n: nat | g(n) /= 0), h: [nat -> int],
            (m: nat | h(m) /= 0)):
      is_neg_remainder_list?(g, n, h, m)(null[list[int]]);


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 619 0 624 999
body:
  % Subtype TCC generated (at line 57, column 23) for  poly_deriv(g)
      % expected type  [nat -> int]
  sturm_chain_TCC1: OBLIGATION
    FORALL (g: [nat -> int], (pn: posnat | g(pn) /= 0)):
      FORALL (x1: nat):
        rational_pred(poly_deriv(g)(x1)) AND integer_pred(poly_deriv(g)(x1));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 626 0 630 999
body:
  % Subtype TCC generated (at line 57, column 37) for  pn - 1
      % expected type  {m | poly_deriv(g)(m) /= 0}
  sturm_chain_TCC2: OBLIGATION
    FORALL (g: [nat -> int], (pn: posnat | g(pn) /= 0)):
      pn - 1 >= 0 AND poly_deriv(g)(pn - 1) /= 0;


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 632 0 638 999
body:
  % Subtype TCC generated (at line 62, column 21) for  6
      % expected type  {n | g(n) /= 0}
  remainder_seq_test_TCC1: OBLIGATION
    FORALL (g: [nat -> int]):
      g =
       (LAMBDA (i: nat): IF i <= 3 THEN 2 ELSIF i <= 6 THEN -3 ELSE 0 ENDIF)
       IMPLIES g(6) /= 0;


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 640 0 649 999
body:
  % Subtype TCC generated (at line 57, column 23) for  poly_deriv(g)
      % expected type  [nat -> int]
  remainder_seq_test_TCC2: OBLIGATION
    FORALL (g: [nat -> int]):
      g =
       (LAMBDA (i: nat): IF i <= 3 THEN 2 ELSIF i <= 6 THEN -3 ELSE 0 ENDIF)
       IMPLIES
       (FORALL (x1: nat):
          rational_pred(poly_deriv(g)(x1)) AND
           integer_pred(poly_deriv(g)(x1)));


decl_type: tcc
theory: remainder_sequence
library: Sturm
signature: nil
location: 651 0 657 999
body:
  % Subtype TCC generated (at line 57, column 37) for  6 - 1
      % expected type  {m | poly_deriv(g)(m) /= 0}
  remainder_seq_test_TCC3: OBLIGATION
    FORALL (g: [nat -> int]):
      g =
       (LAMBDA (i: nat): IF i <= 3 THEN 2 ELSIF i <= 6 THEN -3 ELSE 0 ENDIF)
       IMPLIES 6 - 1 >= 0 AND poly_deriv(g)(6 - 1) /= 0;


decl_type: formula
theory: number_sign_changes
library: Sturm
signature: nil
location: 44 2 46 41
body:
    number_sign_changes_lastnz_nonzero: LEMMA
      number_sign_changes(a,i)`lastnz = 0 IFF
      (FORALL (j:nat): j<=i IMPLIES a(j)=0)


decl_type: formula
theory: number_sign_changes
library: Sturm
signature: nil
location: 51 2 55 76
body:
    number_sign_changes_eq: LEMMA
      (FORALL (j:upto(i)): sign_ext(a(j))=sign_ext(b(j))) IMPLIES
      LET nsca = number_sign_changes(a,i),
          nscb = number_sign_changes(b,i)
      IN (nsca`num = nscb`num AND sign_ext(nsca`lastnz)=sign_ext(nscb`lastnz))


decl_type: formula
theory: number_sign_changes
library: Sturm
signature: nil
location: 76 2 92 70
body:
    nsc_regular_swap: LEMMA
      k<=d AND
      (FORALL (j): j<=k IMPLIES (sign_ext(a(j))=sign_ext(b(j)) OR
        (sign_ext(a(j))/=sign_ext(b(j)) AND
          a(j+1)/=0 AND
          (j>0 IMPLIES sign_ext(a(j-1))=-sign_ext(a(j+1))) AND
          (j>0 IMPLIES sign_ext(b(j-1))=-sign_ext(b(j+1))) AND
          (j=0 IMPLIES sign_ext(a(0))  =-sign_ext(a(1))))))
      AND sign_ext(a(k)) = sign_ext(b(k))
      AND (FORALL (j:nat): j<k IMPLIES 
                  a(j)/=0 AND b(j)/=0)
      IMPLIES
        LET nsca = number_sign_changes(a,k),
            nscb = number_sign_changes(b,k)
        IN  ((k>=1 IMPLIES sign_ext(nsca`lastnz)=sign_ext(nscb`lastnz)) AND
            nsca`num = nscb`num + 
              (IF k>=1 AND sign_ext(a(0))=-sign_ext(b(0)) THEN 1 ELSE 0 ENDIF))


decl_type: formula
theory: number_sign_changes
library: Sturm
signature: nil
location: 94 2 107 57
body:
    nsc_edge_diff: LEMMA (sig=-1 OR sig=1) AND
      k<=d AND
      (FORALL (j): j<=k IMPLIES (sign_ext(a(j))=sign_ext(b(j)) OR b(j)=0))
      AND (FORALL (j): 0<j AND j<=k AND b(j)=0 IMPLIES b(j-1)/=0)
      AND sign_ext(a(k)) = sign_ext(b(k))
      AND (FORALL (j:nat): j<k IMPLIES a(j)/=0)
      AND (b(0)=0 IMPLIES sign_ext(a(0))=sig*sign_ext(a(1)))
      AND (FORALL (j:nat): 0<j AND j<k AND b(j)=0 IMPLIES sign_ext(b(j-1))=-sign_ext(b(j+1)))
      IMPLIES
        LET nsca = number_sign_changes(a,k),
            nscb = number_sign_changes(b,k)
        IN  ((k>=1 IMPLIES sign_ext(nsca`lastnz)=sign_ext(nscb`lastnz)) AND
            nsca`num = nscb`num + 
              (IF k>=1 AND b(0)=0 AND sig=-1 THEN 1 ELSE 0 ENDIF))


decl_type: formula
theory: number_sign_changes
library: Sturm
signature: nil
location: 109 2 119 53
body:
    nsc_multiroot: LEMMA (sig=-1 OR sig=1) AND
      k<=d AND
      (FORALL (j): 0<j AND j<=k IMPLIES sign_ext(a(j))=sig*sign_ext(b(j))) AND
      sign_ext(a(0))=-sig*sign_ext(b(0)) AND
      sign_ext(a(0))=-sign_ext(a(1)) AND
      sign_ext(b(0))= sign_ext(b(1)) AND
      (FORALL (j): j<k IMPLIES (a(j)/=0 AND b(j)/=0))
      IMPLIES
        LET nsca = number_sign_changes(a,k)`num,
            nscb = number_sign_changes(b,k)`num
        IN  nsca = nscb + (IF k>=1 THEN 1 ELSE 0 ENDIF)


decl_type: formula
theory: number_sign_changes
library: Sturm
signature: nil
location: 121 2 136 53
body:
    nsc_multiroot_full: LEMMA FORALL (sigfun:[nat->real]):
      (sig=-1 OR sig=1) AND % The nominal sign
      (FORALL (j): sigfun(j)=-1 OR sigfun(j)=1) AND
      k<=d AND
      (FORALL (j): 0<j AND j<=k IMPLIES sign_ext(a(j))=sigfun(j)*sign_ext(b(j))) AND
      (FORALL (j): 0<j AND j<=k AND sigfun(j)/=sig 
        IMPLIES (1<j AND j<k AND sigfun(j-1)=sig AND sigfun(j+1)=sig
                AND sign_ext(a(j-1))=-sign_ext(a(j+1)) AND sign_ext(b(j-1))=-sign_ext(b(j+1)))) AND 
      sign_ext(a(0))=-sig*sign_ext(b(0)) AND
      sign_ext(a(0))=-sign_ext(a(1)) AND
      sign_ext(b(0))= sign_ext(b(1)) AND
      (FORALL (j): j<=k IMPLIES (a(j)/=0 AND b(j)/=0))
      IMPLIES
        LET nsca = number_sign_changes(a,k)`num,
            nscb = number_sign_changes(b,k)`num
        IN  nsca = nscb + (IF k>=1 THEN 1 ELSE 0 ENDIF)


decl_type: function
theory: number_sign_changes
library: Sturm
signature: [[[nat -> real], nat] -> NSC]
location: 12 2 21 19
body:
    number_sign_changes(a,i): RECURSIVE NSC =
      IF i = 0 THEN (# num:= 0, lastnz:= a(0) #)
      ELSE LET prev = number_sign_changes(a,i-1)
           IN  IF a(i)/=0 AND prev`lastnz/=0 AND sign_ext(a(i))/=sign_ext(prev`lastnz)
                 THEN (# num:=prev`num+1,lastnz:=a(i) #)
               ELSIF a(i)/=0
                 THEN prev WITH [lastnz:=a(i)]
               ELSE prev
               ENDIF
      ENDIF MEASURE i


decl_type: function
theory: number_sign_changes
library: Sturm
location: 26 2 39 15
signature:
  [d: [[nat -> real], n: nat, subrange(1, 1 + n), nat, real] ->
          {m: nat |
                   d`4 = number_sign_changes(d`1, d`3 - 1)`num AND
                    d`5 = number_sign_changes(d`1, d`3 - 1)`lastnz
                    IMPLIES m = number_sign_changes(d`1, d`2)`num}]

body:
    sign_changes(a,n,(i:subrange(1,n+1)),num,lastnz) : RECURSIVE 
      {m: nat | LET nsci = number_sign_changes(a,i-1),
                    nscn = number_sign_changes(a,n) IN
                    num = nsci`num AND lastnz = nsci`lastnz IMPLIES
                    m = nscn`num} =
      IF i = n+1 THEN num
      ELSIF a(i)/=0 AND lastnz/=0 AND sign_ext(a(i))/=sign_ext(lastnz) THEN
        sign_changes(a,n,i+1,num+1,a(i))
      ELSIF a(i)/=0 THEN
        sign_changes(a,n,i+1,num,a(i))
      ELSE
        sign_changes(a,n,i+1,num,lastnz)
      ENDIF
    MEASURE n-i+1


decl_type: function
theory: number_sign_changes
library: Sturm
signature: [nat -> real]
location: 61 2 62 64
body:
    testseqaa5(i): real = IF i = 5 THEN 3 ELSIF i=6 
                   THEN 4 ELSIF i=7 THEN 0 ELSIF i=8 THEN -4 ELSE (-1)^i ENDIF


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 143 0 146 999
body:
  % Subtype TCC generated (at line 14, column 42) for  i - 1
      % expected type  nat
  number_sign_changes_TCC1: OBLIGATION
    FORALL (i: nat): NOT i = 0 IMPLIES i - 1 >= 0;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 148 0 151 999
body:
  % Termination TCC generated (at line 14, column 20) for
      % number_sign_changes(a, i - 1)
  number_sign_changes_TCC2: OBLIGATION
    FORALL (i: nat): NOT i = 0 IMPLIES i - 1 < i;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 153 0 156 999
body:
  % Subtype TCC generated (at line 27, column 47) for  i - 1
      % expected type  nat
  sign_changes_TCC1: OBLIGATION
    FORALL (n, (i: subrange(1, n + 1))): i - 1 >= 0;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 158 0 161 999
body:
  % Subtype TCC generated (at line 39, column 10) for  n - i + 1
      % expected type  naturalnumber
  sign_changes_TCC2: OBLIGATION
    FORALL (n: nat, (i: subrange(1, n + 1))): n - i + 1 >= 0;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 163 0 175 999
body:
  % Subtype TCC generated (at line 31, column 20) for  num
      % expected type  {m: nat |
                     %          num = number_sign_changes(a, i - 1)`num AND
                     %           lastnz =
                     %            number_sign_changes(a, i - 1)`lastnz
                     %           IMPLIES m = number_sign_changes(a, n)`num}
  sign_changes_TCC3: OBLIGATION
    FORALL (a: [nat -> real], n: nat, (i: subrange(1, n + 1)), num: nat,
            lastnz: real):
      i = n + 1 IMPLIES
       num = number_sign_changes(a, i - 1)`num AND
        lastnz = number_sign_changes(a, i - 1)`lastnz
        IMPLIES num = number_sign_changes(a, n)`num;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 177 0 183 999
body:
  % Subtype TCC generated (at line 33, column 23) for  i + 1
      % expected type  subrange(1, 1 + n)
  sign_changes_TCC4: OBLIGATION
    FORALL (a: [nat -> real], n: nat, (i: subrange(1, n + 1)), lastnz: real):
      a(i) /= 0 AND
       lastnz /= 0 AND sign_ext(a(i)) /= sign_ext(lastnz) AND NOT i = n + 1
       IMPLIES 1 <= i + 1 AND i + 1 <= 1 + n;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 185 0 191 999
body:
  % Termination TCC generated (at line 33, column 6) for
      % sign_changes(a, n, i + 1, num + 1, a(i))
  sign_changes_TCC5: OBLIGATION
    FORALL (a: [nat -> real], n: nat, (i: subrange(1, n + 1)), lastnz: real):
      a(i) /= 0 AND
       lastnz /= 0 AND sign_ext(a(i)) /= sign_ext(lastnz) AND NOT i = n + 1
       IMPLIES n - (i + 1) + 1 < n - i + 1;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 193 0 216 999
body:
  % Subtype TCC generated (at line 33, column 6) for
      % sign_changes(a, n, i + 1, num + 1, a(i))
      % expected type  {m: nat |
                     %          num = number_sign_changes(a, i - 1)`num AND
                     %           lastnz =
                     %            number_sign_changes(a, i - 1)`lastnz
                     %           IMPLIES m = number_sign_changes(a, n)`num}
  sign_changes_TCC6: OBLIGATION
    FORALL (a: [nat -> real], n: nat, (i: subrange(1, n + 1)),
            v:
              [d1:
                 {z: [[nat -> real], n: nat, subrange(1, 1 + n), nat, real] |
                          1 - z`3 + z`2 < 1 + n - i} ->
                 {m: nat |
                          d1`4 = number_sign_changes(d1`1, d1`3 - 1)`num AND
                           d1`5 = number_sign_changes(d1`1, d1`3 - 1)`lastnz
                           IMPLIES m = number_sign_changes(d1`1, d1`2)`num}],
            num: nat, lastnz: real):
      a(i) /= 0 AND
       lastnz /= 0 AND sign_ext(a(i)) /= sign_ext(lastnz) AND NOT i = n + 1
       IMPLIES
       num = number_sign_changes(a, i - 1)`num AND
        lastnz = number_sign_changes(a, i - 1)`lastnz
        IMPLIES v(a, n, i + 1, num + 1, a(i)) = number_sign_changes(a, n)`num;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 218 0 225 999
body:
  % Subtype TCC generated (at line 35, column 23) for  i + 1
      % expected type  subrange(1, 1 + n)
  sign_changes_TCC7: OBLIGATION
    FORALL (a: [nat -> real], n: nat, (i: subrange(1, n + 1)), lastnz: real):
      a(i) /= 0 AND
       NOT (a(i) /= 0 AND lastnz /= 0 AND sign_ext(a(i)) /= sign_ext(lastnz))
        AND NOT i = n + 1
       IMPLIES 1 <= i + 1 AND i + 1 <= 1 + n;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 227 0 234 999
body:
  % Termination TCC generated (at line 35, column 6) for
      % sign_changes(a, n, i + 1, num, a(i))
  sign_changes_TCC8: OBLIGATION
    FORALL (a: [nat -> real], n: nat, (i: subrange(1, n + 1)), lastnz: real):
      a(i) /= 0 AND
       NOT (a(i) /= 0 AND lastnz /= 0 AND sign_ext(a(i)) /= sign_ext(lastnz))
        AND NOT i = n + 1
       IMPLIES n - (i + 1) + 1 < n - i + 1;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 236 0 260 999
body:
  % Subtype TCC generated (at line 35, column 6) for
      % sign_changes(a, n, i + 1, num, a(i))
      % expected type  {m: nat |
                     %          num = number_sign_changes(a, i - 1)`num AND
                     %           lastnz =
                     %            number_sign_changes(a, i - 1)`lastnz
                     %           IMPLIES m = number_sign_changes(a, n)`num}
  sign_changes_TCC9: OBLIGATION
    FORALL (a: [nat -> real], n: nat, (i: subrange(1, n + 1)),
            v:
              [d1:
                 {z: [[nat -> real], n: nat, subrange(1, 1 + n), nat, real] |
                          1 - z`3 + z`2 < 1 + n - i} ->
                 {m: nat |
                          d1`4 = number_sign_changes(d1`1, d1`3 - 1)`num AND
                           d1`5 = number_sign_changes(d1`1, d1`3 - 1)`lastnz
                           IMPLIES m = number_sign_changes(d1`1, d1`2)`num}],
            num: nat, lastnz: real):
      a(i) /= 0 AND
       NOT (a(i) /= 0 AND lastnz /= 0 AND sign_ext(a(i)) /= sign_ext(lastnz))
        AND NOT i = n + 1
       IMPLIES
       num = number_sign_changes(a, i - 1)`num AND
        lastnz = number_sign_changes(a, i - 1)`lastnz
        IMPLIES v(a, n, i + 1, num, a(i)) = number_sign_changes(a, n)`num;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 262 0 269 999
body:
  % Subtype TCC generated (at line 37, column 23) for  i + 1
      % expected type  subrange(1, 1 + n)
  sign_changes_TCC10: OBLIGATION
    FORALL (a: [nat -> real], n: nat, (i: subrange(1, n + 1)), lastnz: real):
      NOT a(i) /= 0 AND
       NOT (a(i) /= 0 AND lastnz /= 0 AND sign_ext(a(i)) /= sign_ext(lastnz))
        AND NOT i = n + 1
       IMPLIES 1 <= i + 1 AND i + 1 <= 1 + n;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 271 0 278 999
body:
  % Termination TCC generated (at line 37, column 6) for
      % sign_changes(a, n, i + 1, num, lastnz)
  sign_changes_TCC11: OBLIGATION
    FORALL (a: [nat -> real], n: nat, (i: subrange(1, n + 1)), lastnz: real):
      NOT a(i) /= 0 AND
       NOT (a(i) /= 0 AND lastnz /= 0 AND sign_ext(a(i)) /= sign_ext(lastnz))
        AND NOT i = n + 1
       IMPLIES n - (i + 1) + 1 < n - i + 1;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 280 0 304 999
body:
  % Subtype TCC generated (at line 37, column 6) for
      % sign_changes(a, n, i + 1, num, lastnz)
      % expected type  {m: nat |
                     %          num = number_sign_changes(a, i - 1)`num AND
                     %           lastnz =
                     %            number_sign_changes(a, i - 1)`lastnz
                     %           IMPLIES m = number_sign_changes(a, n)`num}
  sign_changes_TCC12: OBLIGATION
    FORALL (a: [nat -> real], n: nat, (i: subrange(1, n + 1)),
            v:
              [d1:
                 {z: [[nat -> real], n: nat, subrange(1, 1 + n), nat, real] |
                          1 - z`3 + z`2 < 1 + n - i} ->
                 {m: nat |
                          d1`4 = number_sign_changes(d1`1, d1`3 - 1)`num AND
                           d1`5 = number_sign_changes(d1`1, d1`3 - 1)`lastnz
                           IMPLIES m = number_sign_changes(d1`1, d1`2)`num}],
            num: nat, lastnz: real):
      NOT a(i) /= 0 AND
       NOT (a(i) /= 0 AND lastnz /= 0 AND sign_ext(a(i)) /= sign_ext(lastnz))
        AND NOT i = n + 1
       IMPLIES
       num = number_sign_changes(a, i - 1)`num AND
        lastnz = number_sign_changes(a, i - 1)`lastnz
        IMPLIES v(a, n, i + 1, num, lastnz) = number_sign_changes(a, n)`num;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 306 0 309 999
body:
  % Subtype TCC generated (at line 42, column 52) for  1
      % expected type  subrange(1, 1 + i)
  num_sign_changes_def_TCC1: OBLIGATION
    FORALL (i: nat): 1 <= 1 AND 1 <= 1 + i;


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 311 0 319 999
body:
  % Subtype TCC generated (at line 81, column 32) for  j - 1
      % expected type  nat
  nsc_regular_swap_TCC1: OBLIGATION
    FORALL (a, b: [nat -> real], d, k: nat):
      k <= d IMPLIES
       (FORALL (j: nat):
               j > 0 AND a(j + 1) /= 0 AND sign_ext(a(j)) /= sign_ext(b(j))
           AND NOT sign_ext(a(j)) = sign_ext(b(j)) AND j <= k
           IMPLIES j - 1 >= 0);


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 321 0 331 999
body:
  % Subtype TCC generated (at line 97, column 55) for  j - 1
      % expected type  nat
  nsc_edge_diff_TCC1: OBLIGATION
    FORALL (a, b: [nat -> real], d, k: nat, sig: real):
      ((sig = -1 OR sig = 1) AND
        k <= d AND
         (FORALL (j):
            j <= k IMPLIES (sign_ext(a(j)) = sign_ext(b(j)) OR b(j) = 0)))
       IMPLIES
       (FORALL (j1: nat):
          0 < j1 AND j1 <= k AND b(j1) = 0 IMPLIES j1 - 1 >= 0);


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 333 0 346 999
body:
  % Subtype TCC generated (at line 101, column 67) for  j - 1
      % expected type  nat
  nsc_edge_diff_TCC2: OBLIGATION
    FORALL (a, b: [nat -> real], d, k: nat, sig: real):
           (sig = -1 OR sig = 1) AND k <= d
       AND FORALL (j):
             j <= k IMPLIES (sign_ext(a(j)) = sign_ext(b(j)) OR b(j) = 0)
       AND FORALL (j): 0 < j AND j <= k AND b(j) = 0 IMPLIES b(j - 1) /= 0
       AND sign_ext(a(k)) = sign_ext(b(k))
       AND FORALL (j: nat): j < k IMPLIES a(j) /= 0
       AND (b(0) = 0 IMPLIES sign_ext(a(0)) = sig * sign_ext(a(1)))
       IMPLIES
       (FORALL (j1: nat):
          0 < j1 AND j1 < k AND b(j1) = 0 IMPLIES j1 - 1 >= 0);


decl_type: tcc
theory: number_sign_changes
library: Sturm
signature: nil
location: 348 0 363 999
body:
  % Subtype TCC generated (at line 127, column 38) for  j - 1
      % expected type  nat
  nsc_multiroot_full_TCC1: OBLIGATION
    FORALL (a, b: [nat -> real], d, k: nat, sig: real,
            sigfun: [nat -> real]):
      (FORALL (j):
         0 < j AND j <= k IMPLIES
          sign_ext(a(j)) = sigfun(j) * sign_ext(b(j)))
       AND
       k <= d AND
        (FORALL (j): sigfun(j) = -1 OR sigfun(j) = 1) AND
         (sig = -1 OR sig = 1)
       IMPLIES
       (FORALL (j1: nat):
               j1 < k AND 1 < j1 AND 0 < j1 AND j1 <= k AND sigfun(j1) /= sig
           IMPLIES j1 - 1 >= 0);


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 27 2 32 54
body:
    constructed_sturm_seq_repeated_root: LEMMA 
      constructed_sturm_sequence?(p,n,m) IMPLIES
      FORALL (i:nat): i+1<=m AND
      polynomial(p(i),n(i))(x)=0 AND polynomial(p(i+1),n(i+1))(x)=0
      IMPLIES
      (FORALL (j:upto(m)): polynomial(p(j),n(j))(x) = 0)


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 34 2 40 42
body:
    constructed_sturm_seq_repeated_root_mth: LEMMA FORALL (mm:posnat):
      constructed_sturm_sequence?(p,n,m) AND
      max_linear_div_power?(p(0),n(0),y)(mm) AND
      i<m AND mm>1 IMPLIES
      FORALL (u:upto(i)): 
      EXISTS (kp:posnat): kp>=mm-1 AND
      max_linear_div_power?(p(u),n(u),y)(kp)


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 42 2 52 50
body:
    constructed_sturm_seq_repeated_root_struct: LEMMA
      constructed_sturm_sequence?(p,n,m) IMPLIES
      FORALL (i:nat): i+1<=m AND
      polynomial(p(i),n(i))(y)=0 AND polynomial(p(i+1),n(i+1))(y)=0
      IMPLIES
      EXISTS (mm:posnat): mm>1 AND max_linear_div_power?(p(0),n(0),y)(mm) AND
        (FORALL (j:nat): (1<=j AND j<m-1 AND
          (NOT max_linear_div_power?(p(j),n(j),y)(mm-1))) IMPLIES
          (1<j AND max_linear_div_power?(p(j-1),n(j-1),y)(mm-1) AND
                          max_linear_div_power?(p(j+1),n(j+1),y)(mm-1))) AND
        max_linear_div_power?(p(m-1),n(m-1),y)(mm-1)


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 58 2 68 92
body:
    constructed_sturm_seq_first_signs_eq: LEMMA
      x<b AND b<y AND 
      polynomial(p(0),n(0))(b)=0 AND
      (FORALL (c:real): x<=c AND c<=y AND polynomial(p(0),n(0))(c)=0 IMPLIES
        (polynomial(p(1),n(1))(c)/=0 AND c = b)) AND
      constructed_sturm_sequence?(p,n,m)
      IMPLIES
      ((x/=b IMPLIES polynomial(p(0),n(0))(x)/=0) AND
       (y/=b IMPLIES polynomial(p(0),n(0))(y)/=0) AND
       (x/=b IMPLIES sign_ext(polynomial(p(0),n(0))(x)) = -sign_ext(polynomial(p(1),n(1))(b))) AND
       (y/=b IMPLIES sign_ext(polynomial(p(0),n(0))(y)) = sign_ext(polynomial(p(1),n(1))(b))))


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 70 2 74 45
body:
    sturm_lem_no_roots: LEMMA
      x<y AND
      (FORALL (c:real,i:nat): i<=m AND x<=c AND c<=y IMPLIES polynomial(p(i),n(i))(c)/=0)
      IMPLIES
      sturm_sig(p,n,m)(x) = sturm_sig(p,n,m)(y)


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 76 2 85 89
body:
    constructed_sturm_lem_one_simple_root: LEMMA
      x<y AND x<b AND b<y AND
      (FORALL (c:real,i:nat): i<=m-1 AND x<=c AND c<=y AND polynomial(p(i),n(i))(c)=0
       IMPLIES c = b) AND
      (polynomial(p(0),n(0))(b)=0 IMPLIES polynomial(p(1),n(1))(b)/=0) AND
      constructed_sturm_sequence?(p,n,m)
      IMPLIES
      LET nsc = LAMBDA (xyz:real,pj:nat): number_sign_changes(LAMBDA (i): polynomial(p(i),n(i))(xyz),pj) IN
        sign_ext(nsc(x,m-1)`lastnz) = sign_ext(nsc(y,m-1)`lastnz) AND
        nsc(x,m-1)`num = nsc(y,m-1)`num+(IF polynomial(p(0),n(0))(b)=0 THEN 1 ELSE 0 ENDIF)


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 87 2 95 39
body:
    constructed_sturm_lem_one_multi_root: LEMMA
      x<y AND x<b AND b<y AND
      (FORALL (c:real,i:nat): i<=m-1 AND x<=c AND c<=y AND polynomial(p(i),n(i))(c)=0
       IMPLIES c = b) AND
      polynomial(p(0),n(0))(b)=0 AND polynomial(p(1),n(1))(b)=0 AND
      constructed_sturm_sequence?(p,n,m)
      IMPLIES
      LET nsc = LAMBDA (xyz:real,pj:nat): number_sign_changes(LAMBDA (i): polynomial(p(i),n(i))(xyz),pj) IN
        nsc(x,m-1)`num = nsc(y,m-1)`num+1


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 97 2 106 97
body:
    constructed_sturm_lem_edge_root: LEMMA
      x<y AND (x=b OR y=b) AND
      (FORALL (c:real,i:nat): i<=m-1 AND x<=c AND c<=y AND polynomial(p(i),n(i))(c)=0
       IMPLIES c = b) AND
      (polynomial(p(0),n(0))(b)=0 IMPLIES polynomial(p(1),n(1))(b)/=0) AND 
      constructed_sturm_sequence?(p,n,m)
      IMPLIES
      LET nsc = LAMBDA (xyz:real,pj:nat): number_sign_changes(LAMBDA (i): polynomial(p(i),n(i))(xyz),pj) IN
        sign_ext(nsc(x,m-1)`lastnz) = sign_ext(nsc(y,m-1)`lastnz) AND
        nsc(x,m-1)`num = nsc(y,m-1)`num+(IF b=y AND polynomial(p(0),n(0))(b)=0 THEN 1 ELSE 0 ENDIF)


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 108 2 114 38
body:
    constructed_sturm_roots_between_enum: LEMMA % THIS NEEDS TO BE FOR ALL P(i) NOT JUST P(0)
      x<y AND constructed_sturm_sequence?(p,n,m) IMPLIES
        EXISTS ((K:nat|K>=2),enum:[below(K)->real]):
          (FORALL (i,j:below(K)): i<j IMPLIES enum(i)<enum(j)) AND
          enum(0)=x AND enum(K-1)=y AND
          (FORALL (b:real,j:nat): j<=m-1 AND x<b AND b<=y AND polynomial(p(j),n(j))(b)=0 IMPLIES
            EXISTS (i:below(K)): b = enum(i))


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 116 2 123 49
body:
    constructed_sturm_lem_no_roots_full: LEMMA
      x<y AND
      (FORALL (c:real,i:nat): i<=m-1 AND x<c AND c<=y IMPLIES polynomial(p(i),n(i))(c)/=0) AND
      constructed_sturm_sequence?(p,n,m) AND
      (polynomial(p(0),n(0))(x)=0 IMPLIES
        polynomial(p(1),n(1))(x)/=0)
      IMPLIES
      sturm_sig(p,n,m-1)(x) = sturm_sig(p,n,m-1)(y)


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 125 2 134 26
body:
    sturm: LEMMA
      x<y AND
      constructed_sturm_sequence?(p,n,m) AND
      (polynomial(p(1),n(1))(x)/=0 OR polynomial(p(0),n(0))(x)/=0) AND
      (polynomial(p(1),n(1))(y)/=0 OR polynomial(p(0),n(0))(y)/=0)
      IMPLIES
        LET nsc = LAMBDA (xyz:real): number_sign_changes(LAMBDA (i): polynomial(p(i),n(i))(xyz),m-1),
            Nroots = nsc(x)`num-nsc(y)`num
        IN Nroots>=0 AND EXISTS (bij: [below(Nroots)->{xr:real|x<xr AND xr<=y AND polynomial(p(0),n(0))(xr)=0}]):
             bijective?(bij)


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 136 2 144 26
body:
    sturm_unbounded_left: LEMMA
      constructed_sturm_sequence?(p,n,m) AND
      (polynomial(p(1),n(1))(y)/=0 OR polynomial(p(0),n(0))(y)/=0)
      IMPLIES
        LET nscy    = number_sign_changes(LAMBDA (i): polynomial(p(i),n(i))(y),m-1),
            nscninf = number_sign_changes(LAMBDA (i): (-1)^(n(i))*p(i)(n(i)),m-1),
            Nroots  = nscninf`num-nscy`num
        IN Nroots>=0 AND EXISTS (bij: [below(Nroots)->{xr:real|xr<=y AND polynomial(p(0),n(0))(xr)=0}]):
             bijective?(bij)


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 146 2 154 26
body:
    sturm_unbounded_right: LEMMA
      constructed_sturm_sequence?(p,n,m) AND
      (polynomial(p(1),n(1))(x)/=0 OR polynomial(p(0),n(0))(x)/=0)
      IMPLIES
        LET nscx   = number_sign_changes(LAMBDA (i): polynomial(p(i),n(i))(x),m-1),
            nscinf = number_sign_changes(LAMBDA (i): p(i)(n(i)),m-1),
            Nroots = nscx`num-nscinf`num
        IN Nroots>=0 AND EXISTS (bij: [below(Nroots)->{xr:real|xr>x AND polynomial(p(0),n(0))(xr)=0}]):
             bijective?(bij)


decl_type: formula
theory: sturm
library: Sturm
signature: nil
location: 156 2 162 26
body:
    sturm_unbounded: LEMMA
      constructed_sturm_sequence?(p,n,m) IMPLIES
        LET nschigh = number_sign_changes(LAMBDA (i): p(i)(n(i)),m-1),
            nsclow  = number_sign_changes(LAMBDA (i): (-1)^(n(i))*p(i)(n(i)),m-1),
            Nroots  = nsclow`num-nschigh`num
        IN Nroots>=0 AND EXISTS (bij: [below(Nroots)->{xr:real|polynomial(p(0),n(0))(xr)=0}]):
             bijective?(bij)


decl_type: function
theory: sturm
library: Sturm
signature: [[[nat -> [nat -> real]], [nat -> nat], nat] -> bool]
location: 16 2 25 12
body:
    constructed_sturm_sequence?(p,n,m): bool =
      (FORALL (i:below(m)): p(i)(n(i))/=0) AND
      (FORALL (i,j:below(m)): i<j IMPLIES n(i)>n(j)) AND
      p(1) = poly_deriv(p(0)) AND n(1) = n(0)-1 AND
      n(m) = 0 AND p(m)(0) = 0 AND
      (FORALL (j:nat): j>1 AND j<=m IMPLIES LET pd = poly_divide(p(j-2),n(j-2))(p(j-1),n(j-1))(0) IN
                                             EXISTS (c:posreal): 
                                             polynomial(p(j),n(j)) = 
                                             polynomial(-c*pd`rem,pd`rdeg))
      AND m>=2


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 169 0 177 999
body:
  % Subtype TCC generated (at line 21, column 80) for  j - 1
      % expected type  nat
  constructed_sturm_sequence?_TCC1: OBLIGATION
    FORALL (p: [nat -> [nat -> real]], n: [nat -> nat], m: nat):
      (     p(m)(0) = 0 AND n(m) = 0 AND n(1) = n(0) - 1
        AND p(1) = poly_deriv(p(0))
        AND FORALL (i, j: below(m)): i < j IMPLIES n(i) > n(j)
        AND FORALL (i: below(m)): p(i)(n(i)) /= 0)
       IMPLIES (FORALL (j1: nat): j1 > 1 AND j1 <= m IMPLIES j1 - 1 >= 0);


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 179 0 189 999
body:
  % Subtype TCC generated (at line 21, column 85) for  n(j - 1)
      % expected type  {m | p(j - 1)(m) /= 0}
  constructed_sturm_sequence?_TCC2: OBLIGATION
    FORALL (p: [nat -> [nat -> real]], n: [nat -> nat], m: nat):
      (     p(m)(0) = 0 AND n(m) = 0 AND n(1) = n(0) - 1
        AND p(1) = poly_deriv(p(0))
        AND FORALL (i, j: below(m)): i < j IMPLIES n(i) > n(j)
        AND FORALL (i: below(m)): p(i)(n(i)) /= 0)
       IMPLIES
       (FORALL (j1: nat):
          j1 > 1 AND j1 <= m IMPLIES p(j1 - 1)(n(j1 - 1)) /= 0);


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 191 0 199 999
body:
  % Subtype TCC generated (at line 21, column 65) for  j - 2
      % expected type  nat
  constructed_sturm_sequence?_TCC3: OBLIGATION
    FORALL (p: [nat -> [nat -> real]], n: [nat -> nat], m: nat):
      (     p(m)(0) = 0 AND n(m) = 0 AND n(1) = n(0) - 1
        AND p(1) = poly_deriv(p(0))
        AND FORALL (i, j: below(m)): i < j IMPLIES n(i) > n(j)
        AND FORALL (i: below(m)): p(i)(n(i)) /= 0)
       IMPLIES (FORALL (j1: nat): j1 > 1 AND j1 <= m IMPLIES j1 - 2 >= 0);


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 201 0 214 999
body:
  % Subtype TCC generated (at line 49, column 48) for  mm - 1
      % expected type  posnat
  constructed_sturm_seq_repeated_root_struct_TCC1: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]], y: real):
      constructed_sturm_sequence?(p, n, m) IMPLIES
       (FORALL (i: nat):
          i + 1 <= m AND
           polynomial(p(i), n(i))(y) = 0 AND
            polynomial(p(i + 1), n(i + 1))(y) = 0
           IMPLIES
           (FORALL (mm: posnat):
              max_linear_div_power?(p(0), n(0), y)(mm) AND mm > 1 IMPLIES
               (FORALL (j: nat):
                  j < m - 1 AND 1 <= j IMPLIES mm - 1 >= 0 AND mm - 1 > 0)));


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 216 0 233 999
body:
  % Subtype TCC generated (at line 50, column 34) for  j - 1
      % expected type  nat
  constructed_sturm_seq_repeated_root_struct_TCC2: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]], y: real):
      constructed_sturm_sequence?(p, n, m) IMPLIES
       (FORALL (i: nat):
          i + 1 <= m AND
           polynomial(p(i), n(i))(y) = 0 AND
            polynomial(p(i + 1), n(i + 1))(y) = 0
           IMPLIES
           (FORALL (mm: posnat):
              max_linear_div_power?(p(0), n(0), y)(mm) AND mm > 1 IMPLIES
               (FORALL (j: nat):
                  1 < j AND
                   1 <= j AND
                    j < m - 1 AND
                     (NOT max_linear_div_power?(p(j), n(j), y)(mm - 1))
                   IMPLIES j - 1 >= 0)));


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 235 0 255 999
body:
  % Subtype TCC generated (at line 52, column 45) for  mm - 1
      % expected type  posnat
  constructed_sturm_seq_repeated_root_struct_TCC3: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]], y: real):
      constructed_sturm_sequence?(p, n, m) IMPLIES
       (FORALL (i: nat):
          i + 1 <= m AND
           polynomial(p(i), n(i))(y) = 0 AND
            polynomial(p(i + 1), n(i + 1))(y) = 0
           IMPLIES
           (FORALL (mm: posnat):
              (FORALL (j: nat):
                 (1 <= j AND
                   j < m - 1 AND
                    (NOT max_linear_div_power?(p(j), n(j), y)(mm - 1)))
                  IMPLIES
                  (1 < j AND
                    max_linear_div_power?(p(j - 1), n(j - 1), y)(mm - 1) AND
                     max_linear_div_power?(p(j + 1), n(j + 1), y)(mm - 1)))
               AND max_linear_div_power?(p(0), n(0), y)(mm) AND mm > 1
               IMPLIES mm - 1 >= 0 AND mm - 1 > 0));


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 257 0 277 999
body:
  % Subtype TCC generated (at line 52, column 30) for  m - 1
      % expected type  nat
  constructed_sturm_seq_repeated_root_struct_TCC4: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]], y: real):
      constructed_sturm_sequence?(p, n, m) IMPLIES
       (FORALL (i: nat):
          i + 1 <= m AND
           polynomial(p(i), n(i))(y) = 0 AND
            polynomial(p(i + 1), n(i + 1))(y) = 0
           IMPLIES
           (FORALL (mm: posnat):
              (FORALL (j: nat):
                 (1 <= j AND
                   j < m - 1 AND
                    (NOT max_linear_div_power?(p(j), n(j), y)(mm - 1)))
                  IMPLIES
                  (1 < j AND
                    max_linear_div_power?(p(j - 1), n(j - 1), y)(mm - 1) AND
                     max_linear_div_power?(p(j + 1), n(j + 1), y)(mm - 1)))
               AND max_linear_div_power?(p(0), n(0), y)(mm) AND mm > 1
               IMPLIES m - 1 >= 0));


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 279 0 298 999
body:
  % Subtype TCC generated (at line 84, column 21) for  m - 1
      % expected type  nat
  constructed_sturm_lem_one_simple_root_TCC1: OBLIGATION
    FORALL (b: real, m: nat, n: [nat -> nat], p: [nat -> [nat -> real]],
            x, y: real):
           constructed_sturm_sequence?(p, n, m)
       AND (polynomial(p(0), n(0))(b) = 0 IMPLIES
             polynomial(p(1), n(1))(b) /= 0)
       AND FORALL (c: real, i: nat):
             i <= m - 1 AND
              x <= c AND c <= y AND polynomial(p(i), n(i))(c) = 0
              IMPLIES c = b
       AND b < y AND x < b AND x < y
       IMPLIES
       (FORALL (nsc: [[real, nat] -> NSC]):
          (nsc =
            (LAMBDA (xyz: real, pj: nat):
               number_sign_changes(LAMBDA (i): polynomial(p(i), n(i))(xyz),
                                   pj)))
           IMPLIES m - 1 >= 0);


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 300 0 318 999
body:
  % Subtype TCC generated (at line 95, column 12) for  m - 1
      % expected type  nat
  constructed_sturm_lem_one_multi_root_TCC1: OBLIGATION
    FORALL (b: real, m: nat, n: [nat -> nat], p: [nat -> [nat -> real]],
            x, y: real):
           constructed_sturm_sequence?(p, n, m)
       AND polynomial(p(1), n(1))(b) = 0 AND polynomial(p(0), n(0))(b) = 0
       AND FORALL (c: real, i: nat):
             i <= m - 1 AND
              x <= c AND c <= y AND polynomial(p(i), n(i))(c) = 0
              IMPLIES c = b
       AND b < y AND x < b AND x < y
       IMPLIES
       (FORALL (nsc: [[real, nat] -> NSC]):
          (nsc =
            (LAMBDA (xyz: real, pj: nat):
               number_sign_changes(LAMBDA (i): polynomial(p(i), n(i))(xyz),
                                   pj)))
           IMPLIES m - 1 >= 0);


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 320 0 339 999
body:
  % Subtype TCC generated (at line 105, column 21) for  m - 1
      % expected type  nat
  constructed_sturm_lem_edge_root_TCC1: OBLIGATION
    FORALL (b: real, m: nat, n: [nat -> nat], p: [nat -> [nat -> real]],
            x, y: real):
           constructed_sturm_sequence?(p, n, m)
       AND (polynomial(p(0), n(0))(b) = 0 IMPLIES
             polynomial(p(1), n(1))(b) /= 0)
       AND FORALL (c: real, i: nat):
             i <= m - 1 AND
              x <= c AND c <= y AND polynomial(p(i), n(i))(c) = 0
              IMPLIES c = b
       AND (x = b OR y = b) AND x < y
       IMPLIES
       (FORALL (nsc: [[real, nat] -> NSC]):
          (nsc =
            (LAMBDA (xyz: real, pj: nat):
               number_sign_changes(LAMBDA (i): polynomial(p(i), n(i))(xyz),
                                   pj)))
           IMPLIES m - 1 >= 0);


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 341 0 348 999
body:
  % Subtype TCC generated (at line 112, column 8) for  0
      % expected type  below(K)
  constructed_sturm_roots_between_enum_TCC1: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]], x, y: real):
      constructed_sturm_sequence?(p, n, m) AND x < y IMPLIES
       (FORALL ((K: nat | K >= 2), enum: [below(K) -> real]):
          (FORALL (i, j: below(K)): i < j IMPLIES enum(i) < enum(j)) IMPLIES
           0 < K);


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 350 0 358 999
body:
  % Subtype TCC generated (at line 112, column 22) for  K - 1
      % expected type  below(K)
  constructed_sturm_roots_between_enum_TCC2: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]], x, y: real):
      constructed_sturm_sequence?(p, n, m) AND x < y IMPLIES
       (FORALL ((K: nat | K >= 2), enum: [below(K) -> real]):
          enum(0) = x AND
           (FORALL (i, j: below(K)): i < j IMPLIES enum(i) < enum(j))
           IMPLIES K - 1 >= 0 AND K - 1 < K);


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 360 0 371 999
body:
  % Subtype TCC generated (at line 123, column 18) for  m - 1
      % expected type  nat
  constructed_sturm_lem_no_roots_full_TCC1: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]], x, y: real):
      (polynomial(p(0), n(0))(x) = 0 IMPLIES polynomial(p(1), n(1))(x) /= 0)
       AND
       constructed_sturm_sequence?(p, n, m) AND
        (FORALL (c: real, i: nat):
           i <= m - 1 AND x < c AND c <= y IMPLIES
            polynomial(p(i), n(i))(c) /= 0)
         AND x < y
       IMPLIES m - 1 >= 0;


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 373 0 380 999
body:
  % Subtype TCC generated (at line 131, column 94) for  m - 1
      % expected type  nat
  sturm_TCC1: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]], x, y: real):
      (polynomial(p(1), n(1))(y) /= 0 OR polynomial(p(0), n(0))(y) /= 0) AND
       (polynomial(p(1), n(1))(x) /= 0 OR polynomial(p(0), n(0))(x) /= 0) AND
        constructed_sturm_sequence?(p, n, m) AND x < y
       IMPLIES m - 1 >= 0;


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 382 0 388 999
body:
  % Subtype TCC generated (at line 140, column 77) for  m - 1
      % expected type  nat
  sturm_unbounded_left_TCC1: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]], y: real):
      (polynomial(p(1), n(1))(y) /= 0 OR polynomial(p(0), n(0))(y) /= 0) AND
       constructed_sturm_sequence?(p, n, m)
       IMPLIES m - 1 >= 0;


decl_type: tcc
theory: sturm
library: Sturm
signature: nil
location: 390 0 394 999
body:
  % Subtype TCC generated (at line 158, column 63) for  m - 1
      % expected type  nat
  sturm_unbounded_TCC1: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]]):
      constructed_sturm_sequence?(p, n, m) IMPLIES m - 1 >= 0;


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 19 2 23 26
body:
    finite_bij_real_remove_one: LEMMA
      FORALL (m:nat,A:set[real],bij:[below(m)->(A)]):
        bijective?(bij) AND A(x) IMPLIES
         m-1>=0 AND EXISTS (bijec:[below(m-1)->{r:(A)|r/=x}]):
           bijective?(bijec)


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 25 2 29 26
body:
    finite_bij_real_remove_two: LEMMA
      FORALL (m:nat,A:set[real],bij:[below(m)->(A)]):
        bijective?(bij) AND A(x) AND A(y) AND x/=y IMPLIES
         m-2>=0 AND EXISTS (bijec:[below(m-2)->{r:(A)|r/=x AND r/=y}]):
           bijective?(bijec)


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 31 2 39 64
body:
    computed_sturm_spec: LEMMA a(n)/=0 AND (FORALL (i:nat): i>n IMPLIES a(i)=0) IMPLIES
      LET sl = sturm_chain(a,n),
          P: [nat->[nat->int]] = (LAMBDA (j:nat): IF j<length(sl) 
                                    THEN list2array[int](0)(nth(sl,length(sl)-1-j))
                                   ELSE (LAMBDA (i:nat): 0) ENDIF),
          N: [nat->nat] = (LAMBDA (j:nat): IF j<length(sl) 
                             THEN max(length(nth(sl,length(sl)-1-j))-1,0) ELSE 0 ENDIF),
          M: nat = length(sl)-1
      IN  constructed_sturm_sequence?(P,N,M) AND P(0)=a AND N(0)=n


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 80 2 83 81
body:
    roots_closed_int_def_truetrue: LEMMA FORALL (sl:(Eq_computed_remainder?(a,n))): a(n)/=0 AND x<y IMPLIES
          LET rootnum = roots_closed_int(a,n,x,y,true,true,sl),
              Aset = {z:real|x<=z AND z<=y AND polynomial(a,n)(z)=0}
          IN rootnum>=0 AND EXISTS (bij: [below(rootnum)->(Aset)]): bijective?(bij)


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 85 2 88 81
body:
    roots_closed_int_def_falsetrue: LEMMA FORALL (sl:(Eq_computed_remainder?(a,n))): a(n)/=0 AND x<y IMPLIES
          LET rootnum = roots_closed_int(a,n,x,y,false,true,sl),
              Aset = {z:real|z<=y AND polynomial(a,n)(z)=0}
          IN rootnum>=0 AND EXISTS (bij: [below(rootnum)->(Aset)]): bijective?(bij)


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 90 2 93 81
body:
    roots_closed_int_def_truefalse: LEMMA FORALL (sl:(Eq_computed_remainder?(a,n))): a(n)/=0 AND x<y IMPLIES
          LET rootnum = roots_closed_int(a,n,x,y,true,false,sl),
              Aset = {z:real|x<=z AND polynomial(a,n)(z)=0}
          IN rootnum>=0 AND EXISTS (bij: [below(rootnum)->(Aset)]): bijective?(bij)


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 95 2 98 81
body:
    roots_closed_int_def_falsefalse: LEMMA FORALL (sl:(Eq_computed_remainder?(a,n))): a(n)/=0 AND x<y IMPLIES
          LET rootnum = roots_closed_int(a,n,x,y,false,false,sl),
              Aset = {z:real| polynomial(a,n)(z)=0}
          IN rootnum>=0 AND EXISTS (bij: [below(rootnum)->(Aset)]): bijective?(bij)


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 101 2 106 81
body:
    roots_closed_int_def: LEMMA FORALL (sl:(Eq_computed_remainder?(a,n))): a(n)/=0 AND x<y IMPLIES
          LET rootnum = roots_closed_int(a,n,x,y,lower_bound,upper_bound,sl),
              Aset = {z:real|(lower_bound IMPLIES x<=z) 
                              AND (upper_bound IMPLIES z<=y)
                              AND polynomial(a,n)(z)=0}
          IN rootnum>=0 AND EXISTS (bij: [below(rootnum)->(Aset)]): bijective?(bij)


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 119 2 123 81
body:
    number_roots_interval_def: LEMMA FORALL (sl:(Eq_computed_remainder?(a,n))): a(n)/=0 AND I`lb<I`ub
             IMPLIES
          LET rootnum = number_roots_interval(a,n,I,sl),
              Aset = {z:real|contains?(I)(z) AND polynomial(a,n)(z)=0}
          IN rootnum>=0 AND EXISTS (bij: [below(rootnum)->(Aset)]): bijective?(bij)


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 155 2 157 69
body:
    always_nonnegative_def: LEMMA a(n)/=0 AND I`lb<I`ub IMPLIES
      (always_nonnegative(a,n,I) IFF
      (FORALL (x:real): contains?(I)(x) IMPLIES polynomial(a,n)(x)>=0))


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 203 2 205 78
body:
    compute_poly_sat_def: LEMMA a(n)/=0 AND I`lb<I`ub IMPLIES
      (compute_poly_sat(a,n,I,realord) IFF
       (FORALL (x:real): contains?(I)(x) IMPLIES realord(polynomial(a,n)(x),0)))


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 212 2 214 78
body:
    compute_poly_sat_rational_def: LEMMA aq(n)/=0 AND I`lb<I`ub IMPLIES
      (compute_poly_sat_rational(aq,n,I,realord) IFF
      (FORALL (x:real): contains?(I)(x) IMPLIES realord(polynomial(aq,n)(x),0)))


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 229 2 232 44
body:
    compute_poly_mono_basic_def: LEMMA aq(n)/=0 AND I`lb<I`ub IMPLIES
      ((FORALL (x,y:real): x<y AND contains?(I)(x) AND contains?(I)(y) IMPLIES
        realord(polynomial(aq,n)(x),polynomial(aq,n)(y))) IFF
      compute_poly_mono_basic(aq,n,I,realord))


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 243 2 245 46
body:
    poly_non_constant_real_int: LEMMA aq(n)/=0 AND I`lb<I`ub IMPLIES
      EXISTS (x,y:real): x<y AND contains?(I)(x) AND contains?(I)(y) AND
        polynomial(aq,n)(x)/=polynomial(aq,n)(y)


decl_type: formula
theory: compute_sturm
library: Sturm
signature: nil
location: 247 2 250 28
body:
    mono_def: LEMMA aq(n)/=0 AND I`lb<I`ub IMPLIES
      ((FORALL (x,y:real): ro(x,y) AND contains?(I)(x) AND contains?(I)(y) IMPLIES
        realord(polynomial(aq,n)(x),polynomial(aq,n)(y))) IFF
      mono(aq,n,I,ro,realord))


decl_type: function
theory: compute_sturm
library: Sturm
signature:
  [[a: [nat -> int], {n | a(n) /= 0}] ->
  [list[list[int]] -> bool]]

location: 42 2 43 70
body:
    Eq_computed_remainder?(a,(n|a(n)/=0))(sl:list[list[int]]): bool =
      sl = sturm_chain(LAMBDA (i:nat): IF i<=n THEN a(i) ELSE 0 ENDIF,n)


decl_type: function
theory: compute_sturm
library: Sturm
location: 51 2 77 22
signature:
  [[a: [nat -> int], n: {n | a(n) /= 0}, low: real,
         {high: real | low < high}, bool, bool,
         (Eq_computed_remainder?(a, n))] ->
          int]

body:
    roots_closed_int(a,(n|a(n)/=0),low:real,(high:real|low<high),lower_bound,upper_bound:bool,
                     sl:(Eq_computed_remainder?(a,n))): 
      int =
      LET newa       = (LAMBDA (i:nat): IF i<=n THEN a(i) ELSE 0 ENDIF),
          P: [nat->[nat->int]] = (LAMBDA (j:nat): IF j<length(sl) 
                                    THEN list2array[int](0)(nth(sl,length(sl)-1-j))
                                   ELSE (LAMBDA (i:nat): 0) ENDIF),
          N: [nat->nat] = (LAMBDA (j:nat): IF j<length(sl) 
                             THEN max(length(nth(sl,length(sl)-1-j))-1,0) ELSE 0 ENDIF),
          M: nat     = length(sl)-1,
          nscnorm    = LAMBDA (xyz:real): number_sign_changes(
                            LAMBDA (i:nat): polynomial(P(i),N(i))(xyz),M-1),
          nschighlow = LAMBDA (b:bool): IF b THEN number_sign_changes(LAMBDA (i:nat): P(i)(N(i)),M-1)
                                        ELSE number_sign_changes(LAMBDA (i:nat): (-1)^N(i)*P(i)(N(i)),M-1) ENDIF,
          newlow     = IF ((NOT lower_bound) OR polynomial(P(0),N(0))(low)/=0 
                                             OR polynomial(P(1),N(1))(low)/=0) THEN low
                       ELSE low-poly_rootless_width(a,n,low,TRUE)/2 ENDIF,
          newhigh    = IF ((NOT upper_bound) OR polynomial(P(0),N(0))(high)/=0 
                                             OR polynomial(P(1),N(1))(high)/=0) THEN high
                       ELSE high+poly_rootless_width(a,n,high,TRUE)/2 ENDIF,
          Nroots     = IF lower_bound and upper_bound THEN nscnorm(newlow)`num-nscnorm(newhigh)`num
                       ELSIF upper_bound THEN nschighlow(FALSE)`num-nscnorm(newhigh)`num
                       ELSIF lower_bound THEN nscnorm(newlow)`num-nschighlow(TRUE)`num
                       ELSE nschighlow(FALSE)`num-nschighlow(TRUE)`num ENDIF,
          adjlow     = IF lower_bound AND polynomial(P(0),N(0))(low)=0 AND polynomial(P(1),N(1))(low)/=0
                       THEN 1 ELSE 0 ENDIF
      IN Nroots + adjlow


decl_type: function
theory: compute_sturm
library: Sturm
location: 108 2 117 9
signature:
  [[a: [nat -> int], n: {n | a(n) /= 0}, RealInt,
         (Eq_computed_remainder?(a, n))] ->
          nat]

body:
    number_roots_interval(a,(n|a(n)/=0),I,(sl:(Eq_computed_remainder?(a,n)))): nat =
      IF I`lb >= I`ub THEN 0
      ELSE
        LET rootstotal = roots_closed_int(a,n,I`lb,I`ub,I`bounded_below,I`bounded_above,sl),
            adjlow     = IF I`bounded_below AND (NOT I`closed_below) AND polynomial(a,n)(I`lb)=0
                         THEN -1 ELSE 0 ENDIF,
            adjhigh    = IF I`bounded_above AND (NOT I`closed_above) AND polynomial(a,n)(I`ub)=0
                         THEN -1 ELSE 0 ENDIF
        IN rootstotal + adjlow + adjhigh
      ENDIF


decl_type: function
theory: compute_sturm
library: Sturm
location: 125 2 125 89
body: meas_fun_alw_nonneg(a,(n|a(n)/=0),x,y:real,sl:(Eq_computed_remainder?(a,n))):real = y-x
signature:
  [[a: [nat -> int], n: {n | a(n) /= 0}, real, real,
         (Eq_computed_remainder?(a, n))] ->
          real]


decl_type: function
theory: compute_sturm
library: Sturm
location: 127 2 137 69
signature:
  [d:
          [a: [nat -> int], n: {n | a(n) /= 0}, real, real,
           (Eq_computed_remainder?(a, n))] ->
          {bb: bool |
                   bb IFF
                    (FORALL (z: real):
                       d`3 <= z AND z <= d`4 IMPLIES
                        polynomial(d`1, d`2)(z) >= 0)}]

body:
    always_nonnegative_int(a,(n|a(n)/=0),x,y:real,(sl:(Eq_computed_remainder?(a,n)))): RECURSIVE {bb:bool|
      bb IFF FORALL (z:real): x<=z AND z<=y IMPLIES polynomial(a,n)(z)>=0} =
      IF x>y THEN TRUE
      ELSIF x=y THEN polynomial(a,n)(x)>=0
      ELSIF roots_closed_int(a,n,x,y,TRUE,TRUE,sl) <= 1 THEN
        polynomial(a,n)(x)>=0 AND polynomial(a,n)(y)>=0
      ELSE
        always_nonnegative_int(a,n,x,(x+y)/2,sl) AND
        always_nonnegative_int(a,n,(x+y)/2,y,sl)
      ENDIF
    MEASURE meas_fun_alw_nonneg BY real_ord_ep(min_poly_root_dist(a,n))


decl_type: function
theory: compute_sturm
library: Sturm
signature: [[a: [nat -> int], {n | a(n) /= 0}, {I | I`lb < I`ub}] -> bool]
location: 139 2 153 11
body:
    always_nonnegative(a,(n|a(n)/=0),(I|I`lb<I`ub)): bool =
      LET newa = (LAMBDA (i:nat): IF i<=n THEN a(i) ELSE 0 ENDIF),
          sl = sturm_chain(newa,n)
      IN
        IF I`bounded_below AND I`bounded_above 
          THEN always_nonnegative_int(a,n,I`lb,I`ub,sl)
        ELSE
          LET M = Knuth_poly_root_strict_bound(a,n) IN
            IF I`bounded_above THEN
              always_nonnegative_int(a,n,min(-M,I`ub-1),I`ub,sl)
            ELSIF I`bounded_below THEN
              always_nonnegative_int(a,n,I`lb,max(M,I`lb+1),sl)
            ELSE always_nonnegative_int(a,n,-M,M,sl)
            ENDIF
        ENDIF


decl_type: function
theory: compute_sturm
library: Sturm
signature: [[[real, real] -> bool] -> bool]
location: 161 2 162 37
body:
    SturmRel?(R): bool = (R = (<)) OR (R = (<=)) OR (R = (>)) OR (R = (>=))
                         OR (R = (/=[real]))


decl_type: function
theory: compute_sturm
library: Sturm
signature: [(SturmRel?) -> (SturmRel?)]
location: 168 2 174 8
body:
    swap(realord): (SturmRel?) =
            IF realord = (<) THEN >
            ELSIF realord = (<=) THEN >=
            ELSIF realord = (>) THEN <
            ELSIF realord = (>=) THEN <=
            ELSE (/=[real])
            ENDIF


decl_type: function
theory: compute_sturm
library: Sturm
signature:
  [[a: [nat -> int], {n | a(n) /= 0}, {I | I`lb < I`ub},
  (SturmRel?)] ->
  bool]

location: 194 2 201 9
body:
    compute_poly_sat(a,(n|a(n)/=0),(I|I`lb<I`ub),realord): bool =
      IF realord = (>=) THEN always_nonnegative(a,n,I)
      ELSIF realord = (<=) THEN always_nonnegative(-a,n,I)
      ELSE
        LET newa = (LAMBDA (i:nat): IF i<=n THEN a(i) ELSE 0 ENDIF),
            sl = sturm_chain(newa,n)
        IN number_roots_interval(a,n,I,sl)=0 AND realord(polynomial(a,n)((I`lb+I`ub)/2),0)
      ENDIF


decl_type: function
theory: compute_sturm
library: Sturm
signature:
  [[aq: [nat -> rat], {n | aq(n) /= 0}, {I | I`lb < I`ub},
  (SturmRel?)] ->
  bool]

location: 209 2 210 55
body:
    compute_poly_sat_rational(aq,(n|aq(n)/=0),(I|I`lb<I`ub),realord): bool =
      compute_poly_sat(rat_poly_to_int(aq,n),n,I,realord)


decl_type: function
theory: compute_sturm
library: Sturm
signature:
  [[aq: [nat -> rat], {n | aq(n) /= 0}, {I | I`lb < I`ub},
  (SturmRel?)] ->
  bool]

location: 218 2 227 9
body:
    compute_poly_mono_basic(aq,(n|aq(n)/=0),(I|I`lb<I`ub),realord): bool =
      IF n = 1 THEN realord(sign(aq(1))*I`lb,sign(aq(1))*I`ub)
      ELSIF (realord = (/=[real])) THEN
        compute_poly_sat_rational(poly_deriv(aq),n-1,I,>=) OR
        compute_poly_sat_rational(poly_deriv(aq),n-1,I,<=)
      ELSIF realord(I`lb,I`ub) THEN
        compute_poly_sat_rational(poly_deriv(aq),n-1,I,>=)
      ELSE
        compute_poly_sat_rational(poly_deriv(aq),n-1,I,<=)
      ENDIF


decl_type: function
theory: compute_sturm
library: Sturm
location: 234 2 241 9
signature:
  [[aq: [nat -> rat], {n | aq(n) /= 0}, {I | I`lb < I`ub},
         (SturmRel?), (SturmRel?)] ->
          bool]

body:
    mono(aq,(n|aq(n)/=0),(I|I`lb<I`ub),ro,realord): bool =
      IF ro(1,1) AND NOT realord(1,1) THEN FALSE
      ELSIF (ro=(<)) OR (ro=(<=)) THEN compute_poly_mono_basic(aq,n,I,realord)
      ELSIF (ro=(>)) OR (ro=(>=)) THEN compute_poly_mono_basic(aq,n,I,swap(realord))
      ELSIF NOT (realord=(/=[real])) THEN FALSE
      ELSE compute_poly_mono_basic(aq,n,I,realord)
           OR compute_poly_mono_basic(aq,n,I,swap(realord))
      ENDIF 


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 257 0 264 999
body:
  % Subtype TCC generated (at line 57, column 23) for  poly_deriv(a)
      % expected type  [nat -> int]
  computed_sturm_spec_TCC1: OBLIGATION
    FORALL (a: [nat -> int], n: posnat):
      (FORALL (i: nat): i > n IMPLIES a(i) = 0) AND a(n) /= 0 IMPLIES
       (FORALL (x1: nat):
          rational_pred(poly_deriv(a)(x1)) AND
           integer_pred(poly_deriv(a)(x1)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 266 0 271 999
body:
  % Subtype TCC generated (at line 57, column 37) for  n - 1
      % expected type  {m | poly_deriv(a)(m) /= 0}
  computed_sturm_spec_TCC2: OBLIGATION
    FORALL (a: [nat -> int], n: posnat):
      (FORALL (i: nat): i > n IMPLIES a(i) = 0) AND a(n) /= 0 IMPLIES
       n - 1 >= 0 AND poly_deriv(a)(n - 1) /= 0;


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 273 0 283 999
body:
  % Subtype TCC generated (at line 34, column 47) for  length(sl) - 1 - j
      % expected type  below[length[list[int]](sl)]
  computed_sturm_spec_TCC3: OBLIGATION
    FORALL (a: [nat -> int], n: posnat):
      (FORALL (i: nat): i > n IMPLIES a(i) = 0) AND a(n) /= 0 IMPLIES
       (FORALL (sl: list[list[int]]):
          sl = remainder_seq(a, n, poly_deriv(a), n - 1) IMPLIES
           (FORALL (j: nat):
              j < length(sl) IMPLIES
               length[list[int]](sl) - 1 - j >= 0 AND
                length[list[int]](sl) - 1 - j < length[list[int]](sl)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 285 0 308 999
body:
  % Subtype TCC generated (at line 37, column 25) for
      % max(length(nth(sl, length(sl) - 1 - j)) - 1, 0)
      % expected type  nat
  computed_sturm_spec_TCC4: OBLIGATION
    FORALL (a: [nat -> int], n: posnat):
      (FORALL (i: nat): i > n IMPLIES a(i) = 0) AND a(n) /= 0 IMPLIES
       (FORALL (sl: list[list[int]]):
          sl = remainder_seq(a, n, poly_deriv(a), n - 1) IMPLIES
           (FORALL (P: [nat -> [nat -> int]]):
              (P =
                (LAMBDA (j: nat):
                   IF j < length(sl)
                     THEN list2array[int](0)(nth(sl, length(sl) - 1 - j))
                   ELSE (LAMBDA (i: nat): 0)
                   ENDIF))
               IMPLIES
               (FORALL (j1: nat):
                  j1 < length(sl) IMPLIES
                   max(length[int]
                           (nth[list[int]]
                                (sl, length[list[int]](sl) - 1 - j1))
                        - 1,
                       0)
                    >= 0)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 310 0 332 999
body:
  % Subtype TCC generated (at line 38, column 10) for  length(sl) - 1
      % expected type  nat
  computed_sturm_spec_TCC5: OBLIGATION
    FORALL (a: [nat -> int], n: posnat):
      (FORALL (i: nat): i > n IMPLIES a(i) = 0) AND a(n) /= 0 IMPLIES
       (FORALL (sl: list[list[int]]):
          sl = remainder_seq(a, n, poly_deriv(a), n - 1) IMPLIES
           (FORALL (P: [nat -> [nat -> int]]):
              (P =
                (LAMBDA (j: nat):
                   IF j < length(sl)
                     THEN list2array[int](0)(nth(sl, length(sl) - 1 - j))
                   ELSE (LAMBDA (i: nat): 0)
                   ENDIF))
               IMPLIES
               (FORALL (N: [nat -> nat]):
                  (N =
                    (LAMBDA (j: nat):
                       IF j < length(sl)
                         THEN max(length(nth(sl, length(sl) - 1 - j)) - 1, 0)
                       ELSE 0
                       ENDIF))
                   IMPLIES length[list[int]](sl) - 1 >= 0)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 334 0 338 999
body:
  % Subtype TCC generated (at line 43, column 68) for  n
      % expected type  {n_1 | IF n_1 <= n THEN a(n_1) ELSE 0 ENDIF /= 0}
  Eq_computed_remainder?_TCC1: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0)):
      IF n <= n THEN a(n) ELSE 0 ENDIF /= 0;


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 340 0 352 999
body:
  % Subtype TCC generated (at line 57, column 23) for
      % poly_deriv(LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)
      % expected type  [nat -> int]
  Eq_computed_remainder?_TCC2: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0)):
      FORALL (x1: nat):
        rational_pred(poly_deriv(LAMBDA (i: nat):
                                   IF i <= n THEN a(i) ELSE 0 ENDIF)
                                (x1))
         AND
         integer_pred(poly_deriv(LAMBDA (i: nat):
                                   IF i <= n THEN a(i) ELSE 0 ENDIF)
                                (x1));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 354 0 365 999
body:
  % Subtype TCC generated (at line 57, column 37) for  n - 1
      % expected type  {m |
                     %          poly_deriv(LAMBDA
                     %                     (i: nat):
                     %                     IF i <= n THEN a(i) ELSE 0 ENDIF)
                     %                    (m)
                     %           /= 0}
  Eq_computed_remainder?_TCC3: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0)):
      n - 1 >= 0 AND
       poly_deriv(LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)(n - 1)
        /= 0;


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 367 0 377 999
body:
  % Subtype TCC generated (at line 56, column 58) for  length(sl) - 1 - j
      % expected type  below[length[list[int]](sl)]
  roots_closed_int_TCC1: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), low: real,
            (high: real | low < high), sl: (Eq_computed_remainder?(a, n)),
            newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       (FORALL (j: nat):
          j < length(sl) IMPLIES
           length[list[int]](sl) - 1 - j >= 0 AND
            length[list[int]](sl) - 1 - j < length[list[int]](sl));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 379 0 401 999
body:
  % Subtype TCC generated (at line 59, column 25) for
      % max(length(nth(sl, length(sl) - 1 - j)) - 1, 0)
      % expected type  nat
  roots_closed_int_TCC2: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), low: real,
            (high: real | low < high), sl: (Eq_computed_remainder?(a, n)),
            newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       (FORALL (P: [nat -> [nat -> int]]):
          (P =
            (LAMBDA (j: nat):
               IF j < length(sl)
                 THEN list2array[int](0)(nth(sl, length(sl) - 1 - j))
               ELSE (LAMBDA (i: nat): 0)
               ENDIF))
           IMPLIES
           (FORALL (j1: nat):
              j1 < length(sl) IMPLIES
               max(length[int]
                       (nth[list[int]](sl, length[list[int]](sl) - 1 - j1))
                    - 1,
                   0)
                >= 0));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 403 0 425 999
body:
  % Subtype TCC generated (at line 60, column 14) for  length(sl) - 1
      % expected type  nat
  roots_closed_int_TCC3: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), low: real,
            (high: real | low < high), sl: (Eq_computed_remainder?(a, n)),
            newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       (FORALL (P: [nat -> [nat -> int]]):
          (P =
            (LAMBDA (j: nat):
               IF j < length(sl)
                 THEN list2array[int](0)(nth(sl, length(sl) - 1 - j))
               ELSE (LAMBDA (i: nat): 0)
               ENDIF))
           IMPLIES
           (FORALL (N: [nat -> nat]):
              (N =
                (LAMBDA (j: nat):
                   IF j < length(sl)
                     THEN max(length(nth(sl, length(sl) - 1 - j)) - 1, 0)
                   ELSE 0
                   ENDIF))
               IMPLIES length[list[int]](sl) - 1 >= 0));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 427 0 450 999
body:
  % Subtype TCC generated (at line 62, column 62) for  M - 1
      % expected type  nat
  roots_closed_int_TCC4: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), low: real,
            (high: real | low < high), sl: (Eq_computed_remainder?(a, n)),
            newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       (FORALL (P: [nat -> [nat -> int]]):
          (P =
            (LAMBDA (j: nat):
               IF j < length(sl)
                 THEN list2array[int](0)(nth(sl, length(sl) - 1 - j))
               ELSE (LAMBDA (i: nat): 0)
               ENDIF))
           IMPLIES
           (FORALL (N: [nat -> nat]):
              (N =
                (LAMBDA (j: nat):
                   IF j < length(sl)
                     THEN max(length(nth(sl, length(sl) - 1 - j)) - 1, 0)
                   ELSE 0
                   ENDIF))
               IMPLIES
               (FORALL (M: nat): M = length(sl) - 1 IMPLIES M - 1 >= 0)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 452 0 501 999
body:
  % Subtype TCC generated (at line 67, column 44) for  TRUE
      % expected type  {nzb: bool | nzb IFF (EXISTS (i: upto(n)): a(i) /= 0)}
  roots_closed_int_TCC5: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), low: real,
            (high: real | low < high), lower_bound: bool,
            sl: (Eq_computed_remainder?(a, n)), newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       (FORALL (P: [nat -> [nat -> int]]):
          (P =
            (LAMBDA (j: nat):
               IF j < length(sl)
                 THEN list2array[int](0)(nth(sl, length(sl) - 1 - j))
               ELSE (LAMBDA (i: nat): 0)
               ENDIF))
           IMPLIES
           (FORALL (N: [nat -> nat]):
              (N =
                (LAMBDA (j: nat):
                   IF j < length(sl)
                     THEN max(length(nth(sl, length(sl) - 1 - j)) - 1, 0)
                   ELSE 0
                   ENDIF))
               IMPLIES
               (FORALL (M: nat):
                  M = length(sl) - 1 IMPLIES
                   (FORALL (nscnorm: [real -> NSC]):
                      (nscnorm =
                        (LAMBDA (xyz: real):
                           number_sign_changes(LAMBDA
                                               (i: nat):
                                               polynomial(P(i), N(i))(xyz),
                                               M - 1)))
                       IMPLIES
                       (FORALL (nschighlow: [bool -> NSC]):
                          (lower_bound AND
                            NOT polynomial(P(0), N(0))(low) /= 0 AND
                             NOT polynomial(P(1), N(1))(low) /= 0 AND
                              nschighlow =
                               (LAMBDA (b: bool):
                                  IF b
                                    THEN number_sign_changes
                                         (LAMBDA (i: nat): P(i)(N(i)), M - 1)
                                  ELSE number_sign_changes
                                       (LAMBDA
                                        (i: nat):
                                        (-1) ^ N(i) * P(i)(N(i)),
                                        M - 1)
                                  ENDIF))
                           IMPLIES
                           (TRUE IFF (EXISTS (i: upto(n)): a(i) /= 0)))))));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 503 0 569 999
body:
  % Subtype TCC generated (at line 70, column 46) for  TRUE
      % expected type  {nzb: bool | nzb IFF (EXISTS (i: upto(n)): a(i) /= 0)}
  roots_closed_int_TCC6: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), low: real,
            (high: real | low < high), lower_bound, upper_bound: bool,
            sl: (Eq_computed_remainder?(a, n)), newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       (FORALL (P: [nat -> [nat -> int]]):
          (P =
            (LAMBDA (j: nat):
               IF j < length(sl)
                 THEN list2array[int](0)(nth(sl, length(sl) - 1 - j))
               ELSE (LAMBDA (i: nat): 0)
               ENDIF))
           IMPLIES
           (FORALL (N: [nat -> nat]):
              (N =
                (LAMBDA (j: nat):
                   IF j < length(sl)
                     THEN max(length(nth(sl, length(sl) - 1 - j)) - 1, 0)
                   ELSE 0
                   ENDIF))
               IMPLIES
               (FORALL (M: nat):
                  M = length(sl) - 1 IMPLIES
                   (FORALL (nscnorm: [real -> NSC]):
                      (nscnorm =
                        (LAMBDA (xyz: real):
                           number_sign_changes(LAMBDA
                                               (i: nat):
                                               polynomial(P(i), N(i))(xyz),
                                               M - 1)))
                       IMPLIES
                       (FORALL (nschighlow: [bool -> NSC]):
                          (nschighlow =
                            (LAMBDA (b: bool):
                               IF b
                                 THEN number_sign_changes
                                      (LAMBDA (i: nat): P(i)(N(i)), M - 1)
                               ELSE number_sign_changes(LAMBDA
                                                        (i: nat):
                                                        (-1) ^ N(i)
                                                        *
                                                        P(i)(N(i)),
                                                        M - 1)
                               ENDIF))
                           IMPLIES
                           (FORALL (newlow: real):
                              upper_bound AND
                               NOT polynomial(P(0), N(0))(high) /= 0 AND
                                NOT polynomial(P(1), N(1))(high) /= 0 AND
                                 newlow =
                                  IF ((NOT lower_bound)
                                      OR
                                      polynomial(P(0), N(0))(low) /= 0
                                      OR
                                      polynomial(P(1), N(1))(low) /= 0)
                                    THEN low
                                  ELSE low
                                       -
                                       poly_rootless_width(a, n, low, TRUE)
                                       /
                                       2
                                  ENDIF
                               IMPLIES
                               (TRUE IFF
                                 (EXISTS (i: upto(n)): a(i) /= 0))))))));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 571 0 576 999
body:
  % Subtype TCC generated (at line 111, column 49) for  I`ub
      % expected type  {high: real | I`lb < high}
  number_roots_interval_TCC1: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), I: RealInt,
            (sl: (Eq_computed_remainder?(a, n)))):
      NOT I`lb >= I`ub IMPLIES I`lb < I`ub;


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 578 0 605 999
body:
  % Subtype TCC generated (at line 116, column 9) for
      % rootstotal + adjlow + adjhigh
      % expected type  nat
  number_roots_interval_TCC2: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), I: RealInt,
            (sl: (Eq_computed_remainder?(a, n)))):
      NOT I`lb >= I`ub IMPLIES
       (FORALL (rootstotal: int):
          rootstotal =
           roots_closed_int(a, n, I`lb, I`ub, I`bounded_below,
                            I`bounded_above, sl)
           IMPLIES
           (FORALL (adjlow: int):
              adjlow =
               IF I`bounded_below AND
                   (NOT I`closed_below) AND polynomial(a, n)(I`lb) = 0
                 THEN -1
               ELSE 0
               ENDIF
               IMPLIES
               (FORALL (adjhigh: int):
                  adjhigh =
                   IF I`bounded_above AND
                       (NOT I`closed_above) AND polynomial(a, n)(I`ub) = 0
                     THEN -1
                   ELSE 0
                   ENDIF
                   IMPLIES rootstotal + adjlow + adjhigh >= 0)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 607 0 613 999
body:
  % Well-founded TCC generated (at line 137, column 33) for
      % real_ord_ep(min_poly_root_dist(a, n))
      % for always_nonnegative_int
  always_nonnegative_int_TCC1: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0)):
      well_founded?(LAMBDA (x1: real, y1: real):
                      real_ord_ep(min_poly_root_dist(a, n))(x1, y1));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 615 0 627 999
body:
  % Subtype TCC generated (at line 129, column 16) for  TRUE
      % expected type  {bb: bool |
                     %          bb IFF
                     %           (FORALL (z: real):
                     %              x <= z AND z <= y IMPLIES
                     %               polynomial(a, n)(z) >= 0)}
  always_nonnegative_int_TCC2: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), x, y: real,
            (sl: (Eq_computed_remainder?(a, n)))):
      x > y IMPLIES
       (TRUE IFF
         (FORALL (z: real):
            x <= z AND z <= y IMPLIES polynomial(a, n)(z) >= 0));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 629 0 642 999
body:
  % Subtype TCC generated (at line 130, column 19) for
      % polynomial(a, n)(x) >= 0
      % expected type  {bb: bool |
                     %          bb IFF
                     %           (FORALL (z: real):
                     %              x <= z AND z <= y IMPLIES
                     %               polynomial(a, n)(z) >= 0)}
  always_nonnegative_int_TCC3: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), x, y: real,
            (sl: (Eq_computed_remainder?(a, n)))):
      x = y AND NOT x > y IMPLIES
       (polynomial(a, n)(x) >= 0 IFF
         (FORALL (z: real):
            x <= z AND z <= y IMPLIES polynomial(a, n)(z) >= 0));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 644 0 649 999
body:
  % Subtype TCC generated (at line 131, column 33) for  y
      % expected type  {high: real | x < high}
  always_nonnegative_int_TCC4: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), x, y: real,
            (sl: (Eq_computed_remainder?(a, n)))):
      NOT x = y AND NOT x > y IMPLIES x < y;


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 651 0 666 999
body:
  % Subtype TCC generated (at line 132, column 6) for
      % polynomial(a, n)(x) >= 0 AND polynomial(a, n)(y) >= 0
      % expected type  {bb: bool |
                     %          bb IFF
                     %           (FORALL (z: real):
                     %              x <= z AND z <= y IMPLIES
                     %               polynomial(a, n)(z) >= 0)}
  always_nonnegative_int_TCC5: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), x, y: real,
            (sl: (Eq_computed_remainder?(a, n)))):
      roots_closed_int(a, n, x, y, TRUE, TRUE, sl) <= 1 AND
       NOT x = y AND NOT x > y
       IMPLIES
       (polynomial(a, n)(x) >= 0 AND polynomial(a, n)(y) >= 0 IFF
         (FORALL (z: real):
            x <= z AND z <= y IMPLIES polynomial(a, n)(z) >= 0));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 668 0 678 999
body:
  % Termination TCC generated (at line 134, column 6) for
      % always_nonnegative_int(a, n, x, (x + y) / 2, sl)
  always_nonnegative_int_TCC6: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), x, y: real,
            (sl: (Eq_computed_remainder?(a, n)))):
      NOT roots_closed_int(a, n, x, y, TRUE, TRUE, sl) <= 1 AND
       NOT x = y AND NOT x > y
       IMPLIES
       real_ord_ep(min_poly_root_dist(a, n))
                  (meas_fun_alw_nonneg(a, n, x, (x + y) / 2, sl),
                   meas_fun_alw_nonneg(a, n, x, y, sl));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 680 0 705 999
body:
  % Termination TCC generated (at line 135, column 6) for
      % always_nonnegative_int(a, n, (x + y) / 2, y, sl)
  always_nonnegative_int_TCC7: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), x, y: real,
            (sl: (Eq_computed_remainder?(a, n))),
            v:
              [d1:
                 {z1:
                    [a: [nat -> int], n: {n | a(n) /= 0}, real, real,
                     (Eq_computed_remainder?(a, n))] |
                          real_ord_ep(min_poly_root_dist(a, n))
                                     (meas_fun_alw_nonneg(z1),
                                      meas_fun_alw_nonneg
                                      (a, n, x, y, sl))} ->
                 {bb: bool |
                          bb IFF
                           (FORALL (z: real):
                              d1`3 <= z AND z <= d1`4 IMPLIES
                               polynomial(d1`1, d1`2)(z) >= 0)}]):
      v(a, n, x, (x + y) / 2, sl) AND
       NOT roots_closed_int(a, n, x, y, TRUE, TRUE, sl) <= 1 AND
        NOT x = y AND NOT x > y
       IMPLIES
       real_ord_ep(min_poly_root_dist(a, n))
                  (meas_fun_alw_nonneg(a, n, (x + y) / 2, y, sl),
                   meas_fun_alw_nonneg(a, n, x, y, sl));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 707 0 737 999
body:
  % Subtype TCC generated (at line 134, column 6) for
      % always_nonnegative_int(a, n, x, (x + y) / 2, sl) AND
      %  always_nonnegative_int(a, n, (x + y) / 2, y, sl)
      % expected type  {bb: bool |
                     %          bb IFF
                     %           (FORALL (z: real):
                     %              x <= z AND z <= y IMPLIES
                     %               polynomial(a, n)(z) >= 0)}
  always_nonnegative_int_TCC8: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0), x, y: real,
            (sl: (Eq_computed_remainder?(a, n))),
            v:
              [d1:
                 {z1:
                    [a: [nat -> int], n: {n | a(n) /= 0}, real, real,
                     (Eq_computed_remainder?(a, n))] |
                          real_ord_ep(min_poly_root_dist(a, n))
                                     (meas_fun_alw_nonneg(z1),
                                      meas_fun_alw_nonneg
                                      (a, n, x, y, sl))} ->
                 {bb: bool |
                          bb IFF
                           (FORALL (z: real):
                              d1`3 <= z AND z <= d1`4 IMPLIES
                               polynomial(d1`1, d1`2)(z) >= 0)}]):
      NOT roots_closed_int(a, n, x, y, TRUE, TRUE, sl) <= 1 AND
       NOT x = y AND NOT x > y
       IMPLIES
       (v(a, n, x, (x + y) / 2, sl) AND v(a, n, (x + y) / 2, y, sl) IFF
         (FORALL (z: real):
            x <= z AND z <= y IMPLIES polynomial(a, n)(z) >= 0));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 739 0 745 999
body:
  % Subtype TCC generated (at line 141, column 30) for  n
      % expected type  {n | newa(n) /= 0}
  always_nonnegative_TCC1: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0),
            (I: RealInt | I`lb < I`ub), newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       newa(n) /= 0;


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 747 0 755 999
body:
  % Subtype TCC generated (at line 57, column 23) for  poly_deriv(newa)
      % expected type  [nat -> int]
  always_nonnegative_TCC2: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0),
            (I: RealInt | I`lb < I`ub), newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       (FORALL (x1: nat):
          rational_pred(poly_deriv(newa)(x1)) AND
           integer_pred(poly_deriv(newa)(x1)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 757 0 763 999
body:
  % Subtype TCC generated (at line 57, column 37) for  n - 1
      % expected type  {m | poly_deriv(newa)(m) /= 0}
  always_nonnegative_TCC3: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0),
            (I: RealInt | I`lb < I`ub), newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       n - 1 >= 0 AND poly_deriv(newa)(n - 1) /= 0;


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 765 0 775 999
body:
  % Subtype TCC generated (at line 144, column 50) for  sl
      % expected type  (Eq_computed_remainder?(a, n))
  always_nonnegative_TCC4: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0),
            (I: RealInt | I`lb < I`ub), newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       (FORALL (sl: list[list[int]]):
          I`bounded_below AND
           I`bounded_above AND
            sl = remainder_seq(newa, n, poly_deriv(newa), n - 1)
           IMPLIES Eq_computed_remainder?(a, n)(sl));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 777 0 793 999
body:
  % Subtype TCC generated (at line 148, column 52) for  sl
      % expected type  (Eq_computed_remainder?(a, n))
  always_nonnegative_TCC5: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0),
            (I: RealInt | I`lb < I`ub), newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       (FORALL (sl: list[list[int]]):
          NOT (I`bounded_below AND I`bounded_above) AND
           sl = remainder_seq(newa, n, poly_deriv(newa), n - 1)
           IMPLIES
           (FORALL (M:
                      {K: posreal |
                               FORALL (x: real):
                                 polynomial(a, n)(x) = 0 IMPLIES
                                  abs(x) < K}):
              I`bounded_above AND M = Knuth_poly_root_strict_bound(a, n)
               IMPLIES Eq_computed_remainder?(a, n)(sl)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 795 0 812 999
body:
  % Subtype TCC generated (at line 150, column 51) for  sl
      % expected type  (Eq_computed_remainder?(a, n))
  always_nonnegative_TCC6: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0),
            (I: RealInt | I`lb < I`ub), newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       (FORALL (sl: list[list[int]]):
          NOT (I`bounded_below AND I`bounded_above) AND
           sl = remainder_seq(newa, n, poly_deriv(newa), n - 1)
           IMPLIES
           (FORALL (M:
                      {K: posreal |
                               FORALL (x: real):
                                 polynomial(a, n)(x) = 0 IMPLIES
                                  abs(x) < K}):
              I`bounded_below AND
               NOT I`bounded_above AND M = Knuth_poly_root_strict_bound(a, n)
               IMPLIES Eq_computed_remainder?(a, n)(sl)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 814 0 831 999
body:
  % Subtype TCC generated (at line 151, column 40) for  sl
      % expected type  (Eq_computed_remainder?(a, n))
  always_nonnegative_TCC7: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0),
            (I: RealInt | I`lb < I`ub), newa: [nat -> int]):
      (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF)) IMPLIES
       (FORALL (sl: list[list[int]]):
          NOT (I`bounded_below AND I`bounded_above) AND
           sl = remainder_seq(newa, n, poly_deriv(newa), n - 1)
           IMPLIES
           (FORALL (M:
                      {K: posreal |
                               FORALL (x: real):
                                 polynomial(a, n)(x) = 0 IMPLIES
                                  abs(x) < K}):
              NOT I`bounded_below AND
               NOT I`bounded_above AND M = Knuth_poly_root_strict_bound(a, n)
               IMPLIES Eq_computed_remainder?(a, n)(sl)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 833 0 836 999
body:
  % Subtype TCC generated (at line 169, column 25) for  >
      % expected type  (SturmRel?)
  swap_TCC1: OBLIGATION
    FORALL (realord: (SturmRel?)): realord = (<) IMPLIES SturmRel?(>);


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 838 0 842 999
body:
  % Subtype TCC generated (at line 170, column 29) for  >=
      % expected type  (SturmRel?)
  swap_TCC2: OBLIGATION
    FORALL (realord: (SturmRel?)):
      realord = (<=) AND NOT realord = (<) IMPLIES SturmRel?(>=);


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 844 0 849 999
body:
  % Subtype TCC generated (at line 171, column 28) for  <
      % expected type  (SturmRel?)
  swap_TCC3: OBLIGATION
    FORALL (realord: (SturmRel?)):
      realord = (>) AND NOT realord = (<=) AND NOT realord = (<) IMPLIES
       SturmRel?(<);


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 851 0 857 999
body:
  % Subtype TCC generated (at line 172, column 29) for  <=
      % expected type  (SturmRel?)
  swap_TCC4: OBLIGATION
    FORALL (realord: (SturmRel?)):
      realord = (>=) AND
       NOT realord = (>) AND NOT realord = (<=) AND NOT realord = (<)
       IMPLIES SturmRel?(<=);


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 859 0 865 999
body:
  % Subtype TCC generated (at line 173, column 9) for  (/=[real])
      % expected type  (SturmRel?)
  swap_TCC5: OBLIGATION
    FORALL (realord: (SturmRel?)):
      NOT realord = (>=) AND
       NOT realord = (>) AND NOT realord = (<=) AND NOT realord = (<)
       IMPLIES SturmRel?((/=[real]));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 867 0 869 999
body:
  % Subtype TCC generated (at line 177, column 9) for  <
      % expected type  (SturmRel?)
  swap_lt_TCC1: OBLIGATION SturmRel?(<);


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 871 0 873 999
body:
  % Subtype TCC generated (at line 180, column 9) for  >
      % expected type  (SturmRel?)
  swap_gt_TCC1: OBLIGATION SturmRel?(>);


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 875 0 877 999
body:
  % Subtype TCC generated (at line 183, column 9) for  <=
      % expected type  (SturmRel?)
  swap_le_TCC1: OBLIGATION SturmRel?(<=);


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 879 0 881 999
body:
  % Subtype TCC generated (at line 186, column 9) for  >=
      % expected type  (SturmRel?)
  swap_ge_TCC1: OBLIGATION SturmRel?(>=);


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 883 0 885 999
body:
  % Subtype TCC generated (at line 189, column 9) for  /=[real]
      % expected type  (SturmRel?)
  swap_ne_TCC1: OBLIGATION SturmRel?(/=[real]);


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 887 0 893 999
body:
  % Subtype TCC generated (at line 196, column 49) for  -a
      % expected type  [nat -> int]
  compute_poly_sat_TCC1: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0),
            (I: RealInt | I`lb < I`ub), realord: (SturmRel?)):
      realord = (<=) AND NOT realord = (>=) IMPLIES
       (FORALL (x1: nat): rational_pred((-a)(x1)) AND integer_pred((-a)(x1)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 895 0 900 999
body:
  % Subtype TCC generated (at line 196, column 52) for  n
      % expected type  {n | (-a)(n) /= 0}
  compute_poly_sat_TCC2: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0),
            (I: RealInt | I`lb < I`ub), realord: (SturmRel?)):
      realord = (<=) AND NOT realord = (>=) IMPLIES (-a)(n) /= 0;


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 902 0 913 999
body:
  % Subtype TCC generated (at line 200, column 37) for  sl
      % expected type  (Eq_computed_remainder?(a, n))
  compute_poly_sat_TCC3: OBLIGATION
    FORALL (a: [nat -> int], (n: posnat | a(n) /= 0),
            (I: RealInt | I`lb < I`ub), realord: (SturmRel?)):
      NOT realord = (<=) AND NOT realord = (>=) IMPLIES
       (FORALL (newa: [nat -> int]):
          (newa = (LAMBDA (i: nat): IF i <= n THEN a(i) ELSE 0 ENDIF))
           IMPLIES
           (FORALL (sl: list[list[int]]):
              sl = remainder_seq(newa, n, poly_deriv(newa), n - 1) IMPLIES
               Eq_computed_remainder?(a, n)(sl)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 915 0 920 999
body:
  % Subtype TCC generated (at line 210, column 43) for  n
      % expected type  {n_1 | rat_poly_to_int(aq, n)(n_1) /= 0}
  compute_poly_sat_rational_TCC1: OBLIGATION
    FORALL (aq: [nat -> rat], (n: posnat | aq(n) /= 0),
            (I: RealInt | I`lb < I`ub), realord: (SturmRel?)):
      rat_poly_to_int(aq, n)(n) /= 0;


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 922 0 928 999
body:
  % Subtype TCC generated (at line 221, column 32) for  poly_deriv(aq)
      % expected type  [nat -> rat]
  compute_poly_mono_basic_TCC1: OBLIGATION
    FORALL (aq: [nat -> rat], (n: posnat | aq(n) /= 0),
            (I: RealInt | I`lb < I`ub), realord: (SturmRel?)):
      (realord = (/=[real])) AND NOT n = 1 IMPLIES
       (FORALL (x1: nat): rational_pred(poly_deriv(aq)(x1)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 930 0 936 999
body:
  % Subtype TCC generated (at line 221, column 47) for  n - 1
      % expected type  {n | poly_deriv(aq)(n) /= 0}
  compute_poly_mono_basic_TCC2: OBLIGATION
    FORALL (aq: [nat -> rat], (n: posnat | aq(n) /= 0),
            (I: RealInt | I`lb < I`ub), realord: (SturmRel?)):
      (realord = (/=[real])) AND NOT n = 1 IMPLIES
       n - 1 >= 0 AND n - 1 > 0 AND poly_deriv(aq)(n - 1) /= 0;


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 938 0 944 999
body:
  % Subtype TCC generated (at line 224, column 32) for  poly_deriv(aq)
      % expected type  [nat -> rat]
  compute_poly_mono_basic_TCC3: OBLIGATION
    FORALL (aq: [nat -> rat], (n: posnat | aq(n) /= 0),
            (I: RealInt | I`lb < I`ub), realord: (SturmRel?)):
      realord(I`lb, I`ub) AND NOT (realord = (/=[real])) AND NOT n = 1
       IMPLIES (FORALL (x1: nat): rational_pred(poly_deriv(aq)(x1)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 946 0 952 999
body:
  % Subtype TCC generated (at line 224, column 47) for  n - 1
      % expected type  {n | poly_deriv(aq)(n) /= 0}
  compute_poly_mono_basic_TCC4: OBLIGATION
    FORALL (aq: [nat -> rat], (n: posnat | aq(n) /= 0),
            (I: RealInt | I`lb < I`ub), realord: (SturmRel?)):
      realord(I`lb, I`ub) AND NOT (realord = (/=[real])) AND NOT n = 1
       IMPLIES n - 1 >= 0 AND n - 1 > 0 AND poly_deriv(aq)(n - 1) /= 0;


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 954 0 960 999
body:
  % Subtype TCC generated (at line 226, column 32) for  poly_deriv(aq)
      % expected type  [nat -> rat]
  compute_poly_mono_basic_TCC5: OBLIGATION
    FORALL (aq: [nat -> rat], (n: posnat | aq(n) /= 0),
            (I: RealInt | I`lb < I`ub), realord: (SturmRel?)):
      NOT realord(I`lb, I`ub) AND NOT (realord = (/=[real])) AND NOT n = 1
       IMPLIES (FORALL (x1: nat): rational_pred(poly_deriv(aq)(x1)));


decl_type: tcc
theory: compute_sturm
library: Sturm
signature: nil
location: 962 0 968 999
body:
  % Subtype TCC generated (at line 226, column 47) for  n - 1
      % expected type  {n | poly_deriv(aq)(n) /= 0}
  compute_poly_mono_basic_TCC6: OBLIGATION
    FORALL (aq: [nat -> rat], (n: posnat | aq(n) /= 0),
            (I: RealInt | I`lb < I`ub), realord: (SturmRel?)):
      NOT realord(I`lb, I`ub) AND NOT (realord = (/=[real])) AND NOT n = 1
       IMPLIES n - 1 >= 0 AND n - 1 > 0 AND poly_deriv(aq)(n - 1) /= 0;


decl_type: formula
theory: polylist
library: Sturm
signature: nil
location: 25 2 28 34
body:
    eval_polylist_times_x: LEMMA
      FORALL (deg:upfrom(length(pl))):
      eval_polylist(pl,deg-1,acc)(x)*x =
      eval_polylist(pl,deg,acc*x)(x)


decl_type: formula
theory: polylist
library: Sturm
signature: nil
location: 30 2 33 36
body:
    eval_polylist_remove_acc: LEMMA
      FORALL (deg:upfrom(length(pl)-1)):
      eval_polylist(pl,deg,acc)(x) =
      eval_polylist(pl,deg,0)(x) + acc


decl_type: formula
theory: polylist
library: Sturm
signature: nil
location: 134 2 136 49
body:
    polylist_eval_deg: LEMMA deg(pl)>0 IMPLIES
      polynomial(list2array[rat](0)(pl),length(pl)-1)(x) =
      polynomial(list2array[rat](0)(pl),deg(pl))(x)


decl_type: function
theory: polylist
library: Sturm
signature:
  [[pl: Polylist, upfrom(length(pl) - 1), real] ->
  [real -> real]]

location: 16 2 23 22
body:
    eval_polylist(pl:Polylist,deg:upfrom(length(pl)-1),acc:real)(x:real) : RECURSIVE real =
      LET newl = cdr(pl),
          thisco = car(pl),
          thisdeg = deg-length(pl)+1
      IN IF null?(newl) THEN acc+thisco*x^thisdeg
         ELSE eval_polylist(newl,deg,acc+thisco*x^thisdeg)(x)
         ENDIF
      MEASURE length(pl)


decl_type: function
theory: polylist
library: Sturm
location: 43 2 48 15
signature:
  [d: [rat, nat] ->
          {pl: Polylist |
                   length(pl) = 1 + d`2 AND
                    (FORALL (x: real):
                       polylist(pl)(x) = d`1 * x ^ d`2)}]

body:
    pmonom(c:rat,deg:nat): RECURSIVE {pl:Polylist|
                           length(pl)=deg+1 AND
                           FORALL (x:real): polylist(pl)(x) = c*x^deg} =
      IF deg=0 THEN pconst(c)
      ELSE cons(0,pmonom(c,deg-1)) ENDIF
      MEASURE deg


decl_type: function
theory: polylist
library: Sturm
location: 50 2 62 3
signature:
  [d: [Polylist, Polylist] ->
          {pql: Polylist |
                   FORALL (x):
                     polylist(pql)(x) =
                      polylist(d`1)(x) + polylist(d`2)(x)}]

body:
    psum(pl,ql) : RECURSIVE {pql:Polylist|
      FORALL (x): polylist(pql)(x) = polylist(pl)(x)+polylist(ql)(x)} =
      LET plcoeff = car(pl),
          qlcoeff = car(ql),
          newpl   = cdr(pl),
          newql   = cdr(ql)
      IN IF null?(newpl) THEN cons(plcoeff+qlcoeff,newql)
         ELSIF null?(newql) THEN cons(plcoeff+qlcoeff,newpl)
         ELSE cons(car(pl)+car(ql),psum(cdr(pl),cdr(ql)))
      ENDIF
    MEASURE length(pl)+length(ql)

    ;+(pl,ql) : MACRO Polylist = psum(pl,ql)


decl_type: function
theory: polylist
library: Sturm
location: 64 2 71 3
signature:
  [d: [rat, Polylist] ->
          {pql: Polylist |
                   length[rat](pql) = length[rat](d`2) AND
                    (FORALL (x):
                       polylist(pql)(x) = d`1 * polylist(d`2)(x))}]

body:
    pscal(c,pl): RECURSIVE {pql:Polylist|
      length[rat](pql)=length[rat](pl) AND 
      FORALL (x): polylist(pql)(x) = c*polylist(pl)(x)} =
      IF null?(cdr(pl)) THEN (: c*car(pl) :)
      ELSE cons(c*car(pl),pscal(c,cdr(pl))) ENDIF
      MEASURE length(pl)

    ;*(c,pl) : MACRO Polylist = pscal(c,pl)


decl_type: function
theory: polylist
library: Sturm
signature: [[Polylist, Polylist] -> Polylist]
location: 83 2 86 3
body:
    pprod(pl,ql) : Polylist =
      array2list[rat](length(pl)+length(ql)-1)(polynomial_prod(list2array[rat](0)(pl),length(pl)-1,
                                                        list2array[rat](0)(ql),length(ql)-1))
    ;*(pl,ql) : MACRO Polylist = pprod(pl,ql)


decl_type: function
theory: polylist
library: Sturm
signature: [[Polylist, nat] -> Polylist]
location: 88 2 95 3
body:
    ppow(pl,n): RECURSIVE Polylist =
      IF n = 0 THEN pconst(1)
      ELSIF n = 1 THEN pl
      ELSE pprod(pl,ppow(pl,n-1))
      ENDIF
    MEASURE n

    ;^(pl,n) : MACRO Polylist = ppow(pl,n)


decl_type: function
theory: polylist
library: Sturm
location: 103 2 119 28
signature:
  [pl: Polylist ->
          {degans: [# allzero: bool, maxnon: below(length(pl)) #] |
                   (degans`allzero IFF
                     (FORALL (j: below(length(pl))): nth(pl, j) = 0))
                    AND
                    (degans`allzero OR
                      (FORALL (j: below(length(pl))):
                         j > degans`maxnon IMPLIES nth(pl, j) = 0))
                     AND
                     (degans`allzero OR nth(pl, degans`maxnon) /= 0)}]

body:
    deg_rec(pl): RECURSIVE 
      {degans:[# allzero: bool,maxnon:below(length(pl)) #] |
        LET (dz,dmax)=(degans`allzero,degans`maxnon),
            len      =length(pl) 
        IN
          (dz IFF (FORALL (j:below(len)): nth(pl,j)=0)) AND
          (dz OR FORALL (j:below(len)): j>dmax IMPLIES nth(pl,j)=0) AND
          (dz OR nth(pl,dmax)/=0)} =
      IF null?(cdr(pl)) AND car(pl)=0 THEN (# allzero:=TRUE,maxnon:=0 #)
      ELSIF null?(cdr(pl)) THEN (# allzero:=FALSE,maxnon:=0 #)
      ELSE
        LET upans = deg_rec(cdr(pl)),
            upvalid=(NOT upans`allzero)
        IN  IF upvalid THEN (# allzero:=FALSE,maxnon:=1+upans`maxnon #)
            ELSIF car(pl)=0 THEN (# allzero:=TRUE,maxnon:=0 #)
            ELSE (# allzero:=FALSE,maxnon:=0 #) ENDIF
      ENDIF MEASURE length(pl)


decl_type: function
theory: polylist
library: Sturm
location: 122 2 127 51
signature:
  [pl: Polylist ->
          {d: below(length(pl)) |
                   (d > 0 IFF
                     (EXISTS (j: below(length(pl))):
                        j > 0 AND nth(pl, j) /= 0))
                    AND
                    (d > 0 IMPLIES
                      (FORALL (j: below(length(pl))):
                         j > d IMPLIES nth(pl, j) = 0))
                     AND (d > 0 IMPLIES nth(pl, d) /= 0)}]

body:
    deg(pl): {d:below(length(pl)) |
      (d>0 IFF EXISTS (j:below(length(pl))): j>0 AND nth(pl,j)/=0) AND
      (d>0 IMPLIES (FORALL (j:below(length(pl))): j>d IMPLIES nth(pl,j)=0)) AND
      (d>0 IMPLIES nth(pl,d)/=0)} =
      LET drec = deg_rec(pl) IN
        IF drec`allzero THEN 0 ELSE drec`maxnon ENDIF


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 173 0 183 999
body:
  % Subtype TCC generated (at line 20, column 40) for  thisdeg
      % expected type  {i: int | x /= 0 OR i >= 0}
  eval_polylist_TCC1: OBLIGATION
    FORALL (pl: Polylist, deg: upfrom(length[rat](pl) - 1), x: real,
            newl: list[rat]):
      newl = cdr(pl) IMPLIES
       (FORALL (thisco: rat):
          thisco = car(pl) IMPLIES
           (FORALL (thisdeg: int):
              null?(newl) AND thisdeg = deg - length(pl) + 1 IMPLIES
               x /= 0 OR thisdeg >= 0));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 185 0 194 999
body:
  % Subtype TCC generated (at line 21, column 26) for  newl
      % expected type  Polylist
  eval_polylist_TCC2: OBLIGATION
    FORALL (pl: Polylist, deg: upfrom(length[rat](pl) - 1), newl: list[rat]):
      newl = cdr(pl) IMPLIES
       (FORALL (thisco: rat):
          thisco = car(pl) IMPLIES
           (FORALL (thisdeg: int):
              NOT null?(newl) AND thisdeg = deg - length(pl) + 1 IMPLIES
               cons?[rat](newl)));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 196 0 205 999
body:
  % Subtype TCC generated (at line 21, column 31) for  deg
      % expected type  upfrom(length(newl) - 1)
  eval_polylist_TCC3: OBLIGATION
    FORALL (pl: Polylist, deg: upfrom(length[rat](pl) - 1), newl: list[rat]):
      newl = cdr(pl) IMPLIES
       (FORALL (thisco: rat):
          thisco = car(pl) IMPLIES
           (FORALL (thisdeg: int):
              NOT null?(newl) AND thisdeg = deg - length(pl) + 1 IMPLIES
               deg >= length[rat](newl) - 1));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 207 0 217 999
body:
  % Subtype TCC generated (at line 21, column 48) for  thisdeg
      % expected type  {i: int | x /= 0 OR i >= 0}
  eval_polylist_TCC4: OBLIGATION
    FORALL (pl: Polylist, deg: upfrom(length[rat](pl) - 1), x: real,
            newl: list[rat]):
      newl = cdr(pl) IMPLIES
       (FORALL (thisco: rat):
          thisco = car(pl) IMPLIES
           (FORALL (thisdeg: int):
              NOT null?(newl) AND thisdeg = deg - length(pl) + 1 IMPLIES
               x /= 0 OR thisdeg >= 0));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 219 0 228 999
body:
  % Termination TCC generated (at line 21, column 12) for
      % eval_polylist(newl, deg, acc + thisco * x ^ thisdeg)
  eval_polylist_TCC5: OBLIGATION
    FORALL (pl: Polylist, deg: upfrom(length[rat](pl) - 1), newl: list[rat]):
      newl = cdr(pl) IMPLIES
       (FORALL (thisco: rat):
          thisco = car(pl) IMPLIES
           (FORALL (thisdeg: int):
              NOT null?(newl) AND thisdeg = deg - length(pl) + 1 IMPLIES
               length[rat](newl) < length[rat](pl)));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 230 0 234 999
body:
  % Subtype TCC generated (at line 27, column 21) for  deg - 1
      % expected type  upfrom(length(pl) - 1)
  eval_polylist_times_x_TCC1: OBLIGATION
    FORALL (pl: Polylist, deg: upfrom(length[rat](pl))):
      deg - 1 >= length[rat](pl) - 1;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 236 0 240 999
body:
  % Subtype TCC generated (at line 28, column 21) for  deg
      % expected type  upfrom(length(pl) - 1)
  eval_polylist_times_x_TCC2: OBLIGATION
    FORALL (pl: Polylist, deg: upfrom(length[rat](pl))):
      deg >= length[rat](pl) - 1;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 242 0 248 999
body:
  % Subtype TCC generated (at line 36, column 23) for  (: 2, 3, 4 :)
      % expected type  list[rat]
  eval_polylist_test_TCC1: OBLIGATION
    every[number]
        (LAMBDA (x: number):
           number_field_pred(x) AND real_pred(x) AND rational_pred(x))
        ((: 2, 3, 4 :));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 250 0 252 999
body:
  % Subtype TCC generated (at line 36, column 32) for  3
      % expected type  upfrom(length((: 1, 2, 3, 4 :)) - 1)
  eval_polylist_test_TCC2: OBLIGATION 3 >= length[rat]((: 1, 2, 3, 4 :)) - 1;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 254 0 256 999
body:
  % Subtype TCC generated (at line 36, column 52) for  2
      % expected type  {i: int | x /= 0 OR i >= 0}
  eval_polylist_test_TCC3: OBLIGATION FORALL (x: real): x /= 0 OR 2 >= 0;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 258 0 260 999
body:
  % Subtype TCC generated (at line 36, column 58) for  3
      % expected type  {i: int | x /= 0 OR i >= 0}
  eval_polylist_test_TCC4: OBLIGATION FORALL (x: real): x /= 0 OR 3 >= 0;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 262 0 265 999
body:
  % Subtype TCC generated (at line 39, column 21) for  length(pl) - 1
      % expected type  upfrom(length(pl) - 1)
  polylist_TCC1: OBLIGATION
    FORALL (pl: Polylist): length[rat](pl) - 1 >= length[rat](pl) - 1;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 267 0 271 999
body:
  % Subtype TCC generated (at line 45, column 45) for  deg
      % expected type  {i: int | x /= 0 OR i >= 0}
  pmonom_TCC1: OBLIGATION
    FORALL (deg: nat, pl: Polylist):
      length(pl) = deg + 1 IMPLIES (FORALL (x: real): x /= 0 OR deg >= 0);


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 273 0 282 999
body:
  % Subtype TCC generated (at line 46, column 18) for  pconst(c)
      % expected type  {pl: Polylist |
                     %          length(pl) = 1 + deg AND
                     %           (FORALL (x: real):
                     %              polylist(pl)(x) = c * x ^ deg)}
  pmonom_TCC2: OBLIGATION
    FORALL (c: rat, deg: nat):
      deg = 0 IMPLIES
       length[rat](pconst(c)) = 1 + deg AND
        (FORALL (x: real): polylist(pconst(c))(x) = c * x ^ deg);


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 284 0 286 999
body:
  % Subtype TCC generated (at line 47, column 25) for  deg - 1
      % expected type  nat
  pmonom_TCC3: OBLIGATION FORALL (deg: nat): NOT deg = 0 IMPLIES deg - 1 >= 0;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 288 0 290 999
body:
  % Termination TCC generated (at line 47, column 16) for  pmonom(c, deg - 1)
  pmonom_TCC4: OBLIGATION
    FORALL (deg: nat): NOT deg = 0 IMPLIES deg - 1 < deg;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 292 0 309 999
body:
  % Subtype TCC generated (at line 47, column 9) for
      % cons(0, pmonom(c, deg - 1))
      % expected type  {pl: Polylist |
                     %          length(pl) = 1 + deg AND
                     %           (FORALL (x: real):
                     %              polylist(pl)(x) = c * x ^ deg)}
  pmonom_TCC5: OBLIGATION
    FORALL (c: rat, deg: nat,
            v:
              [d1: {z: [rat, nat] | z`2 < deg} ->
                 {pl: Polylist |
                          length(pl) = 1 + d1`2 AND
                           (FORALL (x: real):
                              polylist(pl)(x) = d1`1 * x ^ d1`2)}]):
      NOT deg = 0 IMPLIES
       length[rat](cons[rat](0, v(c, deg - 1))) = 1 + deg AND
        (FORALL (x: real):
           polylist(cons[rat](0, v(c, deg - 1)))(x) = c * x ^ deg);


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 311 0 328 999
body:
  % Subtype TCC generated (at line 56, column 28) for
      % cons(plcoeff + qlcoeff, newql)
      % expected type  {pql: Polylist |
                     %          FORALL (x):
                     %            polylist(pql)(x) =
                     %             polylist(pl)(x) + polylist(ql)(x)}
  psum_TCC1: OBLIGATION
    FORALL (pl: Polylist, ql: Polylist, plcoeff: rat):
      plcoeff = car(pl) IMPLIES
       (FORALL (qlcoeff: rat):
          qlcoeff = car(ql) IMPLIES
           (FORALL (newpl: list[rat]):
              newpl = cdr(pl) IMPLIES
               (FORALL (newql: list[rat]):
                  null?(newpl) AND newql = cdr(ql) IMPLIES
                   (FORALL (x):
                      polylist(cons[rat](plcoeff + qlcoeff, newql))(x) =
                       polylist(pl)(x) + polylist(ql)(x)))));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 330 0 348 999
body:
  % Subtype TCC generated (at line 57, column 31) for
      % cons(plcoeff + qlcoeff, newpl)
      % expected type  {pql: Polylist |
                     %          FORALL (x):
                     %            polylist(pql)(x) =
                     %             polylist(pl)(x) + polylist(ql)(x)}
  psum_TCC2: OBLIGATION
    FORALL (pl: Polylist, ql: Polylist, plcoeff: rat):
      plcoeff = car(pl) IMPLIES
       (FORALL (qlcoeff: rat):
          qlcoeff = car(ql) IMPLIES
           (FORALL (newpl: list[rat]):
              newpl = cdr(pl) IMPLIES
               (FORALL (newql: list[rat]):
                  null?(newql) AND NOT null?(newpl) AND newql = cdr(ql)
                   IMPLIES
                   (FORALL (x):
                      polylist(cons[rat](plcoeff + qlcoeff, newpl))(x) =
                       polylist(pl)(x) + polylist(ql)(x)))));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 350 0 361 999
body:
  % Subtype TCC generated (at line 58, column 38) for  cdr(pl)
      % expected type  Polylist
  psum_TCC3: OBLIGATION
    FORALL (pl: Polylist, ql: Polylist, plcoeff: rat):
      plcoeff = car(pl) IMPLIES
       (FORALL (qlcoeff: rat):
          qlcoeff = car(ql) IMPLIES
           (FORALL (newpl: list[rat]):
              newpl = cdr(pl) IMPLIES
               (FORALL (newql: list[rat]):
                  NOT null?(newql) AND NOT null?(newpl) AND newql = cdr(ql)
                   IMPLIES cons?[rat](cdr[rat](pl)))));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 363 0 374 999
body:
  % Subtype TCC generated (at line 58, column 46) for  cdr(ql)
      % expected type  Polylist
  psum_TCC4: OBLIGATION
    FORALL (pl: Polylist, ql: Polylist, plcoeff: rat):
      plcoeff = car(pl) IMPLIES
       (FORALL (qlcoeff: rat):
          qlcoeff = car(ql) IMPLIES
           (FORALL (newpl: list[rat]):
              newpl = cdr(pl) IMPLIES
               (FORALL (newql: list[rat]):
                  NOT null?(newql) AND NOT null?(newpl) AND newql = cdr(ql)
                   IMPLIES cons?[rat](cdr[rat](ql)))));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 376 0 389 999
body:
  % Termination TCC generated (at line 58, column 33) for
      % psum(cdr(pl), cdr(ql))
  psum_TCC5: OBLIGATION
    FORALL (pl: Polylist, ql: Polylist, plcoeff: rat):
      plcoeff = car(pl) IMPLIES
       (FORALL (qlcoeff: rat):
          qlcoeff = car(ql) IMPLIES
           (FORALL (newpl: list[rat]):
              newpl = cdr(pl) IMPLIES
               (FORALL (newql: list[rat]):
                  NOT null?(newql) AND NOT null?(newpl) AND newql = cdr(ql)
                   IMPLIES
                   length[rat](cdr[rat](pl)) + length[rat](cdr[rat](ql)) <
                    length[rat](pl) + length[rat](ql))));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 391 0 428 999
body:
  % Subtype TCC generated (at line 58, column 12) for
      % cons(car(pl) + car(ql), psum(cdr(pl), cdr(ql)))
      % expected type  {pql: Polylist |
                     %          FORALL (x):
                     %            polylist(pql)(x) =
                     %             polylist(pl)(x) + polylist(ql)(x)}
  psum_TCC6: OBLIGATION
    FORALL (pl: Polylist, ql: Polylist, plcoeff: rat):
      plcoeff = car(pl) IMPLIES
       (FORALL (qlcoeff: rat):
          qlcoeff = car(ql) IMPLIES
           (FORALL (newpl: list[rat]):
              newpl = cdr(pl) IMPLIES
               (FORALL (newql: list[rat]):
                  NOT null?(newql) AND NOT null?(newpl) AND newql = cdr(ql)
                   IMPLIES
                   (FORALL (x,
                            v:
                              [d1:
                                 {z: [Polylist, Polylist] |
                                          length[rat](z`1) + length[rat](z`2)
                                          <
                                          length[rat](pl)
                                          +
                                          length[rat](ql)} ->
                                 {pql: Polylist |
                                          FORALL
                                          (x_1: real):
                                          polylist(pql)(x_1)
                                          =
                                          polylist(d1`1)(x_1)
                                          +
                                          polylist(d1`2)(x_1)}]):
                      polylist(cons[rat]
                                   (car[rat](pl) + car[rat](ql),
                                    v(cdr[rat](pl), cdr[rat](ql))))
                              (x)
                       = polylist(pl)(x) + polylist(ql)(x)))));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 430 0 440 999
body:
  % Subtype TCC generated (at line 67, column 27) for  (: c * car(pl) :)
      % expected type  {pql: Polylist |
                     %          length[rat](pql) = length[rat](pl) AND
                     %           (FORALL (x):
                     %              polylist(pql)(x) = c * polylist(pl)(x))}
  pscal_TCC1: OBLIGATION
    FORALL (c: rat, pl: Polylist):
      null?(cdr(pl)) IMPLIES
       length[rat]((: c * car[rat](pl) :)) = length[rat](pl) AND
        (FORALL (x):
           polylist((: c * car[rat](pl) :))(x) = c * polylist(pl)(x));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 442 0 446 999
body:
  % Subtype TCC generated (at line 68, column 32) for  cdr(pl)
      % expected type  Polylist
  pscal_TCC2: OBLIGATION
    FORALL (pl: Polylist):
      NOT null?(cdr(pl)) IMPLIES cons?[rat](cdr[rat](pl));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 448 0 451 999
body:
  % Termination TCC generated (at line 68, column 24) for  pscal(c, cdr(pl))
  pscal_TCC3: OBLIGATION
    FORALL (pl: Polylist):
      NOT null?(cdr(pl)) IMPLIES length[rat](cdr[rat](pl)) < length[rat](pl);


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 453 0 474 999
body:
  % Subtype TCC generated (at line 68, column 9) for
      % cons(c * car(pl), pscal(c, cdr(pl)))
      % expected type  {pql: Polylist |
                     %          length[rat](pql) = length[rat](pl) AND
                     %           (FORALL (x):
                     %              polylist(pql)(x) = c * polylist(pl)(x))}
  pscal_TCC4: OBLIGATION
    FORALL (c: rat, pl: Polylist,
            v:
              [d1: {z: [rat, Polylist] | length(z`2) < length(pl)} ->
                 {pql: Polylist |
                          length[rat](pql) = length[rat](d1`2) AND
                           (FORALL (x):
                              polylist(pql)(x) =
                               d1`1 * polylist(d1`2)(x))}]):
      NOT null?(cdr(pl)) IMPLIES
       length[rat](cons[rat](c * car[rat](pl), v(c, cdr[rat](pl)))) =
        length[rat](pl)
        AND
        (FORALL (x):
           polylist(cons[rat](c * car[rat](pl), v(c, cdr[rat](pl))))(x) =
            c * polylist(pl)(x));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 476 0 478 999
body:
  % Subtype TCC generated (at line 84, column 84) for  length(pl) - 1
      % expected type  nat
  pprod_TCC1: OBLIGATION FORALL (pl: Polylist): length[rat](pl) - 1 >= 0;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 480 0 491 999
body:
  % Subtype TCC generated (at line 84, column 45) for
      % polynomial_prod(list2array[rat](0)(pl), length(pl) - 1,
      %                 list2array[rat](0)(ql), length(ql) - 1)
      % expected type  a: [nat -> rat]
  pprod_TCC2: OBLIGATION
    FORALL (pl: Polylist, ql: Polylist):
      FORALL (x1: nat):
        rational_pred(polynomial_prod(list2array[rat](0)(pl),
                                      length[rat](pl) - 1,
                                      list2array[rat](0)(ql),
                                      length[rat](ql) - 1)
                                     (x1));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 493 0 498 999
body:
  % Subtype TCC generated (at line 84, column 20) for
      % length(pl) + length(ql) - 1
      % expected type  n: nat
  pprod_TCC3: OBLIGATION
    FORALL (pl: Polylist, ql: Polylist):
      length[rat](pl) + length[rat](ql) - 1 >= 0;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 500 0 513 999
body:
  % Subtype TCC generated (at line 84, column 4) for
      % array2list[rat]
      %     (length(pl) + length(ql) - 1)
      %     (polynomial_prod(list2array[rat](0)(pl), length(pl) - 1,
      %                      list2array[rat](0)(ql), length(ql) - 1))
      % expected type  Polylist
  pprod_TCC4: OBLIGATION
    FORALL (pl: Polylist, ql: Polylist):
      cons?[rat]
          (array2list[rat]
               (length[rat](pl) + length[rat](ql) - 1)
               (polynomial_prod(list2array[rat](0)(pl), length[rat](pl) - 1,
                                list2array[rat](0)(ql),
                                length[rat](ql) - 1)));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 515 0 523 999
body:
  % Subtype TCC generated (at line 108, column 47) for  j
      % expected type  below[length[rat](pl)]
  deg_rec_TCC1: OBLIGATION
    FORALL (pl, degans: [# allzero: bool, maxnon: below(length[rat](pl)) #],
            dz: bool, dmax: below(length[rat](pl))):
      dmax = degans`maxnon AND dz = degans`allzero IMPLIES
       (FORALL (len: nat):
          len = length(pl) IMPLIES
           (FORALL (j: below(len)): j < length[rat](pl)));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 525 0 529 999
body:
  % Subtype TCC generated (at line 111, column 66) for  0
      % expected type  below(length(pl))
  deg_rec_TCC2: OBLIGATION
    FORALL (pl: Polylist):
      null?(cdr(pl)) AND car(pl) = 0 IMPLIES 0 < length[rat](pl);


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 531 0 550 999
body:
  % Subtype TCC generated (at line 111, column 41) for
      % (# allzero := TRUE, maxnon := 0 #)
      % expected type  {degans:
                     %    [# allzero: bool, maxnon: below(length(pl)) #] |
                     %          (degans`allzero IFF
                     %            (FORALL (j: below(length(pl))):
                     %               nth(pl, j) = 0))
                     %           AND
                     %           (degans`allzero OR
                     %             (FORALL (j: below(length(pl))):
                     %                j > degans`maxnon
                     %                IMPLIES
                     %                nth(pl, j) = 0))
                     %            AND
                     %            (degans`allzero OR
                     %              nth(pl, degans`maxnon) /= 0)}
  deg_rec_TCC3: OBLIGATION
    FORALL (pl: Polylist):
      null?(cdr(pl)) AND car(pl) = 0 IMPLIES
       (TRUE IFF (FORALL (j: below(length[rat](pl))): nth[rat](pl, j) = 0));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 552 0 557 999
body:
  % Subtype TCC generated (at line 112, column 56) for  0
      % expected type  below(length(pl))
  deg_rec_TCC4: OBLIGATION
    FORALL (pl: Polylist):
      null?(cdr(pl)) AND NOT (null?(cdr(pl)) AND car(pl) = 0) IMPLIES
       0 < length[rat](pl);


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 559 0 582 999
body:
  % Subtype TCC generated (at line 112, column 30) for
      % (# allzero := FALSE, maxnon := 0 #)
      % expected type  {degans:
                     %    [# allzero: bool, maxnon: below(length(pl)) #] |
                     %          (degans`allzero IFF
                     %            (FORALL (j: below(length(pl))):
                     %               nth(pl, j) = 0))
                     %           AND
                     %           (degans`allzero OR
                     %             (FORALL (j: below(length(pl))):
                     %                j > degans`maxnon
                     %                IMPLIES
                     %                nth(pl, j) = 0))
                     %            AND
                     %            (degans`allzero OR
                     %              nth(pl, degans`maxnon) /= 0)}
  deg_rec_TCC5: OBLIGATION
    FORALL (pl: Polylist):
      null?(cdr(pl)) AND NOT (null?(cdr(pl)) AND car(pl) = 0) IMPLIES
       (FALSE IFF (FORALL (j: below(length[rat](pl))): nth[rat](pl, j) = 0))
        AND
        (FORALL (j: below(length[rat](pl))):
           j > 0 IMPLIES nth[rat](pl, j) = 0)
         AND nth[rat](pl, 0) /= 0;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 584 0 619 999
body:
  % Subtype TCC generated (at line 116, column 52) for  1 + upans`maxnon
      % expected type  below(length(pl))
  deg_rec_TCC6: OBLIGATION
    FORALL (pl: Polylist,
            v:
              [pl1: {z: Polylist | length(z) < length(pl)} ->
                 {degans: [# allzero: bool, maxnon: below(length(pl1)) #] |
                          (degans`allzero IFF
                            (FORALL (j: below(length(pl1))):
                               nth(pl1, j) = 0))
                           AND
                           (degans`allzero OR
                             (FORALL (j: below(length(pl1))):
                                j > degans`maxnon IMPLIES nth(pl1, j) = 0))
                            AND
                            (degans`allzero OR
                              nth(pl1, degans`maxnon) /= 0)}]):
      NOT null?(cdr(pl)) AND NOT (null?(cdr(pl)) AND car(pl) = 0) IMPLIES
       (FORALL (upans:
                  {degans:
                     [# allzero: bool, maxnon: below(length(cdr(pl))) #] |
                           (degans`allzero IFF
                             (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                nth[rat](cdr[rat](pl), j) = 0))
                            AND
                            (degans`allzero OR
                              (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                 j > degans`maxnon IMPLIES
                                  nth[rat](cdr[rat](pl), j) = 0))
                             AND
                             (degans`allzero OR
                               nth[rat](cdr[rat](pl), degans`maxnon) /= 0)}):
          upans = v(cdr(pl)) IMPLIES
           (FORALL (upvalid: bool):
              upvalid AND upvalid = (NOT upans`allzero) IMPLIES
               1 + upans`maxnon < length[rat](pl)));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 621 0 675 999
body:
  % Subtype TCC generated (at line 116, column 26) for
      % (# allzero := FALSE, maxnon := 1 + upans`maxnon #)
      % expected type  {degans:
                     %    [# allzero: bool, maxnon: below(length(pl)) #] |
                     %          (degans`allzero IFF
                     %            (FORALL (j: below(length(pl))):
                     %               nth(pl, j) = 0))
                     %           AND
                     %           (degans`allzero OR
                     %             (FORALL (j: below(length(pl))):
                     %                j > degans`maxnon
                     %                IMPLIES
                     %                nth(pl, j) = 0))
                     %            AND
                     %            (degans`allzero OR
                     %              nth(pl, degans`maxnon) /= 0)}
  deg_rec_TCC7: OBLIGATION
    FORALL (pl: Polylist,
            v:
              [pl1: {z: Polylist | length(z) < length(pl)} ->
                 {degans: [# allzero: bool, maxnon: below(length(pl1)) #] |
                          (degans`allzero IFF
                            (FORALL (j: below(length(pl1))):
                               nth(pl1, j) = 0))
                           AND
                           (degans`allzero OR
                             (FORALL (j: below(length(pl1))):
                                j > degans`maxnon IMPLIES nth(pl1, j) = 0))
                            AND
                            (degans`allzero OR
                              nth(pl1, degans`maxnon) /= 0)}]):
      NOT null?(cdr(pl)) AND NOT (null?(cdr(pl)) AND car(pl) = 0) IMPLIES
       (FORALL (upans:
                  {degans:
                     [# allzero: bool, maxnon: below(length(cdr(pl))) #] |
                           (degans`allzero IFF
                             (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                nth[rat](cdr[rat](pl), j) = 0))
                            AND
                            (degans`allzero OR
                              (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                 j > degans`maxnon IMPLIES
                                  nth[rat](cdr[rat](pl), j) = 0))
                             AND
                             (degans`allzero OR
                               nth[rat](cdr[rat](pl), degans`maxnon) /= 0)}):
          upans = v(cdr(pl)) IMPLIES
           (FORALL (upvalid: bool):
              upvalid AND upvalid = (NOT upans`allzero) IMPLIES
               (FALSE IFF
                 (FORALL (j: below(length[rat](pl))): nth[rat](pl, j) = 0))
                AND
                (FORALL (j: below(length[rat](pl))):
                   j > 1 + upans`maxnon IMPLIES nth[rat](pl, j) = 0)
                 AND nth[rat](pl, 1 + upans`maxnon) /= 0));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 677 0 712 999
body:
  % Subtype TCC generated (at line 117, column 55) for  0
      % expected type  below(length(pl))
  deg_rec_TCC8: OBLIGATION
    FORALL (pl: Polylist,
            v:
              [pl1: {z: Polylist | length(z) < length(pl)} ->
                 {degans: [# allzero: bool, maxnon: below(length(pl1)) #] |
                          (degans`allzero IFF
                            (FORALL (j: below(length(pl1))):
                               nth(pl1, j) = 0))
                           AND
                           (degans`allzero OR
                             (FORALL (j: below(length(pl1))):
                                j > degans`maxnon IMPLIES nth(pl1, j) = 0))
                            AND
                            (degans`allzero OR
                              nth(pl1, degans`maxnon) /= 0)}]):
      NOT null?(cdr(pl)) AND NOT (null?(cdr(pl)) AND car(pl) = 0) IMPLIES
       (FORALL (upans:
                  {degans:
                     [# allzero: bool, maxnon: below(length(cdr(pl))) #] |
                           (degans`allzero IFF
                             (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                nth[rat](cdr[rat](pl), j) = 0))
                            AND
                            (degans`allzero OR
                              (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                 j > degans`maxnon IMPLIES
                                  nth[rat](cdr[rat](pl), j) = 0))
                             AND
                             (degans`allzero OR
                               nth[rat](cdr[rat](pl), degans`maxnon) /= 0)}):
          upans = v(cdr(pl)) IMPLIES
           (FORALL (upvalid: bool):
              car(pl) = 0 AND NOT upvalid AND upvalid = (NOT upans`allzero)
               IMPLIES 0 < length[rat](pl)));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 714 0 765 999
body:
  % Subtype TCC generated (at line 117, column 30) for
      % (# allzero := TRUE, maxnon := 0 #)
      % expected type  {degans:
                     %    [# allzero: bool, maxnon: below(length(pl)) #] |
                     %          (degans`allzero IFF
                     %            (FORALL (j: below(length(pl))):
                     %               nth(pl, j) = 0))
                     %           AND
                     %           (degans`allzero OR
                     %             (FORALL (j: below(length(pl))):
                     %                j > degans`maxnon
                     %                IMPLIES
                     %                nth(pl, j) = 0))
                     %            AND
                     %            (degans`allzero OR
                     %              nth(pl, degans`maxnon) /= 0)}
  deg_rec_TCC9: OBLIGATION
    FORALL (pl: Polylist,
            v:
              [pl1: {z: Polylist | length(z) < length(pl)} ->
                 {degans: [# allzero: bool, maxnon: below(length(pl1)) #] |
                          (degans`allzero IFF
                            (FORALL (j: below(length(pl1))):
                               nth(pl1, j) = 0))
                           AND
                           (degans`allzero OR
                             (FORALL (j: below(length(pl1))):
                                j > degans`maxnon IMPLIES nth(pl1, j) = 0))
                            AND
                            (degans`allzero OR
                              nth(pl1, degans`maxnon) /= 0)}]):
      NOT null?(cdr(pl)) AND NOT (null?(cdr(pl)) AND car(pl) = 0) IMPLIES
       (FORALL (upans:
                  {degans:
                     [# allzero: bool, maxnon: below(length(cdr(pl))) #] |
                           (degans`allzero IFF
                             (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                nth[rat](cdr[rat](pl), j) = 0))
                            AND
                            (degans`allzero OR
                              (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                 j > degans`maxnon IMPLIES
                                  nth[rat](cdr[rat](pl), j) = 0))
                             AND
                             (degans`allzero OR
                               nth[rat](cdr[rat](pl), degans`maxnon) /= 0)}):
          upans = v(cdr(pl)) IMPLIES
           (FORALL (upvalid: bool):
              car(pl) = 0 AND NOT upvalid AND upvalid = (NOT upans`allzero)
               IMPLIES
               (TRUE IFF
                 (FORALL (j: below(length[rat](pl))): nth[rat](pl, j) = 0))));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 767 0 803 999
body:
  % Subtype TCC generated (at line 118, column 34) for  0
      % expected type  below(length(pl))
  deg_rec_TCC10: OBLIGATION
    FORALL (pl: Polylist,
            v:
              [pl1: {z: Polylist | length(z) < length(pl)} ->
                 {degans: [# allzero: bool, maxnon: below(length(pl1)) #] |
                          (degans`allzero IFF
                            (FORALL (j: below(length(pl1))):
                               nth(pl1, j) = 0))
                           AND
                           (degans`allzero OR
                             (FORALL (j: below(length(pl1))):
                                j > degans`maxnon IMPLIES nth(pl1, j) = 0))
                            AND
                            (degans`allzero OR
                              nth(pl1, degans`maxnon) /= 0)}]):
      NOT null?(cdr(pl)) AND NOT (null?(cdr(pl)) AND car(pl) = 0) IMPLIES
       (FORALL (upans:
                  {degans:
                     [# allzero: bool, maxnon: below(length(cdr(pl))) #] |
                           (degans`allzero IFF
                             (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                nth[rat](cdr[rat](pl), j) = 0))
                            AND
                            (degans`allzero OR
                              (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                 j > degans`maxnon IMPLIES
                                  nth[rat](cdr[rat](pl), j) = 0))
                             AND
                             (degans`allzero OR
                               nth[rat](cdr[rat](pl), degans`maxnon) /= 0)}):
          upans = v(cdr(pl)) IMPLIES
           (FORALL (upvalid: bool):
              NOT car(pl) = 0 AND
               NOT upvalid AND upvalid = (NOT upans`allzero)
               IMPLIES 0 < length[rat](pl)));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 805 0 861 999
body:
  % Subtype TCC generated (at line 118, column 8) for
      % (# allzero := FALSE, maxnon := 0 #)
      % expected type  {degans:
                     %    [# allzero: bool, maxnon: below(length(pl)) #] |
                     %          (degans`allzero IFF
                     %            (FORALL (j: below(length(pl))):
                     %               nth(pl, j) = 0))
                     %           AND
                     %           (degans`allzero OR
                     %             (FORALL (j: below(length(pl))):
                     %                j > degans`maxnon
                     %                IMPLIES
                     %                nth(pl, j) = 0))
                     %            AND
                     %            (degans`allzero OR
                     %              nth(pl, degans`maxnon) /= 0)}
  deg_rec_TCC11: OBLIGATION
    FORALL (pl: Polylist,
            v:
              [pl1: {z: Polylist | length(z) < length(pl)} ->
                 {degans: [# allzero: bool, maxnon: below(length(pl1)) #] |
                          (degans`allzero IFF
                            (FORALL (j: below(length(pl1))):
                               nth(pl1, j) = 0))
                           AND
                           (degans`allzero OR
                             (FORALL (j: below(length(pl1))):
                                j > degans`maxnon IMPLIES nth(pl1, j) = 0))
                            AND
                            (degans`allzero OR
                              nth(pl1, degans`maxnon) /= 0)}]):
      NOT null?(cdr(pl)) AND NOT (null?(cdr(pl)) AND car(pl) = 0) IMPLIES
       (FORALL (upans:
                  {degans:
                     [# allzero: bool, maxnon: below(length(cdr(pl))) #] |
                           (degans`allzero IFF
                             (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                nth[rat](cdr[rat](pl), j) = 0))
                            AND
                            (degans`allzero OR
                              (FORALL (j: below(length[rat](cdr[rat](pl)))):
                                 j > degans`maxnon IMPLIES
                                  nth[rat](cdr[rat](pl), j) = 0))
                             AND
                             (degans`allzero OR
                               nth[rat](cdr[rat](pl), degans`maxnon) /= 0)}):
          upans = v(cdr(pl)) IMPLIES
           (FORALL (upvalid: bool):
              NOT car(pl) = 0 AND
               NOT upvalid AND upvalid = (NOT upans`allzero)
               IMPLIES
               (FALSE IFF
                 (FORALL (j: below(length[rat](pl))): nth[rat](pl, j) = 0))
                AND
                (FORALL (j: below(length[rat](pl))):
                   j > 0 IMPLIES nth[rat](pl, j) = 0)
                 AND nth[rat](pl, 0) /= 0));


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 863 0 896 999
body:
  % Subtype TCC generated (at line 127, column 27) for  0
      % expected type  {d: below(length(pl)) |
                     %          (d > 0 IFF
                     %            (EXISTS (j: below(length(pl))):
                     %               j > 0 AND nth(pl, j) /= 0))
                     %           AND
                     %           (d > 0 IMPLIES
                     %             (FORALL (j: below(length(pl))):
                     %                j > d IMPLIES nth(pl, j) = 0))
                     %            AND (d > 0 IMPLIES nth(pl, d) /= 0)}
  deg_TCC1: OBLIGATION
    FORALL (pl: Polylist,
            drec:
              {degans: [# allzero: bool, maxnon: below(length(pl)) #] |
                       (degans`allzero IFF
                         (FORALL (j: below(length[rat](pl))):
                            nth[rat](pl, j) = 0))
                        AND
                        (degans`allzero OR
                          (FORALL (j: below(length[rat](pl))):
                             j > degans`maxnon IMPLIES nth[rat](pl, j) = 0))
                         AND
                         (degans`allzero OR
                           nth[rat](pl, degans`maxnon) /= 0)}):
      drec`allzero AND drec = deg_rec(pl) IMPLIES
       ((0 > 0 IFF
          (EXISTS (j: below(length[rat](pl))):
             j > 0 AND nth[rat](pl, j) /= 0))
         AND
         (0 > 0 IMPLIES
           (FORALL (j: below(length[rat](pl))):
              j > 0 IMPLIES nth[rat](pl, j) = 0))
          AND (0 > 0 IMPLIES nth[rat](pl, 0) /= 0))
        AND 0 < length[rat](pl);


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 898 0 930 999
body:
  % Subtype TCC generated (at line 127, column 34) for  drec`maxnon
      % expected type  {d: below(length(pl)) |
                     %          (d > 0 IFF
                     %            (EXISTS (j: below(length(pl))):
                     %               j > 0 AND nth(pl, j) /= 0))
                     %           AND
                     %           (d > 0 IMPLIES
                     %             (FORALL (j: below(length(pl))):
                     %                j > d IMPLIES nth(pl, j) = 0))
                     %            AND (d > 0 IMPLIES nth(pl, d) /= 0)}
  deg_TCC2: OBLIGATION
    FORALL (pl: Polylist,
            drec:
              {degans: [# allzero: bool, maxnon: below(length(pl)) #] |
                       (degans`allzero IFF
                         (FORALL (j: below(length[rat](pl))):
                            nth[rat](pl, j) = 0))
                        AND
                        (degans`allzero OR
                          (FORALL (j: below(length[rat](pl))):
                             j > degans`maxnon IMPLIES nth[rat](pl, j) = 0))
                         AND
                         (degans`allzero OR
                           nth[rat](pl, degans`maxnon) /= 0)}):
      NOT drec`allzero AND drec = deg_rec(pl) IMPLIES
       (drec`maxnon > 0 IFF
         (EXISTS (j: below(length[rat](pl))):
            j > 0 AND nth[rat](pl, j) /= 0))
        AND
        (drec`maxnon > 0 IMPLIES
          (FORALL (j: below(length[rat](pl))):
             j > drec`maxnon IMPLIES nth[rat](pl, j) = 0))
         AND (drec`maxnon > 0 IMPLIES nth[rat](pl, drec`maxnon) /= 0);


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 932 0 934 999
body:
  % Subtype TCC generated (at line 142, column 35) for  n
      % expected type  {i: int | x /= 0 OR i >= 0}
  polylist_monom_TCC1: OBLIGATION FORALL (n: nat, x: real): x /= 0 OR n >= 0;


decl_type: tcc
theory: polylist
library: Sturm
signature: nil
location: 936 0 939 999
body:
  % Subtype TCC generated (at line 157, column 40) for  n
      % expected type  {i: int | polylist(pl)(x) /= 0 OR i >= 0}
  polylist_pow_TCC1: OBLIGATION
    FORALL (n: nat, pl: Polylist, x: real): polylist(pl)(x) /= 0 OR n >= 0;


decl_type: formula
theory: poly_strategy
library: Sturm
signature: nil
location: 14 2 19 75
body:
    sturm_def: LEMMA 
      I`lb<I`ub AND 
      (deg(pl)>0 OR (EXISTS (j:below(length(pl))):j>0 AND nth(pl,j)/=0))
      IMPLIES
      (sturm(pl,I,realord) IFF
       (FORALL (x:real): contains?(I)(x) IMPLIES realord(polylist(pl)(x),0)))


decl_type: function
theory: poly_strategy
library: Sturm
signature: [[{pl | deg(pl) > 0}, {I | I`lb < I`ub}, (SturmRel?)] -> bool]
location: 11 2 12 71
body:
    sturm((pl|deg(pl)>0),(I|I`lb<I`ub),realord): bool =
      compute_poly_sat_rational(list2array[rat](0)(pl),deg(pl),I,realord)


decl_type: tcc
theory: poly_strategy
library: Sturm
signature: nil
location: 26 0 31 999
body:
  % Subtype TCC generated (at line 12, column 53) for  deg(pl)
      % expected type  {n | list2array[rat](0)(pl)(n) /= 0}
  sturm_TCC1: OBLIGATION
    FORALL ((pl: Polylist | deg(pl) > 0), (I: RealInt | I`lb < I`ub),
            realord: (SturmRel?)):
      deg(pl) > 0 AND list2array[rat](0)(pl)(deg(pl)) /= 0;


decl_type: tcc
theory: poly_strategy
library: Sturm
signature: nil
location: 33 0 40 999
body:
  % Subtype TCC generated (at line 18, column 11) for  pl
      % expected type  {pl | deg(pl) > 0}
  sturm_def_TCC1: OBLIGATION
    FORALL (I: RealInt, pl: Polylist):
      (deg(pl) > 0 OR
        (EXISTS (j: below(length(pl))): j > 0 AND nth(pl, j) /= 0))
       AND I`lb < I`ub
       IMPLIES deg(pl) > 0;


decl_type: formula
theory: examples
library: Sturm
signature: nil
location: 20 1 22 53
body:
   example_3: LEMMA 
    (x^16-x^15-3*x^13+x^12-x^11+2*x^10-6*x^9+8*x^8 
     -7*x^7-6*x^6+5*x^5+4*x^4-3*x^3+350*x + 478)^2 /= 0


decl_type: formula
theory: examples
library: Sturm
signature: nil
location: 117 2 123 31
body:
    legendre : LEMMA
      abs(x) < 1 IMPLIES
      3969/65536 + 63063/4096 * x^6 + 1792791/4096 * x^10 +
      3002285/4096 * x^18 + 6600165/4096 * x^14
      - 72765/65536 * x^4 - 3558555/32768 * x^8
      - 10207769/65536 * x^20 - 35043645/32768 * x^12
      - 95851899/65536 * x^16 > 0


decl_type: formula
theory: examples
library: Sturm
signature: nil
location: 128 2 134 35
body:
    legendre3 : LEMMA
      abs(x) < 1 IMPLIES
      (3969/65536 + 63063/4096 * x^6 + 1792791/4096 * x^10 +
       3002285/4096 * x^18 + 6600165/4096 * x^14
       - 72765/65536 * x^4 - 3558555/32768 * x^8
       - 10207769/65536 * x^20 - 35043645/32768 * x^12
       - 95851899/65536 * x^16)^3 > 0


decl_type: formula
theory: examples
library: Sturm
signature: nil
location: 181 2 182 80
body:
    mono_example_1 : LEMMA
      FORALL (x,y:real) : x >= 1 AND x < y IMPLIES (x-1/4)^2 <= y*y-(1/2)*y+(1/16)


decl_type: formula
theory: examples
library: Sturm
signature: nil
location: 193 2 195 31
body:
    mono_example_3: LEMMA
      FORALL (x,y:real) : 0.4 <= x AND x < y AND y <= 0.6 IMPLIES
      x^5-x^3+x/5>y*(y^4-y^2+1/5)


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 223 0 225 999
body:
  % Subtype TCC generated (at line 9, column 17) for  2
      % expected type  {i: int | NOT (x - 1/2) = 0 OR i >= 0}
  example_1_TCC1: OBLIGATION FORALL (x: real): NOT (x - 1/2) = 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 227 0 229 999
body:
  % Subtype TCC generated (at line 9, column 25) for  4
      % expected type  {i: int | (x - 9) /= 0 OR i >= 0}
  example_1_TCC2: OBLIGATION FORALL (x: real): (x - 9) /= 0 OR 4 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 231 0 233 999
body:
  % Subtype TCC generated (at line 9, column 35) for  2
      % expected type  {i: int | NOT (x + 17/2) = 0 OR i >= 0}
  example_1_TCC3: OBLIGATION FORALL (x: real): NOT (x + 17/2) = 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 235 0 237 999
body:
  % Subtype TCC generated (at line 21, column 5) for  16
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC1: OBLIGATION FORALL (x: real): x /= 0 OR 16 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 239 0 241 999
body:
  % Subtype TCC generated (at line 21, column 10) for  15
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC2: OBLIGATION FORALL (x: real): x /= 0 OR 15 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 243 0 245 999
body:
  % Subtype TCC generated (at line 21, column 17) for  13
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC3: OBLIGATION FORALL (x: real): x /= 0 OR 13 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 247 0 249 999
body:
  % Subtype TCC generated (at line 21, column 22) for  12
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC4: OBLIGATION FORALL (x: real): x /= 0 OR 12 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 251 0 253 999
body:
  % Subtype TCC generated (at line 21, column 27) for  11
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC5: OBLIGATION FORALL (x: real): x /= 0 OR 11 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 255 0 257 999
body:
  % Subtype TCC generated (at line 21, column 34) for  10
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC6: OBLIGATION FORALL (x: real): x /= 0 OR 10 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 259 0 261 999
body:
  % Subtype TCC generated (at line 21, column 41) for  9
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC7: OBLIGATION FORALL (x: real): x /= 0 OR 9 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 263 0 265 999
body:
  % Subtype TCC generated (at line 21, column 47) for  8
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC8: OBLIGATION FORALL (x: real): x /= 0 OR 8 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 267 0 269 999
body:
  % Subtype TCC generated (at line 22, column 8) for  7
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC9: OBLIGATION FORALL (x: real): x /= 0 OR 7 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 271 0 273 999
body:
  % Subtype TCC generated (at line 22, column 14) for  6
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC10: OBLIGATION FORALL (x: real): x /= 0 OR 6 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 275 0 277 999
body:
  % Subtype TCC generated (at line 22, column 20) for  5
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC11: OBLIGATION FORALL (x: real): x /= 0 OR 5 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 279 0 281 999
body:
  % Subtype TCC generated (at line 22, column 26) for  4
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC12: OBLIGATION FORALL (x: real): x /= 0 OR 4 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 283 0 285 999
body:
  % Subtype TCC generated (at line 22, column 32) for  3
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_3_TCC13: OBLIGATION FORALL (x: real): x /= 0 OR 3 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 287 0 316 999
body:
  % Subtype TCC generated (at line 22, column 47) for  2
      % expected type  {i: int |
                     %          NOT 478 + 350 * x + 4 * x ^ 4 + 5 * x ^ 5 +
                     %               8 * x ^ 8
                     %               + 2 * x ^ 10
                     %               + x ^ 12
                     %               + x ^ 16
                     %               - 7 * x ^ 7
                     %               - 6 * x ^ 6
                     %               - 6 * x ^ 9
                     %               - 3 * x ^ 3
                     %               - 3 * x ^ 13
                     %               - x ^ 11
                     %               - x ^ 15
                     %               = 0
                     %           OR i >= 0}
  example_3_TCC14: OBLIGATION
    FORALL (x: real):
      NOT 478 + 350 * x + 4 * x ^ 4 + 5 * x ^ 5 + 8 * x ^ 8 + 2 * x ^ 10 +
           x ^ 12
           + x ^ 16
           - 7 * x ^ 7
           - 6 * x ^ 6
           - 6 * x ^ 9
           - 3 * x ^ 3
           - 3 * x ^ 13
           - x ^ 11
           - x ^ 15
           = 0
       OR 2 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 318 0 321 999
body:
  % Subtype TCC generated (at line 28, column 18) for  101
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC1: OBLIGATION
    FORALL (x: real): x < 0 IMPLIES x /= 0 OR 101 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 323 0 325 999
body:
  % Subtype TCC generated (at line 39, column 21) for  2
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_6_TCC1: OBLIGATION FORALL (x: real): x /= 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 327 0 329 999
body:
  % Subtype TCC generated (at line 112, column 6) for  120
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_12_TCC1: OBLIGATION FORALL (x: real): x /= 0 OR 120 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 331 0 333 999
body:
  % Subtype TCC generated (at line 112, column 14) for  60
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_12_TCC2: OBLIGATION FORALL (x: real): x /= 0 OR 60 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 335 0 338 999
body:
  % Subtype TCC generated (at line 120, column 21) for  18
      % expected type  {i: int | x /= 0 OR i >= 0}
  legendre_TCC1: OBLIGATION
    FORALL (x: real): abs(x) < 1 IMPLIES x /= 0 OR 18 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 340 0 343 999
body:
  % Subtype TCC generated (at line 120, column 43) for  14
      % expected type  {i: int | x /= 0 OR i >= 0}
  legendre_TCC2: OBLIGATION
    FORALL (x: real): abs(x) < 1 IMPLIES x /= 0 OR 14 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 345 0 348 999
body:
  % Subtype TCC generated (at line 122, column 25) for  20
      % expected type  {i: int | x /= 0 OR i >= 0}
  legendre_TCC3: OBLIGATION
    FORALL (x: real): abs(x) < 1 IMPLIES x /= 0 OR 20 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 350 0 375 999
body:
  % Subtype TCC generated (at line 134, column 30) for  3
      % expected type  {i: int |
                     %          NOT 3969/65536 - 95851899/65536 * x ^ 16 -
                     %               35043645/32768 * x ^ 12
                     %               - 10207769/65536 * x ^ 20
                     %               - 3558555/32768 * x ^ 8
                     %               - 72765/65536 * x ^ 4
                     %               + 63063/4096 * x ^ 6
                     %               + 1792791/4096 * x ^ 10
                     %               + 3002285/4096 * x ^ 18
                     %               + 6600165/4096 * x ^ 14
                     %               = 0
                     %           OR i >= 0}
  legendre3_TCC1: OBLIGATION
    FORALL (x: real):
      abs(x) < 1 IMPLIES
       NOT 3969/65536 - 95851899/65536 * x ^ 16 - 35043645/32768 * x ^ 12 -
            10207769/65536 * x ^ 20
            - 3558555/32768 * x ^ 8
            - 72765/65536 * x ^ 4
            + 63063/4096 * x ^ 6
            + 1792791/4096 * x ^ 10
            + 3002285/4096 * x ^ 18
            + 6600165/4096 * x ^ 14
            = 0
        OR 3 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 377 0 379 999
body:
  % Subtype TCC generated (at line 140, column 11) for  8
      % expected type  {i: int | (x - 1) /= 0 OR i >= 0}
  harrison_sos_TCC1: OBLIGATION FORALL (x: real): (x - 1) /= 0 OR 8 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 381 0 383 999
body:
  % Subtype TCC generated (at line 140, column 33) for  8
      % expected type  {i: int | (x - 3) /= 0 OR i >= 0}
  harrison_sos_TCC2: OBLIGATION FORALL (x: real): (x - 3) /= 0 OR 8 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 385 0 388 999
body:
  % Subtype TCC generated (at line 173, column 44) for  20
      % expected type  {i: int | (2 - x) /= 0 OR i >= 0}
  example_17_TCC1: OBLIGATION
    FORALL (x: real): x > 0 IMPLIES (2 - x) /= 0 OR 20 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 390 0 393 999
body:
  % Subtype TCC generated (at line 173, column 53) for  2
      % expected type  {i: int | (6 - x) /= 0 OR i >= 0}
  example_17_TCC2: OBLIGATION
    FORALL (x: real): x > 0 IMPLIES (6 - x) /= 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 395 0 398 999
body:
  % Subtype TCC generated (at line 173, column 62) for  4
      % expected type  {i: int | (12 - x) /= 0 OR i >= 0}
  example_17_TCC3: OBLIGATION
    FORALL (x: real): x > 0 IMPLIES (12 - x) /= 0 OR 4 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 400 0 403 999
body:
  % Subtype TCC generated (at line 173, column 71) for  6
      % expected type  {i: int | (20 - x) /= 0 OR i >= 0}
  example_17_TCC4: OBLIGATION
    FORALL (x: real): x > 0 IMPLIES (20 - x) /= 0 OR 6 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 405 0 408 999
body:
  % Subtype TCC generated (at line 182, column 57) for  2
      % expected type  {i: int | NOT (x - 1/4) = 0 OR i >= 0}
  mono_example_1_TCC1: OBLIGATION
    FORALL (x, y: real): x >= 1 AND x < y IMPLIES NOT (x - 1/4) = 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 410 0 413 999
body:
  % Subtype TCC generated (at line 188, column 47) for  5
      % expected type  {i: int | y /= 0 OR i >= 0}
  mono_example_2_TCC1: OBLIGATION
    FORALL (x, y: real): x < y IMPLIES y /= 0 OR 5 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 415 0 419 999
body:
  % Subtype TCC generated (at line 195, column 21) for  4
      % expected type  {i: int | y /= 0 OR i >= 0}
  mono_example_3_TCC1: OBLIGATION
    FORALL (x, y: real):
      0.4 <= x AND x < y AND y <= 0.6 IMPLIES y /= 0 OR 4 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 421 0 425 999
body:
  % Subtype TCC generated (at line 195, column 25) for  2
      % expected type  {i: int | y /= 0 OR i >= 0}
  mono_example_3_TCC2: OBLIGATION
    FORALL (x, y: real):
      0.4 <= x AND x < y AND y <= 0.6 IMPLIES y /= 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 427 0 430 999
body:
  % Subtype TCC generated (at line 201, column 47) for  3
      % expected type  {i: int | y /= 0 OR i >= 0}
  mono_example_4_TCC1: OBLIGATION
    FORALL (x, y: real): x /= y IMPLIES y /= 0 OR 3 >= 0;


decl_type: tcc
theory: examples
library: Sturm
signature: nil
location: 432 0 435 999
body:
  % Subtype TCC generated (at line 213, column 52) for  4
      % expected type  {i: int | y /= 0 OR i >= 0}
  mono_example_6_TCC1: OBLIGATION
    FORALL (x: real, y: real | y >= -1): x > y IMPLIES y /= 0 OR 4 >= 0;


decl_type: formula
theory: sturmsquarefree
library: Sturm
signature: nil
location: 27 2 30 26
body:
    sturm_sequence_degree_1: LEMMA
      n(0)=1 AND n(1)=0 AND p(0)(1)/=0 AND p(1) = poly_deriv(p(0))
      IMPLIES
      sturm_sequence?(p,n,1)


decl_type: formula
theory: sturmsquarefree
library: Sturm
signature: nil
location: 32 2 36 54
body:
    sturm_seq_repeated_root: LEMMA sturm_sequence?(p,n,m) IMPLIES
      FORALL (i:nat): i+1<=m AND
      polynomial(p(i),n(i))(x)=0 AND polynomial(p(i+1),n(i+1))(x)=0
      IMPLIES
      (FORALL (j:upto(m)): polynomial(p(j),n(j))(x) = 0)


decl_type: formula
theory: sturmsquarefree
library: Sturm
signature: nil
location: 38 2 44 52
body:
    sturm_seq_last_nonzero: LEMMA
      m>0 AND
      sturm_sequence?(p,n,m) AND
      (FORALL (c:real): polynomial(p(0),n(0))(c)=0 IMPLIES
        polynomial(p(1),n(1))(c)/=0)
      IMPLIES
      FORALL (xyz:real): polynomial(p(m),n(m))(xyz)/=0


decl_type: formula
theory: sturmsquarefree
library: Sturm
signature: nil
location: 50 2 60 77
body:
    sturm_seq_first_signs_eq: LEMMA
      x<b AND b<y AND
      polynomial(p(0),n(0))(b)=0 AND
      (FORALL (c:real): x<=c AND c<=y AND polynomial(p(0),n(0))(c)=0 IMPLIES
        (polynomial(p(1),n(1))(c)/=0 AND c = b)) AND
      sturm_sequence?(p,n,m)
      IMPLIES
      (polynomial(p(0),n(0))(x)/=0 AND
       polynomial(p(0),n(0))(y)/=0 AND
       sign_ext(polynomial(p(0),n(0))(x)) = -sign_ext(polynomial(p(1),n(1))(b)) AND
       sign_ext(polynomial(p(0),n(0))(y)) = sign_ext(polynomial(p(1),n(1))(b)))


decl_type: formula
theory: sturmsquarefree
library: Sturm
signature: nil
location: 62 2 67 45
body:
    sturm_lem_no_roots: LEMMA
      x<y AND
      (FORALL (c:real,i:nat): i<=m AND x<=c AND c<=y IMPLIES polynomial(p(i),n(i))(c)/=0) AND
      sturm_sequence?(p,n,m)
      IMPLIES
      sturm_sig(p,n,m)(x) = sturm_sig(p,n,m)(y)


decl_type: formula
theory: sturmsquarefree
library: Sturm
signature: nil
location: 69 2 80 85
body:
    sturm_lem_one_root: LEMMA
      x<y AND x<b AND b<y AND
      (FORALL (c:real,i:nat): i<=m AND x<=c AND c<=y AND polynomial(p(i),n(i))(c)=0
       IMPLIES c = b) AND
      (FORALL (c:real): x<=c AND c<=y AND polynomial(p(0),n(0))(c)=0 IMPLIES
        (polynomial(p(1),n(1))(c)/=0))
      AND j<=m AND polynomial(p(j),n(j))(b)/=0 AND
      sturm_sequence?(p,n,m)
      IMPLIES
      LET nsc = LAMBDA (xyz:real,pj:nat): number_sign_changes(LAMBDA (i): polynomial(p(i),n(i))(xyz),pj) IN
        sign_ext(nsc(x,j)`lastnz) = sign_ext(nsc(y,j)`lastnz) AND
        nsc(x,j)`num = nsc(y,j)`num+(IF polynomial(p(0),n(0))(b)=0 THEN 1 ELSE 0 ENDIF)


decl_type: formula
theory: sturmsquarefree
library: Sturm
signature: nil
location: 82 2 94 85
body:
    sturm_lem_edge_root: LEMMA
      x<y AND
      (FORALL (c:real,i:nat): i<=m AND x<=c AND c<=y AND polynomial(p(i),n(i))(c)=0
       IMPLIES c = y) AND
      (FORALL (c:real): x<=c AND c<=y AND polynomial(p(0),n(0))(c)=0 IMPLIES
        (polynomial(p(1),n(1))(c)/=0))
      AND j<=m AND polynomial(p(j),n(j))(y)/=0 AND
      sturm_sequence?(p,n,m) AND
      p(1) = poly_deriv(p(0)) AND n(1) = n(0)-1
      IMPLIES
      LET nsc = LAMBDA (xyz:real,pj:nat): number_sign_changes(LAMBDA (i): polynomial(p(i),n(i))(xyz),pj) IN
        sign_ext(nsc(x,j)`lastnz) = sign_ext(nsc(y,j)`lastnz) AND
        nsc(x,j)`num = nsc(y,j)`num+(IF polynomial(p(0),n(0))(y)=0 THEN 1 ELSE 0 ENDIF)


decl_type: formula
theory: sturmsquarefree
library: Sturm
signature: nil
location: 96 2 102 38
body:
    roots_between_enum: LEMMA % THIS NEEDS TO BE FOR ALL P(i) NOT JUST P(0)
      x<y AND sturm_sequence?(p,n,m) IMPLIES
        EXISTS ((K:nat|K>=2),enum:[below(K)->real]):
          (FORALL (i,j:below(K)): i<j IMPLIES enum(i)<enum(j)) AND
          enum(0)=x AND enum(K-1)=y AND
          (FORALL (b:real,j:nat): j<=m AND x<b AND b<=y AND polynomial(p(j),n(j))(b)=0 IMPLIES
            EXISTS (i:below(K)): b = enum(i))


decl_type: formula
theory: sturmsquarefree
library: Sturm
signature: nil
location: 104 2 112 45
body:
    sturm_lem_no_roots_full: LEMMA
      m>0 AND x<y AND
      (FORALL (c:real,i:nat): i<=m AND x<c AND c<=y IMPLIES polynomial(p(i),n(i))(c)/=0) AND
      sturm_sequence?(p,n,m) AND
      (FORALL (c:real): polynomial(p(0),n(0))(c)=0 IMPLIES
        polynomial(p(1),n(1))(c)/=0) AND
      p(1) = poly_deriv(p(0)) AND n(1) = n(0)-1
      IMPLIES
      sturm_sig(p,n,m)(x) = sturm_sig(p,n,m)(y)


decl_type: formula
theory: sturmsquarefree
library: Sturm
signature: nil
location: 114 2 124 26
body:
    sturm_square_free: LEMMA
      m>0 AND x<y AND (EXISTS (i:upto(n(0))): p(0)(i)/=0) AND
      (FORALL (c:real): polynomial(p(0),n(0))(c)=0 IMPLIES
        (polynomial(p(1),n(1))(c)/=0)) AND
      sturm_sequence?(p,n,m) AND
      p(1) = poly_deriv(p(0)) AND n(1) = n(0)-1
      IMPLIES
        LET nsc = LAMBDA (xyz:real): number_sign_changes(LAMBDA (i): polynomial(p(i),n(i))(xyz),m),
            Nroots = nsc(x)`num-nsc(y)`num
        IN Nroots>=0 AND EXISTS (bij: [below(Nroots)->{xr:real|x<xr AND xr<=y AND polynomial(p(0),n(0))(xr)=0}]):
             bijective?(bij)


decl_type: formula
theory: sturmsquarefree
library: Sturm
signature: nil
location: 126 2 138 47
body:
    sturm_seq_square_free: LEMMA
      (m>0 AND n(m)=0 AND (FORALL (i:below(m)): p(i)(n(i))/=0) AND
      (FORALL (i,j:upto(m)): i<j IMPLIES n(i)>n(j)) AND
      (FORALL (c:real): polynomial(p(0),n(0))(c)=0 IMPLIES
        (polynomial(p(1),n(1))(c)/=0)) AND
      p(1) = poly_deriv(p(0)) AND n(1) = n(0)-1 AND
      (FORALL (j:nat): j>1 AND j<=m IMPLIES LET pd = poly_divide(p(j-2),n(j-2))(p(j-1),n(j-1))(0) IN
                                             EXISTS (c:posreal): 
                                             polynomial(p(j),n(j)) = 
                                             polynomial(-c*pd`rem,pd`rdeg)))
      IMPLIES
        (p(m)(0)/=0 AND sturm_sequence?(p,n,m)) OR
        (p(m)(0) =0 AND sturm_sequence?(p,n,m-1))


decl_type: function
theory: sturmsquarefree
library: Sturm
signature: [[[nat -> [nat -> real]], [nat -> nat], nat] -> bool]
location: 16 2 25 63
body:
    sturm_sequence?(p,n,m): bool =
      LET P = (LAMBDA (k): polynomial(p(k),n(k))) IN
        (FORALL (i): i<m IMPLIES (n(i)>n(i+1) OR n(i+1)=0))  % Decreasing Degree
        AND (FORALL (i): i<=m IMPLIES p(i)(n(i))/=0)
        AND (FORALL (x): P(0)(x)=0 
               IMPLIES sign_ext(P(1)(x)) = 
                 sign_ext(polynomial(poly_deriv(p(0)),max(n(0)-1,0))(x)))
        AND (FORALL (x,i): 0<i AND i<m AND P(i)(x)=0 IMPLIES
              sign_ext(P(i-1)(x)) = -sign_ext(P(i+1)(x)))
        AND (FORALL (x,y): sign_ext(P(m)(x)) = sign_ext(P(m)(y)))


decl_type: tcc
theory: sturmsquarefree
library: Sturm
signature: nil
location: 145 0 153 999
body:
  % Subtype TCC generated (at line 22, column 45) for  max(n(0) - 1, 0)
      % expected type  nat
  sturm_sequence?_TCC1: OBLIGATION
    FORALL (p: [nat -> [nat -> real]], n: [nat -> nat], m: nat,
            P: [nat -> [real -> real]]):
      ((FORALL (i): i <= m IMPLIES p(i)(n(i)) /= 0) AND
        (FORALL (i): i < m IMPLIES (n(i) > n(i + 1) OR n(i + 1) = 0)) AND
         P = (LAMBDA (k): polynomial(p(k), n(k))))
       IMPLIES (FORALL (x: real): P(0)(x) = 0 IMPLIES max(n(0) - 1, 0) >= 0);


decl_type: tcc
theory: sturmsquarefree
library: Sturm
signature: nil
location: 155 0 170 999
body:
  % Subtype TCC generated (at line 24, column 20) for  i - 1
      % expected type  nat
  sturm_sequence?_TCC2: OBLIGATION
    FORALL (p: [nat -> [nat -> real]], n: [nat -> nat], m: nat,
            P: [nat -> [real -> real]]):
      ((FORALL (x):
          P(0)(x) = 0 IMPLIES
           sign_ext(P(1)(x)) =
            sign_ext(polynomial(poly_deriv(p(0)), max(n(0) - 1, 0))(x)))
        AND
        (FORALL (i): i <= m IMPLIES p(i)(n(i)) /= 0) AND
         (FORALL (i): i < m IMPLIES (n(i) > n(i + 1) OR n(i + 1) = 0)) AND
          P = (LAMBDA (k): polynomial(p(k), n(k))))
       IMPLIES
       (FORALL (x1: real, i1: nat):
          0 < i1 AND i1 < m AND P(i1)(x1) = 0 IMPLIES i1 - 1 >= 0);


decl_type: tcc
theory: sturmsquarefree
library: Sturm
signature: nil
location: 172 0 179 999
body:
  % Subtype TCC generated (at line 100, column 8) for  0
      % expected type  below(K)
  roots_between_enum_TCC1: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]], x, y: real):
      sturm_sequence?(p, n, m) AND x < y IMPLIES
       (FORALL ((K: nat | K >= 2), enum: [below(K) -> real]):
          (FORALL (i, j: below(K)): i < j IMPLIES enum(i) < enum(j)) IMPLIES
           0 < K);


decl_type: tcc
theory: sturmsquarefree
library: Sturm
signature: nil
location: 181 0 189 999
body:
  % Subtype TCC generated (at line 100, column 22) for  K - 1
      % expected type  below(K)
  roots_between_enum_TCC2: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]], x, y: real):
      sturm_sequence?(p, n, m) AND x < y IMPLIES
       (FORALL ((K: nat | K >= 2), enum: [below(K) -> real]):
          enum(0) = x AND
           (FORALL (i, j: below(K)): i < j IMPLIES enum(i) < enum(j))
           IMPLIES K - 1 >= 0 AND K - 1 < K);


decl_type: tcc
theory: sturmsquarefree
library: Sturm
signature: nil
location: 191 0 201 999
body:
  % Subtype TCC generated (at line 132, column 80) for  j - 1
      % expected type  nat
  sturm_seq_square_free_TCC1: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]]):
           m > 0 AND n(m) = 0 AND FORALL (i: below(m)): p(i)(n(i)) /= 0
       AND FORALL (i, j: upto(m)): i < j IMPLIES n(i) > n(j)
       AND FORALL (c: real):
             polynomial(p(0), n(0))(c) = 0 IMPLIES
              (polynomial(p(1), n(1))(c) /= 0)
       AND p(1) = poly_deriv(p(0)) AND n(1) = n(0) - 1
       IMPLIES (FORALL (j1: nat): j1 > 1 AND j1 <= m IMPLIES j1 - 1 >= 0);


decl_type: tcc
theory: sturmsquarefree
library: Sturm
signature: nil
location: 203 0 215 999
body:
  % Subtype TCC generated (at line 132, column 85) for  n(j - 1)
      % expected type  {m | p(j - 1)(m) /= 0}
  sturm_seq_square_free_TCC2: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]]):
           m > 0 AND n(m) = 0 AND FORALL (i: below(m)): p(i)(n(i)) /= 0
       AND FORALL (i, j: upto(m)): i < j IMPLIES n(i) > n(j)
       AND FORALL (c: real):
             polynomial(p(0), n(0))(c) = 0 IMPLIES
              (polynomial(p(1), n(1))(c) /= 0)
       AND p(1) = poly_deriv(p(0)) AND n(1) = n(0) - 1
       IMPLIES
       (FORALL (j1: nat):
          j1 > 1 AND j1 <= m IMPLIES p(j1 - 1)(n(j1 - 1)) /= 0);


decl_type: tcc
theory: sturmsquarefree
library: Sturm
signature: nil
location: 217 0 227 999
body:
  % Subtype TCC generated (at line 132, column 65) for  j - 2
      % expected type  nat
  sturm_seq_square_free_TCC3: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]]):
           m > 0 AND n(m) = 0 AND FORALL (i: below(m)): p(i)(n(i)) /= 0
       AND FORALL (i, j: upto(m)): i < j IMPLIES n(i) > n(j)
       AND FORALL (c: real):
             polynomial(p(0), n(0))(c) = 0 IMPLIES
              (polynomial(p(1), n(1))(c) /= 0)
       AND p(1) = poly_deriv(p(0)) AND n(1) = n(0) - 1
       IMPLIES (FORALL (j1: nat): j1 > 1 AND j1 <= m IMPLIES j1 - 2 >= 0);


decl_type: tcc
theory: sturmsquarefree
library: Sturm
signature: nil
location: 229 0 246 999
body:
  % Subtype TCC generated (at line 138, column 42) for  m - 1
      % expected type  nat
  sturm_seq_square_free_TCC4: OBLIGATION
    FORALL (m: nat, n: [nat -> nat], p: [nat -> [nat -> real]]):
           FORALL (j: nat):
             j > 1 AND j <= m IMPLIES
              LET pd = poly_divide(p(j - 2), n(j - 2))(p(j - 1), n(j - 1))(0)
                IN
                EXISTS (c: posreal):
                  polynomial(p(j), n(j)) = polynomial(-c * pd`rem, pd`rdeg)
       AND n(1) = n(0) - 1 AND p(1) = poly_deriv(p(0))
       AND FORALL (c: real):
             polynomial(p(0), n(0))(c) = 0 IMPLIES
              (polynomial(p(1), n(1))(c) /= 0)
       AND FORALL (i, j: upto(m)): i < j IMPLIES n(i) > n(j)
       AND FORALL (i: below(m)): p(i)(n(i)) /= 0 AND n(m) = 0 AND m > 0
       AND NOT (p(m)(0) /= 0 AND sturm_sequence?(p, n, m)) AND p(m)(0) = 0
       IMPLIES m - 1 >= 0;


decl_type: tcc
theory: mem_test
library: TRS
signature: nil
location: 5 0 10 999
body:
  % Subtype TCC generated (at line 58, column 27) for  i
      % expected type  below[seq1`length]
  seq_construct_TCC1: OBLIGATION
    FORALL (n: nat, seq1, seq2: finseq[T]):
      seq1`length = n AND seq2`length = n IMPLIES
       (FORALL (i: below[n], x): i < seq1`length);


decl_type: tcc
theory: mem_test
library: TRS
signature: nil
location: 12 0 17 999
body:
  % Subtype TCC generated (at line 59, column 27) for  i
      % expected type  below[seq2`length]
  seq_construct_TCC2: OBLIGATION
    FORALL (P: [[T, T] -> bool], n: nat, seq1, seq2: finseq[T]):
      seq1`length = n AND seq2`length = n IMPLIES
       (FORALL (i: below[n], x): P(seq1`seq(i), x) IMPLIES i < seq2`length);


decl_type: tcc
theory: mem_test
library: TRS
signature: nil
location: 19 0 27 999
body:
  % Subtype TCC generated (at line 62, column 25) for  i
      % expected type  below[seq1`length]
  seq_construct_TCC3: OBLIGATION
    FORALL (P: [[T, T] -> bool], n: nat, seq1, seq2: finseq[T]):
      (FORALL (i: below[n]): EXISTS x: P(seq1`seq(i), x) & P(seq2`seq(i), x))
       AND seq2`length = n AND seq1`length = n
       IMPLIES
       (FORALL (seq):
          seq`length = n IMPLIES (FORALL (i1: below[n]): i1 < seq1`length));


decl_type: tcc
theory: mem_test
library: TRS
signature: nil
location: 29 0 37 999
body:
  % Subtype TCC generated (at line 62, column 37) for  i
      % expected type  below[seq`length]
  seq_construct_TCC4: OBLIGATION
    FORALL (P: [[T, T] -> bool], n: nat, seq1, seq2: finseq[T]):
      (FORALL (i: below[n]): EXISTS x: P(seq1`seq(i), x) & P(seq2`seq(i), x))
       AND seq2`length = n AND seq1`length = n
       IMPLIES
       (FORALL (seq):
          seq`length = n IMPLIES (FORALL (i1: below[n]): i1 < seq`length));


decl_type: tcc
theory: mem_test
library: TRS
signature: nil
location: 39 0 49 999
body:
  % Subtype TCC generated (at line 63, column 25) for  i
      % expected type  below[seq2`length]
  seq_construct_TCC5: OBLIGATION
    FORALL (P: [[T, T] -> bool], n: nat, seq1, seq2: finseq[T]):
      (FORALL (i: below[n]): EXISTS x: P(seq1`seq(i), x) & P(seq2`seq(i), x))
       AND seq2`length = n AND seq1`length = n
       IMPLIES
       (FORALL (seq):
          seq`length = n IMPLIES
           (FORALL (i1: below[n]):
              P(seq1`seq(i1), seq`seq(i1)) IMPLIES i1 < seq2`length));


decl_type: tcc
theory: mem_test
library: TRS
signature: nil
location: 51 0 57 999
body:
  % Subtype TCC generated (at line 70, column 28) for  i
      % expected type  below[seq`length]
  seq_construct2_TCC1: OBLIGATION
    FORALL (P1: [[nat, T] -> bool], n: nat):
      (FORALL (i: below[n]): EXISTS x: P1(i, x)) IMPLIES
       (FORALL (seq):
          seq`length = n IMPLIES (FORALL (i1: below[n]): i1 < seq`length));


decl_type: function
theory: extending_rename
library: TRS
signature: [[S: set[T], R: set[T], (bijective?[(S), (R)])] -> [T -> T]]
location: 23 2 27 13
body:
    extend_to_identity((S),(R),(f:(bijective?[(S),(R)])))(t): T = 
          IF S(t) THEN f(t)
          ELSE 
            t 
          ENDIF


decl_type: tcc
theory: relations_closure
library: TRS
signature: nil
location: 150 0 153 999
body:
  % Subtype TCC generated (at line 56, column 23) for  union(R, =)
      % expected type  reflexive
  RC_TCC1: OBLIGATION
    FORALL (R: pred[[T, T]]): reflexive?[T](union[[T, T]](R, =));


decl_type: tcc
theory: relations_closure
library: TRS
signature: nil
location: 155 0 159 999
body:
  % Subtype TCC generated (at line 73, column 23) for  union(R, converse(R))
      % expected type  symmetric
  SC_TCC1: OBLIGATION
    FORALL (R: pred[[T, T]]):
      symmetric?[T](union[[T, T]](R, converse[T, T](R)));


decl_type: tcc
theory: relations_closure
library: TRS
signature: nil
location: 161 0 166 999
body:
  % Subtype TCC generated (at line 90, column 24) for
      % IUnion(LAMBDA p: iterate(R, p))
      % expected type  transitive
  TC_TCC1: OBLIGATION
    FORALL (R: pred[[T, T]]):
      transitive?[T](IUnion[posnat, [T, T]](LAMBDA p: iterate[T](R, p)));


decl_type: tcc
theory: relations_closure
library: TRS
signature: nil
location: 168 0 173 999
body:
  % Subtype TCC generated (at line 109, column 34) for
      % IUnion(LAMBDA n: iterate(R, n))
      % expected type  reflexive_transitive
  RTC_TCC1: OBLIGATION
    FORALL (R: pred[[T, T]]):
      reflexive_transitive?(IUnion[nat, [T, T]](LAMBDA n: iterate[T](R, n)));


decl_type: tcc
theory: relations_closure
library: TRS
signature: nil
location: 175 0 177 999
body:
  % Subtype TCC generated (at line 128, column 25) for  RTC(SC(R))
      % expected type  equivalence
  EC_TCC1: OBLIGATION FORALL (R: pred[[T, T]]): equivalence?[T](RTC(SC(R)));


decl_type: function
theory: ars_terminology
library: TRS
signature: [[PRED[[T, T]], T] -> bool]
location: 85 1 86 76
body:
   has_unique_nf?(R,x): bool = EXISTS y: normal_form?(R)(x,y) 
                                   &  FORALL z: normal_form?(R)(x,z)  => y = z


decl_type: function
theory: ars_terminology
library: TRS
signature: [PRED[[T, T]] -> [[T, T] -> bool]]
location: 88 1 89 76
body:
   unique_nf?(R)(x,y): bool = normal_form?(R)(x,y) 
                                   &  FORALL z: normal_form?(R)(x,z)  => y = z


decl_type: function
theory: ars_terminology
library: TRS
signature: [PRED[[T, T]] -> bool]
location: 123 1 124 71
body:
   locally_confluent?(R): bool = FORALL x, y, z: R(x,y) & R(x,z) => 
                                                        joinable?(R)(y,z)


decl_type: function
theory: ars_terminology
library: TRS
signature: [PRED[[T, T]] -> bool]
location: 126 1 127 70
body:
   semi_confluent?(R): bool = FORALL x, y, z: R(x,y) & RTC(R)(x,z) => 
                                                       joinable?(R)(y,z)


decl_type: function
theory: ars_terminology
library: TRS
signature: [PRED[[T, T]] -> bool]
location: 129 1 130 70
body:
   confluent?(R): bool = FORALL x, y, z: RTC(R)(x,y) & RTC(R)(x,z) => 
                                                       joinable?(R)(y,z)


decl_type: function
theory: ars_terminology
library: TRS
signature: [PRED[[T, T]] -> bool]
location: 132 1 133 76
body:
   strong_confluent?(R): bool = FORALL x, y, z: R(x,y) & R(x,z) => 
                                            EXISTS r: RTC(R)(y,r) & RC(R)(z,r)


decl_type: function
theory: ars_terminology
library: TRS
signature: [PRED[[T, T]] -> bool]
location: 135 1 136 76
body:
   diamond_property?(R): bool = FORALL x, y, z: R(x,y) & R(x,z) => 
                                                     EXISTS r: R(y,r) & R(z,r)


decl_type: function
theory: ars_terminology
library: TRS
signature: [[PRED[[T, T]], PRED[[T, T]]] -> bool]
location: 160 1 161 77
body:
   commute?(R1,R2): bool = FORALL x, y, z: RTC(R1)(x,y) & RTC(R2)(x,z) =>
                                          EXISTS r: RTC(R2)(y,r) & RTC(R1)(z,r)


decl_type: function
theory: ars_terminology
library: TRS
signature: [[PRED[[T, T]], PRED[[T, T]]] -> bool]
location: 163 1 164 78
body:
   strong_commute?(R1,R2): bool = FORALL x, y, z: R1(x,y) & R2(x,z) =>
                                            EXISTS r: RC(R2)(y,r) & RTC(R1)(z,r)


decl_type: function
theory: ars_terminology
library: TRS
signature: [[PRED[[T, T]], PRED[[T, T]]] -> bool]
location: 167 1 168 79
body:
   locally_commute?(R1,R2): bool = FORALL x, y, z: R1(x,y) & R2(x,z) =>
                                            EXISTS r: RTC(R2)(y,r) & RTC(R1)(z,r)


decl_type: function
theory: ars_terminology
library: TRS
signature: [[PRED[[T, T]], PRED[[T, T]]] -> bool]
location: 171 1 172 77
body:
   commute_DP?(R1,R2): bool = FORALL x, y, z: R1(x,y) & R2(x,z) =>
                                                    EXISTS r: R2(y,r) & R1(z,r)


decl_type: formula
theory: noetherian
library: TRS
signature: nil
location: 59 1 65 31
body:
   noetherian_induction: LEMMA 
               (FORALL (R: noetherian, P):
                 (FORALL x: 
                    (FORALL y: TC(R)(x, y) IMPLIES P(y)) 
                        IMPLIES P(x))
              IMPLIES
                (FORALL x: P(x)))


decl_type: formula
theory: results_confluence
library: TRS
signature: nil
location: 96 1 98 76
body:
   semi_and_iterate: LEMMA FORALL (n: nat): semi_confluent?(R) & 
                                            iterate(SC(R), n)(x,y) => 
                                                             joinable?(R)(x,y)


decl_type: formula
theory: results_confluence
library: TRS
signature: nil
location: 112 1 114 75
body:
   strong_and_iterate: LEMMA FORALL (n: nat): strong_confluent?(R) & R(x,y)
                                     &  iterate(R, n)(x, z) =>
                                          EXISTS r: RTC(R)(y,r) & RC(R)(z, r)


decl_type: formula
theory: results_confluence
library: TRS
signature: nil
location: 117 1 118 77
body:
   Str_Confl_implies_Semi_Confl: THEOREM strong_confluent?(R)
                                                          => semi_confluent?(R)


decl_type: formula
theory: results_confluence
library: TRS
signature: nil
location: 127 1 128 77
body:
   R1_Confl_iff_R2_Confl: LEMMA RTC(R1) = RTC(R2) => 
                                          ( confluent?(R1) <=> confluent?(R2) )


decl_type: formula
theory: results_confluence
library: TRS
signature: nil
location: 134 1 136 77
body:
   R2_Str_Confl_implies_R1_Confl: COROLLARY subset?(R1, R2) 
                                      & subset?(R2, RTC(R1))
                                      & strong_confluent?(R2) => confluent?(R1)


decl_type: formula
theory: results_confluence
library: TRS
signature: nil
location: 139 1 140 78
body:
   Confluence_Commute: THEOREM confluent?(R1) & confluent?(R2) & commute?(R1,R2)
                                         => diamond_property?(RTC(R1) o RTC(R2))


decl_type: formula
theory: results_confluence
library: TRS
signature: nil
location: 143 1 144 70
body:
   R1_R2_RTC_R1_R2: LEMMA subset?(union(R1, R2), RTC(R1) o RTC(R2)) & 
                          subset?(RTC(R1) o RTC(R2), RTC(union(R1, R2)))


decl_type: formula
theory: results_confluence
library: TRS
signature: nil
location: 147 1 148 75
body:
   Commutative_Union_Lemma: THEOREM confluent?(R1) & confluent?(R2) &
                                 commute?(R1,R2) => confluent?(union(R1, R2))


decl_type: formula
theory: newman_yokouchi
library: TRS
signature: nil
location: 33 1 37 79
body:
   Yokouchi_lemma_ax1: LEMMA ( noetherian?(R) & confluent?(R) &
                  (FORALL x, y, z: ( S(x,y) & R(x,z) ) => 
                   ( EXISTS (u: T): RTC(R)(y,u) & (RTC(R) o S o RTC(R))(z,u) ))) 
                  => (FORALL x, y, z: ( S(x,y) & RTC(R)(x,z) ) => 
                     ( EXISTS (w: T): RTC(R)(y,w) & (RTC(R) o S o RTC(R))(z,w) ))


decl_type: formula
theory: newman_yokouchi
library: TRS
signature: nil
location: 40 1 43 59
body:
   Yokouchi_lemma: THEOREM (noetherian?(R) & confluent?(R) & diamond_property?(S)
                   & (FORALL x, y, z: ( S(x,y) & R(x,z) ) => 
                   ( EXISTS (u: T): RTC(R)(y,u) & (RTC(R) o S o RTC(R))(z,u) ))) 
                    => diamond_property?(RTC(R) o S o RTC(R))


decl_type: formula
theory: results_normal_form
library: TRS
signature: nil
location: 74 1 75 75
body:
   NF_implies_RTC: LEMMA ( confluent?(R) & EC(R)(x,y) ) => 
                                      (is_normal_form?(R)(y) => RTC(R)(x,y) ) 


decl_type: formula
theory: results_normal_form
library: TRS
signature: nil
location: 77 1 79 69
body:
   NFs_implies_Equal: LEMMA ( confluent?(R) & EC(R)(x,y) ) => 
                                 (is_normal_form?(R)(x) & is_normal_form?(R)(y)
                                                             => x = y )


decl_type: formula
theory: results_normal_form
library: TRS
signature: nil
location: 81 1 82 79
body:
   Norm_and_Confl_implies_UNF: LEMMA normalizing?(R) & confluent?(R) => 
                                                    FORALL x: has_unique_nf?(R,x)


decl_type: formula
theory: results_normal_form
library: TRS
signature: nil
location: 84 1 86 42
body:
   Normalizing_and_Confl: LEMMA ( normalizing?(R) & confluent?(R) ) =>
                     EXISTS u, v: unique_nf?(R)(x,u) & unique_nf?(R)(y,v)
                      & EC(R)(x,y) <=> u = v 


decl_type: formula
theory: results_normal_form
library: TRS
signature: nil
location: 88 1 89 78
body:
   Normal_Confl_iff_UNF: LEMMA normalizing?(R) & confluent?(R) <=>
                                                   FORALL x: has_unique_nf?(R,x)


decl_type: formula
theory: results_normal_form
library: TRS
signature: nil
location: 95 1 97 75
body:
   Noet_and_Confl_iff_UNF: LEMMA noetherian?(R) => 
                                    ( confluent?(R) <=>
                                              FORALL x: has_unique_nf?(R,x) )


decl_type: formula
theory: results_normal_form
library: TRS
signature: nil
location: 99 1 103 70
body:
   Convergent_iff_eqNF: LEMMA convergent?(R) =>
                               ( EC(R)(x,y) <=> 
                                 (FORALL u,v: normal_form?(R)(x,u) 
                                              & normal_form?(R)(y,v)
                                                             => u = v) )


decl_type: formula
theory: confluence_commute
library: TRS
signature: nil
location: 87 3 90 23
body:
     conf_local_request_implies_request : LEMMA
          confluent?(R2) & (FORALL x, y, z: RTC(R1)(x,y) & R2(x,z) =>
          EXISTS r, s: RTC(R2)(y,r) & RTC(R1)(z,s) & RTC(R2)(s,r) )
       => request?(R1,R2)


decl_type: formula
theory: confluence_commute
library: TRS
signature: nil
location: 95 3 100 35
body:
     comp_rtc_req_conf_impl_diamond: LEMMA
       LET R3 = RTC(R1) o RTC(R2) IN
       ((request?(R1,R2) & confluent?(R2) & 
       (FORALL x, y, z: RTC(R1)(x,y) & RTC(R1)(x,z) => EXISTS r: R3(y,r) & R3(z,r)))
            => 
              diamond_property?(R3) )


decl_type: formula
theory: confluence_commute
library: TRS
signature: nil
location: 102 3 107 28
body:
     union_req_conf_is_confluent  : LEMMA 
       request?(R1,R2) & confluent?(R2) & (LET R3 = RTC(R1) o RTC(R2) IN 
       (FORALL x, y, z: RTC(R1)(x,y) & RTC(R1)(x,z) => EXISTS r: R3(y,r) & R3(z,r)))
            => 
             (LET R = union(R1, R2) IN 
              (confluent?(R)))


decl_type: formula
theory: confluence_commute
library: TRS
signature: nil
location: 112 3 114 60
body:
     comp_rtc_confs_req_impl_diamond: LEMMA
          confluent?(R1) & confluent?(R2) & request?(R1,R2)
      => (LET R3 = RTC(R1) o RTC(R2) IN diamond_property?(R3))


decl_type: formula
theory: confluence_commute
library: TRS
signature: nil
location: 116 3 118 49
body:
     union_confs_req_is_confluent: LEMMA
          confluent?(R1) & confluent?(R2) & request?(R1,R2)
      => (LET R = union(R1, R2) IN (confluent?(R)))


decl_type: formula
theory: confluence_commute
library: TRS
signature: nil
location: 132 1 134 35
body:
   hip_Hindley_implies_semi_comm : LEMMA 
    (FORALL x, y, z :  (R1(x, y) & R2(x, z) => EXISTS r : R2(y, r) & RC(R1)(z, r)))
        IMPLIES semi_commute?(R1, R2)


decl_type: formula
theory: confluence_commute
library: TRS
signature: nil
location: 136 1 138 30
body:
   lemma_Hindley_1964 : LEMMA 
     (FORALL x, y, z:  (R1(x, y) & R2(x, z) => EXISTS r : R2(y, r) & RC(R1)(z, r)))
        IMPLIES commute?(R1, R2)                   


decl_type: formula
theory: confluence_commute
library: TRS
signature: nil
location: 143 3 146 58
body:
     ref_condition_to_refcomp : LEMMA 
         refinement?(R1,R2)  => (ref_compatible?(R1,R2)
                            <=> 
    (FORALL x, y:(R2 o RTC(R1))(x,y) => joinable?(R1)(x,y)))


decl_type: formula
theory: confluence_commute
library: TRS
signature: nil
location: 162 3 164 21
body:
     lemma_Rosen_1973 : LEMMA      
       RTC(R1) = RTC(R2) & sub_commutative?(R1) =>
         confluent?(R2)


decl_type: formula
theory: confluence_commute
library: TRS
signature: nil
location: 170 3 173 62
body:
     lcomm_and_snunion_implies_comm : LEMMA locally_commute?(R1,R2) & 
                                            noetherian?(union(R1,R2))
                                               =>
                                                 commute?(R1,R2) 


decl_type: function
theory: confluence_commute
library: TRS
signature: [[PRED[[T, T]], PRED[[T, T]]] -> bool]
location: 31 3 33 38
body:
     semi_commute?(R1,R2): bool =
          FORALL x, y, z: R1(x,y) & RTC(R2)(x,z) =>
          EXISTS r: RTC(R2)(y,r) & RTC(R1)(z,r)


decl_type: function
theory: confluence_commute
library: TRS
signature: [PRED[[T, T]] -> bool]
location: 35 3 37 34
body:
     sub_commutative?(R): bool =
          FORALL x, y, z: R(x,y) & R(x,z) =>
          EXISTS r: RC(R)(y,r) & RC(R)(z,r)


decl_type: function
theory: confluence_commute
library: TRS
signature: [[PRED[[T, T]], PRED[[T, T]]] -> bool]
location: 39 3 41 56
body:
     request?(R1,R2): bool =
          FORALL x, y, z: RTC(R1)(x,y) & RTC(R2)(x,z) =>
          EXISTS r, s: RTC(R2)(y,r) & RTC(R1)(z,s) & RTC(R2)(s,r)


decl_type: function
theory: confluence_commute
library: TRS
signature: [[PRED[[T, T]], PRED[[T, T]]] -> bool]
location: 46 3 47 71
body:
     ref_compatible?(R1,R2): bool =
          refinement?(R1,R2) & (FORALL x, y: RTC(R2)(x,y) => joinable?(R1)(x,y))


decl_type: function
theory: confluence_commute
library: TRS
signature: [[PRED[[T, T]], PRED[[T, T]]] -> bool]
location: 49 3 51 38
body:
     postponement?(R1,R2): bool =
          FORALL x, y: LET R = union(R1,R2) IN RTC(R)(x,y) =>
          EXISTS z: RTC(R1)(x,z) & RTC(R2)(z,y)


decl_type: function
theory: confluence_commute
library: TRS
signature: [PRED[[T, T]] -> bool]
location: 53 3 56 62
body:
     UN_terese?(R): bool = FORALL x, y :( is_normal_form?(R)(x) & 
                                         is_normal_form?(R)(y) &
                                         EC(R)(x,y) ) =>
                                                           x = y


decl_type: function
theory: confluence_commute
library: TRS
signature: [PRED[[T, T]] -> bool]
location: 58 1 62 51
body:
   UNseta_terese?(R): bool = FORALL x, y :( is_normal_form?(R)(x) & 
                                            is_normal_form?(R)(y) & 
                                           (EXISTS z : RTC(R)(z,x) & RTC(R)(z,y)) )
                                              =>
                                                x = y


decl_type: formula
theory: modulo_equivalence
library: TRS
signature: nil
location: 67 0 70 79
body:
  newman_lemma_general : THEOREM noetherian?(R) => 
                                (local_confluent_m?(R, Eq) & 
                                 locally_coherent?(R, Eq, Eq) <=>  
                                                             confluent_m?(R, Eq))


decl_type: function
theory: modulo_equivalence
library: TRS
signature: [[PRED[[T, T]], equivalence[T]] -> [[T, T] -> bool]]
location: 33 2 34 68
body:
    joinable_m?(R, Eq)(x,y) : bool = EXISTS u,v: RTC(R)(x,u) & 
                                                 Eq(u,v) & RTC(R)(y,v)


decl_type: function
theory: modulo_equivalence
library: TRS
signature: [[PRED[[T, T]], equivalence[T]] -> bool]
location: 36 2 37 71
body:
    church_rosser_m?(R, Eq) : bool = FORALL x, y: Eq_Eq(R, Eq)(x,y) => 
                                                  joinable_m?(R, Eq)(x,y)


decl_type: function
theory: modulo_equivalence
library: TRS
signature: [[PRED[[T, T]], equivalence[T]] -> bool]
location: 39 2 40 76
body:
    local_confluent_m?(R, Eq) : bool = FORALL x, y, z: R(x,y) & R(x,z) => 
                                                       joinable_m?(R, Eq)(y,z)


decl_type: function
theory: modulo_equivalence
library: TRS
signature: [[PRED[[T, T]], equivalence[T]] -> bool]
location: 42 2 45 73
body:
    confluent_m?(R, Eq) : bool = FORALL x, y, z, w: RTC(R)(x,z)  & 
                                                    Eq(x,y) &
                                                    RTC(R)(y,w) => 
                                                    joinable_m?(R, Eq)(z,w)


decl_type: function
theory: modulo_equivalence
library: TRS
signature: [[PRED[[T, T]], equivalence[T]] -> bool]
location: 47 2 51 76
body:
    has_unique_nf_m?(R, Eq) : bool = FORALL x, y, u, v: is_normal_form?(R)(u) &
                                                        is_normal_form?(R)(v) &
                                                        RTC(R)(x,u) &
                                                        Eq_Eq(R, Eq)(x,y)  &
                                                        RTC(R)(y,v) => Eq(u,v)


decl_type: function
theory: modulo_equivalence
library: TRS
signature: [[PRED[[T, T]], equivalence[T], PRED[[T, T]]] -> bool]
location: 53 2 55 72
body:
    locally_coherent?(R, Eq, S) : bool = symmetric?(S) &
                                         FORALL  x, y, z: R(x,y) & 
                                         S(x,z) => joinable_m?(R, Eq)(y,z)


decl_type: formula
theory: results_commutation
library: TRS
signature: nil
location: 50 1 51 76
body:
   Local_Comu_and_Noeth: THEOREM locally_commute?(R1,R2) 
                               & noetherian?(union(R1, R2)) => commute?(R1,R2)


decl_type: formula
theory: results_commutation
library: TRS
signature: nil
location: 53 1 55 76
body:
   commute_and_iterate_one: LEMMA FORALL (n: nat): strong_commute?(R1,R2) &
                            iterate(R1, n)(x,y) & R2(x,z) => 
                                          EXISTS r: RTC(R1)(z,r) & RC(R2)(y,r)


decl_type: formula
theory: results_commutation
library: TRS
signature: nil
location: 57 1 59 77
body:
   commute_and_iterate_two: LEMMA FORALL (n,m: nat): strong_commute?(R1,R2) &
                             iterate(R1, n)(x,y) & iterate(R2, m)(x,z) => 
                                          EXISTS r: RTC(R2)(y,r) & RTC(R1)(z,r)


decl_type: formula
theory: IUnion_extra
library: TRS
signature: nil
location: 35 2 36 45
body:
    disjoint_subset: LEMMA subset?(A,B) & subset?(C,D) & disjoint?(B,D) 
                              => disjoint?(A,C)


decl_type: formula
theory: IUnion_extra
library: TRS
signature: nil
location: 40 2 43 55
body:
    IUnion_of_finite_is_finite: LEMMA
      FORALL (n: posnat, (f:[upto?(n) -> set[T]])):
        (FORALL (i: upto?(n)): is_finite(f(i)))
         => is_finite(IUnion(LAMBDA (i: upto?(n)): f(i)))


decl_type: formula
theory: IUnion_extra
library: TRS
signature: nil
location: 46 2 49 55
body:
    IUnion_of_finite_is_finite1: LEMMA
      FORALL (n: posnat, (f:[below[n] -> set[T]])):
        (FORALL (i: below[n]): is_finite(f(i)))
         => is_finite(IUnion(LAMBDA (i: below[n]): f(i)))


decl_type: tcc
theory: IUnion_extra
library: TRS
signature: nil
location: 56 0 58 999
body:
  % Subtype TCC generated (at line 29, column 68) for  n
      % expected type  upto?(n)
  upto?_TCC1: OBLIGATION FORALL (n: posnat): n <= n;


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 124 2 129 60
body:
    equal_symbol_equal_length_arg : LEMMA
        FORALL (s, t: term, fs, ft: symbol, 
                ss:{args: finite_sequence[term] | args`length = arity(fs)},
                st:{argt: finite_sequence[term] | argt`length = arity(ft)}) :
         (s = app(fs, ss) AND t = app(ft,st) AND fs = ft)
                                 IMPLIES ss`length = st`length


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 137 2 138 62
body:
    rest_of_positions: LEMMA (positionsOF(s)(p) & length(p) /= 0)  =>
                            positionsOF(args(s)(first(p) - 1))(rest(p))


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 140 2 141 72
body:
    delete_is_position: LEMMA positionsOF(s)(p) & length(p) /= 0 =>
                                  positionsOF(s)(delete(p, length(p) - 1))


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 146 2 147 73
body:
    rest_parallel: LEMMA length(p)/= 0 & length(q)/= 0 & first(p) = first(q)
                             & parallel(p, q) => parallel(rest(p), rest(q))


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 159 2 160 76
body:
    delete_of_SP_is_SP: LEMMA
       FORALL s, (fss: SP(s)), (i: below[length(fss)]): SP?(s)(delete(fss, i))


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 164 2 168 34
body:
    add_first_parallel_pos_to_PP_is_PP : LEMMA 
     FORALL (fss: PP), (q: position): 
         (FORALL (i: below[length(fss)]): parallel(fss(i),q))
             =>
              PP?(add_first(q, fss))


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 171 2 172 73
body:
    add_first_parallel_pos_to_SP_is_SP : LEMMA 
     FORALL s, (fss: SP(s)), (q: positions?(s)): SP?(s)(add_first(q, fss) )


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 175 2 179 33
body:
    add_last_parallel_pos_to_PP_is_PP : LEMMA 
     FORALL (fss: PP), (q: position): 
         (FORALL (i: below[length(fss)]): parallel(fss(i),q))
             =>
              PP?(add_last(fss, q))


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 182 2 183 71
body:
    add_last_parallel_pos_to_SP_is_SP : LEMMA 
     FORALL s, (fss: SP(s)), (q: positions?(s)): SP?(s)(add_last(fss, q))


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 188 1 190 40
body:
   positions_of_arg : LEMMA
        FORALL ( (s : term | app?(s) ), k : below[length(args(s))] ) :
        positionsOF(s)( #[posnat]( k+1 ) )


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 192 1 194 62
body:
   left_pos_transitive : LEMMA
      FORALL (q1 : position) :
      left_pos(p, q1) AND left_pos(q1, q) IMPLIES left_pos(p, q)


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 199 1 202 41
body:
   lwc_transitive : LEMMA
      FORALL (q1 : position) :
        left_without_children(p, q1) AND left_without_children(q1, q)
        IMPLIES left_without_children(p, q)


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 204 1 206 34
body:
   subterm_if_le_arity : LEMMA
      ( app?(s) AND arity(f(s)) >= i )
       IMPLIES positionsOF(s)( #(i))


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 211 1 215 66
body:
   lwc_add_last_delete : LEMMA
       FORALL (q1 : position) : 
          (p /= empty_seq AND left_without_children(p, q1)) IMPLIES
            LET q = add_last(delete(p, length(p) - 1), 1 + last(p)) IN
              left_without_children(q, q1) OR child(q1, q) OR q1 = q


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 217 1 221 64
body:
   lwc_add_last_delete1 : LEMMA
       FORALL (q1 : position, p : position | p /= empty_seq) :
        LET q = add_last(delete(p, length(p) - 1), 1 + last(p)) IN
          left_without_children(q1, q) IMPLIES
            left_without_children(q1, p) OR child(q1, p) OR q1 = p


decl_type: formula
theory: positions
library: TRS
signature: nil
location: 223 1 226 63
body:
   leftmost_pos : LEMMA
     ( NOT positionsOF(s)( #(i + 1)) AND
       positionsOF(s)( #(i)) AND positionsOF(s)(q) )
       IMPLIES ( q = empty_seq OR left_pos(q, #(i)) OR q = #(i) )


decl_type: function
theory: positions
library: TRS
signature: [[posnat, positions] -> positions]
location: 34 2 36 71
body:
    catenate(i: posnat, s: positions): positions  =
          {seq: position | EXISTS (x: position): (member(x,s) AND 
                                                   seq = add_first(i,x))}


decl_type: function
theory: positions
library: TRS
signature: [term[variable, symbol, arity] -> positions]
location: 39 2 51 17
body:
    positionsOF(t: term): RECURSIVE positions =
      (CASES t OF 
         vars(t): only_empty_seq,
         app(f, st): IF length(st) = 0
                     THEN
                      only_empty_seq
                     ELSE
                      union(only_empty_seq, 
                            IUnion((LAMBDA (i: upto?(length(st))):
                                 catenate(i, positionsOF(st(i-1)) ))))
                     ENDIF
       ENDCASES)
    MEASURE t BY << 


decl_type: function
theory: positions
library: TRS
signature: [[position, position] -> bool]
location: 74 2 77 31
body:
    left_without_children(p, q): bool = (EXISTS (r,p1,q1: position): 
         (q = r o q1 AND p = r o p1 AND 
          q1 /= empty_seq AND p1 /= empty_seq AND
          first(p1) < first(q1)))


decl_type: function
theory: positions
library: TRS
signature: [[position, position] -> bool]
location: 79 2 83 31
body:
    left_pos(p, q): bool = (EXISTS (r,p1,q1: position): 
         (q = r AND p1 /= empty_seq AND p = r o p1) OR
         (q = r o q1 AND p = r o p1 AND 
          q1 /= empty_seq AND p1 /= empty_seq AND
          first(p1) < first(q1))) 


decl_type: function
theory: positions
library: TRS
signature: [finseq[position] -> bool]
location: 92 2 97 24
body:
    PP?(fsp): bool = IF fsp`length < 2
                     THEN true
                     ELSE
                       FORALL (i, j: below[length(fsp)]): i /= j  => 
                                       parallel(fsp(i), fsp(j))
                     ENDIF


decl_type: function
theory: positions
library: TRS
signature: [term[variable, symbol, arity] -> [finseq[position] -> bool]]
location: 100 2 101 48
body:
    SP?(t)(fsp): bool = FORALL (i: below[length(fsp)]): 
                            positionsOF(t)(fsp(i))


decl_type: tcc
theory: positions
library: TRS
signature: nil
location: 233 0 242 999
body:
  % Subtype TCC generated (at line 48, column 58) for  i - 1
      % expected type  below[length(st)]
  positionsOF_TCC1: OBLIGATION
    FORALL (t: term[variable, symbol, arity], f: symbol,
            st:
              {args: finite_sequence[term[variable, symbol, arity]] |
                       args`length = arity(f)}):
      NOT length(st) = 0 AND t = app(f, st) IMPLIES
       (FORALL (i: upto?[position](length(st))):
          i - 1 >= 0 AND i - 1 < length(st));


decl_type: tcc
theory: positions
library: TRS
signature: nil
location: 244 0 254 999
body:
  % Termination TCC generated (at line 48, column 43) for
      % positionsOF(finseq_appl[term[variable, symbol, arity]](st)(i - 1))
  positionsOF_TCC2: OBLIGATION
    FORALL (t: term[variable, symbol, arity], f: symbol,
            st:
              {args: finite_sequence[term[variable, symbol, arity]] |
                       args`length = arity(f)}):
      NOT length(st) = 0 AND t = app(f, st) IMPLIES
       (FORALL (i: upto?[position](length(st))):
          <<[variable, symbol, arity]
              (finseq_appl[term[variable, symbol, arity]](st)(i - 1), t));


decl_type: tcc
theory: positions
library: TRS
signature: nil
location: 256 0 261 999
body:
  % Subtype TCC generated (at line 77, column 14) for  p1
      % expected type  not_empty_seq[posnat]
  left_without_children_TCC1: OBLIGATION
    FORALL (p: position, q: position, r, p1, q1: position):
      p1 /= empty_seq AND q1 /= empty_seq AND p = r o p1 AND q = r o q1
       IMPLIES length(p1) /= 0;


decl_type: tcc
theory: positions
library: TRS
signature: nil
location: 263 0 268 999
body:
  % Subtype TCC generated (at line 77, column 26) for  q1
      % expected type  not_empty_seq[posnat]
  left_without_children_TCC2: OBLIGATION
    FORALL (p: position, q: position, r, p1, q1: position):
      p1 /= empty_seq AND q1 /= empty_seq AND p = r o p1 AND q = r o q1
       IMPLIES length(q1) /= 0;


decl_type: tcc
theory: positions
library: TRS
signature: nil
location: 270 0 276 999
body:
  % Subtype TCC generated (at line 138, column 39) for  first(p) - 1
      % expected type  below[length(args(s))]
  rest_of_positions_TCC1: OBLIGATION
    FORALL (p: position, s: term[variable, symbol, arity]):
      length(p) /= 0 AND positionsOF(s)(p) IMPLIES
       first[posnat](p) - 1 >= 0 AND
        first[posnat](p) - 1 < length(args[variable, symbol, arity](s));


decl_type: tcc
theory: positions
library: TRS
signature: nil
location: 278 0 283 999
body:
  % Subtype TCC generated (at line 138, column 36) for  s
      % expected type  d: (app?[variable, symbol, arity])
  rest_of_positions_TCC2: OBLIGATION
    FORALL (p: position, s: term[variable, symbol, arity]):
      length(p) /= 0 AND positionsOF(s)(p) IMPLIES
       app?[variable, symbol, arity](s);


decl_type: tcc
theory: positions
library: TRS
signature: nil
location: 285 0 290 999
body:
  % Subtype TCC generated (at line 141, column 57) for  length(p) - 1
      % expected type  below[length(p)]
  delete_is_position_TCC1: OBLIGATION
    FORALL (p: position, s: term[variable, symbol, arity]):
      length(p) /= 0 AND positionsOF(s)(p) IMPLIES
       length(p) - 1 >= 0 AND length(p) - 1 < length(p);


decl_type: tcc
theory: positions
library: TRS
signature: nil
location: 292 0 297 999
body:
  % Subtype TCC generated (at line 214, column 37) for  length(p) - 1
      % expected type  below[length(p)]
  lwc_add_last_delete_TCC1: OBLIGATION
    FORALL (p, q1: position):
      p /= empty_seq AND left_without_children(p, q1) IMPLIES
       length(p) - 1 >= 0 AND length(p) - 1 < length(p);


decl_type: tcc
theory: positions
library: TRS
signature: nil
location: 299 0 303 999
body:
  % Subtype TCC generated (at line 214, column 62) for  p
      % expected type  not_empty_seq[posnat]
  lwc_add_last_delete_TCC2: OBLIGATION
    FORALL (p, q1: position):
      p /= empty_seq AND left_without_children(p, q1) IMPLIES length(p) /= 0;


decl_type: tcc
theory: positions
library: TRS
signature: nil
location: 305 0 309 999
body:
  % Subtype TCC generated (at line 219, column 33) for  length(p) - 1
      % expected type  below[length(p)]
  lwc_add_last_delete1_TCC1: OBLIGATION
    FORALL (p: position | p /= empty_seq[posnat]):
      length(p) - 1 >= 0 AND length(p) - 1 < length(p);


decl_type: tcc
theory: positions
library: TRS
signature: nil
location: 311 0 314 999
body:
  % Subtype TCC generated (at line 219, column 58) for  p
      % expected type  not_empty_seq[posnat]
  lwc_add_last_delete1_TCC2: OBLIGATION
    FORALL (p: position | p /= empty_seq[posnat]): length(p) /= 0;


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 61 3 63 56
body:
     pos_vars_subset_pos : LEMMA
                             LET Posv = Pos_var(t, x) IN
                             subset?(Posv, positionsOF(t))


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 65 3 67 39
body:
     Pos_var_is_finite: LEMMA 
                          LET Posv = Pos_var(t, x) IN
                          is_finite(Posv)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 77 2 81 12
body:
    vars_term_is_union: LEMMA 
    (CASES t OF 
      vars(t): Vars(vars(t)) = singleton(vars(t)),
      app(f, st): Vars(t) = IUnion(LAMBDA (i: below[length(st)]): Vars(st(i)))
     ENDCASES)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 87 2 88 75
body:
    pos_subterm_ax: LEMMA positionsOF(t)(p o q) =>
                                              positionsOF(subtermOF(t, p))(q)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 90 2 91 75
body:
    pos_subterm: LEMMA  positionsOF(t)(p o q) => 
                          subtermOF(t, p o q) = subtermOF(subtermOF(t, p), q)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 93 2 94 49
body:
    pos_o_term: LEMMA positionsOF(t)(p)  &  positionsOF(subtermOF(t, p))(q)
                           => positionsOF(t)(p o q)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 96 2 97 72
body:
    subterm_is_app: LEMMA positionsOF(s)(p) AND length(p) /= 0 => 
                               app?(subtermOF(s,delete(p, length(p) - 1)))


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 99 2 100 75
body:
    vars_subterm: LEMMA positionsOF(t)(p) => 
                                      subset?(Vars(subtermOF(t, p)), Vars(t))


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 102 2 103 80
body:
    disjoint_subterm: LEMMA positionsOF(t)(p) =>
      ( disjoint?(Vars(t), Vars(s)) => disjoint?(Vars(subtermOF(t, p)), Vars(s)) )


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 106 2 110 33
body:
    variable_positions_parallel: LEMMA
          FORALL (p, q: positions?(t)):
              subtermOF(t,p) = x &  
              subtermOF(t,q) = y & x /= y 
               =>     parallel(p,q)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 113 2 117 63
body:
    variable_positions: LEMMA  FORALL (p, q: positions?(t)):
                                 LET Posv = Pos_var(t, x) IN
                                 member(p, Posv) & 
                                 member(q, Posv) 
                                       =>  p = q OR parallel(p,q)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 121 2 124 36
body:
    pos_occ_var_HAStypePP: LEMMA    
                             LET Posv = Pos_var(t, x),
                                 seqv = set2seq(Posv) IN
                             PP?(seqv)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 128 2 131 39
body:
    pos_occ_var_HAStypeSP: LEMMA 
                             LET Posv = Pos_var(t, x),
                                 seqv = set2seq(Posv) IN
                             SP?(t)(seqv)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 134 2 136 65
body:
    no_empty_set_positions: LEMMA FORALL t, x, (p: positions?(t)):
                                    LET Posv = Pos_var(t, x) IN
                                    subtermOF(t, p) = x =>  Posv(p) 


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 138 2 142 48
body:
    length_seq_var_g0: LEMMA  FORALL t, x: 
                        LET Posv = Pos_var(t, x),
                            seqv = set2seq(Posv) IN
                         (EXISTS (p: positions?(t)): subtermOF(t, p) = x) 
                               => length(seqv) > 0  


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 151 1 157 8
body:
   equal_subterms_equal_term : LEMMA
     IF FORALL (p : position | positionsOF(s)(p) AND
                               positionsOF(t)(p) ):
        subtermOF(s, p) = subtermOF(t, p)
     THEN s = t
     ELSE s /= t
     ENDIF


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 160 1 166 70
body:
   subt_of_subt_is_subt_of_term : LEMMA
      FORALL (s : term,
             (k : posnat   | positionsOF(s)( #(k))),
             (p : position | positionsOF(subtermOF(s, #(k)))(p)),
             (x : position | positionsOF(s)(x))):
         x = add_first(k, p) IMPLIES 
                     subtermOF(s, x) = subtermOF( subtermOF(s, #(k)), p)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 168 1 171 73
body:
   subterm_to_subtermOF : LEMMA
      FORALL (s : term, t : term):
        subterm(s, t) IMPLIES
        (EXISTS ( p : position | positionsOF(t)(p) ) : subtermOF(t, p) = s)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 173 1 175 47
body:
   subtermOF_to_subterm : LEMMA
      FORALL (s : term, t: term, (p : position | positionsOF(t)(p))):
        subtermOF(t, p) = s IMPLIES subterm(s, t)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 177 1 179 63
body:
   subterm_to_subterm : LEMMA 
      FORALL (s : term, t : term, r : term):
        ( subterm(s, r) AND subterm(r, t) ) IMPLIES subterm(s, t)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 192 1 194 70
body:
   n_for_a_pstart : LEMMA
      FORALL (p : position, q : (set_of_seq_pos(p)) ) : 
         p /= empty_seq IMPLIES  EXISTS (n : nat) : q = comp_of_pos(p,n)


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 206 2 208 71
body:
    is_injective_function_inj: LEMMA 
       p /= empty_seq 
             IMPLIES injective?[nat,(set_of_seq_pos(p))](function_inj(p))


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 215 1 217 80
body:
   comp_of_pos_is_pos: LEMMA 
      FORALL (n: nat): positionsOF(s)(p) AND subtermOF(s, p) = s 
                                          IMPLIES positionsOF(s)(comp_of_pos(p,n))


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 219 1 221 65
body:
   subset_of_seq_pos : LEMMA
      positionsOF(s)(p) AND subtermOF(s, p) = s IMPLIES  
                          subset?(set_of_seq_pos(p),positionsOF(s))


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 226 1 228 34
body:
   app_term : LEMMA
       ( positionsOF(s)(p) AND positionsOF(s)(q) AND child(p, q) )
       IMPLIES app?(subtermOF(s, q))


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 231 1 238 55
body:
   positions_of_a_term : LEMMA
     FORALL (p : position | positionsOF(t)(p)) :
       positionsOF(t)(q) IMPLIES (left_without_children(p, q) OR
                                  left_without_children(q, p) OR
                                  child(p, q) OR
                                  (EXISTS(q1 : position) :
                                        positionsOF(subtermOF(t, p))(q1) 
                                        AND q = p o q1) )


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 240 1 242 15
body:
   equal_app_term : LEMMA
    ( app?(s) AND app?(t) AND f(s) = f(t) AND args(s) = args(t) )
    IMPLIES s = t


decl_type: formula
theory: subterm
library: TRS
signature: nil
location: 244 1 266 17
body:
   equal_term : LEMMA
     FORALL (s : term, 
             t : term, 
             p : position | positionsOF(s)(p) AND  
                            positionsOF(t)(p)) :
     ( (FORALL (q: position | positionsOF(s)(q) AND 
                              positionsOF(t)(q)):
          left_without_children(p, q) =>
           subtermOF(s, q) = subtermOF(t, q))
      AND
       (FORALL (q: position | positionsOF(s)(q) AND
                              positionsOF(t)(q)):
          left_without_children(q, p) =>
           subtermOF(s, q) = subtermOF(t, q))
      AND
       (FORALL (p1: position | positionsOF(s)(p1) AND
                               positionsOF(t)(p1)):
          child(p, p1) => f(subtermOF(s, p1)) = f(subtermOF(t, p1)))
      AND
        subtermOF(s, p) = subtermOF(t, p)
      AND
        NOT p = empty_seq )
      IMPLIES s = t


decl_type: function
theory: subterm
library: TRS
signature:
  [[t: term, positions?[variable, symbol, arity](t)] ->
  term[variable, symbol, arity]]

location: 33 3 43 20
body:
     subtermOF(t: term, (p: positions?(t))): RECURSIVE term =
           (IF length(p) = 0
            THEN
              t
            ELSE
              LET st = args(t),
                   i = first(p),
                   q = rest(p)  IN
              subtermOF(st(i-1), q)
            ENDIF)
     MEASURE length(p)


decl_type: function
theory: subterm
library: TRS
signature:
  [[position[variable, symbol, arity], nat] ->
  position[variable, symbol, arity]]

location: 182 1 186 11
body:
   comp_of_pos(p : position, n : nat) : RECURSIVE  position =  
      IF n = 0 then empty_seq 
      ELSE p o comp_of_pos(p, n - 1) 
      ENDIF
    MEASURE n 


decl_type: function
theory: subterm
library: TRS
signature:
  [position[variable, symbol, arity] ->
  set[position[variable, symbol, arity]]]

location: 189 1 190 72
body:
   set_of_seq_pos(p) : set[position] =
                    IUnion(LAMBDA (n : nat) : singleton(comp_of_pos(p,n))) 


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 275 0 285 999
body:
  % Subtype TCC generated (at line 39, column 27) for  p
      % expected type  not_empty_seq[posnat]
  subtermOF_TCC1: OBLIGATION
    FORALL (t: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](t))):
      NOT length(p) = 0 IMPLIES
       (FORALL (st:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length =
                            arity(f[variable, symbol, arity](t))}):
          st = args(t) IMPLIES length(p) /= 0);


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 287 0 301 999
body:
  % Subtype TCC generated (at line 41, column 25) for  i - 1
      % expected type  below[length(st)]
  subtermOF_TCC2: OBLIGATION
    FORALL (t: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](t))):
      NOT length(p) = 0 IMPLIES
       (FORALL (st:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length =
                            arity(f[variable, symbol, arity](t))}):
          st = args(t) IMPLIES
           (FORALL (i: posnat):
              i = first(p) IMPLIES
               (FORALL (q: position[variable, symbol, arity]):
                  q = rest(p) IMPLIES i - 1 >= 0 AND i - 1 < length(st))));


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 303 0 323 999
body:
  % Subtype TCC generated (at line 41, column 31) for  q
      % expected type  positions?
                     %     [variable, symbol,
                     %      arity](finseq_appl[term[variable, symbol, arity]]
                     %                 (st)(i - 1))
  subtermOF_TCC3: OBLIGATION
    FORALL (t: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](t))):
      NOT length(p) = 0 IMPLIES
       (FORALL (st:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length =
                            arity(f[variable, symbol, arity](t))}):
          st = args(t) IMPLIES
           (FORALL (i: posnat):
              i = first(p) IMPLIES
               (FORALL (q: position[variable, symbol, arity]):
                  q = rest(p) IMPLIES
                   positionsOF[variable, symbol, arity]
                       (finseq_appl[term[variable, symbol, arity]](st)(i - 1))
                       (q))));


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 325 0 339 999
body:
  % Termination TCC generated (at line 41, column 12) for
      % subtermOF(finseq_appl[term[variable, symbol, arity]](st)(i - 1), q)
  subtermOF_TCC4: OBLIGATION
    FORALL (t: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](t))):
      NOT length(p) = 0 IMPLIES
       (FORALL (st:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length =
                            arity(f[variable, symbol, arity](t))}):
          st = args(t) IMPLIES
           (FORALL (i: posnat):
              i = first(p) IMPLIES
               (FORALL (q: position[variable, symbol, arity]):
                  q = rest(p) IMPLIES length(q) < length(p))));


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 341 0 346 999
body:
  % Subtype TCC generated (at line 38, column 26) for  t
      % expected type  d: (app?)
  subtermOF_TCC5: OBLIGATION
    FORALL (t: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](t))):
      NOT length(p) = 0 IMPLIES app?[variable, symbol, arity](t);


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 348 0 354 999
body:
  % Subtype TCC generated (at line 88, column 69) for  p
      % expected type  positions?[variable, symbol, arity](t)
  pos_subterm_ax_TCC1: OBLIGATION
    FORALL (p, q: position[variable, symbol, arity],
            t: term[variable, symbol, arity]):
      positionsOF(t)(p o q) IMPLIES
       positionsOF[variable, symbol, arity](t)(p);


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 356 0 362 999
body:
  % Subtype TCC generated (at line 91, column 73) for  q
      % expected type  positions?[variable, symbol, arity](subtermOF(t, p))
  pos_subterm_TCC1: OBLIGATION
    FORALL (p, q: position[variable, symbol, arity],
            t: term[variable, symbol, arity]):
      positionsOF(t)(p o q) IMPLIES
       positionsOF[variable, symbol, arity](subtermOF(t, p))(q);


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 364 0 370 999
body:
  % Subtype TCC generated (at line 97, column 56) for  length(p) - 1
      % expected type  below[length(p)]
  subterm_is_app_TCC1: OBLIGATION
    FORALL (p: position[variable, symbol, arity],
            s: term[variable, symbol, arity]):
      length(p) /= 0 AND positionsOF(s)(p) IMPLIES
       length(p) - 1 >= 0 AND length(p) - 1 < length(p);


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 372 0 380 999
body:
  % Subtype TCC generated (at line 97, column 46) for
      % delete(p, length(p) - 1)
      % expected type  positions?[variable, symbol, arity](s)
  subterm_is_app_TCC2: OBLIGATION
    FORALL (p: position[variable, symbol, arity],
            s: term[variable, symbol, arity]):
      length(p) /= 0 AND positionsOF(s)(p) IMPLIES
       positionsOF[variable, symbol, arity]
           (s)(delete[posnat](p, length(p) - 1));


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 382 0 388 999
body:
  % Subtype TCC generated (at line 123, column 46) for  Posv
      % expected type  finite_set[position[variable, symbol, arity]]
  pos_occ_var_HAStypePP_TCC1: OBLIGATION
    FORALL (t: term[variable, symbol, arity], x: (V),
            Posv: positions[variable, symbol, arity]):
      Posv = Pos_var(t, x) IMPLIES
       is_finite[position[variable, symbol, arity]](Posv);


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 390 0 394 999
body:
  % Subtype TCC generated (at line 149, column 17) for  empty_seq
      % expected type  positions?[variable, symbol, arity](s)
  subterm_empty_seq_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity]):
      positionsOF[variable, symbol, arity](s)(empty_seq[posnat]);


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 396 0 402 999
body:
  % Subtype TCC generated (at line 163, column 52) for   #(k)
      % expected type  positions?[variable, symbol, arity](s)
  subt_of_subt_is_subt_of_term_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (k: posnat
                 | positionsOF[variable, symbol, arity](s)( #[posnat](k)))):
      positionsOF[variable, symbol, arity](s)( #[posnat](k));


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 404 0 406 999
body:
  % Subtype TCC generated (at line 184, column 28) for  n - 1
      % expected type  nat
  comp_of_pos_TCC1: OBLIGATION FORALL (n: nat): NOT n = 0 IMPLIES n - 1 >= 0;


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 408 0 410 999
body:
  % Termination TCC generated (at line 184, column 13) for
      % comp_of_pos(p, n - 1)
  comp_of_pos_TCC2: OBLIGATION FORALL (n: nat): NOT n = 0 IMPLIES n - 1 < n;


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 412 0 417 999
body:
  % Subtype TCC generated (at line 208, column 55) for  function_inj(p)
      % expected type  [nat -> (set_of_seq_pos(p))]
  is_injective_function_inj_TCC1: OBLIGATION
    FORALL (p: position[variable, symbol, arity]):
      p /= empty_seq IMPLIES
       (FORALL (x1: nat): set_of_seq_pos(p)(function_inj(p)(x1)));


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 419 0 439 999
body:
  % Subtype TCC generated (at line 261, column 26) for  subtermOF(s, p1)
      % expected type  (app?)
  equal_term_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            t: term[variable, symbol, arity],
            p: position[variable, symbol, arity]
                | positionsOF[variable, symbol, arity](s)(p) AND
                   positionsOF[variable, symbol, arity](t)(p)):
      ((FORALL (q: position[variable, symbol, arity]
                    | positionsOF(s)(q) AND positionsOF(t)(q)):
          left_without_children(q, p) => subtermOF(s, q) = subtermOF(t, q))
        AND
        (FORALL (q: position[variable, symbol, arity]
                     | positionsOF(s)(q) AND positionsOF(t)(q)):
           left_without_children(p, q) => subtermOF(s, q) = subtermOF(t, q)))
       IMPLIES
       (FORALL (p1: position[variable, symbol, arity]
                    | positionsOF[variable, symbol, arity](s)(p1) AND
                       positionsOF[variable, symbol, arity](t)(p1)):
          child(p, p1) IMPLIES
           app?[variable, symbol, arity](subtermOF(s, p1)));


decl_type: tcc
theory: subterm
library: TRS
signature: nil
location: 441 0 461 999
body:
  % Subtype TCC generated (at line 261, column 48) for  subtermOF(t, p1)
      % expected type  (app?)
  equal_term_TCC2: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            t: term[variable, symbol, arity],
            p: position[variable, symbol, arity]
                | positionsOF[variable, symbol, arity](s)(p) AND
                   positionsOF[variable, symbol, arity](t)(p)):
      ((FORALL (q: position[variable, symbol, arity]
                    | positionsOF(s)(q) AND positionsOF(t)(q)):
          left_without_children(q, p) => subtermOF(s, q) = subtermOF(t, q))
        AND
        (FORALL (q: position[variable, symbol, arity]
                     | positionsOF(s)(q) AND positionsOF(t)(q)):
           left_without_children(p, q) => subtermOF(s, q) = subtermOF(t, q)))
       IMPLIES
       (FORALL (p1: position[variable, symbol, arity]
                    | positionsOF[variable, symbol, arity](s)(p1) AND
                       positionsOF[variable, symbol, arity](t)(p1)):
          child(p, p1) IMPLIES
           app?[variable, symbol, arity](subtermOF(t, p1)));


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 48 1 50 65
body:
   replace_preserv_pos: LEMMA positionsOF(s)(p) 
                              => 
                               positionsOF(replaceTerm(s, t, p))(p)


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 53 1 55 72
body:
   replace_compose_pos: LEMMA positionsOF(t)(q) & positionsOF(s)(p)
                                =>
                                  positionsOF(replaceTerm(s, t, p))(p o q)


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 58 1 62 78
body:
   replace_preserv_parallel_pos: LEMMA positionsOF(s)(q) & 
                                       positionsOF(s)(p) & 
                                       parallel(p, q)
                                          =>
                                            positionsOF(replaceTerm(s, t, p))(q)


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 65 1 68 46
body:
   preserv_unchanged_pos: LEMMA positionsOF(s)(p) & 
                       positionsOF(replaceTerm(s, t, p))(q) & 
                       parallel(p, q)  
                            => positionsOF(s)(q)


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 71 1 73 69
body:
   subterm_of_replace: LEMMA positionsOF(s)(p) 
                                => 
                                  subtermOF(replaceTerm(s, t, p),p) = t


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 76 1 78 75
body:
   replace_subterm_of_term: LEMMA positionsOF(s)(p)
                                      => 
                                       replaceTerm(s, subtermOF(s, p), p) = s


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 81 1 82 75
body:
   replace_embedding: LEMMA positionsOF(s)(p) & positionsOF(t)(q) =>
                      subtermOF(replaceTerm(s, t, p),p o q) = subtermOF(t, q)


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 85 1 86 79
body:
   replace_associativity: LEMMA positionsOF(s)(p) & positionsOF(t)(q) =>
    replaceTerm(replaceTerm(s,t,p),r,p o q) = replaceTerm(s,replaceTerm(t,r,q),p)


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 89 1 90 76
body:
   replace_distributivity: LEMMA positionsOF(s)(p o q) =>
     subtermOF(replaceTerm(s,t,p o q), p) = replaceTerm(subtermOF(s, p), t, q)


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 93 1 94 76
body:
   replace_dominance: LEMMA positionsOF(s)(p o q) =>
                  replaceTerm(replaceTerm(s,t,p o q),r,p) = replaceTerm(s,r,p)


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 97 1 101 81
body:
   replace_persistence: LEMMA positionsOF(s)(p) & 
                              positionsOF(s)(q) & 
                              parallel(p,q)
                               =>
                                subtermOF(replaceTerm(s, t, p), q) = subtermOF(s,q)


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 104 1 107 79
body:
   replace_commutativity: LEMMA 
     positionsOF(s)(p) & positionsOF(s)(q) & parallel(p,q) 
       =>
        replaceTerm(replaceTerm(s,t,p),r,q) = replaceTerm(replaceTerm(s,r,q),t,p)


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 110 1 112 69
body:
   pos_replaces_is_subset: LEMMA
         FORALL t, x, (p: positions?(t)): 
             subset?(positionsOF(replaceTerm(t, x, p)), positionsOF(t))


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 115 1 118 76
body:
   pos_occ_var_replace: LEMMA
       FORALL t, y, x, (p: positions?(t)): 
             Pos_var(t, x)(p) & y /= x
               =>  Pos_var(replaceTerm(t, y, p), x) = remove(p, Pos_var(t, x))


decl_type: formula
theory: replacement
library: TRS
signature: nil
location: 121 2 125 79
body:
    pos_occ_var_replace_as_diff: LEMMA
     FORALL t, y, x, (p: positions?(t)): 
      Pos_var(t, x)(p) & y /= x
      =>  
       Pos_var(replaceTerm(t, y, p), x) = difference(Pos_var(t, x), singleton(p))


decl_type: function
theory: replacement
library: TRS
location: 31 1 42 20
signature:
  [[s: term, term[variable, symbol, arity],
         positions?[variable, symbol, arity](s)] ->
          term[variable, symbol, arity]]

body:
   replaceTerm(s: term, t: term, (p: positions?(s))): RECURSIVE term =
       (IF length(p) = 0
        THEN
          t
        ELSE
          LET st = args(s),
               i = first(p),
               q = rest(p),
             rst = replace(replaceTerm(st(i-1), t, q), st,i-1) IN
          app(f(s), rst)
        ENDIF)
     MEASURE length(p)


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 133 0 143 999
body:
  % Subtype TCC generated (at line 37, column 23) for  p
      % expected type  not_empty_seq[posnat]
  replaceTerm_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](s))):
      NOT length(p) = 0 IMPLIES
       (FORALL (st:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length =
                            arity(f[variable, symbol, arity](s))}):
          st = args(s) IMPLIES length(p) /= 0);


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 145 0 159 999
body:
  % Subtype TCC generated (at line 39, column 40) for  i - 1
      % expected type  below[length(st)]
  replaceTerm_TCC2: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](s))):
      NOT length(p) = 0 IMPLIES
       (FORALL (st:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length =
                            arity(f[variable, symbol, arity](s))}):
          st = args(s) IMPLIES
           (FORALL (i: posnat):
              i = first(p) IMPLIES
               (FORALL (q: position[variable, symbol, arity]):
                  q = rest(p) IMPLIES i - 1 >= 0 AND i - 1 < length(st))));


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 161 0 181 999
body:
  % Subtype TCC generated (at line 39, column 49) for  q
      % expected type  positions?
                     %     [variable, symbol,
                     %      arity](finseq_appl[term[variable, symbol, arity]]
                     %                 (st)(i - 1))
  replaceTerm_TCC3: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](s))):
      NOT length(p) = 0 IMPLIES
       (FORALL (st:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length =
                            arity(f[variable, symbol, arity](s))}):
          st = args(s) IMPLIES
           (FORALL (i: posnat):
              i = first(p) IMPLIES
               (FORALL (q: position[variable, symbol, arity]):
                  q = rest(p) IMPLIES
                   positionsOF[variable, symbol, arity]
                       (finseq_appl[term[variable, symbol, arity]](st)(i - 1))
                       (q))));


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 183 0 198 999
body:
  % Termination TCC generated (at line 39, column 25) for
      % replaceTerm(finseq_appl[term[variable, symbol, arity]](st)(i - 1), t,
      %             q)
  replaceTerm_TCC4: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](s))):
      NOT length(p) = 0 IMPLIES
       (FORALL (st:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length =
                            arity(f[variable, symbol, arity](s))}):
          st = args(s) IMPLIES
           (FORALL (i: posnat):
              i = first(p) IMPLIES
               (FORALL (q: position[variable, symbol, arity]):
                  q = rest(p) IMPLIES length(q) < length(p))));


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 200 0 228 999
body:
  % Subtype TCC generated (at line 40, column 14) for  s
      % expected type  (app?)
  replaceTerm_TCC5: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            t: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](s)),
            v:
              [{z:
                  [s: term, term[variable, symbol, arity],
                   positions?[variable, symbol, arity](s)] |
                        length(z`3) < length(p)} ->
                 term[variable, symbol, arity]]):
      NOT length(p) = 0 IMPLIES
       (FORALL (st:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length =
                            arity(f[variable, symbol, arity](s))}):
          st = args(s) IMPLIES
           (FORALL (i: posnat):
              i = first(p) IMPLIES
               (FORALL (q: position[variable, symbol, arity]):
                  q = rest(p) IMPLIES
                   (FORALL (rst: finseq[term[variable, symbol, arity]]):
                      rst =
                       replace(v(finseq_appl[term[variable, symbol, arity]]
                                     (st)(i - 1),
                                 t, q),
                               st, i - 1)
                       IMPLIES app?[variable, symbol, arity](s)))));


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 230 0 261 999
body:
  % Subtype TCC generated (at line 40, column 18) for  rst
      % expected type  {args:
                     %    finite_sequence[term[variable, symbol, arity]] |
                     %          args`length = arity(f(s))}
  replaceTerm_TCC6: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            t: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](s)),
            v:
              [{z:
                  [s: term, term[variable, symbol, arity],
                   positions?[variable, symbol, arity](s)] |
                        length(z`3) < length(p)} ->
                 term[variable, symbol, arity]]):
      NOT length(p) = 0 IMPLIES
       (FORALL (st:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length =
                            arity(f[variable, symbol, arity](s))}):
          st = args(s) IMPLIES
           (FORALL (i: posnat):
              i = first(p) IMPLIES
               (FORALL (q: position[variable, symbol, arity]):
                  q = rest(p) IMPLIES
                   (FORALL (rst: finseq[term[variable, symbol, arity]]):
                      rst =
                       replace(v(finseq_appl[term[variable, symbol, arity]]
                                     (st)(i - 1),
                                 t, q),
                               st, i - 1)
                       IMPLIES
                       rst`length = arity(f[variable, symbol, arity](s))))));


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 263 0 268 999
body:
  % Subtype TCC generated (at line 36, column 22) for  s
      % expected type  d: (app?)
  replaceTerm_TCC7: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (p: positions?[variable, symbol, arity](s))):
      NOT length(p) = 0 IMPLIES app?[variable, symbol, arity](s);


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 270 0 277 999
body:
  % Subtype TCC generated (at line 73, column 63) for  p
      % expected type  positions?
                     %     [variable, symbol, arity](replaceTerm(s, t, p))
  subterm_of_replace_TCC1: OBLIGATION
    FORALL (p: position[variable, symbol, arity],
            s, t: term[variable, symbol, arity]):
      positionsOF(s)(p) IMPLIES
       positionsOF[variable, symbol, arity](replaceTerm(s, t, p))(p);


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 279 0 287 999
body:
  % Subtype TCC generated (at line 82, column 51) for  p o q
      % expected type  positions?
                     %     [variable, symbol, arity](replaceTerm(s, t, p))
  replace_embedding_TCC1: OBLIGATION
    FORALL (p, q: position[variable, symbol, arity],
            s, t: term[variable, symbol, arity]):
      positionsOF(t)(q) AND positionsOF(s)(p) IMPLIES
       positionsOF[variable, symbol, arity]
           (replaceTerm(s, t, p))(o[posnat](p, q));


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 289 0 297 999
body:
  % Subtype TCC generated (at line 90, column 37) for  p
      % expected type  positions?
                     %     [variable, symbol, arity](replaceTerm(s, t, p o q))
  replace_distributivity_TCC1: OBLIGATION
    FORALL (p, q: position[variable, symbol, arity],
            s, t: term[variable, symbol, arity]):
      positionsOF(s)(p o q) IMPLIES
       positionsOF[variable, symbol, arity]
           (replaceTerm(s, t, o[posnat](p, q)))(p);


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 299 0 305 999
body:
  % Subtype TCC generated (at line 90, column 67) for  p
      % expected type  positions?[variable, symbol, arity](s)
  replace_distributivity_TCC2: OBLIGATION
    FORALL (p, q: position[variable, symbol, arity],
            s: term[variable, symbol, arity]):
      positionsOF(s)(p o q) IMPLIES
       positionsOF[variable, symbol, arity](s)(p);


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 307 0 314 999
body:
  % Subtype TCC generated (at line 90, column 74) for  q
      % expected type  positions?[variable, symbol, arity](subtermOF(s, p))
  replace_distributivity_TCC3: OBLIGATION
    FORALL (p, q: position[variable, symbol, arity],
            s: term[variable, symbol, arity]):
      positionsOF(s)(p o q) IMPLIES
       positionsOF[variable, symbol, arity]
           (subtermOF[variable, symbol, arity](s, p))(q);


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 316 0 323 999
body:
  % Subtype TCC generated (at line 101, column 62) for  q
      % expected type  positions?
                     %     [variable, symbol, arity](replaceTerm(s, t, p))
  replace_persistence_TCC1: OBLIGATION
    FORALL (p, q: position[variable, symbol, arity],
            s, t: term[variable, symbol, arity]):
      parallel(p, q) AND positionsOF(s)(q) AND positionsOF(s)(p) IMPLIES
       positionsOF[variable, symbol, arity](replaceTerm(s, t, p))(q);


decl_type: tcc
theory: replacement
library: TRS
signature: nil
location: 325 0 332 999
body:
  % Subtype TCC generated (at line 107, column 77) for  p
      % expected type  positions?
                     %     [variable, symbol, arity](replaceTerm(s, r, q))
  replace_commutativity_TCC1: OBLIGATION
    FORALL (p, q: position[variable, symbol, arity],
            r, s: term[variable, symbol, arity]):
      parallel(p, q) AND positionsOF(s)(q) AND positionsOF(s)(p) IMPLIES
       positionsOF[variable, symbol, arity](replaceTerm(s, r, q))(p);


decl_type: formula
theory: compatibility
library: TRS
signature: nil
location: 65 1 66 71
body:
   closure_comp_op: LEMMA comp_op?(R) => 
                   (comp_op?(TC(R)) & comp_op?(RTC(R)) & comp_op?(EC(R)))


decl_type: formula
theory: compatibility
library: TRS
signature: nil
location: 68 1 69 77
body:
   closure_comp_cont: LEMMA comp_cont?(R) => 
                   (comp_cont?(TC(R)) & comp_cont?(RTC(R)) & comp_cont?(EC(R)))


decl_type: function
theory: compatibility
library: TRS
location: 41 1 44 40
signature:
  [pred
            [[term[variable, symbol, arity],
              term[variable, symbol, arity]]] ->
          bool]

body:
   close_op?(R): bool = 
      FORALL ( n: nat, (f: arity_eq(n)), (st1, st2: fset.fs_len(n))):
        (FORALL (m: below[n]): R(st1(m), st2(m))
           => R(app(f, st1), app(f, st2)))


decl_type: function
theory: compatibility
library: TRS
location: 47 1 50 45
signature:
  [pred
            [[term[variable, symbol, arity],
              term[variable, symbol, arity]]] ->
          bool]

body:
   comp_op?(R): bool = 
      FORALL (n: nat, i: below[n], (f: arity_eq(n)), (st1: fset.fs_len(n)), t):
         LET s = st1(i), st2 = replace(t, st1, i) IN
           R(s,t) =>  R(app(f,st1), app(f,st2))


decl_type: function
theory: compatibility
library: TRS
location: 53 1 55 73
signature:
  [pred
            [[term[variable, symbol, arity],
              term[variable, symbol, arity]]] ->
          bool]

body:
   comp_cont?(R): bool = FORALL (p: position), s: positionsOF(s)(p) =>
                          (FORALL r, t: R(r,t) =>  
                             R(replaceTerm(s, r, p), replaceTerm(s, t, p)))


decl_type: tcc
theory: compatibility
library: TRS
signature: nil
location: 76 0 82 999
body:
  % Subtype TCC generated (at line 43, column 35) for  m
      % expected type  below[length(st1)]
  close_op?_TCC1: OBLIGATION
    FORALL (n: nat, (f: arity_eq(n)),
            (st1, st2: fset[term[variable, symbol, arity]].fs_len(n)),
            m: below[n]):
      m < length(st1);


decl_type: tcc
theory: compatibility
library: TRS
signature: nil
location: 84 0 90 999
body:
  % Subtype TCC generated (at line 43, column 43) for  m
      % expected type  below[length(st2)]
  close_op?_TCC2: OBLIGATION
    FORALL (n: nat, (f: arity_eq(n)),
            (st1, st2: fset[term[variable, symbol, arity]].fs_len(n)),
            m: below[n]):
      m < length(st2);


decl_type: tcc
theory: compatibility
library: TRS
signature: nil
location: 92 0 106 999
body:
  % Subtype TCC generated (at line 44, column 21) for  st1
      % expected type  {args:
                     %    finite_sequence[term[variable, symbol, arity]] |
                     %          args`length = arity(f)}
  close_op?_TCC3: OBLIGATION
    FORALL (R:
              pred
                  [[term[variable, symbol, arity],
                    term[variable, symbol, arity]]],
            n: nat, (f: arity_eq(n)),
            (st1, st2: fset[term[variable, symbol, arity]].fs_len(n)),
            m: below[n]):
      R(finseq_appl[term[variable, symbol, arity]](st1)(m),
        finseq_appl[term[variable, symbol, arity]](st2)(m))
       IMPLIES st1`length = arity(f);


decl_type: tcc
theory: compatibility
library: TRS
signature: nil
location: 108 0 122 999
body:
  % Subtype TCC generated (at line 44, column 34) for  st2
      % expected type  {args:
                     %    finite_sequence[term[variable, symbol, arity]] |
                     %          args`length = arity(f)}
  close_op?_TCC4: OBLIGATION
    FORALL (R:
              pred
                  [[term[variable, symbol, arity],
                    term[variable, symbol, arity]]],
            n: nat, (f: arity_eq(n)),
            (st1, st2: fset[term[variable, symbol, arity]].fs_len(n)),
            m: below[n]):
      R(finseq_appl[term[variable, symbol, arity]](st1)(m),
        finseq_appl[term[variable, symbol, arity]](st2)(m))
       IMPLIES st2`length = arity(f);


decl_type: tcc
theory: compatibility
library: TRS
signature: nil
location: 124 0 129 999
body:
  % Subtype TCC generated (at line 49, column 19) for  i
      % expected type  below[length(st1)]
  comp_op?_TCC1: OBLIGATION
    FORALL (n: nat, i: below[n], (f: arity_eq(n)),
            (st1: fset[term[variable, symbol, arity]].fs_len(n))):
      i < length(st1);


decl_type: tcc
theory: compatibility
library: TRS
signature: nil
location: 131 0 146 999
body:
  % Subtype TCC generated (at line 50, column 28) for  st1
      % expected type  {args:
                     %    finite_sequence[term[variable, symbol, arity]] |
                     %          args`length = arity(f)}
  comp_op?_TCC2: OBLIGATION
    FORALL (R:
              pred
                  [[term[variable, symbol, arity],
                    term[variable, symbol, arity]]],
            n: nat, i: below[n], (f: arity_eq(n)),
            (st1: fset[term[variable, symbol, arity]].fs_len(n)),
            t: term[variable, symbol, arity],
            s: term[variable, symbol, arity]):
      s = finseq_appl[term[variable, symbol, arity]](st1)(i) IMPLIES
       (FORALL (st2: finseq[term[variable, symbol, arity]]):
          R(s, t) AND st2 = replace(t, st1, i) IMPLIES st1`length = arity(f));


decl_type: tcc
theory: compatibility
library: TRS
signature: nil
location: 148 0 163 999
body:
  % Subtype TCC generated (at line 50, column 40) for  st2
      % expected type  {args:
                     %    finite_sequence[term[variable, symbol, arity]] |
                     %          args`length = arity(f)}
  comp_op?_TCC3: OBLIGATION
    FORALL (R:
              pred
                  [[term[variable, symbol, arity],
                    term[variable, symbol, arity]]],
            n: nat, i: below[n], (f: arity_eq(n)),
            (st1: fset[term[variable, symbol, arity]].fs_len(n)),
            t: term[variable, symbol, arity],
            s: term[variable, symbol, arity]):
      s = finseq_appl[term[variable, symbol, arity]](st1)(i) IMPLIES
       (FORALL (st2: finseq[term[variable, symbol, arity]]):
          R(s, t) AND st2 = replace(t, st1, i) IMPLIES st2`length = arity(f));


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 129 2 130 78
body:
    union_commute: LEMMA disjoint?(Dom(sigma), Dom(tau)) => 
                             union_subs((sigma, tau)) = union_subs((tau, sigma))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 163 1 164 69
body:
   restriction_term: LEMMA subset?(Vars(t), Vs) =>  
                        ext(sigma)(t) =  ext(restriction(sigma)(Vs))(t)


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 166 1 169 67
body:
   restriction_union: LEMMA disjoint?(Dom(sg1), Dom(sg2)) & 
                         disjoint?(Vars(t), Dom(sg2)) 
                          =>
                           ext(union_subs(sg1, sg2))(t) = ext(sg1)(t)


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 192 1 194 55
body:
   inverse_renaming: LEMMA
        EXISTS rho1: 
          FORALL x: Dom(rho)(x) => comp(rho1, rho)(x) = x


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 196 1 200 33
body:
   inverse_rename_identity: LEMMA
      subset?(Vars(t), Dom(rho)) &
     (FORALL x: Dom(rho)(x) => comp(rho1, rho)(x) = x)
       => 
        ext(comp(rho1, rho))(t) = t


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 211 1 213 71
body:
   idemp_sub_term_empty_inter: LEMMA
      FORALL (t: term, sigma: Sub): 
         ext(sigma)(t) = t IFF  empty?(intersection(Dom(sigma), Vars(t)))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 215 1 216 79
body:
   idemp_sub_iff_empty_intersection : LEMMA
        idempotent_sub?(sigma) IFF empty?(intersection( Dom(sigma), VRan(sigma)))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 236 2 239 39
body:
    DSigma_do_nothing: LEMMA
     FORALL t, s, x:
       empty?(Pos_var(s, x))
          IMPLIES ext(DSigma(t,x))(s) = s


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 268 2 269 73
body:
    SigmaP_Dom: LEMMA  positionsOF(sigma(x))(p) =>
      subset?(Dom(SigmaP(sigma, t, x, p)), union(Dom(sigma), singleton(x)))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 271 2 272 62
body:
    SigmaP_Dom_fin: LEMMA positionsOF(sigma(x))(p) =>
                          is_finite(Dom(SigmaP(sigma, t, x, p)))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 274 2 275 54
body:
    SigmaP_Subs: LEMMA positionsOF(sigma(x))(p) => 
                            Sub?(SigmaP(sigma, t, x, p))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 277 2 280 74
body:
    SigmaP_is_RSigma: LEMMA (positionsOF(sigma(x))(p) &
                                 comp_cont?(R) &
                                 R(subtermOF(sigma(x), p), t)) =>
                                 RSigma(R, sigma, SigmaP(sigma, t, x, p), x)


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 283 2 285 69
body:
    gamma_Dom: LEMMA 
      LET sg1Usg2 = union(Dom(sg1), Dom(sg2)) IN 
      subset?(Dom(gamma(sg1, sg2, x, y)), union(sg1Usg2, singleton(y)))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 293 3 296 70
body:
     gamma_is_RSigma: LEMMA 
        RSigma(R, sg1, sg2, z) & z /= y
            => 
              RSigma(R, gamma(sg1, sg2, x, y), gamma(sg2, sg2, x, y), z)


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 298 2 302 65
body:
    gamma_term: LEMMA 
                  NOT member(y, Vars(t)) 
                      => 
                        ext(gamma(sg1, sg2, x, y))(t) = ext(sg1)(t) &
                        ext(gamma(sg2, sg2, x, y))(t) = ext(sg2)(t)


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 304 3 308 67
body:
     Rhop_Dom: LEMMA
              x /= y          &
              NOT Dom(rho)(x)
                =>  
                 Dom(Rhop(rho, x, y)) = union(Dom(rho), singleton(x))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 310 3 315 67
body:
     Rhop_Ran: LEMMA
              x /= y          &
              NOT Dom(rho)(x) &
              NOT Ran(rho)(y)
                =>  
                 Ran(Rhop(rho, x, y)) = union(Ran(rho), singleton(y))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 317 3 321 47
body:
     Rhop_Dom_fin: LEMMA 
              x /= y &
              NOT Dom(rho)(x)   
                =>   
                  is_finite(Dom(Rhop(rho, x, y)))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 323 3 326 39
body:
     Rhop_Subs: LEMMA 
             x /= y &
             NOT Dom(rho)(x)   
               =>   Sub?(Rhop(rho, x, y))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 328 3 332 38
body:
     Rhop_Ren: LEMMA      
                   x /= y &
                   NOT Dom(rho)(x) &
                   NOT Ran(rho)(y) => 
                   Ren?(Rhop(rho, x, y))     


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 341 1 342 80
body:
   subterm_ext_commute: LEMMA 
    positionsOF(s)(p) => subtermOF(ext(sigma)(s), p) = ext(sigma)(subtermOF(s, p))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 345 1 347 54
body:
   ext_replace_ext: LEMMA positionsOF(s)(p) =>
    ext(sigma)(replaceTerm(s, t, p)) 
          = replaceTerm(ext(sigma)(s), ext(sigma)(t), p)


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 350 1 355 76
body:
   positions_of_ext: LEMMA positionsOF(ext(sigma)(t)) = 
     union({p | positionsOF(t)(p) & (NOT vars?(subtermOF(t, p)))}, 
           {q | EXISTS p1, p2: q = p1 o p2 AND 
                               positionsOF(t)(p1) AND 
                               vars?(subtermOF(t, p1)) AND 
                               positionsOF(ext(sigma)(subtermOF(t, p1)))(p2)})


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 361 0 368 7
body:
  subterm_of_ext: LEMMA positionsOF(t)(p) => 
  (IF vars?(subtermOF(t, p))
   THEN 
   (positionsOF(ext(sigma)(subtermOF(t, p)))(p1) =>
    subtermOF(ext(sigma)(t), p o p1) = subtermOF(ext(sigma)(subtermOF(t, p)), p1))
   ELSE
   subtermOF(ext(sigma)(t), p) = ext(sigma)(subtermOF(t, p))
   ENDIF)


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 371 1 372 78
body:
   rename_preserv_inclusion: LEMMA subset?(Vars(t), Vars(s)) => 
                                   subset?(Vars(ext(rho)(t)), Vars(ext(rho)(s)))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 375 1 376 76
body:
   same_substitution: LEMMA ext(sg1)(t) = ext(sg2)(t) => 
                             (FORALL x: member(x, Vars(t)) => sg1(x) = sg2(x))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 379 2 380 77
body:
    same_term: LEMMA (FORALL x: member(x, Vars(t)) => sg1(x) = sg2(x)) =>  
                                                      ext(sg1)(t) = ext(sg2)(t)


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 395 1 397 76
body:
   add_parallel_pos: LEMMA FORALL t, sigma, (fst: SPP(t)), (p: positions?(t)):
         ( FORALL (i: below[length(fst)]): parallel(fst(i),p)) =>
                                         SPP?(ext(sigma)(t))(add_first(p,fst))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 404 1 407 69
body:
   rest_parallel_first: LEMMA FORALL t, (fst: SPP(t)): fst`length /= 0 
                       =>
                         FORALL (i: below[length(rest(fst))]):
                                     parallel(rest(fst)(i), fst`seq(0))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 409 1 413 66
body:
   rest_parallel_pos_parallel: LEMMA  FORALL t, (fst: SPP(t)), (p: positions?(t)):
                 ( FORALL (i: below[length(fst)]): parallel(fst(i),p))
                  =>
                   FORALL (i: below[length(rest(fst))]):
                                           parallel(rest(fst)(i), p)


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 415 0 418 45
body:
  vars_subst_not_in: LEMMA
    FORALL t, sigma, x: Dom(sigma)(x) AND 
                       (FORALL r: Ran(sigma)(r) IMPLIES NOT member(x, Vars(r)))
     IMPLIES NOT member(x, Vars(ext(sigma)(t)))


decl_type: formula
theory: substitution
library: TRS
signature: nil
location: 420 0 425 60
body:
  ext_preserve_symbol : LEMMA
      FORALL (s : term,
              sig : Sub, 
              p : position | positionsOF(s)(p)):
         app?(subtermOF(s, p)) IMPLIES
             f(subtermOF(s, p)) = f(subtermOF(ext(sig)(s), p)) 


decl_type: function
theory: substitution
library: TRS
signature:
  [[(V) -> term[variable, symbol, arity]] ->
  set[term[variable, symbol, arity]]]

location: 49 6 50 79
body:
        Ran(sig): set[term] = 
                   {y: term | EXISTS (x: (V)): member(x, Dom(sig)) &  y = sig(x)}


decl_type: function
theory: substitution
library: TRS
signature: [Sub -> bool]
location: 69 3 70 70
body:
     Ren?(sigma): bool =  subset?(Ran(sigma),V) & 
                          (bijective?[(Dom(sigma)),(Ran(sigma))])(sigma)


decl_type: function
theory: substitution
library: TRS
signature: [Sub -> [set[(V)] -> [(V) -> term[variable, symbol, arity]]]]
location: 87 2 92 37
body:
    restriction(sigma)(Vs)(x): term = IF member(x, Vs)
                                 THEN 
                                    sigma(x)
                                  ELSE
                                    x
                                  ENDIF


decl_type: function
theory: substitution
library: TRS
signature: [disjoint_D -> [(V) -> term[variable, symbol, arity]]]
location: 114 2 121 38
body:
    union_subs(sgi)(x): term = IF member(x, Dom(sgi`1)) 
                                   THEN sgi`1(x)
                                   ELSE 
                                    IF member(x, Dom(sgi`2)) 
                                    THEN sgi`2(x)
                                    ELSE x
                                    ENDIF 
                                   ENDIF


decl_type: function
theory: substitution
library: TRS
signature:
  [Sub ->
  [term[variable, symbol, arity] ->
  term[variable, symbol, arity]]]

location: 136 1 150 16
body:
   ext(sigma)(t): RECURSIVE term = 
      CASES t OF
        vars(t): sigma(t),
     app(f, st): IF length(st) = 0
                 THEN t
                 ELSE   
                   LET
                   sst = (# length := st`length,
                               seq := (LAMBDA (n: below[st`length]):
                                         ext(sigma)(st(n)))#)
                   IN
                    app(f, sst)
                 ENDIF
      ENDCASES
   MEASURE t BY <<


decl_type: function
theory: substitution
library: TRS
location: 243 2 246 55
signature:
  [[pred
             [[term[variable, symbol, arity],
               term[variable, symbol, arity]]],
         Sub, Sub, (V)] ->
          bool]

body:
    RSigma(R, sg1, sg2, x): bool = FORALL (y: (V)): IF y /= x 
                                                    THEN sg1(y) = sg2(y)
                                                    ELSE R(sg1(x), sg2(x))
                                                    ENDIF


decl_type: function
theory: substitution
library: TRS
location: 249 2 253 12
signature:
  [[sigma: Sub, term[variable, symbol, arity], x: (V),
         positions?[variable, symbol, arity](sigma(x))] ->
          [(V) -> term[variable, symbol, arity]]]

body:
    SigmaP(sigma, t, x, (p: positions?(sigma(x))))(y): term = 
         IF y /= x 
         THEN sigma(y)
         ELSE replaceTerm(sigma(x), t, p)
         ENDIF


decl_type: function
theory: substitution
library: TRS
signature:
  [[Sub, Sub, (V), (V)] ->
  [(V) -> term[variable, symbol, arity]]]

location: 256 2 259 40
body:
    gamma(sg1, sg2, x, y)(z): term = IF y /= z 
                                     THEN sg1(z)
                                     ELSE sg2(x)
                                     ENDIF


decl_type: function
theory: substitution
library: TRS
signature: [[Ren, (V), (V)] -> [(V) -> (V)]]
location: 262 2 265 33
body:
    Rhop(rho, x, y)(z): (V) = IF x /= z 
                              THEN rho(z)
                              ELSE y
                              ENDIF


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 433 0 442 999
body:
  % Subtype TCC generated (at line 70, column 64) for
      % restrict
      %     [(V[variable, symbol, arity]), (Dom(sigma)),
      %      term[variable, symbol, arity]]
      %     (sigma)
      % expected type  [(Dom(sigma)) -> (Ran(sigma))]
  Ren?_TCC1: OBLIGATION
    FORALL (sigma: Sub):
      subset?(Ran(sigma), V) IMPLIES
       (FORALL (x1: (Dom(sigma))): Ran(sigma)(sigma(x1)));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 444 0 448 999
body:
  % Subtype TCC generated (at line 130, column 38) for  (sigma, tau)
      % expected type  disjoint_D
  union_commute_TCC1: OBLIGATION
    FORALL (sigma, tau: Sub):
      disjoint?(Dom(sigma), Dom(tau)) IMPLIES disjoint_D?(sigma, tau);


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 450 0 454 999
body:
  % Subtype TCC generated (at line 130, column 65) for  (tau, sigma)
      % expected type  disjoint_D
  union_commute_TCC2: OBLIGATION
    FORALL (sigma, tau: Sub):
      disjoint?(Dom(sigma), Dom(tau)) IMPLIES disjoint_D?(tau, sigma);


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 456 0 460 999
body:
  % Subtype TCC generated (at line 138, column 21) for  t
      % expected type  (V)
  ext_TCC1: OBLIGATION
    FORALL (sigma: Sub, t: term[variable, symbol, arity], t1: variable):
      t = vars(t1) IMPLIES V[variable, symbol, arity](t);


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 462 0 490 999
body:
  % Subtype TCC generated (at line 147, column 25) for  sst
      % expected type  {args:
                     %    finite_sequence[term[variable, symbol, arity]] |
                     %          args`length = arity(f)}
  ext_TCC2: OBLIGATION
    FORALL (sigma: Sub, t: term[variable, symbol, arity],
            v:
              [Sub ->
                 [{z1: term[variable, symbol, arity] | z1 << t} ->
                    term[variable, symbol, arity]]],
            f: symbol,
            st:
              {args: finite_sequence[term[variable, symbol, arity]] |
                       args`length = arity(f)}):
      NOT length(st) = 0 AND t = app(f, st) IMPLIES
       (FORALL (sst:
                  [# length: nat,
                     seq:
                       [below[st`length] ->
                          term[variable, symbol, arity]] #]):
          sst =
           (# length := st`length,
              seq
                := LAMBDA (n: below[st`length]):
                     v(sigma)
                      (finseq_appl[term[variable, symbol, arity]](st)(n)) #)
           IMPLIES
           (FORALL (x: nat): x < st`length IFF x < sst`length) AND
            sst`length = arity(f));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 492 0 519 999
body:
  % Termination TCC generated (at line 145, column 39) for
      % ext(sigma)(finseq_appl[term[variable, symbol, arity]](st)(n))
  ext_TCC3: OBLIGATION
    FORALL (sigma: Sub, t: term[variable, symbol, arity],
            v:
              [Sub ->
                 [{z1: term[variable, symbol, arity] | z1 << t} ->
                    term[variable, symbol, arity]]],
            f: symbol,
            st:
              {args: finite_sequence[term[variable, symbol, arity]] |
                       args`length = arity(f)}):
      NOT length(st) = 0 AND t = app(f, st) IMPLIES
       (FORALL (n: below[st`length],
                sst:
                  [# length: nat,
                     seq:
                       [below[st`length] ->
                          term[variable, symbol, arity]] #]):
          sst =
           (# length := st`length,
              seq
                := LAMBDA (n: below[st`length]):
                     v(sigma)
                      (finseq_appl[term[variable, symbol, arity]](st)(n)) #)
           IMPLIES
           <<[variable, symbol, arity]
               (finseq_appl[term[variable, symbol, arity]](st)(n), t));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 521 0 523 999
body:
  % Subtype TCC generated (at line 159, column 25) for  identity
      % expected type  Sub
  iden_rename_TCC1: OBLIGATION Sub?(identity[(V)]);


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 525 0 529 999
body:
  % Subtype TCC generated (at line 164, column 43) for  restriction(sigma)(Vs)
      % expected type  Sub
  restriction_term_TCC1: OBLIGATION
    FORALL (Vs: set[(V)], sigma: Sub, t: term[variable, symbol, arity]):
      subset?(Vars(t), Vs) IMPLIES Sub?(restriction(sigma)(Vs));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 531 0 536 999
body:
  % Subtype TCC generated (at line 169, column 29) for  union_subs(sg1, sg2)
      % expected type  Sub
  restriction_union_TCC1: OBLIGATION
    FORALL (sg1, sg2: Sub, t: term[variable, symbol, arity]):
      disjoint?(Vars(t), Dom(sg2)) AND disjoint?(Dom(sg1), Dom(sg2)) IMPLIES
       Sub?(union_subs(sg1, sg2));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 538 0 540 999
body:
  % Subtype TCC generated (at line 184, column 18) for  comp(sigma, tau)
      % expected type  Sub
  ext_o_TCC1: OBLIGATION FORALL (sigma, tau: Sub): Sub?(comp(sigma, tau));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 542 0 545 999
body:
  % Subtype TCC generated (at line 188, column 32) for  comp(sigma, identity)
      % expected type  Sub
  ext_subs_o_identity_TCC1: OBLIGATION
    FORALL (sigma: Sub): Sub?(comp(sigma, identity[(V)]));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 547 0 553 999
body:
  % Subtype TCC generated (at line 200, column 10) for  comp(rho1, rho)
      % expected type  Sub
  inverse_rename_identity_TCC1: OBLIGATION
    FORALL (rho, rho1: Ren, t: term[variable, symbol, arity]):
      (FORALL x: Dom(rho)(x) => comp(rho1, rho)(x) = x) AND
       subset?(Vars(t), Dom(rho))
       IMPLIES Sub?(comp(rho1, rho));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 555 0 558 999
body:
  % Subtype TCC generated (at line 239, column 20) for  DSigma(t, x)
      % expected type  Sub
  DSigma_do_nothing_TCC1: OBLIGATION
    FORALL (t, s, x): empty?(Pos_var(s, x)) IMPLIES Sub?(DSigma(t, x));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 560 0 566 999
body:
  % Subtype TCC generated (at line 263, column 33) for  rho(z)
      % expected type  (V)
  Rhop_TCC1: OBLIGATION
    FORALL (rho: Ren, x: (V[variable, symbol, arity]),
            y: (V[variable, symbol, arity]),
            z: (V[variable, symbol, arity])):
      x /= z IMPLIES V[variable, symbol, arity](rho(z));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 568 0 575 999
body:
  % Subtype TCC generated (at line 280, column 48) for  SigmaP(sigma, t, x, p)
      % expected type  Sub
  SigmaP_is_RSigma_TCC1: OBLIGATION
    FORALL (R: pred[[term, term]], p: position[variable, symbol, arity],
            sigma: Sub, t: term[variable, symbol, arity], x: (V)):
      R(subtermOF(sigma(x), p), t) AND
       comp_cont?(R) AND positionsOF(sigma(x))(p)
       IMPLIES Sub?(SigmaP(sigma, t, x, p));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 577 0 581 999
body:
  % Subtype TCC generated (at line 296, column 22) for  gamma(sg1, sg2, x, y)
      % expected type  Sub
  gamma_is_RSigma_TCC1: OBLIGATION
    FORALL (R: pred[[term, term]], sg1, sg2: Sub, x, y, z: (V)):
      z /= y AND RSigma(R, sg1, sg2, z) IMPLIES Sub?(gamma(sg1, sg2, x, y));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 583 0 587 999
body:
  % Subtype TCC generated (at line 296, column 45) for  gamma(sg2, sg2, x, y)
      % expected type  Sub
  gamma_is_RSigma_TCC2: OBLIGATION
    FORALL (R: pred[[term, term]], sg1, sg2: Sub, x, y, z: (V)):
      z /= y AND RSigma(R, sg1, sg2, z) IMPLIES Sub?(gamma(sg2, sg2, x, y));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 589 0 593 999
body:
  % Subtype TCC generated (at line 301, column 26) for  gamma(sg1, sg2, x, y)
      % expected type  Sub
  gamma_term_TCC1: OBLIGATION
    FORALL (sg1, sg2: Sub, t: term[variable, symbol, arity], x, y: (V)):
      NOT member(y, Vars(t)) IMPLIES Sub?(gamma(sg1, sg2, x, y));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 595 0 600 999
body:
  % Subtype TCC generated (at line 302, column 26) for  gamma(sg2, sg2, x, y)
      % expected type  Sub
  gamma_term_TCC2: OBLIGATION
    FORALL (sg1, sg2: Sub, t: term[variable, symbol, arity], x, y: (V)):
      NOT member(y, Vars(t)) AND ext(gamma(sg1, sg2, x, y))(t) = ext(sg1)(t)
       IMPLIES Sub?(gamma(sg2, sg2, x, y));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 602 0 607 999
body:
  % Subtype TCC generated (at line 332, column 22) for  Rhop(rho, x, y)
      % expected type  Sub
  Rhop_Ren_TCC1: OBLIGATION
    FORALL (rho: Ren, x, y: (V)):
      NOT Ran(rho)(y) AND NOT Dom(rho)(x) AND x /= y IMPLIES
       Sub?(Rhop(rho, x, y));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 609 0 615 999
body:
  % Subtype TCC generated (at line 342, column 48) for  p
      % expected type  positions?[variable, symbol, arity](ext(sigma)(s))
  subterm_ext_commute_TCC1: OBLIGATION
    FORALL (p: position[variable, symbol, arity],
            s: term[variable, symbol, arity], sigma: Sub):
      positionsOF(s)(p) IMPLIES
       positionsOF[variable, symbol, arity](ext(sigma)(s))(p);


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 617 0 626 999
body:
  % Subtype TCC generated (at line 365, column 27) for  p o p1
      % expected type  positions?[variable, symbol, arity](ext(sigma)(t))
  subterm_of_ext_TCC1: OBLIGATION
    FORALL (p, p1: position[variable, symbol, arity], sigma: Sub,
            t: term[variable, symbol, arity]):
      positionsOF(t)(p) AND
       vars?(subtermOF(t, p)) AND
        positionsOF(ext(sigma)(subtermOF(t, p)))(p1)
       IMPLIES
       positionsOF[variable, symbol, arity](ext(sigma)(t))(o[posnat](p, p1));


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 628 0 637 999
body:
  % Subtype TCC generated (at line 407, column 66) for  0
      % expected type  below[fst`length]
  rest_parallel_first_TCC1: OBLIGATION
    FORALL (t, fst: SPP[variable, symbol, arity](t)):
      fst`length /= 0 IMPLIES
       (FORALL (i:
                  below
                      [length
                         (rest[position[variable, symbol, arity]](fst))]):
          0 < fst`length);


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 639 0 646 999
body:
  % Subtype TCC generated (at line 425, column 57) for  p
      % expected type  positions?[variable, symbol, arity](ext(sig)(s))
  ext_preserve_symbol_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity], sig: Sub,
            p: position[variable, symbol, arity]
                | positionsOF[variable, symbol, arity](s)(p)):
      app?(subtermOF(s, p)) IMPLIES
       positionsOF[variable, symbol, arity](ext(sig)(s))(p);


decl_type: tcc
theory: substitution
library: TRS
signature: nil
location: 648 0 657 999
body:
  % Subtype TCC generated (at line 425, column 34) for
      % subtermOF(ext(sig)(s), p)
      % expected type  (app?)
  ext_preserve_symbol_TCC2: OBLIGATION
    FORALL (s: term[variable, symbol, arity], sig: Sub,
            p: position[variable, symbol, arity]
                | positionsOF[variable, symbol, arity](s)(p)):
      app?(subtermOF(s, p)) IMPLIES
       app?[variable, symbol, arity]
           (subtermOF[variable, symbol, arity](ext(sig)(s), p));


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 74 1 80 42
body:
   uni_diff_equal_length_arg : LEMMA
        FORALL (s: term, (t: term | unifiable(s, t) & s /= t), f: symbol,
                st: {args: finite_sequence[term] | args`length = arity(f)}):
                NOT st`length = 0 AND s = app(f, st) IMPLIES
                (FORALL (fp: symbol, stp: {args: finite_sequence[term] |
                 args`length = arity(fp)}): t = app(fp, stp) IMPLIES
                 (f = fp & st`length = stp`length))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 109 1 112 32
body:
   resol_diff_nonempty_implies_funct_terms : LEMMA
      FORALL (s: term, (t: term | unifiable(s, t) & s /= t)):
             resolving_diff(s,t) /= empty_seq IMPLIES
             (app?(s) AND app?(t))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 114 1 119 64
body:
   resol_diff_to_rest_resol_diff : LEMMA
      FORALL (s: term, (t: term | unifiable(s, t) & s /= t)):
          LET rd =  resolving_diff(s,t) IN
              rd /= empty_seq IMPLIES
              resolving_diff(subtermOF(s,#(first(rd))),
                             subtermOF(t,#(first(rd)))) = rest(rd)


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 121 1 123 59
body:
   position_s_resolving_diff : LEMMA
      FORALL (s : term, t : term | unifiable(s, t) & s /= t, p : position):
          p = resolving_diff(s, t) IMPLIES positionsOF(s)(p);


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 125 1 127 59
body:
   position_t_resolving_diff : LEMMA
      FORALL (s : term, t : term | unifiable(s, t) & s /= t, p : position):
          p = resolving_diff(s, t) IMPLIES positionsOF(t)(p);


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 129 1 133 44
body:
   resolving_diff_has_diff_argument : LEMMA 
      FORALL (s : term, t : term | unifiable(s,t) & s /= t,
              p : position | positionsOF(s)(p) & positionsOF(t)(p)):
          p = resolving_diff(s, t) IMPLIES
            subtermOF(s, p) /= subtermOF(t, p)


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 135 1 139 53
body:
   resolving_diff_has_unifiable_argument : LEMMA 
      FORALL (s : term, t : term | unifiable(s,t) & s /= t,
              p : position | positionsOF(s)(p) & positionsOF(t)(p)):
          p = resolving_diff(s, t) IMPLIES
            unifiable(subtermOF(s, p), subtermOF(t, p))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 141 1 145 52
body:
   resolving_diff_vars : LEMMA
      FORALL (s : term, t : term | unifiable(s, t) & s /= t,
              p : position | positionsOF(s)(p) & positionsOF(t)(p)):
          p = resolving_diff(s, t) IMPLIES
            vars?(subtermOF(s, p)) OR vars?(subtermOF(t, p))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 150 1 152 41
body:
   unifier_o : LEMMA
          member(sig, U(ext(theta)(s), ext(theta)(t))) IMPLIES
          member(comp(sig, theta), U(s, t))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 157 1 159 62
body:
   unifier_and_subs : LEMMA
          member(theta, U(s, t)) IMPLIES 
          (FORALL (sig: Sub): member(comp(sig, theta), U(s, t)))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 161 1 164 74
body:
   idemp_mgu_iff_all_unifier : LEMMA
      FORALL (theta: Sub | member(theta, U(s, t))):
          mgu(theta)(s, t) & idempotent_sub?(theta) IFF
          (FORALL (sig: Sub | member(sig, U(s, t))): sig = comp(sig, theta))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 166 1 170 59
body:
   unifiable_terms_unifiable_args : LEMMA
      FORALL (s : term, t : term,
              p : position | positionsOF(s)(p) & positionsOF(t)(p)):
          member(sig, U(s, t)) IMPLIES
             member(sig, U(subtermOF(s, p), subtermOF(t, p)))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 172 1 175 33
body:
   var_term_unifiable_not_var_in_term : LEMMA 
      FORALL (s : term, t : term ):
          vars?(s) & unifiable(s, t) & s /= t IMPLIES
             NOT member(s, Vars(t))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 192 1 199 16
body:
   dom_sub_of_frst_diff_is : LEMMA
      FORALL (s : term, t : term | unifiable(s, t) & s /= t, sig : Sub):
          sig = sub_of_frst_diff(s, t) AND p = resolving_diff(s, t)
          IMPLIES
             IF vars?(subtermOF(s, p))
               THEN Dom(sig) = singleton(subtermOF(s, p))
               ELSE Dom(sig) = singleton(subtermOF(t, p))
             ENDIF


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 201 1 205 37
body:
   var_sub_1stdiff_not_member_term : LEMMA 
      FORALL (s : term, t : term | unifiable(s, t) & s /= t): 
          LET sig = sub_of_frst_diff(s ,t) IN
             FORALL ( x | member(x,Dom(sig)), r | member(r,Ran(sig) )) :
                 NOT member(x, Vars(r))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 207 1 211 51
body:
   sub_of_frst_diff_unifier_o : LEMMA
      FORALL (s : term, t : term | unifiable(s, t) & s /= t):
          member(rho, U(s, t)) IMPLIES
             LET sig = sub_of_frst_diff(s, t) IN
                EXISTS theta : rho = comp(theta, sig)


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 213 1 216 48
body:
   ext_sub_of_frst_diff_unifiable : LEMMA
      FORALL (s : term, t : term | unifiable(s, t) & s /= t):
          LET sig = sub_of_frst_diff(s, t) IN
             unifiable(ext(sig)(s), (ext(sig)(t)))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 218 1 223 49
body:
   sub_of_frst_diff_remove_x : LEMMA
      FORALL (s : term, t : term | unifiable(s, t) & s /= t):
          LET sig = sub_of_frst_diff(s, t) IN
             Dom(sig)(x) IMPLIES  
                 (NOT member(x, Vars(ext(sig)(s)))) AND
                 (NOT member(x, Vars(ext(sig)(t))))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 225 1 228 63
body:
   vars_sub_of_frst_diff_s_is_subset_union : LEMMA
      FORALL (s : term, t : term | unifiable(s, t) & s /= t):
          LET sig = sub_of_frst_diff(s, t) IN
             subset?(Vars(ext(sig)(s)), union( Vars(s), Vars(t)))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 230 1 233 63
body:
   vars_sub_of_frst_diff_t_is_subset_union : LEMMA
      FORALL (s : term, t : term | unifiable(s, t) & s /= t):
          LET sig = sub_of_frst_diff(s, t) IN
             subset?(Vars(ext(sig)(t)), union( Vars(s), Vars(t)))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 235 1 239 59
body:
   union_vars_ext_sub_of_frst_diff : LEMMA
      FORALL (s : term, t : term | unifiable(s, t) & s /= t) :
          LET sig = sub_of_frst_diff(s, t) IN
             union(Vars(ext(sig)(s)), Vars(ext(sig)(t)))
             = difference(union( Vars(s), Vars(t)), Dom(sig))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 241 1 245 43
body:
   vars_ext_sub_of_frst_diff_decrease : LEMMA
      FORALL (s : term, t : term | unifiable(s, t) & s /= t):
          LET sig = sub_of_frst_diff(s, t) IN
             Card(union( Vars(ext(sig)(s)), Vars(ext(sig)(t))))
             < Card(union( Vars(s), Vars(t)))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 261 1 262 71
body:
   unification_algorithm_gives_unifier : LEMMA 
      unifiable(s,t) IMPLIES member(unification_algorithm(s, t), U(s, t))


decl_type: formula
theory: unification
library: TRS
signature: nil
location: 264 1 265 67
body:
   unification_algorithm_gives_mg_subs : LEMMA 
      member(rho, U(s, t)) IMPLIES unification_algorithm(s, t) <= rho


decl_type: function
theory: unification
library: TRS
location: 59 1 59 58
body: unifier(sigma)(s,t): bool = ext(sigma)(s) = ext(sigma)(t)
signature:
  [Sub[variable, symbol, arity] ->
          [[term[variable, symbol, arity],
            term[variable, symbol, arity]] ->
             bool]]


decl_type: function
theory: unification
library: TRS
location: 68 1 69 78
signature:
  [Sub[variable, symbol, arity] ->
          [[term[variable, symbol, arity],
            term[variable, symbol, arity]] ->
             bool]]

body:
   mgu(theta)(s,t): bool = member(theta, U(s,t)) & 
                      FORALL sigma: member(sigma, U(s,t)) IMPLIES theta <= sigma


decl_type: function
theory: unification
library: TRS
signature:
  [[s: term, {t: term | unifiable(s, t) & s /= t}] ->
  position[variable, symbol, arity]]

location: 86 1 104 16
body:
   resolving_diff(s : term, (t : term | unifiable(s,t) & s /= t ) ):
     RECURSIVE position =
      (CASES s OF
         vars(s) : empty_seq,
         app(f, st) :
         IF length(st) = 0 THEN empty_seq
         ELSE 
          (CASES t OF
             vars(t) : empty_seq,
             app(fp, stp) :
             LET k : below[length(stp)] = 
               min({kk : below[length(stp)] |
                           subtermOF(s,#(kk+1)) /= subtermOF(t,#(kk+1))}) IN
               add_first(k+1,
                        resolving_diff(subtermOF(s,#(k+1)),subtermOF(t,#(k+1))))
           ENDCASES)
         ENDIF
       ENDCASES)
   MEASURE s BY << 


decl_type: function
theory: unification
library: TRS
signature:
  [[s: term, {t: term | unifiable(s, t) & s /= t}] ->
  Sub[variable, symbol, arity]]

location: 181 1 187 13
body:
   sub_of_frst_diff(s : term , (t : term | unifiable(s,t) & s /= t )) : Sub =
    LET k : position = resolving_diff(s,t) IN
       LET sp = subtermOF(s,k) , tp = subtermOF(t,k) IN 
          IF vars?(sp)
          THEN (LAMBDA (x : (V)) : IF x = sp THEN tp ELSE x ENDIF) 
          ELSE (LAMBDA (x : (V)) : IF x = tp THEN sp ELSE x ENDIF)
          ENDIF 


decl_type: function
theory: unification
library: TRS
signature:
  [[s: term, {t: term | unifiable(s, t)}] ->
  Sub[variable, symbol, arity]]

location: 251 1 256 38
body:
   unification_algorithm(s : term, (t : term | unifiable(s,t))) : RECURSIVE Sub =
      IF s = t THEN identity  
      ELSE LET sig = sub_of_frst_diff(s, t) IN
              comp( unification_algorithm(ext(sig)(s) , ext(sig)(t)) , sig)
      ENDIF
   MEASURE Card(union(Vars(s), Vars(t)))


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 279 0 284 999
body:
  % Assuming TCC generated (at line 29, column 13) for
      % substitution[variable, symbol, arity]
      % generated from assumption substitution.var_countable
  IMP_substitution_TCC1: OBLIGATION
    is_countably_infinite[term[variable, symbol, arity]]
        (V[variable, symbol, arity]);


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 286 0 306 999
body:
  % Subtype TCC generated (at line 100, column 49) for   #(k + 1)
      % expected type  positions?[variable, symbol, arity](s)
  resolving_diff_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            f: symbol,
            st:
              {args: finite_sequence[term[variable, symbol, arity]] |
                       args`length = arity(f)}):
      NOT length(st) = 0 AND s = app(f, st) IMPLIES
       (FORALL (fp: symbol,
                stp:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length = arity(fp)}):
          t = app(fp, stp) IMPLIES
           (FORALL (k: below[length(stp)]):
              k =
               min({kk: below[length(stp)] |
                      subtermOF(s,  #(kk + 1)) /= subtermOF(t,  #(kk + 1))})
               IMPLIES
               positionsOF[variable, symbol, arity](s)( #[posnat](k + 1))));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 308 0 328 999
body:
  % Subtype TCC generated (at line 100, column 69) for   #(k + 1)
      % expected type  positions?[variable, symbol, arity](t)
  resolving_diff_TCC2: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            f: symbol,
            st:
              {args: finite_sequence[term[variable, symbol, arity]] |
                       args`length = arity(f)}):
      NOT length(st) = 0 AND s = app(f, st) IMPLIES
       (FORALL (fp: symbol,
                stp:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length = arity(fp)}):
          t = app(fp, stp) IMPLIES
           (FORALL (k: below[length(stp)]):
              k =
               min({kk: below[length(stp)] |
                      subtermOF(s,  #(kk + 1)) /= subtermOF(t,  #(kk + 1))})
               IMPLIES
               positionsOF[variable, symbol, arity](t)( #[posnat](k + 1))));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 330 0 361 999
body:
  % Subtype TCC generated (at line 100, column 57) for
      % subtermOF(t,  #(k + 1))
      % expected type  {t: term |
                     %          unifiable(subtermOF(s,  #(1 + k)), t) &
                     %           NOT subtermOF(s,  #(1 + k)) = t}
  resolving_diff_TCC3: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            f: symbol,
            st:
              {args: finite_sequence[term[variable, symbol, arity]] |
                       args`length = arity(f)}):
      NOT length(st) = 0 AND s = app(f, st) IMPLIES
       (FORALL (fp: symbol,
                stp:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length = arity(fp)}):
          t = app(fp, stp) IMPLIES
           (FORALL (k: below[length(stp)]):
              k =
               min({kk: below[length(stp)] |
                      subtermOF(s,  #(kk + 1)) /= subtermOF(t,  #(kk + 1))})
               IMPLIES
               unifiable(subtermOF[variable, symbol, arity]
                             (s,  #[posnat](1 + k)),
                         subtermOF[variable, symbol, arity]
                             (t,  #[posnat](k + 1)))
                &
                NOT subtermOF[variable, symbol, arity](s,  #[posnat](1 + k))
                     =
                     subtermOF[variable, symbol, arity]
                         (t,  #[posnat](k + 1))));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 363 0 385 999
body:
  % Termination TCC generated (at line 100, column 22) for
      % resolving_diff(subtermOF(s,  #(k + 1)), subtermOF(t,  #(k + 1)))
  resolving_diff_TCC4: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            f: symbol,
            st:
              {args: finite_sequence[term[variable, symbol, arity]] |
                       args`length = arity(f)}):
      NOT length(st) = 0 AND s = app(f, st) IMPLIES
       (FORALL (fp: symbol,
                stp:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length = arity(fp)}):
          t = app(fp, stp) IMPLIES
           (FORALL (k: below[length(stp)]):
              k =
               min({kk: below[length(stp)] |
                      subtermOF(s,  #(kk + 1)) /= subtermOF(t,  #(kk + 1))})
               IMPLIES
               <<[variable, symbol, arity]
                   (subtermOF[variable, symbol, arity](s,  #[posnat](k + 1)),
                    s)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 387 0 407 999
body:
  % Subtype TCC generated (at line 98, column 37) for   #(kk + 1)
      % expected type  positions?[variable, symbol, arity](s)
  resolving_diff_TCC5: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            f: symbol,
            st:
              {args: finite_sequence[term[variable, symbol, arity]] |
                       args`length = arity(f)}):
      NOT length(st) = 0 AND s = app(f, st) IMPLIES
       (FORALL (fp: symbol,
                stp:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length = arity(fp)}):
          t = app(fp, stp) IMPLIES
           (FORALL (kk: below[length(stp)], k: below[length(stp)]):
              k =
               min({kk: below[length(stp)] |
                      subtermOF(s,  #(kk + 1)) /= subtermOF(t,  #(kk + 1))})
               IMPLIES
               positionsOF[variable, symbol, arity](s)( #[posnat](kk + 1))));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 409 0 429 999
body:
  % Subtype TCC generated (at line 98, column 61) for   #(kk + 1)
      % expected type  positions?[variable, symbol, arity](t)
  resolving_diff_TCC6: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            f: symbol,
            st:
              {args: finite_sequence[term[variable, symbol, arity]] |
                       args`length = arity(f)}):
      NOT length(st) = 0 AND s = app(f, st) IMPLIES
       (FORALL (fp: symbol,
                stp:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length = arity(fp)}):
          t = app(fp, stp) IMPLIES
           (FORALL (kk: below[length(stp)], k: below[length(stp)]):
              k =
               min({kk: below[length(stp)] |
                      subtermOF(s,  #(kk + 1)) /= subtermOF(t,  #(kk + 1))})
               IMPLIES
               positionsOF[variable, symbol, arity](t)( #[posnat](kk + 1))));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 431 0 453 999
body:
  % Subtype TCC generated (at line 97, column 17) for
      % {kk: below[length(stp)] |
      %    subtermOF(s,  #(kk + 1)) /= subtermOF(t,  #(kk + 1))}
      % expected type  S: (nonempty?[below[length(stp)]])
  resolving_diff_TCC7: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            f: symbol,
            st:
              {args: finite_sequence[term[variable, symbol, arity]] |
                       args`length = arity(f)}):
      NOT length(st) = 0 AND s = app(f, st) IMPLIES
       (FORALL (fp: symbol,
                stp:
                  {args: finite_sequence[term[variable, symbol, arity]] |
                           args`length = arity(fp)}):
          t = app(fp, stp) IMPLIES
           nonempty?[below[length(stp)]]
               ({kk: below[length(stp)] |
                   subtermOF[variable, symbol, arity](s,  #[posnat](kk + 1))
                    /=
                    subtermOF[variable, symbol, arity]
                        (t,  #[posnat](kk + 1))}));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 455 0 461 999
body:
  % Subtype TCC generated (at line 118, column 47) for  rd
      % expected type  not_empty_seq[posnat]
  resol_diff_to_rest_resol_diff_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            rd: position[variable, symbol, arity]):
      rd /= empty_seq AND rd = resolving_diff(s, t) IMPLIES length(rd) /= 0;


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 463 0 470 999
body:
  % Subtype TCC generated (at line 118, column 39) for   #(first(rd))
      % expected type  positions?[variable, symbol, arity](s)
  resol_diff_to_rest_resol_diff_TCC2: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            rd: position[variable, symbol, arity]):
      rd /= empty_seq AND rd = resolving_diff(s, t) IMPLIES
       positionsOF[variable, symbol, arity](s)( #[posnat](first[posnat](rd)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 472 0 479 999
body:
  % Subtype TCC generated (at line 119, column 39) for   #(first(rd))
      % expected type  positions?[variable, symbol, arity](t)
  resol_diff_to_rest_resol_diff_TCC3: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            rd: position[variable, symbol, arity]):
      rd /= empty_seq AND rd = resolving_diff(s, t) IMPLIES
       positionsOF[variable, symbol, arity](t)( #[posnat](first[posnat](rd)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 481 0 498 999
body:
  % Subtype TCC generated (at line 119, column 27) for
      % subtermOF(t,  #(first(rd)))
      % expected type  {t: term |
                     %          unifiable(subtermOF(s,  #(first(rd))), t) &
                     %           subtermOF(s,  #(first(rd))) /= t}
  resol_diff_to_rest_resol_diff_TCC4: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            rd: position[variable, symbol, arity]):
      rd /= empty_seq AND rd = resolving_diff(s, t) IMPLIES
       unifiable(subtermOF[variable, symbol, arity]
                     (s,  #[posnat](first[posnat](rd))),
                 subtermOF[variable, symbol, arity]
                     (t,  #[posnat](first[posnat](rd))))
        &
        subtermOF[variable, symbol, arity](s,  #[posnat](first[posnat](rd)))
         /=
         subtermOF[variable, symbol, arity](t,  #[posnat](first[posnat](rd)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 500 0 509 999
body:
  % Subtype TCC generated (at line 152, column 15) for  comp(sig, theta)
      % expected type  Sub[variable, symbol, arity]
  unifier_o_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            sig: Sub[variable, symbol, arity],
            t: term[variable, symbol, arity],
            theta: Sub[variable, symbol, arity]):
      member(sig, U(ext(theta)(s), ext(theta)(t))) IMPLIES
       Sub?[variable, symbol, arity]
           (comp[variable, symbol, arity](sig, theta));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 511 0 517 999
body:
  % Subtype TCC generated (at line 155, column 27) for  comp(sig, theta)
      % expected type  Sub[variable, symbol, arity]
  mgu_o_TCC1: OBLIGATION
    FORALL (rho, sig, theta: Sub[variable, symbol, arity]):
      sig <= rho IMPLIES
       Sub?[variable, symbol, arity]
           (comp[variable, symbol, arity](sig, theta));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 519 0 525 999
body:
  % Subtype TCC generated (at line 155, column 47) for  comp(rho, theta)
      % expected type  Sub[variable, symbol, arity]
  mgu_o_TCC2: OBLIGATION
    FORALL (rho, sig, theta: Sub[variable, symbol, arity]):
      sig <= rho IMPLIES
       Sub?[variable, symbol, arity]
           (comp[variable, symbol, arity](rho, theta));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 527 0 535 999
body:
  % Subtype TCC generated (at line 159, column 35) for  comp(sig, theta)
      % expected type  Sub[variable, symbol, arity]
  unifier_and_subs_TCC1: OBLIGATION
    FORALL (s, t: term[variable, symbol, arity],
            theta: Sub[variable, symbol, arity]):
      member(theta, U(s, t)) IMPLIES
       (FORALL (sig: Sub[variable, symbol, arity]):
          Sub?[variable, symbol, arity]
              (comp[variable, symbol, arity](sig, theta)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 537 0 543 999
body:
  % Subtype TCC generated (at line 175, column 22) for  s
      % expected type  (V)
  var_term_unifiable_not_var_in_term_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            t: term[variable, symbol, arity]):
      vars?(s) AND unifiable(s, t) AND s /= t IMPLIES
       V[variable, symbol, arity](s);


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 545 0 552 999
body:
  % Subtype TCC generated (at line 183, column 26) for  k
      % expected type  positions?[variable, symbol, arity](s)
  sub_of_frst_diff_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            k: position[variable, symbol, arity]):
      k = resolving_diff(s, t) IMPLIES
       positionsOF[variable, symbol, arity](s)(k);


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 554 0 563 999
body:
  % Subtype TCC generated (at line 183, column 48) for  k
      % expected type  positions?[variable, symbol, arity](t)
  sub_of_frst_diff_TCC2: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            k: position[variable, symbol, arity]):
      k = resolving_diff(s, t) IMPLIES
       (FORALL (sp: term[variable, symbol, arity]):
          sp = subtermOF(s, k) IMPLIES
           positionsOF[variable, symbol, arity](t)(k));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 565 0 579 999
body:
  % Subtype TCC generated (at line 185, column 14) for
      % (LAMBDA (x: (V)): IF x = sp THEN tp ELSE x ENDIF)
      % expected type  Sub[variable, symbol, arity]
  sub_of_frst_diff_TCC3: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            k: position[variable, symbol, arity]):
      k = resolving_diff(s, t) IMPLIES
       (FORALL (sp: term[variable, symbol, arity]):
          sp = subtermOF(s, k) IMPLIES
           (FORALL (tp: term[variable, symbol, arity]):
              vars?(sp) AND tp = subtermOF(t, k) IMPLIES
               Sub?[variable, symbol, arity]
                   (LAMBDA (x: (V[variable, symbol, arity])):
                      IF x = sp THEN tp ELSE x ENDIF)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 581 0 595 999
body:
  % Subtype TCC generated (at line 186, column 14) for
      % (LAMBDA (x: (V)): IF x = tp THEN sp ELSE x ENDIF)
      % expected type  Sub[variable, symbol, arity]
  sub_of_frst_diff_TCC4: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t) & s /= t),
            k: position[variable, symbol, arity]):
      k = resolving_diff(s, t) IMPLIES
       (FORALL (sp: term[variable, symbol, arity]):
          sp = subtermOF(s, k) IMPLIES
           (FORALL (tp: term[variable, symbol, arity]):
              NOT vars?(sp) AND tp = subtermOF(t, k) IMPLIES
               Sub?[variable, symbol, arity]
                   (LAMBDA (x: (V[variable, symbol, arity])):
                      IF x = tp THEN sp ELSE x ENDIF)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 597 0 606 999
body:
  % Subtype TCC generated (at line 198, column 52) for  p
      % expected type  positions?[variable, symbol, arity](t)
  dom_sub_of_frst_diff_is_TCC1: OBLIGATION
    FORALL (p: position[variable, symbol, arity],
            s: term[variable, symbol, arity],
            t: term[variable, symbol, arity] | unifiable(s, t) & s /= t,
            sig: Sub[variable, symbol, arity]):
      NOT vars?(subtermOF(s, p)) AND
       sig = sub_of_frst_diff(s, t) AND p = resolving_diff(s, t)
       IMPLIES positionsOF[variable, symbol, arity](t)(p);


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 608 0 621 999
body:
  % Subtype TCC generated (at line 244, column 16) for
      % union(Vars(ext(sig)(s)), Vars(ext(sig)(t)))
      % expected type  finite_set[(V)]
  vars_ext_sub_of_frst_diff_decrease_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            t: term[variable, symbol, arity] | unifiable(s, t) & s /= t,
            sig: Sub[variable, symbol, arity]):
      sig = sub_of_frst_diff(s, t) IMPLIES
       is_finite[(V)]
           (union[(V)]
                (Vars[variable, symbol, arity]
                     (ext[variable, symbol, arity](sig)(s)),
                 Vars[variable, symbol, arity]
                     (ext[variable, symbol, arity](sig)(t))));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 623 0 634 999
body:
  % Subtype TCC generated (at line 245, column 18) for
      % union(Vars(s), Vars(t))
      % expected type  finite_set[(V)]
  vars_ext_sub_of_frst_diff_decrease_TCC2: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            t: term[variable, symbol, arity] | unifiable(s, t) & s /= t,
            sig: Sub[variable, symbol, arity]):
      sig = sub_of_frst_diff(s, t) IMPLIES
       is_finite[(V)]
           (union[(V)]
                (Vars[variable, symbol, arity](s),
                 Vars[variable, symbol, arity](t)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 636 0 645 999
body:
  % Subtype TCC generated (at line 256, column 14) for
      % union(Vars(s), Vars(t))
      % expected type  finite_set[(V)]
  unification_algorithm_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t))):
      is_finite[(V)]
          (union[(V)]
               (Vars[variable, symbol, arity](s),
                Vars[variable, symbol, arity](t)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 647 0 655 999
body:
  % Subtype TCC generated (at line 256, column 14) for
      % union(Vars(z`1), Vars(z`2))
      % expected type  finite_set[(V)]
  unification_algorithm_TCC2: OBLIGATION
    FORALL (z: [s: term, {t: term | unifiable(s, t)}]):
      is_finite[(V)]
          (union[(V)]
               (Vars[variable, symbol, arity](z`1),
                Vars[variable, symbol, arity](z`2)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 657 0 662 999
body:
  % Subtype TCC generated (at line 252, column 18) for  identity
      % expected type  Sub[variable, symbol, arity]
  unification_algorithm_TCC3: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t))):
      s = t IMPLIES Sub?[variable, symbol, arity](identity[(V)]);


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 664 0 673 999
body:
  % Subtype TCC generated (at line 254, column 54) for  ext(sig)(t)
      % expected type  {t: term | unifiable(ext(sig)(s), t)}
  unification_algorithm_TCC4: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t))):
      NOT s = t IMPLIES
       (FORALL (sig: Sub[variable, symbol, arity]):
          sig = sub_of_frst_diff(s, t) IMPLIES
           unifiable(ext[variable, symbol, arity](sig)(s),
                     ext[variable, symbol, arity](sig)(t)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 675 0 693 999
body:
  % Termination TCC generated (at line 254, column 18) for
      % unification_algorithm(ext(sig)(s), ext(sig)(t))
  unification_algorithm_TCC5: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t))):
      NOT s = t IMPLIES
       (FORALL (sig: Sub[variable, symbol, arity]):
          sig = sub_of_frst_diff(s, t) IMPLIES
           Card[(V)]
               (union[(V)]
                    (Vars[variable, symbol, arity]
                         (ext[variable, symbol, arity](sig)(s)),
                     Vars[variable, symbol, arity]
                         (ext[variable, symbol, arity](sig)(t))))
            <
            Card[(V)]
                (union[(V)]
                     (Vars[variable, symbol, arity](s),
                      Vars[variable, symbol, arity](t))));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 695 0 713 999
body:
  % Subtype TCC generated (at line 254, column 12) for
      % comp(unification_algorithm(ext(sig)(s), ext(sig)(t)), sig)
      % expected type  Sub[variable, symbol, arity]
  unification_algorithm_TCC6: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t)),
            v:
              [{z: [s: term, {t: term | unifiable(s, t)}] |
                        Card(union(Vars(z`1), Vars(z`2))) <
                         Card(union(Vars(s), Vars(t)))} ->
                 Sub[variable, symbol, arity]]):
      NOT s = t IMPLIES
       (FORALL (sig: Sub[variable, symbol, arity]):
          sig = sub_of_frst_diff(s, t) IMPLIES
           Sub?[variable, symbol, arity]
               (comp[variable, symbol, arity]
                    (v(ext[variable, symbol, arity](sig)(s),
                       ext[variable, symbol, arity](sig)(t)),
                     sig)));


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 715 0 720 999
body:
  % Subtype TCC generated (at line 253, column 39) for  t
      % expected type  {t: term | unifiable(s, t) & s /= t}
  unification_algorithm_TCC7: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (t: term[variable, symbol, arity] | unifiable(s, t))):
      NOT s = t IMPLIES unifiable(s, t) & s /= t;


decl_type: tcc
theory: unification
library: TRS
signature: nil
location: 722 0 727 999
body:
  % Subtype TCC generated (at line 265, column 58) for  t
      % expected type  {t: term | unifiable(s, t)}
  unification_algorithm_gives_mg_subs_TCC1: OBLIGATION
    FORALL (rho: Sub[variable, symbol, arity],
            s, t: term[variable, symbol, arity]):
      member(rho, U(s, t)) IMPLIES unifiable(s, t);


decl_type: tcc
theory: rewrite_rules
library: TRS
signature: nil
location: 61 0 66 999
body:
  % Assuming TCC generated (at line 30, column 15) for
      % substitution[variable, symbol, arity]
      % generated from assumption substitution.var_countable
  IMP_substitution_TCC1: OBLIGATION
    is_countably_infinite[term[variable, symbol, arity]]
        (V[variable, symbol, arity]);


decl_type: formula
theory: reduction
library: TRS
signature: nil
location: 56 1 57 79
body:
   closure_close_subs: LEMMA close_subs?(R)  =>
                  (close_subs?(TC(R)) & close_subs?(RTC(R)) & close_subs?(EC(R)))


decl_type: formula
theory: reduction
library: TRS
signature: nil
location: 61 1 62 81
body:
   lhs_reduces_to_rhs: LEMMA
                      FORALL (E, (e | member(e, E))): reduction?(E)(lhs(e), rhs(e))


decl_type: function
theory: reduction
library: TRS
location: 44 1 47 77
signature:
  [set[rewrite_rule] ->
          [[term[variable, symbol, arity],
            term[variable, symbol, arity]] ->
             bool]]

body:
   reduction?(E)(s,t): bool =  
       EXISTS ( (e | member(e, E)), sigma, (p: positions?(s))): 
                        subtermOF(s, p) = ext(sigma)(lhs(e)) & 
                                      t = replaceTerm(s, ext(sigma)(rhs(e)), p)


decl_type: function
theory: reduction
library: TRS
location: 50 1 51 74
signature:
[cell repeats an earlier one in this file: 109 characters]

body:
   close_subs?(R): bool = FORALL s, t, sigma: R(s,t) => 
                                              R(ext(sigma)(s),ext(sigma)(t))


decl_type: tcc
theory: reduction
library: TRS
signature: nil
location: 69 0 74 999
body:
  % Assuming TCC generated (at line 30, column 12) for
      % rewrite_rules[variable, symbol, arity]
      % generated from assumption rewrite_rules.var_countable
  IMP_rewrite_rules_TCC1: OBLIGATION
    is_countably_infinite[term[variable, symbol, arity]]
        (V[variable, symbol, arity]);


decl_type: formula
theory: replace_positions
library: TRS
signature: nil
location: 61 1 63 80
body:
   replace_pos_is_stable: LEMMA 
     FORALL t, s, (fss: SPP(s)), sig:
       ext(sig)(replace_pos(s, t, fss)) = replace_pos(ext(sig)(s),ext(sig)(t),fss)


decl_type: formula
theory: replace_positions
library: TRS
signature: nil
location: 67 1 71 64
body:
   preserv_first_position: LEMMA
     FORALL t, s, (fss: SPP(s)), (q: positions?(s)): 
         (FORALL (i: below[length(fss)]): parallel(fss(i),q))
             =>
              positionsOF(replace_pos(s, t, add_first(q, fss)))(q)


decl_type: formula
theory: replace_positions
library: TRS
signature: nil
location: 75 1 79 50
body:
   preserv_all_parallel_positions: LEMMA
     FORALL t, s, (fss: SPP(s)), (q: positions?(s)): 
         (FORALL (i: below[length(fss)]): parallel(fss(i),q))
             => 
              positionsOF(replace_pos(s, t, fss))(q)


decl_type: formula
theory: replace_positions
library: TRS
signature: nil
location: 83 1 85 57
body:
   preserv_all_replaced_positions: LEMMA 
    FORALL t, s, (fssp: SPP(s)), (i: below[fssp`length]): 
              positionsOF(replace_pos(s, t, fssp))(fssp(i))


decl_type: formula
theory: replace_positions
library: TRS
signature: nil
location: 89 1 93 61
body:
   preserv_unchanged_subterms: LEMMA
    FORALL t, s, (fss: SPP(s)), (q: positions?(s)): 
     (FORALL (i: below[length(fss)]): parallel(fss(i),q))
        => 
         subtermOF(replace_pos(s, t, fss), q) = subtermOF(s, q)


decl_type: formula
theory: replace_positions
library: TRS
signature: nil
location: 96 1 99 44
body:
   replace_pos_subterm_to_term: LEMMA
      FORALL t, s, (fss: SPP(s)):
        (FORALL (i: below[length(fss)]): subtermOF(s, fss(i)) = t)
            IMPLIES replace_pos(s, t, fss) = s       


decl_type: formula
theory: replace_positions
library: TRS
signature: nil
location: 106 2 110 80
body:
    CP_lemma_aux2a: LEMMA
    FORALL t, s, (fss: SPP(s)), (q: positions?(s)): 
     (FORALL (i: below[length(fss)]): parallel(fss(i),q))
        => 
    replace_pos(s, t, add_last(fss,q)) = replaceTerm(replace_pos(s, t, fss), t, q)


decl_type: formula
theory: replace_positions
library: TRS
signature: nil
location: 114 2 118 82
body:
    CP_lemma_aux2a1: LEMMA
    FORALL t, s, (fss: SPP(s)), (q: positions?(s)): 
     (FORALL (i: below[length(fss)]): parallel(fss(i),q))
        => 
    replace_pos(s, t, add_first(q, fss)) = replaceTerm(replace_pos(s, t, fss), t, q)


decl_type: formula
theory: replace_positions
library: TRS
signature: nil
location: 122 2 125 78
body:
    CP_lemma_aux2a2: LEMMA
    FORALL t, s, (fss: SPP(s)), (i: below[length(fss)]): 
       replace_pos(s, t, fss) = 
                        replaceTerm(replace_pos(s, t, delete(fss,i)), t, fss(i))


decl_type: formula
theory: replace_positions
library: TRS
signature: nil
location: 128 2 132 54
body:
    CP_lemma_aux2a3: LEMMA
    FORALL t, s, (fss1, fss2: SPP(s)): 
      equivalent(fss1, fss2)
         =>
       replace_pos(s, t, fss1) = replace_pos(s, t, fss2)


decl_type: function
theory: replace_positions
library: TRS
location: 45 1 52 22
signature:
  [[s: term[variable, symbol, arity], term[variable, symbol, arity],
         SPP[variable, symbol, arity](s)] ->
          term[variable, symbol, arity]]

body:
   replace_pos(s, t, (fssp:SPP(s)) ): RECURSIVE term =
      IF length(fssp) = 0
      THEN 
       s
      ELSE
       replace_pos(replaceTerm(s, t, fssp(0)), t, rest(fssp))
      ENDIF
    MEASURE length(fssp)


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 140 0 145 999
body:
  % Assuming TCC generated (at line 31, column 15) for
      % substitution[variable, symbol, arity]
      % generated from assumption substitution.var_countable
  IMP_substitution_TCC1: OBLIGATION
    is_countably_infinite[term[variable, symbol, arity]]
        (V[variable, symbol, arity]);


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 147 0 152 999
body:
  % Subtype TCC generated (at line 50, column 40) for  0
      % expected type  below[length(fssp)]
  replace_pos_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (fssp: SPP[variable, symbol, arity](s))):
      NOT length(fssp) = 0 IMPLIES 0 < length(fssp);


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 154 0 162 999
body:
  % Subtype TCC generated (at line 50, column 35) for
      % finseq_appl[position[variable, symbol, arity]](fssp)(0)
      % expected type  positions?[variable, symbol, arity](s)
  replace_pos_TCC2: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (fssp: SPP[variable, symbol, arity](s))):
      NOT length(fssp) = 0 IMPLIES
       positionsOF[variable, symbol, arity]
           (s)(finseq_appl[position[variable, symbol, arity]](fssp)(0));


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 164 0 184 999
body:
  % Subtype TCC generated (at line 50, column 48) for  rest(fssp)
      % expected type  SPP
                     %     [variable, symbol, arity](replaceTerm
                     %                               (s,
                     %                                t,
                     %                                finseq_appl
                     %                                [position
                     %                                 [variable,
                     %                                  symbol,
                     %                                  arity]]
                     %                                (fssp)(0)))
  replace_pos_TCC3: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            t: term[variable, symbol, arity],
            (fssp: SPP[variable, symbol, arity](s))):
      NOT length(fssp) = 0 IMPLIES
       SPP?[variable, symbol, arity]
           (replaceTerm[variable, symbol, arity]
                (s, t,
                 finseq_appl[position[variable, symbol, arity]](fssp)(0)))
           (rest[position[variable, symbol, arity]](fssp));


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 186 0 195 999
body:
  % Termination TCC generated (at line 50, column 5) for
      % replace_pos(replaceTerm(s, t,
      %                         finseq_appl[position[variable, symbol, arity]]
      %                             (fssp)(0)),
      %             t, rest(fssp))
  replace_pos_TCC4: OBLIGATION
    FORALL (s: term[variable, symbol, arity],
            (fssp: SPP[variable, symbol, arity](s))):
      NOT length(fssp) = 0 IMPLIES
       length(rest[position[variable, symbol, arity]](fssp)) < length(fssp);


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 197 0 202 999
body:
  % Subtype TCC generated (at line 63, column 76) for  fss
      % expected type  SPP[variable, symbol, arity](ext(sig)(s))
  replace_pos_is_stable_TCC1: OBLIGATION
    FORALL (s, fss: SPP[variable, symbol, arity](s), sig):
      SPP?[variable, symbol, arity]
          (ext[variable, symbol, arity](sig)(s))(fss);


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 204 0 213 999
body:
  % Subtype TCC generated (at line 71, column 42) for  add_first(q, fss)
      % expected type  SPP[variable, symbol, arity](s)
  preserv_first_position_TCC1: OBLIGATION
    FORALL (s, fss: SPP[variable, symbol, arity](s),
            q: positions?[variable, symbol, arity](s)):
      (FORALL (i: below[length(fss)]):
         parallel(finseq_appl[position[variable, symbol, arity]](fss)(i), q))
       IMPLIES
       SPP?[variable, symbol, arity]
           (s)(add_first[position[variable, symbol, arity]](q, fss));


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 215 0 224 999
body:
  % Subtype TCC generated (at line 93, column 41) for  q
      % expected type  positions?
                     %     [variable, symbol, arity](replace_pos(s, t, fss))
  preserv_unchanged_subterms_TCC1: OBLIGATION
    FORALL (t, s, fss: SPP[variable, symbol, arity](s),
            q: positions?[variable, symbol, arity](s)):
      (FORALL (i: below[length(fss)]):
         parallel(finseq_appl[position[variable, symbol, arity]](fss)(i), q))
       IMPLIES
       positionsOF[variable, symbol, arity](replace_pos(s, t, fss))(q);


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 226 0 232 999
body:
  % Subtype TCC generated (at line 98, column 52) for
      % finseq_appl[position[variable, symbol, arity]](fss)(i)
      % expected type  positions?[variable, symbol, arity](s)
  replace_pos_subterm_to_term_TCC1: OBLIGATION
    FORALL (s, fss: SPP[variable, symbol, arity](s), i: below[length(fss)]):
      positionsOF[variable, symbol, arity]
          (s)(finseq_appl[position[variable, symbol, arity]](fss)(i));


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 234 0 239 999
body:
  % Subtype TCC generated (at line 102, column 56) for  Pos_var(s, x)
      % expected type  finite_set[position[variable, symbol, arity]]
  replace_pos_to_term_TCC1: OBLIGATION
    FORALL (s: term[variable, symbol, arity], x: (V)):
      is_finite[position[variable, symbol, arity]]
          (Pos_var[variable, symbol, arity](s, x));


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 241 0 248 999
body:
  % Subtype TCC generated (at line 102, column 48) for  set2seq(Pos_var(s, x))
      % expected type  SPP[variable, symbol, arity](s)
  replace_pos_to_term_TCC2: OBLIGATION
    FORALL (s: term[variable, symbol, arity], x: (V)):
      SPP?[variable, symbol, arity]
          (s)
          (set2seq[position[variable, symbol, arity]]
               (Pos_var[variable, symbol, arity](s, x)));


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 250 0 259 999
body:
  % Subtype TCC generated (at line 110, column 20) for  add_last(fss, q)
      % expected type  SPP[variable, symbol, arity](s)
  CP_lemma_aux2a_TCC1: OBLIGATION
    FORALL (s, fss: SPP[variable, symbol, arity](s),
            q: positions?[variable, symbol, arity](s)):
      (FORALL (i: below[length(fss)]):
         parallel(finseq_appl[position[variable, symbol, arity]](fss)(i), q))
       IMPLIES
       SPP?[variable, symbol, arity]
           (s)(add_last[position[variable, symbol, arity]](fss, q));


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 261 0 266 999
body:
  % Subtype TCC generated (at line 125, column 52) for  delete(fss, i)
      % expected type  SPP[variable, symbol, arity](s)
  CP_lemma_aux2a2_TCC1: OBLIGATION
    FORALL (s, fss: SPP[variable, symbol, arity](s), i: below[length(fss)]):
      SPP?[variable, symbol, arity]
          (s)(delete[position[variable, symbol, arity]](fss, i));


decl_type: tcc
theory: replace_positions
library: TRS
signature: nil
location: 268 0 279 999
body:
  % Subtype TCC generated (at line 125, column 71) for
      % finseq_appl[position[variable, symbol, arity]](fss)(i)
      % expected type  positions?
                     %     [variable, symbol, arity](replace_pos
                     %                               (s, t, delete(fss, i)))
  CP_lemma_aux2a2_TCC2: OBLIGATION
    FORALL (t, s, fss: SPP[variable, symbol, arity](s),
            i: below[length(fss)]):
      positionsOF[variable, symbol, arity]
          (replace_pos(s, t,
                       delete[position[variable, symbol, arity]](fss, i)))
          (finseq_appl[position[variable, symbol, arity]](fss)(i));


decl_type: formula
theory: critical_pairs_aux
library: TRS
signature: nil
location: 46 1 52 62
body:
   CP_lemma_aux2b: LEMMA
     FORALL R, t, x, sg1, sg2, (fstp: SPP(t)):
       LET Mtn = replace_pos(ext(sg1)(t), ext(sg2)(x), fstp) IN
       (FORALL (i: below[length(fstp)]): subtermOF(t,fstp(i)) = x) &
                                         comp_cont?(R) & 
                                         RSigma(R, sg1, sg2, x) 
                   => iterate(R, length(fstp))(ext(sg1)(t), Mtn)


decl_type: formula
theory: critical_pairs_aux
library: TRS
signature: nil
location: 57 1 66 80
body:
   CP_lemma_aux2c1: LEMMA
     FORALL R, t, x, sg1, sg2, (fst: SPP(t)), (q: positions?(t)):
         ( FORALL (i: below[length(fst)]): parallel(fst(i),q)           &
                                            subtermOF(t, fst(i)) = x  ) &
                                            subtermOF(t, q) = x         &
                                            comp_cont?(R)               & 
                                            RSigma(R, sg1, sg2, x)
     => 
  iterate(R, length(fst))(replace_pos(ext(sg1)(t), ext(sg2)(x), #(q)), 
                          replace_pos(ext(sg1)(t), ext(sg2)(x), add_first(q,fst)))


decl_type: formula
theory: critical_pairs_aux
library: TRS
signature: nil
location: 70 1 78 76
body:
   CP_lemma_aux2c: LEMMA
     FORALL R, t, x, sg1, sg2, (fstp: SPP(t)):
       fstp`length /= 0 &
       ( FORALL (i: below[length(fstp)]): subtermOF(t,fstp(i)) = x  ) &
                                          comp_cont?(R) & 
                                          RSigma(R, sg1, sg2, x)
     => ( FORALL (i: below[length(fstp)]):
  iterate(R, length(fstp) - 1)(replace_pos(ext(sg1)(t), ext(sg2)(x), #(fstp(i))), 
                               replace_pos(ext(sg1)(t), ext(sg2)(x), fstp))  )


decl_type: formula
theory: critical_pairs_aux
library: TRS
signature: nil
location: 83 0 89 68
body:
  CP_lemma_aux2d: LEMMA
     FORALL R, t, x, sg1, sg2:
       LET Posv = Pos_var(t, x),
           seqv = set2seq(Posv) IN
       comp_cont?(R) & 
       RSigma(R, sg1, sg2, x) 
          => replace_pos(ext(sg1)(t), ext(sg2)(x), seqv) = ext(sg2)(t)


decl_type: tcc
theory: critical_pairs_aux
library: TRS
signature: nil
location: 97 0 102 999
body:
  % Assuming TCC generated (at line 32, column 15) for
      % rewrite_rules[variable, symbol, arity]
      % generated from assumption rewrite_rules.var_countable
  IMP_rewrite_rules_TCC1: OBLIGATION
    is_countably_infinite[term[variable, symbol, arity]]
        (V[variable, symbol, arity]);


decl_type: tcc
theory: critical_pairs_aux
library: TRS
signature: nil
location: 104 0 109 999
body:
  % Subtype TCC generated (at line 48, column 53) for  fstp
      % expected type  SPP[variable, symbol, arity](ext(sg1)(t))
  CP_lemma_aux2b_TCC1: OBLIGATION
    FORALL (t, x, sg1, sg2, fstp: SPP[variable, symbol, arity](t)):
      SPP?[variable, symbol, arity]
          (ext[variable, symbol, arity](sg1)(t))(fstp);


decl_type: tcc
theory: critical_pairs_aux
library: TRS
signature: nil
location: 111 0 120 999
body:
  % Subtype TCC generated (at line 49, column 51) for
      % finseq_appl[position[variable, symbol, arity]](fstp)(i)
      % expected type  positions?[variable, symbol, arity](t)
  CP_lemma_aux2b_TCC2: OBLIGATION
    FORALL (t, x, sg1, sg2, fstp: SPP[variable, symbol, arity](t),
            Mtn: term[variable, symbol, arity]):
      Mtn = replace_pos(ext(sg1)(t), ext(sg2)(x), fstp) IMPLIES
       (FORALL (i: below[length(fstp)]):
          positionsOF[variable, symbol, arity]
              (t)(finseq_appl[position[variable, symbol, arity]](fstp)(i)));


decl_type: tcc
theory: critical_pairs_aux
library: TRS
signature: nil
location: 122 0 132 999
body:
  % Subtype TCC generated (at line 60, column 55) for
      % finseq_appl[position[variable, symbol, arity]](fst)(i)
      % expected type  positions?[variable, symbol, arity](t)
  CP_lemma_aux2c1_TCC1: OBLIGATION
    FORALL (t, x, sg1, sg2, fst: SPP[variable, symbol, arity](t),
            q: positions?[variable, symbol, arity](t),
            i: below[length(fst)]):
      parallel(finseq_appl[position[variable, symbol, arity]](fst)(i), q)
       IMPLIES
       positionsOF[variable, symbol, arity]
           (t)(finseq_appl[position[variable, symbol, arity]](fst)(i));


decl_type: tcc
theory: critical_pairs_aux
library: TRS
signature: nil
location: 134 0 149 999
body:
  % Subtype TCC generated (at line 65, column 62) for   #(q)
      % expected type  SPP[variable, symbol, arity](ext(sg1)(t))
  CP_lemma_aux2c1_TCC2: OBLIGATION
    FORALL (R, t, x, sg1, sg2, fst: SPP[variable, symbol, arity](t),
            q: positions?[variable, symbol, arity](t)):
      (FORALL (i: below[length(fst)]):
         parallel(finseq_appl[position[variable, symbol, arity]](fst)(i), q)
          &
          subtermOF(t,
                    finseq_appl[position[variable, symbol, arity]](fst)(i))
           = x)
       AND subtermOF(t, q) = x AND comp_cont?(R) AND RSigma(R, sg1, sg2, x)
       IMPLIES
       SPP?[variable, symbol, arity]
           (ext[variable, symbol, arity](sg1)(t))
           ( #[position[variable, symbol, arity]](q));


decl_type: tcc
theory: critical_pairs_aux
library: TRS
signature: nil
location: 151 0 166 999
body:
  % Subtype TCC generated (at line 66, column 62) for  add_first(q, fst)
      % expected type  SPP[variable, symbol, arity](ext(sg1)(t))
  CP_lemma_aux2c1_TCC3: OBLIGATION
    FORALL (R, t, x, sg1, sg2, fst: SPP[variable, symbol, arity](t),
            q: positions?[variable, symbol, arity](t)):
      (FORALL (i: below[length(fst)]):
         parallel(finseq_appl[position[variable, symbol, arity]](fst)(i), q)
          &
          subtermOF(t,
                    finseq_appl[position[variable, symbol, arity]](fst)(i))
           = x)
       AND subtermOF(t, q) = x AND comp_cont?(R) AND RSigma(R, sg1, sg2, x)
       IMPLIES
       SPP?[variable, symbol, arity]
           (ext[variable, symbol, arity](sg1)(t))
           (add_first[position[variable, symbol, arity]](q, fst));


decl_type: tcc
theory: critical_pairs_aux
library: TRS
signature: nil
location: 168 0 176 999
body:
  % Subtype TCC generated (at line 73, column 52) for
      % finseq_appl[position[variable, symbol, arity]](fstp)(i)
      % expected type  positions?[variable, symbol, arity](t)
  CP_lemma_aux2c_TCC1: OBLIGATION
    FORALL (t, x, sg1, sg2, fstp: SPP[variable, symbol, arity](t)):
      fstp`length /= 0 IMPLIES
       (FORALL (i: below[length(fstp)]):
          positionsOF[variable, symbol, arity]
              (t)(finseq_appl[position[variable, symbol, arity]](fstp)(i)));


decl_type: tcc
theory: critical_pairs_aux
library: TRS
signature: nil
location: 178 0 195 999
body:
  % Subtype TCC generated (at line 77, column 67) for
      %  #(finseq_appl[position[variable, symbol, arity]](fstp)(i))
      % expected type  SPP[variable, symbol, arity](ext(sg1)(t))
  CP_lemma_aux2c_TCC2: OBLIGATION
    FORALL (R, t, x, sg1, sg2, fstp: SPP[variable, symbol, arity](t)):
      fstp`length /= 0 AND
       (FORALL (i: below[length(fstp)]):
          subtermOF(t,
                    finseq_appl[position[variable, symbol, arity]](fstp)(i))
           = x)
        AND comp_cont?(R) AND RSigma(R, sg1, sg2, x)
       IMPLIES
       (FORALL (i1: below[length(fstp)]):
          SPP?[variable, symbol, arity]
              (ext[variable, symbol, arity](sg1)(t))
              ( #[position[variable, symbol, arity]]
                   (finseq_appl[position[variable, symbol, arity]]
                        (fstp)(i1))));


decl_type: tcc
theory: critical_pairs_aux
library: TRS
signature: nil
location: 197 0 207 999
body:
  % Subtype TCC generated (at line 77, column 11) for  length(fstp) - 1
      % expected type  nat
  CP_lemma_aux2c_TCC3: OBLIGATION
    FORALL (R, t, x, sg1, sg2, fstp: SPP[variable, symbol, arity](t)):
      fstp`length /= 0 AND
       (FORALL (i: below[length(fstp)]):
          subtermOF(t,
                    finseq_appl[position[variable, symbol, arity]](fstp)(i))
           = x)
        AND comp_cont?(R) AND RSigma(R, sg1, sg2, x)
       IMPLIES (FORALL (i1: below[length(fstp)]): length(fstp) - 1 >= 0);


decl_type: tcc
theory: critical_pairs_aux
library: TRS
signature: nil
location: 209 0 214 999
body:
  % Subtype TCC generated (at line 86, column 24) for  Posv
      % expected type  finite_set[position[variable, symbol, arity]]
  CP_lemma_aux2d_TCC1: OBLIGATION
    FORALL (t, x, sg1, sg2, Posv: positions[variable, symbol, arity]):
      Posv = Pos_var(t, x) IMPLIES
       is_finite[position[variable, symbol, arity]](Posv);


decl_type: tcc
theory: critical_pairs_aux
library: TRS
signature: nil
location: 216 0 225 999
body:
  % Subtype TCC generated (at line 89, column 49) for  seqv
      % expected type  SPP[variable, symbol, arity](ext(sg1)(t))
  CP_lemma_aux2d_TCC2: OBLIGATION
    FORALL (R, t, x, sg1, sg2, Posv: positions[variable, symbol, arity]):
      Posv = Pos_var(t, x) IMPLIES
       (FORALL (seqv: finite_sequence[position[variable, symbol, arity]]):
          comp_cont?(R) AND RSigma(R, sg1, sg2, x) AND seqv = set2seq(Posv)
           IMPLIES
           SPP?[variable, symbol, arity]
               (ext[variable, symbol, arity](sg1)(t))(seqv));


decl_type: formula
theory: critical_pairs
library: TRS
signature: nil
location: 63 0 71 77
body:
  CP_lemma_aux1a: LEMMA 
   FORALL E, (p: position), (e1 | member(e1, E)), (e2 | member(e2, E)):
   ( positionsOF(lhs(e1))(p)                                                    & 
     NOT vars?(subtermOF(lhs(e1), p))                                           &
     ext(sg1)(subtermOF(lhs(e1), p)) = ext(sg2)(lhs(e2)) )
          => 
            EXISTS alpha, rho: 
               disjoint?(Vars(lhs(e1)), Vars(ext(rho)(lhs(e2))))                &
               ext(sg1)(subtermOF(lhs(e1), p)) = ext(comp(alpha, rho))(lhs(e2))


decl_type: formula
theory: critical_pairs
library: TRS
signature: nil
location: 74 1 83 79
body:
   CP_lemma_aux1: LEMMA
    FORALL E, (p: position), (e1 | member(e1, E)), (e2 | member(e2, E)):
    ( positionsOF(lhs(e1))(p)                                                & 
      NOT vars?(subtermOF(lhs(e1), p))                                       &
      ext(sg1)(subtermOF(lhs(e1), p)) = ext(sg2)(lhs(e2)) )
           => 
            EXISTS t1, t2, delta: 
              CP?(E)(t1, t2)                                                 &
              ext(delta)(t1) = ext(sg1)(rhs(e1))                             &
            ext(delta)(t2) = replaceTerm(ext(sg1)(lhs(e1)), ext(sg2)(rhs(e2)), p)


decl_type: formula
theory: critical_pairs
library: TRS
signature: nil
location: 90 1 100 50
body:
   CP_lemma_aux2: LEMMA
     FORALL R, t, x, sg1, sg2:
      LET Posv = Pos_var(t, x),
          seqv = set2seq(Posv) IN
       comp_cont?(R) & 
       RSigma(R, sg1, sg2, x) 
          => 
          (FORALL (i: below[length(seqv)]):
            RTC(R)(replace_pos(ext(sg1)(t), ext(sg2)(x), #(seqv(i))),ext(sg2)(t)))
                                    &
                    RTC(R)(ext(sg1)(t), ext(sg2)(t))


decl_type: formula
theory: critical_pairs
library: TRS
signature: nil
location: 107 0 112 56
body:
  CP_Theorem: THEOREM 
   FORALL E: 
     LET RRE = reduction?(E) IN
     locally_confluent?(RRE)
                 <=> 
  (FORALL t1, t2: CP?(E)(t1, t2) => joinable?(RRE)(t1,t2))


decl_type: function
theory: critical_pairs
library: TRS
location: 48 1 58 76
signature:
  [set[rewrite_rule] ->
          [[term[variable, symbol, arity],
            term[variable, symbol, arity]] ->
             bool]]

body:
   CP?(E)(t1, t2): bool = 
      EXISTS (sigma,rho,
             (e1 | member(e1, E)), 
             (e2p | member(e2p, E)), 
             (p: positions?(lhs(e1)))): 
           LET e2 = (# lhs := ext(rho)(lhs(e2p)), rhs := ext(rho)(rhs(e2p)) #) IN
                 disjoint?(Vars(lhs(e1)),Vars(lhs(e2)))                        &
                 NOT vars?(subtermOF(lhs(e1), p))                              &
                 mgu(sigma)(subtermOF(lhs(e1), p), lhs(e2))                    &
                 t1 = ext(sigma)(rhs(e1))                                      &
                 t2 = replaceTerm(ext(sigma)(lhs(e1)), ext(sigma)(rhs(e2)), p)


decl_type: tcc
theory: critical_pairs
library: TRS
signature: nil
location: 119 0 124 999
body:
  % Assuming TCC generated (at line 31, column 14) for
      % critical_pairs_aux[variable, symbol, arity]
      % generated from assumption critical_pairs_aux.var_countable
  IMP_critical_pairs_aux_TCC1: OBLIGATION
    is_countably_infinite[term[variable, symbol, arity]]
        (V[variable, symbol, arity]);


decl_type: tcc
theory: critical_pairs
library: TRS
signature: nil
location: 126 0 154 999
body:
  % Subtype TCC generated (at line 58, column 74) for  p
      % expected type  positions?
                     %     [variable, symbol, arity](ext(sigma)(lhs(e1)))
  CP?_TCC1: OBLIGATION
    FORALL (E: set[rewrite_rule[variable, symbol, arity]],
            t1: term[variable, symbol, arity],
            sigma: Sub[variable, symbol, arity],
            rho: Ren[variable, symbol, arity],
            (e1: rewrite_rule[variable, symbol, arity]
                 | member[rewrite_rule[variable, symbol, arity]](e1, E)),
            (e2p: rewrite_rule[variable, symbol, arity]
                 | member[rewrite_rule[variable, symbol, arity]](e2p, E)),
            (p:
               positions?
                   [variable, symbol, arity](lhs[variable, symbol, arity]
                                             (e1))),
            e2:
              [# lhs: term[variable, symbol, arity],
                 rhs: term[variable, symbol, arity] #]):
           t1 = ext(sigma)(rhs(e1))
       AND mgu(sigma)(subtermOF(lhs(e1), p), lhs(e2))
       AND NOT vars?(subtermOF(lhs(e1), p))
       AND disjoint?(Vars(lhs(e1)), Vars(lhs(e2)))
       AND e2 = (# lhs := ext(rho)(lhs(e2p)), rhs := ext(rho)(rhs(e2p)) #)
       IMPLIES
       positionsOF[variable, symbol, arity]
           (ext[variable, symbol, arity]
                (sigma)(lhs[variable, symbol, arity](e1)))
           (p);


decl_type: tcc
theory: critical_pairs
library: TRS
signature: nil
location: 156 0 172 999
body:
  % Subtype TCC generated (at line 71, column 51) for  comp(alpha, rho)
      % expected type  Sub[variable, symbol, arity]
  CP_lemma_aux1a_TCC1: OBLIGATION
    FORALL (sg1, sg2: Sub[variable, symbol, arity], E,
            p: position[variable, symbol, arity],
            e1: rewrite_rule[variable, symbol, arity]
                | member[rewrite_rule[variable, symbol, arity]](e1, E),
            e2: rewrite_rule[variable, symbol, arity]
                | member[rewrite_rule[variable, symbol, arity]](e2, E)):
      positionsOF(lhs(e1))(p) AND
       NOT vars?(subtermOF(lhs(e1), p)) AND
        ext(sg1)(subtermOF(lhs(e1), p)) = ext(sg2)(lhs(e2))
       IMPLIES
       (FORALL (alpha, rho):
          disjoint?(Vars(lhs(e1)), Vars(ext(rho)(lhs(e2)))) IMPLIES
           Sub?[variable, symbol, arity]
               (comp[variable, symbol, arity](alpha, rho)));


decl_type: tcc
theory: critical_pairs
library: TRS
signature: nil
location: 174 0 192 999
body:
  % Subtype TCC generated (at line 83, column 77) for  p
      % expected type  positions?[variable, symbol, arity](ext(sg1)(lhs(e1)))
  CP_lemma_aux1_TCC1: OBLIGATION
    FORALL (sg1, sg2: Sub[variable, symbol, arity], E,
            p: position[variable, symbol, arity],
            e1: rewrite_rule[variable, symbol, arity]
                | member[rewrite_rule[variable, symbol, arity]](e1, E),
            e2: rewrite_rule[variable, symbol, arity]
                | member[rewrite_rule[variable, symbol, arity]](e2, E)):
      positionsOF(lhs(e1))(p) AND
       NOT vars?(subtermOF(lhs(e1), p)) AND
        ext(sg1)(subtermOF(lhs(e1), p)) = ext(sg2)(lhs(e2))
       IMPLIES
       (FORALL (t1, t2, delta):
          ext(delta)(t1) = ext(sg1)(rhs(e1)) AND CP?(E)(t1, t2) IMPLIES
           positionsOF[variable, symbol, arity]
               (ext[variable, symbol, arity]
                    (sg1)(lhs[variable, symbol, arity](e1)))
               (p));


decl_type: tcc
theory: critical_pairs
library: TRS
signature: nil
location: 194 0 199 999
body:
  % Subtype TCC generated (at line 93, column 23) for  Posv
      % expected type  finite_set[position[variable, symbol, arity]]
  CP_lemma_aux2_TCC1: OBLIGATION
    FORALL (t, x, sg1, sg2, Posv: positions[variable, symbol, arity]):
      Posv = Pos_var(t, x) IMPLIES
       is_finite[position[variable, symbol, arity]](Posv);


