# Declarations

decl_type: tcc
theory: poly_systems
library: Tarski
signature: nil
location: 202 0 208 999
body:
  % Subtype TCC generated (at line 50, column 18) for
      % row(tensor_power_alt(A63, 1 + k))(ii)
      % expected type  v: {v | length(v) > 0}
  A63_tensor_power_mat_row_def_TCC1: OBLIGATION
    FORALL (RelF6: [nat -> subrange(0, 5)], k, ii: nat):
      ii = base_n_to_nat(6, RelF6, k) IMPLIES
       length[real](row(tensor_power_alt(A63, 1 + k))(ii)) > 0;


decl_type: tcc
theory: poly_systems
library: Tarski
signature: nil
location: 210 0 231 999
body:
  % Subtype TCC generated (at line 55, column 8) for
      % super_dot(row(A63_tensor_power_mat_row(k + 1)(RelF6))(0),
      %           col(TQ_vect3k(k, a, m, p, n))(0))
      % expected type  {r: real |
                     %          r = NSol_all(k, a, m, p, n, RelF6) AND
                     %           rational_pred(r) AND integer_pred(r)}
  sturm_tarski_solver_slow_basic_TCC1: OBLIGATION
    FORALL (k: nat, a: [nat -> int], (m: posnat | a(m) /= 0),
            p: [nat -> [nat -> int]],
            (n: [nat -> nat] | FORALL (i: upto(k)): p(i)(n(i)) /= 0),
            RelF6: [nat -> subrange(0, 5)]):
      super_dot(row(A63_tensor_power_mat_row(k + 1)(RelF6))(0),
                col(TQ_vect3k(k, a, m, p, n))(0))
       = NSol_all(k, a, m, p, n, RelF6)
       AND
       rational_pred(super_dot(row(A63_tensor_power_mat_row(k + 1)(RelF6))
                                  (0),
                               col(TQ_vect3k(k, a, m, p, n))(0)))
        AND
        integer_pred(super_dot(row(A63_tensor_power_mat_row(k + 1)(RelF6))
                                  (0),
                               col(TQ_vect3k(k, a, m, p, n))(0)));


decl_type: formula
theory: system_solvers
library: Tarski
signature: nil
location: 54 0 56 71
body:
  entry_is: LEMMA FORALL (RelF6, k, (i:below(3^(k+1))) ):
         entry_fun(k, rows_fun(RelF6, k))(base_list(3, i, k+1)) = 
         entry(tensor_power_alt(A63, k+1))(base_n_to_nat(6, RelF6, k), i)


decl_type: formula
theory: system_solvers
library: Tarski
signature: nil
location: 60 0 61 78
body:
  TQlist_lem: LEMMA FORALL (k,a,(m|a(m)/=0),p, (n|FORALL (i:upto(k)):p(i)(n(i))/=0), j:below(3^(k+1))):
      TQlist_fun(k,a,m,p,n)(base_list(3,j,k+1)) = TQ_fam(k,a,m,p,n,base_n(3, j))


decl_type: function
theory: system_solvers
library: Tarski
location: 49 0 49 105
signature:
  [d: [[nat -> subrange(0, 5)], nat] ->
          [j: upto(d`2) ->
             {V: Vector | V = row(A63)(d`1(j)) AND length(V) = 3}]]

body:
  rows_fun(RelF6, k)(j:upto(k)):  {V: Vector| V = row(A63)(RelF6(j)) AND length(V)=3} = row(A63)( RelF6(j))


decl_type: function
theory: system_solvers
library: Tarski
location: 51 0 52 100
signature:
  [d: [k: nat, [upto(k) -> {V: Vector | length(V) = 3}]] ->
          [listn[below(3)](1 + d`1) -> real]]

body:
  entry_fun(k, (RowF:[upto(k)->{V:Vector|length(V) = 3}]))((L:listn[below(3)](k+1))): 
           real = product[nat](0, k, LAMBDA(i:nat): IF i<=k THEN nth(RowF(i), nth(L, i)) ELSE 1 ENDIF)    


decl_type: function
theory: system_solvers
library: Tarski
location: 58 0 58 146
signature:
  [d:
          [k: nat, a: [nat -> int], {m | a(m) /= 0},
           p: [nat -> [nat -> int]],
           {n | FORALL (i: upto(k)): p(i)(n(i)) /= 0}] ->
          [listn[below(3)](1 + d`1) -> real]]

body:
  TQlist_fun(k,a,(m|a(m)/=0),p, (n|FORALL (i:upto(k)):p(i)(n(i))/=0))(L:listn[below(3)](k+1)): real = TQ_fam(k,a,m, p ,n,list2array[below(3)](0)(L))


decl_type: function
theory: system_solvers
library: Tarski
location: 63 0 69 10
signature:
  [d:
          [k: nat, a: [nat -> int], {m | a(m) /= 0},
           p: [nat -> [nat -> int]],
           {n | FORALL (i: upto(k)): p(i)(n(i)) /= 0},
           [nat -> subrange(0, 5)]] ->
          {r: real |
                   r = NSol_all(d`1, d`2, d`3, d`4, d`5, d`6) AND
                    rational_pred(r) AND integer_pred(r)}]

body:
  sturm_tarski_faster(k,a,(m|a(m)/=0),p,
                  (n|FORALL (i:upto(k)):p(i)(n(i))/=0),RelF6):
       {r:real | r = NSol_all(k,a,m,p,n,RelF6) AND rational_pred(r) AND integer_pred(r)} =
       LET EntFun  = entry_fun(k, rows_fun(RelF6, k)) IN 
       IF k=0 THEN   sturm_tarski_solver_slow_basic(k,a,m,p,n,RelF6) 
       ELSE dot_tail_sum2plus(k+1, EntFun, TQlist_fun(k,a,m,p,n), 0, 0, base_list(3, 0, k+1))
       ENDIF


decl_type: function
theory: system_solvers
library: Tarski
signature: [[posnat, nat] -> real]
location: 77 1 82 12
body:
   Test1(n:posnat, j:nat): RECURSIVE real = 
     if j=0 THEN T1(n, j, j) 
     ELSE LET ent = T1(n, j, j) in
          Test1(n, j-1)
     ENDIF
     MEASURE j


decl_type: function
theory: system_solvers
library: Tarski
signature: [[PosFullMatrix, nat] -> real]
location: 84 1 89 11
body:
   Test2recurse(M:PosFullMatrix, j:nat): RECURSIVE real= 
    IF j=0 THEN T2(M, j, j)
    ELSE LET ent  = T2(M, j, j) IN        
         Test2recurse(M, j-1)
    ENDIF                
    MEASURE j


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 104 0 108 999
body:
  % Subtype TCC generated (at line 49, column 86) for  row(A63)(RelF6(j))
      % expected type  {V: Vector | V = row(A63)(RelF6(j)) AND length(V) = 3}
  rows_fun_TCC1: OBLIGATION
    FORALL (RelF6: [nat -> subrange(0, 5)], k: nat, j: upto(k)):
      length[real](row(A63)(RelF6(j))) = 3;


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 110 0 115 999
body:
  % Subtype TCC generated (at line 52, column 32) for  k
      % expected type  T_high[nat]
  entry_fun_TCC1: OBLIGATION
    FORALL (k: nat, (RowF: [upto(k) -> {V: Vector | length[real](V) = 3}]),
            (L: listn[below(3)](k + 1))):
      k >= 0 OR (EXISTS (j: nat): k <= j);


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 117 0 122 999
body:
  % Subtype TCC generated (at line 52, column 83) for  i
      % expected type  below[length[below(3)](L)]
  entry_fun_TCC2: OBLIGATION
    FORALL (k: nat, (RowF: [upto(k) -> {V: Vector | length[real](V) = 3}]),
            (L: listn[below(3)](k + 1)), i: nat):
      i <= k IMPLIES i < length[below(3)](L);


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 124 0 129 999
body:
  % Subtype TCC generated (at line 52, column 76) for  nth(L, i)
      % expected type  below[length[real](RowF(i))]
  entry_fun_TCC3: OBLIGATION
    FORALL (k: nat, (RowF: [upto(k) -> {V: Vector | length[real](V) = 3}]),
            (L: listn[below(3)](k + 1)), i: nat):
      i <= k IMPLIES nth[below(3)](L, i) < length[real](RowF(i));


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 131 0 137 999
body:
  % Existence TCC generated (at line 58, column 119) for  list2array[below(3)]
  TQlist_fun_TCC1: OBLIGATION
    FORALL (k: nat, a: [nat -> int], (m: posnat | a(m) /= 0),
            p: [nat -> [nat -> int]],
            (n: [nat -> nat] | FORALL (i: upto(k)): p(i)(n(i)) /= 0),
            L: listn[below(3)](k + 1)):
      EXISTS (x: below(3)): TRUE;


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 139 0 149 999
body:
  % Subtype TCC generated (at line 58, column 119) for
      % list2array[below(3)](0)(L)
      % expected type  [nat -> subrange(0, 2)]
  TQlist_fun_TCC2: OBLIGATION
    FORALL (k: nat, a: [nat -> int], (m: posnat | a(m) /= 0),
            p: [nat -> [nat -> int]],
            (n: [nat -> nat] | FORALL (i: upto(k)): p(i)(n(i)) /= 0),
            L: listn[below(3)](k + 1)):
      FORALL (x1: nat):
        0 <= list2array[below(3)](0)(L)(x1) AND
         list2array[below(3)](0)(L)(x1) <= 2;


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 151 0 158 999
body:
  % Subtype TCC generated (at line 61, column 65) for  base_n(3, j)
      % expected type  [nat -> subrange(0, 2)]
  TQlist_lem_TCC1: OBLIGATION
    FORALL (k: nat, a: [nat -> int], (m: posnat | a(m) /= 0),
            p: [nat -> [nat -> int]],
            (n: [nat -> nat] | FORALL (i: upto(k)): p(i)(n(i)) /= 0),
            j: below(3 ^ (k + 1))):
      FORALL (x1: nat): 0 <= base_n(3, j)(x1) AND base_n(3, j)(x1) <= 2;


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 160 0 169 999
body:
  % Subtype TCC generated (at line 68, column 28) for  k + 1
      % expected type  {x: nat | x > 1}
  sturm_tarski_faster_TCC1: OBLIGATION
    FORALL (k: nat, a: [nat -> int], (m: posnat | a(m) /= 0),
            p: [nat -> [nat -> int]],
            (n: [nat -> nat] | FORALL (i: upto(k)): p(i)(n(i)) /= 0),
            RelF6: [nat -> subrange(0, 5)],
            EntFun: [listn[below(3)](1 + k) -> real]):
      NOT k = 0 AND EntFun = entry_fun(k, rows_fun(RelF6, k)) IMPLIES
       k + 1 > 1;


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 171 0 180 999
body:
  % Subtype TCC generated (at line 68, column 67) for  0
      % expected type  upto(3 ^ (1 + k))
  sturm_tarski_faster_TCC2: OBLIGATION
    FORALL (k: nat, a: [nat -> int], (m: posnat | a(m) /= 0),
            p: [nat -> [nat -> int]],
            (n: [nat -> nat] | FORALL (i: upto(k)): p(i)(n(i)) /= 0),
            RelF6: [nat -> subrange(0, 5)],
            EntFun: [listn[below(3)](1 + k) -> real]):
      NOT k = 0 AND EntFun = entry_fun(k, rows_fun(RelF6, k)) IMPLIES
       0 <= 3 ^ (1 + k);


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 182 0 191 999
body:
  % Subtype TCC generated (at line 68, column 70) for  base_list(3, 0, k + 1)
      % expected type  {ll: list[below(3)] | ll = base_list(3, 0, 1 + k)}
  sturm_tarski_faster_TCC3: OBLIGATION
    FORALL (k: nat, a: [nat -> int], (m: posnat | a(m) /= 0),
            p: [nat -> [nat -> int]],
            (n: [nat -> nat] | FORALL (i: upto(k)): p(i)(n(i)) /= 0),
            RelF6: [nat -> subrange(0, 5)],
            EntFun: [listn[below(3)](1 + k) -> real]):
      NOT k = 0 AND EntFun = entry_fun(k, rows_fun(RelF6, k)) IMPLIES
       base_list(3, 0, k + 1) = base_list(3, 0, 1 + k);


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 193 0 222 999
body:
  % Subtype TCC generated (at line 68, column 10) for
      % dot_tail_sum2plus(k + 1, EntFun, TQlist_fun(k, a, m, p, n), 0, 0,
      %                   base_list(3, 0, k + 1))
      % expected type  {r: real |
                     %          r = NSol_all(k, a, m, p, n, RelF6) AND
                     %           rational_pred(r) AND integer_pred(r)}
  sturm_tarski_faster_TCC4: OBLIGATION
    FORALL (k: nat, a: [nat -> int], (m: posnat | a(m) /= 0),
            p: [nat -> [nat -> int]],
            (n: [nat -> nat] | FORALL (i: upto(k)): p(i)(n(i)) /= 0),
            RelF6: [nat -> subrange(0, 5)],
            EntFun: [listn[below(3)](1 + k) -> real]):
      NOT k = 0 AND EntFun = entry_fun(k, rows_fun(RelF6, k)) IMPLIES
       dot_tail_sum2plus(k + 1, EntFun, TQlist_fun(k, a, m, p, n), 0, 0,
                         base_list(3, 0, k + 1))
        = NSol_all(k, a, m, p, n, RelF6)
        AND
        rational_pred(dot_tail_sum2plus(k + 1,
                                        EntFun,
                                        TQlist_fun(k, a, m, p, n),
                                        0,
                                        0,
                                        base_list(3, 0, k + 1)))
         AND
         integer_pred(dot_tail_sum2plus(k + 1,
                                        EntFun,
                                        TQlist_fun(k, a, m, p, n),
                                        0,
                                        0,
                                        base_list(3, 0, k + 1)));


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 224 0 229 999
body:
  % Subtype TCC generated (at line 80, column 13) for  j - 1
      % expected type  nat
  Test1_TCC1: OBLIGATION
    FORALL (n: posnat, j: nat):
      NOT j = 0 IMPLIES
       (FORALL (ent: real): ent = T1(n, j, j) IMPLIES j - 1 >= 0);


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 231 0 235 999
body:
  % Termination TCC generated (at line 80, column 4) for  Test1(n, j - 1)
  Test1_TCC2: OBLIGATION
    FORALL (n: posnat, j: nat):
      NOT j = 0 IMPLIES
       (FORALL (ent: real): ent = T1(n, j, j) IMPLIES j - 1 < j);


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 237 0 242 999
body:
  % Subtype TCC generated (at line 87, column 23) for  j - 1
      % expected type  nat
  Test2recurse_TCC1: OBLIGATION
    FORALL (M: PosFullMatrix, j: nat):
      NOT j = 0 IMPLIES
       (FORALL (ent: real): ent = T2(M, j, j) IMPLIES j - 1 >= 0);


decl_type: tcc
theory: system_solvers
library: Tarski
signature: nil
location: 244 0 249 999
body:
  % Termination TCC generated (at line 87, column 7) for
      % Test2recurse(M, j - 1)
  Test2recurse_TCC2: OBLIGATION
    FORALL (M: PosFullMatrix, j: nat):
      NOT j = 0 IMPLIES
       (FORALL (ent: real): ent = T2(M, j, j) IMPLIES j - 1 < j);


decl_type: formula
theory: poly_system_strategy
library: Tarski
signature: nil
location: 60 2 62 66
body:
    greatify_def: LEMMA (FORALL (j:upto(k)): p(j)(n(j))/=0) IMPLIES
      (solvable?(k,p,n,RelF6) IFF
      solvable?(k,greatify_poly_rel(p,RelF6),n,greatify_rel(RelF6)))


decl_type: formula
theory: poly_system_strategy
library: Tarski
signature: nil
location: 82 2 84 34
body:
    compute_solvable_single_def: LEMMA a(d)/=0 IMPLIES FORALL (i:subrange(0,5)):
      (EXISTS (x): rel5(i)(polynomial(a,d)(x),0)) IFF
      compute_solvable_single(i,a,d)


decl_type: formula
theory: poly_system_strategy
library: Tarski
signature: nil
location: 86 2 88 34
body:
    poly_deriv_integer: LEMMA
      rational_pred(poly_deriv(a)(d)) AND
      integer_pred(poly_deriv(a)(d))


decl_type: formula
theory: poly_system_strategy
library: Tarski
signature: nil
location: 116 2 119 35
body:
    compute_solvable_def: LEMMA
      (FORALL (j:upto(k)): p(j)(n(j))/=0 AND n(j)>0) IMPLIES
      ((EXISTS (x:real): FORALL (j:upto(k)): rel5(RelF6(j))(polynomial(p(j),n(j))(x),0)) IFF
       compute_solvable(k,p,n,RelF6))


decl_type: formula
theory: poly_system_strategy
library: Tarski
signature: nil
location: 134 2 137 26
body:
    tarski_def: LEMMA
      (FORALL (j:upto(k)): pq(j)(n(j))/=0 AND n(j)>0) IMPLIES
      ((EXISTS (x:real): FORALL (j:upto(k)): rel5(RelF6(j))(polynomial(pq(j),n(j))(x),0)) IFF
       tarski(k,pq,n,RelF6))


decl_type: function
theory: poly_system_strategy
library: Tarski
signature: [[nat -> subrange(0, 5)] -> [nat -> subrange(0, 5)]]
location: 24 2 24 103
body:
    strictify(RelF6)(i): subrange(0,5) = IF RelF6(i)=4 THEN 1 ELSIF RelF6(i)=5 THEN 2 ELSE RelF6(i) ENDIF


decl_type: function
theory: poly_system_strategy
library: Tarski
location: 26 2 32 19
signature:
  [d: [[nat -> subrange(0, 5)], nat] ->
          {i |
                   (i > d`2 IMPLIES (FORALL (j: upto(d`2)): d`1(j) > 0))
                    AND
                    (i <= d`2 IMPLIES
                      d`1(i) = 0 AND
                       (FORALL (j): j < i IMPLIES d`1(j) > 0))}]

body:
    first_eq(RelF6,k): RECURSIVE {i | (i>k IMPLIES FORALL (j:upto(k)): RelF6(j)>0) AND
                                      (i<=k IMPLIES RelF6(i)=0 AND FORALL (j): j<i IMPLIES RelF6(j)>0)} =
      IF k=0 THEN (IF RelF6(0)=0 THEN 0 ELSE 1 ENDIF)
      ELSE LET last = first_eq(RelF6,k-1) IN
             IF last>k-1 THEN (IF RelF6(k)=0 THEN k ELSE k+1 ENDIF)
             ELSE last ENDIF
      ENDIF MEASURE k


decl_type: function
theory: poly_system_strategy
library: Tarski
location: 34 2 36 77
signature:
  [[k: nat, p: [nat -> [nat -> int]],
         {n | FORALL (j: upto(k)): p(j)(n(j)) /= 0},
         [nat -> subrange(0, 5)]] ->
          list[int]]

body:
    prod_nonstrict(k,p,(n|FORALL (j:upto(k)): p(j)(n(j))/=0),RelF6): list[int] =
      prod_polynomials_list(LAMBDA (i): IF RelF6(i)>=4 THEN p(i) ELSE (LAMBDA (j:nat): 1) ENDIF,
                            LAMBDA (i): IF RelF6(i)>=4 THEN n(i) ELSE 0 ENDIF,(LAMBDA (i): 1),k)


decl_type: function
theory: poly_system_strategy
library: Tarski
signature: [subrange(0, 5) -> [[real, real] -> bool]]
location: 38 2 41 61
body:
    rel5(i:subrange(0,5))(r1,r2:real): bool =
      (IF i=0 THEN r1=r2 ELSIF i=1 THEN r1>r2
          ELSIF i=2 THEN r1<r2 ELSIF i=3 THEN r1/=r2 
          ELSIF i=4 THEN r1>=r2 ELSIF i=5 THEN r1<=r2 ELSE TRUE ENDIF)


decl_type: function
theory: poly_system_strategy
library: Tarski
location: 43 2 45 48
signature:
  [[k: nat, p: [nat -> [nat -> int]],
         {n | FORALL (j: upto(k)): p(j)(n(j)) /= 0},
         [nat -> subrange(0, 5)]] ->
          [real -> bool]]

body:
    solvable_at?(k,p,(n|FORALL (j:upto(k)): p(j)(n(j))/=0),RelF6)(x): bool =
     FORALL (i:upto(k)): 
        rel5(RelF6(i))(polynomial(p(i),n(i))(x),0)


decl_type: function
theory: poly_system_strategy
library: Tarski
location: 48 2 49 44
signature:
  [[k: nat, p: [nat -> [nat -> int]],
         {n | FORALL (j: upto(k)): p(j)(n(j)) /= 0},
         [nat -> subrange(0, 5)]] ->
          bool]

body:
    solvable?(k,p,(n|FORALL (j:upto(k)): p(j)(n(j))/=0),RelF6): bool =
      EXISTS (x): solvable_at?(k,p,n,RelF6)(x)


decl_type: function
theory: poly_system_strategy
library: Tarski
signature:
  [[nat -> subrange(0, 5)] ->
  [nat -> {pz: subrange(0, 5) | pz /= 2 AND pz /= 5}]]

location: 57 2 58 68
body:
    greatify_rel(RelF6)(i): {pz:subrange(0,5)|pz/=2 AND pz/=5} =
      IF RelF6(i)=2 THEN 1 ELSIF RelF6(i)=5 THEN 4 ELSE RelF6(i) ENDIF


decl_type: function
theory: poly_system_strategy
library: Tarski
signature: [[subrange(0, 5), a: [nat -> int], {d | a(d) /= 0}] -> bool]
location: 65 2 79 9
body:
    compute_solvable_single(i:subrange(0,5),a,(d|a(d)/=0)): bool = 
     IF d=0 THEN rel5(i)(a(0),0)
     ELSIF d=1 THEN TRUE
     ELSIF i=3 THEN TRUE
     ELSE LET iseq = sturm_tarski_faster(1,a,d,LAMBDA (k):LAMBDA (j):1,
                     LAMBDA (k):0,LAMBDA (j):1)/=0
          IN IF i=0 THEN iseq
             ELSIF i/=1 AND i/=2 AND iseq THEN TRUE
             ELSE LET newa = IF rel5(i)(1,0) THEN a ELSE (-1)*a ENDIF
                  IN 
                    newa(d)>0 OR (odd?(d) AND newa(d)<0) OR
                    sturm_tarski_faster(1,poly_deriv(a),d-1,LAMBDA (j): newa,
                      LAMBDA (j): d,greatify_rel(LAMBDA (j): i))/=0
             ENDIF
      ENDIF


decl_type: function
theory: poly_system_strategy
library: Tarski
location: 91 2 114 9
signature:
  [[k: nat, p: [nat -> [nat -> int]],
         {n | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0},
         [nat -> subrange(0, 5)]] ->
          bool]

body:
    compute_solvable(k,p,(n|FORALL (j:upto(k)): p(j)(n(j))/=0 AND n(j)>0),RelF6): bool =
      LET newp=greatify_poly_rel(p,RelF6),
          newRel=greatify_rel(RelF6)
      IN
      IF k=0 THEN compute_solvable_single(RelF6(0),p(0),n(0))
      ELSIF (EXISTS (i:upto(k)): newRel(i)=0) THEN
        LET fe = first_eq(newRel,k) IN 
          sturm_tarski_faster(k-1,newp(fe),n(fe),
                  (LAMBDA (i): IF i<fe THEN newp(i) ELSE newp(i+1) ENDIF),
                  (LAMBDA (i): IF i<fe THEN n(i) ELSE n(i+1) ENDIF),
                  (LAMBDA (i): IF i<fe THEN newRel(i) ELSE newRel(i+1) ENDIF))/=0
      ELSE
        LET Qprodlist = prod_polynomials_list(newp,n,LAMBDA i: 1,k),
            Qdeg = length(Qprodlist)-1,
            Qprod = (LAMBDA (i): IF i<length(Qprodlist) THEN nth(Qprodlist,i) ELSE 0 ENDIF)
        IN 
          (Qdeg>0 AND sturm_tarski_faster(k,Qprod,Qdeg,newp,n,newRel)/=0)
          OR
          (Qdeg>=2  AND
            ((FORALL (j:upto(k)): rel5(newRel(j))(newp(j)(n(j)),0)) OR
            (FORALL (j:upto(k)): (odd?(n(j)) IMPLIES rel5(newRel(j))(-newp(j)(n(j)),0)) AND
                                 (even?(n(j)) IMPLIES rel5(newRel(j))(newp(j)(n(j)),0))) OR
            sturm_tarski_faster(k,poly_deriv(Qprod),Qdeg-1,newp,n,newRel)/=0))
      ENDIF


decl_type: function
theory: poly_system_strategy
library: Tarski
location: 121 2 124 79
signature:
  [d:
          [k: nat, p: [nat -> [nat -> int]],
           {n | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0}] ->
          {lli: list[list[int]] |
                   length[list[int]](lli) = 1 + d`1 AND
                    (FORALL (i: upto(d`1)):
                       length[int](nth[list[int]](lli, i)) = 1 + d`3(i))
                     AND
                     (FORALL (j: upto(d`1), i: upto(d`3(j))):
                        nth[int](nth[list[int]](lli, j), i) =
                         d`2(j)(i))}]

body:
    poly_system_list(k,p,(n|FORALL (j:upto(k)): p(j)(n(j))/=0 AND n(j)>0)): {lli : list[list[int]] |
      length[list[int]](lli) = k+1 AND (FORALL (i:upto(k)): length[int](nth[list[int]](lli,i)) = n(i)+1) AND
      (FORALL (j:upto(k),i:upto(n(j))): nth[int](nth[list[int]](lli,j),i)=p(j)(i))} =
        array2list[list[int]](k+1)(LAMBDA (j:nat): array2list[int](n(j)+1)(p(j)))


decl_type: function
theory: poly_system_strategy
library: Tarski
location: 128 2 132 36
signature:
  [[k: nat, pq: [nat -> [nat -> rat]],
         {n | FORALL (j: upto(k)): pq(j)(n(j)) /= 0 AND n(j) > 0},
         [nat -> subrange(0, 5)]] ->
          bool]

body:
    tarski(k,pq,(n|FORALL (j:upto(k)): pq(j)(n(j))/=0 AND n(j)>0),RelF6): bool =
      LET pi = (LAMBDA (j): rat_poly_to_int(pq(j),n(j))),
          pl = poly_system_list(k,pi,n),
          p = (LAMBDA (i): LAMBDA (j): IF i<=k AND j<=n(i) THEN nth[int](nth[list[int]](pl,i),j) ELSE 0 ENDIF)
      IN compute_solvable(k,p,n,RelF6)


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 146 0 159 999
body:
  % Subtype TCC generated (at line 28, column 36) for  0
      % expected type  {i |
                     %          (i > k IMPLIES
                     %            (FORALL (j: upto(k)): RelF6(j) > 0))
                     %           AND
                     %           (i <= k IMPLIES
                     %             RelF6(i) = 0 AND
                     %              (FORALL (j): j < i IMPLIES RelF6(j) > 0))}
  first_eq_TCC1: OBLIGATION
    FORALL (RelF6: [nat -> subrange(0, 5)], k: nat):
      RelF6(0) = 0 AND k = 0 IMPLIES
       (0 > k IMPLIES (FORALL (j: upto(k)): RelF6(j) > 0)) AND
        (0 <= k IMPLIES
          RelF6(0) = 0 AND (FORALL (j): j < 0 IMPLIES RelF6(j) > 0));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 161 0 174 999
body:
  % Subtype TCC generated (at line 28, column 43) for  1
      % expected type  {i |
                     %          (i > k IMPLIES
                     %            (FORALL (j: upto(k)): RelF6(j) > 0))
                     %           AND
                     %           (i <= k IMPLIES
                     %             RelF6(i) = 0 AND
                     %              (FORALL (j): j < i IMPLIES RelF6(j) > 0))}
  first_eq_TCC2: OBLIGATION
    FORALL (RelF6: [nat -> subrange(0, 5)], k: nat):
      NOT RelF6(0) = 0 AND k = 0 IMPLIES
       (1 > k IMPLIES (FORALL (j: upto(k)): RelF6(j) > 0)) AND
        (1 <= k IMPLIES
          RelF6(1) = 0 AND (FORALL (j): j < 1 IMPLIES RelF6(j) > 0));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 176 0 207 999
body:
  % Subtype TCC generated (at line 30, column 48) for  k
      % expected type  {i |
                     %          (i > k IMPLIES
                     %            (FORALL (j: upto(k)): RelF6(j) > 0))
                     %           AND
                     %           (i <= k IMPLIES
                     %             RelF6(i) = 0 AND
                     %              (FORALL (j): j < i IMPLIES RelF6(j) > 0))}
  first_eq_TCC3: OBLIGATION
    FORALL (RelF6: [nat -> subrange(0, 5)], k: nat,
            v:
              [d1: {z: [[nat -> subrange(0, 5)], nat] | z`2 < k} ->
                 {i |
                          (i > d1`2 IMPLIES
                            (FORALL (j: upto(d1`2)): d1`1(j) > 0))
                           AND
                           (i <= d1`2 IMPLIES
                             d1`1(i) = 0 AND
                              (FORALL (j): j < i IMPLIES d1`1(j) > 0))}]):
      NOT k = 0 IMPLIES
       (FORALL (last:
                  {i |
                           (i > k - 1 IMPLIES
                             (FORALL (j: upto(k - 1)): RelF6(j) > 0))
                            AND
                            (i <= k - 1 IMPLIES
                              RelF6(i) = 0 AND
                               (FORALL (j): j < i IMPLIES RelF6(j) > 0))}):
          RelF6(k) = 0 AND last > k - 1 AND last = v(RelF6, k - 1) IMPLIES
           (k > k IMPLIES (FORALL (j: upto(k)): RelF6(j) > 0)) AND
            (k <= k IMPLIES
              RelF6(k) = 0 AND (FORALL (j): j < k IMPLIES RelF6(j) > 0)));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 209 0 242 999
body:
  % Subtype TCC generated (at line 30, column 55) for  k + 1
      % expected type  {i |
                     %          (i > k IMPLIES
                     %            (FORALL (j: upto(k)): RelF6(j) > 0))
                     %           AND
                     %           (i <= k IMPLIES
                     %             RelF6(i) = 0 AND
                     %              (FORALL (j): j < i IMPLIES RelF6(j) > 0))}
  first_eq_TCC4: OBLIGATION
    FORALL (RelF6: [nat -> subrange(0, 5)], k: nat,
            v:
              [d1: {z: [[nat -> subrange(0, 5)], nat] | z`2 < k} ->
                 {i |
                          (i > d1`2 IMPLIES
                            (FORALL (j: upto(d1`2)): d1`1(j) > 0))
                           AND
                           (i <= d1`2 IMPLIES
                             d1`1(i) = 0 AND
                              (FORALL (j): j < i IMPLIES d1`1(j) > 0))}]):
      NOT k = 0 IMPLIES
       (FORALL (last:
                  {i |
                           (i > k - 1 IMPLIES
                             (FORALL (j: upto(k - 1)): RelF6(j) > 0))
                            AND
                            (i <= k - 1 IMPLIES
                              RelF6(i) = 0 AND
                               (FORALL (j): j < i IMPLIES RelF6(j) > 0))}):
          NOT RelF6(k) = 0 AND last > k - 1 AND last = v(RelF6, k - 1)
           IMPLIES
           (k + 1 > k IMPLIES (FORALL (j: upto(k)): RelF6(j) > 0)) AND
            (k + 1 <= k IMPLIES
              RelF6(k + 1) = 0 AND
               (FORALL (j): j < k + 1 IMPLIES RelF6(j) > 0)));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 244 0 276 999
body:
  % Subtype TCC generated (at line 31, column 9) for  last
      % expected type  {i |
                     %          (i > k IMPLIES
                     %            (FORALL (j: upto(k)): RelF6(j) > 0))
                     %           AND
                     %           (i <= k IMPLIES
                     %             RelF6(i) = 0 AND
                     %              (FORALL (j): j < i IMPLIES RelF6(j) > 0))}
  first_eq_TCC5: OBLIGATION
    FORALL (RelF6: [nat -> subrange(0, 5)], k: nat,
            v:
              [d1: {z: [[nat -> subrange(0, 5)], nat] | z`2 < k} ->
                 {i |
                          (i > d1`2 IMPLIES
                            (FORALL (j: upto(d1`2)): d1`1(j) > 0))
                           AND
                           (i <= d1`2 IMPLIES
                             d1`1(i) = 0 AND
                              (FORALL (j): j < i IMPLIES d1`1(j) > 0))}]):
      NOT k = 0 IMPLIES
       (FORALL (last:
                  {i |
                           (i > k - 1 IMPLIES
                             (FORALL (j: upto(k - 1)): RelF6(j) > 0))
                            AND
                            (i <= k - 1 IMPLIES
                              RelF6(i) = 0 AND
                               (FORALL (j): j < i IMPLIES RelF6(j) > 0))}):
          NOT last > k - 1 AND last = v(RelF6, k - 1) IMPLIES
           (last > k IMPLIES (FORALL (j: upto(k)): RelF6(j) > 0)) AND
            (last <= k IMPLIES
              RelF6(last) = 0 AND
               (FORALL (j): j < last IMPLIES RelF6(j) > 0)));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 278 0 282 999
body:
  % Subtype TCC generated (at line 29, column 35) for  k - 1
      % expected type  nat
  first_eq_TCC6: OBLIGATION
    FORALL (RelF6: [nat -> subrange(0, 5)], k: nat):
      NOT k = 0 IMPLIES k - 1 >= 0;


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 284 0 288 999
body:
  % Termination TCC generated (at line 29, column 20) for
      % first_eq(RelF6, k - 1)
  first_eq_TCC7: OBLIGATION
    FORALL (RelF6: [nat -> subrange(0, 5)], k: nat):
      NOT k = 0 IMPLIES k - 1 < k;


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 290 0 297 999
body:
  % Subtype TCC generated (at line 52, column 23) for  (-1) * a
      % expected type  [nat -> int]
  greatify_poly_TCC1: OBLIGATION
    FORALL (i: subrange(0, 5), a: [nat -> int]):
      i = 2 OR i = 5 IMPLIES
       (FORALL (x1: nat):
          rational_pred((*[nat]((-1), a))(x1)) AND
           integer_pred((*[nat]((-1), a))(x1)));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 299 0 304 999
body:
  % Subtype TCC generated (at line 58, column 54) for  RelF6(i)
      % expected type  {pz: subrange(0, 5) | pz /= 2 AND pz /= 5}
  greatify_rel_TCC1: OBLIGATION
    FORALL (RelF6: [nat -> subrange(0, 5)], i: nat):
      NOT RelF6(i) = 5 AND NOT RelF6(i) = 2 IMPLIES
       RelF6(i) /= 2 AND RelF6(i) /= 5;


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 306 0 314 999
body:
  % Subtype TCC generated (at line 62, column 43) for  n
      % expected type  {n |
                     %          FORALL (j: upto(k)):
                     %            greatify_poly_rel(p, RelF6)(j)(n(j)) /= 0}
  greatify_def_TCC1: OBLIGATION
    FORALL (RelF6: [nat -> subrange(0, 5)], k: nat, n: [nat -> nat],
            p: [nat -> [nat -> int]]):
      (FORALL (j: upto(k)): p(j)(n(j)) /= 0) IMPLIES
       (FORALL (j: upto(k)): greatify_poly_rel(p, RelF6)(j)(n(j)) /= 0);


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 316 0 320 999
body:
  % Subtype TCC generated (at line 69, column 43) for  d
      % expected type  {m | a(m) /= 0}
  compute_solvable_single_TCC1: OBLIGATION
    FORALL (i: subrange(0, 5), a: [nat -> int], (d: nat | a(d) /= 0)):
      NOT i = 3 AND NOT d = 1 AND NOT d = 0 IMPLIES d > 0 AND a(d) /= 0;


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 322 0 342 999
body:
  % Subtype TCC generated (at line 76, column 26) for  poly_deriv(a)
      % expected type  [nat -> int]
  compute_solvable_single_TCC2: OBLIGATION
    FORALL (i: subrange(0, 5), a: [nat -> int], (d: nat | a(d) /= 0)):
      NOT i = 3 AND NOT d = 1 AND NOT d = 0 IMPLIES
       (FORALL (iseq: boolean):
          NOT (i /= 1 AND i /= 2 AND iseq) AND
           NOT i = 0 AND
            iseq =
             (sturm_tarski_faster(1, a, d, LAMBDA (k): LAMBDA (j): 1,
                                  LAMBDA (k): 0, LAMBDA (j): 1)
               /= 0)
           IMPLIES
           (FORALL (newa: [nat -> real]):
              NOT (odd?(d) AND newa(d) < 0) AND
               NOT newa(d) > 0 AND
                newa = IF rel5(i)(1, 0) THEN a ELSE (-1) * a ENDIF
               IMPLIES
               (FORALL (x1: nat):
                  rational_pred(poly_deriv(a)(x1)) AND
                   integer_pred(poly_deriv(a)(x1)))));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 344 0 362 999
body:
  % Subtype TCC generated (at line 76, column 40) for  d - 1
      % expected type  {m | poly_deriv(a)(m) /= 0}
  compute_solvable_single_TCC3: OBLIGATION
    FORALL (i: subrange(0, 5), a: [nat -> int], (d: nat | a(d) /= 0)):
      NOT i = 3 AND NOT d = 1 AND NOT d = 0 IMPLIES
       (FORALL (iseq: boolean):
          NOT (i /= 1 AND i /= 2 AND iseq) AND
           NOT i = 0 AND
            iseq =
             (sturm_tarski_faster(1, a, d, LAMBDA (k): LAMBDA (j): 1,
                                  LAMBDA (k): 0, LAMBDA (j): 1)
               /= 0)
           IMPLIES
           (FORALL (newa: [nat -> real]):
              NOT (odd?(d) AND newa(d) < 0) AND
               NOT newa(d) > 0 AND
                newa = IF rel5(i)(1, 0) THEN a ELSE (-1) * a ENDIF
               IMPLIES
               d - 1 >= 0 AND d - 1 > 0 AND poly_deriv(a)(d - 1) /= 0));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 364 0 383 999
body:
  % Subtype TCC generated (at line 76, column 56) for  newa
      % expected type  [nat -> int]
  compute_solvable_single_TCC4: OBLIGATION
    FORALL (i: subrange(0, 5), a: [nat -> int], (d: nat | a(d) /= 0)):
      NOT i = 3 AND NOT d = 1 AND NOT d = 0 IMPLIES
       (FORALL (iseq: boolean):
          NOT (i /= 1 AND i /= 2 AND iseq) AND
           NOT i = 0 AND
            iseq =
             (sturm_tarski_faster(1, a, d, LAMBDA (k): LAMBDA (j): 1,
                                  LAMBDA (k): 0, LAMBDA (j): 1)
               /= 0)
           IMPLIES
           (FORALL (newa: [nat -> real]):
              NOT (odd?(d) AND newa(d) < 0) AND
               NOT newa(d) > 0 AND
                newa = IF rel5(i)(1, 0) THEN a ELSE (-1) * a ENDIF
               IMPLIES
               (FORALL (x1: nat):
                  rational_pred(newa(x1)) AND integer_pred(newa(x1)))));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 385 0 402 999
body:
  % Subtype TCC generated (at line 77, column 20) for  LAMBDA (j): d
      % expected type  {n | FORALL (i: upto(1)): newa(n(i)) /= 0}
  compute_solvable_single_TCC5: OBLIGATION
    FORALL (i: subrange(0, 5), a: [nat -> int], (d: nat | a(d) /= 0)):
      NOT i = 3 AND NOT d = 1 AND NOT d = 0 IMPLIES
       (FORALL (iseq: boolean):
          NOT (i /= 1 AND i /= 2 AND iseq) AND
           NOT i = 0 AND
            iseq =
             (sturm_tarski_faster(1, a, d, LAMBDA (k): LAMBDA (j): 1,
                                  LAMBDA (k): 0, LAMBDA (j): 1)
               /= 0)
           IMPLIES
           (FORALL (newa: [nat -> real]):
              NOT (odd?(d) AND newa(d) < 0) AND
               NOT newa(d) > 0 AND
                newa = IF rel5(i)(1, 0) THEN a ELSE (-1) * a ENDIF
               IMPLIES (FORALL (i: upto(1)): newa(d) /= 0)));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 404 0 413 999
body:
  % Subtype TCC generated (at line 95, column 54) for  n(0)
      % expected type  {d | p(0)(d) /= 0}
  compute_solvable_TCC1: OBLIGATION
    FORALL (k: nat, p: [nat -> [nat -> int]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)], newp: [nat -> [nat -> int]]):
      newp = greatify_poly_rel(p, RelF6) IMPLIES
       (FORALL (newRel: [nat -> {pz: subrange(0, 5) | pz /= 2 AND pz /= 5}]):
          k = 0 AND newRel = greatify_rel(RelF6) IMPLIES p(0)(n(0)) /= 0);


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 415 0 437 999
body:
  % Subtype TCC generated (at line 98, column 41) for  n(fe)
      % expected type  {m | newp(fe)(m) /= 0}
  compute_solvable_TCC2: OBLIGATION
    FORALL (k: nat, p: [nat -> [nat -> int]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)], newp: [nat -> [nat -> int]]):
      newp = greatify_poly_rel(p, RelF6) IMPLIES
       (FORALL (newRel: [nat -> {pz: subrange(0, 5) | pz /= 2 AND pz /= 5}]):
          (EXISTS (i: upto(k)): newRel(i) = 0) AND
           NOT k = 0 AND newRel = greatify_rel(RelF6)
           IMPLIES
           (FORALL (fe:
                      {i |
                               (i > k IMPLIES
                                 (FORALL (j: upto(k)): newRel(j) > 0))
                                AND
                                (i <= k IMPLIES
                                  newRel(i) = 0 AND
                                   (FORALL (j):
                                      j < i IMPLIES newRel(j) > 0))}):
              fe = first_eq(newRel, k) IMPLIES
               n(fe) > 0 AND newp(fe)(n(fe)) /= 0));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 439 0 480 999
body:
  % Subtype TCC generated (at line 100, column 17) for
      % (LAMBDA (i): IF i < fe THEN n(i) ELSE n(i + 1) ENDIF)
      % expected type  {n |
                     %          FORALL (i_1: upto(k - 1)):
                     %            NOT IF i_1 < fe
                     %                THEN newp(i_1)(n(i_1))
                     %                ELSE newp(1 + i_1)(n(i_1))
                     %                ENDIF
                     %                =
                     %                0}
  compute_solvable_TCC3: OBLIGATION
    FORALL (k: nat, p: [nat -> [nat -> int]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)], newp: [nat -> [nat -> int]]):
      newp = greatify_poly_rel(p, RelF6) IMPLIES
       (FORALL (newRel: [nat -> {pz: subrange(0, 5) | pz /= 2 AND pz /= 5}]):
          (EXISTS (i: upto(k)): newRel(i) = 0) AND
           NOT k = 0 AND newRel = greatify_rel(RelF6)
           IMPLIES
           (FORALL (fe:
                      {i |
                               (i > k IMPLIES
                                 (FORALL (j: upto(k)): newRel(j) > 0))
                                AND
                                (i <= k IMPLIES
                                  newRel(i) = 0 AND
                                   (FORALL (j):
                                      j < i IMPLIES newRel(j) > 0))}):
              fe = first_eq(newRel, k) IMPLIES
               (FORALL (i_1: upto(k - 1)):
                  NOT IF i_1 < fe
                        THEN newp(i_1)
                                 (IF i_1 < fe THEN n(i_1)
                                  ELSE n(i_1 + 1)
                                  ENDIF)
                      ELSE newp(1 + i_1)
                               (IF i_1 < fe THEN n(i_1)
                                ELSE n(i_1 + 1)
                                ENDIF)
                      ENDIF
                       = 0)));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 482 0 516 999
body:
  % Subtype TCC generated (at line 107, column 48) for  Qdeg
      % expected type  {m | Qprod(m) /= 0}
  compute_solvable_TCC4: OBLIGATION
    FORALL (k: nat, p: [nat -> [nat -> int]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)], newp: [nat -> [nat -> int]]):
      newp = greatify_poly_rel(p, RelF6) IMPLIES
       (FORALL (newRel: [nat -> {pz: subrange(0, 5) | pz /= 2 AND pz /= 5}]):
          NOT (EXISTS (i: upto(k)): newRel(i) = 0) AND
           NOT k = 0 AND newRel = greatify_rel(RelF6)
           IMPLIES
           (FORALL (Qprodlist:
                      {ll |
                               length[int](ll) - 1 =
                                sigma[nat](0, k, *[nat](n, LAMBDA i: 1))
                                AND
                                prod_polynomials(newp, n, LAMBDA i: 1, k) =
                                 (LAMBDA (i):
                                    IF i < length[int](ll)
                                      THEN nth[int](ll, i)
                                    ELSE 0
                                    ENDIF)}):
              Qprodlist = prod_polynomials_list(newp, n, LAMBDA i: 1, k)
               IMPLIES
               (FORALL (Qdeg: int):
                  Qdeg = length(Qprodlist) - 1 IMPLIES
                   (FORALL (Qprod: [nat -> int]):
                      (Qdeg > 0 AND
                        Qprod =
                         (LAMBDA (i):
                            IF i < length(Qprodlist) THEN nth(Qprodlist, i)
                            ELSE 0
                            ENDIF))
                       IMPLIES Qdeg >= 0 AND Qprod(Qdeg) /= 0))));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 518 0 552 999
body:
  % Subtype TCC generated (at line 107, column 58) for  n
      % expected type  {n | FORALL (i: upto(k)): newp(i)(n(i)) /= 0}
  compute_solvable_TCC5: OBLIGATION
    FORALL (k: nat, p: [nat -> [nat -> int]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)], newp: [nat -> [nat -> int]]):
      newp = greatify_poly_rel(p, RelF6) IMPLIES
       (FORALL (newRel: [nat -> {pz: subrange(0, 5) | pz /= 2 AND pz /= 5}]):
          NOT (EXISTS (i: upto(k)): newRel(i) = 0) AND
           NOT k = 0 AND newRel = greatify_rel(RelF6)
           IMPLIES
           (FORALL (Qprodlist:
                      {ll |
                               length[int](ll) - 1 =
                                sigma[nat](0, k, *[nat](n, LAMBDA i: 1))
                                AND
                                prod_polynomials(newp, n, LAMBDA i: 1, k) =
                                 (LAMBDA (i):
                                    IF i < length[int](ll)
                                      THEN nth[int](ll, i)
                                    ELSE 0
                                    ENDIF)}):
              Qprodlist = prod_polynomials_list(newp, n, LAMBDA i: 1, k)
               IMPLIES
               (FORALL (Qdeg: int):
                  Qdeg = length(Qprodlist) - 1 IMPLIES
                   (FORALL (Qprod: [nat -> int]):
                      (Qdeg > 0 AND
                        Qprod =
                         (LAMBDA (i):
                            IF i < length(Qprodlist) THEN nth(Qprodlist, i)
                            ELSE 0
                            ENDIF))
                       IMPLIES (FORALL (i: upto(k)): newp(i)(n(i)) /= 0)))));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 554 0 608 999
body:
  % Subtype TCC generated (at line 113, column 25) for  poly_deriv(Qprod)
      % expected type  [nat -> int]
  compute_solvable_TCC6: OBLIGATION
    FORALL (k: nat, p: [nat -> [nat -> int]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)], newp: [nat -> [nat -> int]]):
      newp = greatify_poly_rel(p, RelF6) IMPLIES
       (FORALL (newRel: [nat -> {pz: subrange(0, 5) | pz /= 2 AND pz /= 5}]):
          NOT (EXISTS (i: upto(k)): newRel(i) = 0) AND
           NOT k = 0 AND newRel = greatify_rel(RelF6)
           IMPLIES
           (FORALL (Qprodlist:
                      {ll |
                               length[int](ll) - 1 =
                                sigma[nat](0, k, *[nat](n, LAMBDA i: 1))
                                AND
                                prod_polynomials(newp, n, LAMBDA i: 1, k) =
                                 (LAMBDA (i):
                                    IF i < length[int](ll)
                                      THEN nth[int](ll, i)
                                    ELSE 0
                                    ENDIF)}):
              Qprodlist = prod_polynomials_list(newp, n, LAMBDA i: 1, k)
               IMPLIES
               (FORALL (Qdeg: int):
                  Qdeg = length(Qprodlist) - 1 IMPLIES
                   (FORALL (Qprod: [nat -> int]):
                      (     NOT (FORALL (j: upto(k)):
                                   (odd?(n(j)) IMPLIES
                                     rel5(newRel(j))(-newp(j)(n(j)), 0))
                                    AND
                                    (even?(n(j)) IMPLIES
                                      rel5(newRel(j))(newp(j)(n(j)), 0)))
                        AND NOT (FORALL (j: upto(k)):
                                   rel5(newRel(j))(newp(j)(n(j)), 0))
                        AND Qdeg >= 2
                        AND NOT (Qdeg > 0 AND
                                  sturm_tarski_faster(k,
                                                      Qprod,
                                                      Qdeg,
                                                      newp,
                                                      n,
                                                      newRel)
                                   /= 0)
                        AND Qprod =
                             (LAMBDA (i):
                                IF i < length(Qprodlist)
                                  THEN nth(Qprodlist, i)
                                ELSE 0
                                ENDIF))
                       IMPLIES
                       (FORALL (x1: nat):
                          rational_pred(poly_deriv(Qprod)(x1)) AND
                           integer_pred(poly_deriv(Qprod)(x1)))))));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 610 0 663 999
body:
  % Subtype TCC generated (at line 113, column 43) for  Qdeg - 1
      % expected type  {m | poly_deriv(Qprod)(m) /= 0}
  compute_solvable_TCC7: OBLIGATION
    FORALL (k: nat, p: [nat -> [nat -> int]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)], newp: [nat -> [nat -> int]]):
      newp = greatify_poly_rel(p, RelF6) IMPLIES
       (FORALL (newRel: [nat -> {pz: subrange(0, 5) | pz /= 2 AND pz /= 5}]):
          NOT (EXISTS (i: upto(k)): newRel(i) = 0) AND
           NOT k = 0 AND newRel = greatify_rel(RelF6)
           IMPLIES
           (FORALL (Qprodlist:
                      {ll |
                               length[int](ll) - 1 =
                                sigma[nat](0, k, *[nat](n, LAMBDA i: 1))
                                AND
                                prod_polynomials(newp, n, LAMBDA i: 1, k) =
                                 (LAMBDA (i):
                                    IF i < length[int](ll)
                                      THEN nth[int](ll, i)
                                    ELSE 0
                                    ENDIF)}):
              Qprodlist = prod_polynomials_list(newp, n, LAMBDA i: 1, k)
               IMPLIES
               (FORALL (Qdeg: int):
                  Qdeg = length(Qprodlist) - 1 IMPLIES
                   (FORALL (Qprod: [nat -> int]):
                      (     NOT (FORALL (j: upto(k)):
                                   (odd?(n(j)) IMPLIES
                                     rel5(newRel(j))(-newp(j)(n(j)), 0))
                                    AND
                                    (even?(n(j)) IMPLIES
                                      rel5(newRel(j))(newp(j)(n(j)), 0)))
                        AND NOT (FORALL (j: upto(k)):
                                   rel5(newRel(j))(newp(j)(n(j)), 0))
                        AND Qdeg >= 2
                        AND NOT (Qdeg > 0 AND
                                  sturm_tarski_faster(k,
                                                      Qprod,
                                                      Qdeg,
                                                      newp,
                                                      n,
                                                      newRel)
                                   /= 0)
                        AND Qprod =
                             (LAMBDA (i):
                                IF i < length(Qprodlist)
                                  THEN nth(Qprodlist, i)
                                ELSE 0
                                ENDIF))
                       IMPLIES
                       Qdeg - 1 >= 0 AND
                        Qdeg - 1 > 0 AND poly_deriv(Qprod)(Qdeg - 1) /= 0))));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 665 0 716 999
body:
  % Subtype TCC generated (at line 113, column 55) for  n
      % expected type  {n | FORALL (i: upto(k)): newp(i)(n(i)) /= 0}
  compute_solvable_TCC8: OBLIGATION
    FORALL (k: nat, p: [nat -> [nat -> int]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)], newp: [nat -> [nat -> int]]):
      newp = greatify_poly_rel(p, RelF6) IMPLIES
       (FORALL (newRel: [nat -> {pz: subrange(0, 5) | pz /= 2 AND pz /= 5}]):
          NOT (EXISTS (i: upto(k)): newRel(i) = 0) AND
           NOT k = 0 AND newRel = greatify_rel(RelF6)
           IMPLIES
           (FORALL (Qprodlist:
                      {ll |
                               length[int](ll) - 1 =
                                sigma[nat](0, k, *[nat](n, LAMBDA i: 1))
                                AND
                                prod_polynomials(newp, n, LAMBDA i: 1, k) =
                                 (LAMBDA (i):
                                    IF i < length[int](ll)
                                      THEN nth[int](ll, i)
                                    ELSE 0
                                    ENDIF)}):
              Qprodlist = prod_polynomials_list(newp, n, LAMBDA i: 1, k)
               IMPLIES
               (FORALL (Qdeg: int):
                  Qdeg = length(Qprodlist) - 1 IMPLIES
                   (FORALL (Qprod: [nat -> int]):
                      (     NOT (FORALL (j: upto(k)):
                                   (odd?(n(j)) IMPLIES
                                     rel5(newRel(j))(-newp(j)(n(j)), 0))
                                    AND
                                    (even?(n(j)) IMPLIES
                                      rel5(newRel(j))(newp(j)(n(j)), 0)))
                        AND NOT (FORALL (j: upto(k)):
                                   rel5(newRel(j))(newp(j)(n(j)), 0))
                        AND Qdeg >= 2
                        AND NOT (Qdeg > 0 AND
                                  sturm_tarski_faster(k,
                                                      Qprod,
                                                      Qdeg,
                                                      newp,
                                                      n,
                                                      newRel)
                                   /= 0)
                        AND Qprod =
                             (LAMBDA (i):
                                IF i < length(Qprodlist)
                                  THEN nth(Qprodlist, i)
                                ELSE 0
                                ENDIF))
                       IMPLIES (FORALL (i: upto(k)): newp(i)(n(i)) /= 0)))));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 718 0 723 999
body:
  % Subtype TCC generated (at line 122, column 89) for  i
      % expected type  below[length(lli)]
  poly_system_list_TCC1: OBLIGATION
    FORALL (k, lli: list[list[int]]):
      length[list[int]](lli) = k + 1 IMPLIES
       (FORALL (i: upto(k)): i < length[list[int]](lli));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 725 0 736 999
body:
  % Subtype TCC generated (at line 123, column 69) for  i
      % expected type  below[length[int](nth[list[int]](lli, j))]
  poly_system_list_TCC2: OBLIGATION
    FORALL (k, p,
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0),
            lli: list[list[int]]):
      (FORALL (i: upto(k)): length[int](nth[list[int]](lli, i)) = n(i) + 1)
       AND length[list[int]](lli) = k + 1
       IMPLIES
       (FORALL (j: upto(k), i1: upto(n(j))):
          i1 < length[int](nth[list[int]](lli, j)));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 738 0 776 999
body:
  % Subtype TCC generated (at line 124, column 6) for
      % array2list[list[int]]
      %     (k + 1)(LAMBDA (j: nat): array2list[int](n(j) + 1)(p(j)))
      % expected type  {lli: list[list[int]] |
                     %          length[list[int]](lli) = 1 + k AND
                     %           (FORALL (i: upto(k)):
                     %              length[int](nth[list[int]](lli, i)) =
                     %               1 + n(i))
                     %            AND
                     %            (FORALL (j: upto(k), i: upto(n(j))):
                     %               nth[int](nth[list[int]](lli, j), i) =
                     %                p(j)(i))}
  poly_system_list_TCC3: OBLIGATION
    FORALL (k: nat, p: [nat -> [nat -> int]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0)):
      length[list[int]]
          (array2list[list[int]]
               (k + 1)(LAMBDA (j: nat): array2list[int](n(j) + 1)(p(j))))
       = 1 + k
       AND
       (FORALL (i: upto(k)):
          length[int]
              (nth[list[int]]
                   (array2list[list[int]]
                        (k + 1)
                        (LAMBDA (j: nat): array2list[int](n(j) + 1)(p(j))),
                    i))
           = 1 + n(i))
        AND
        (FORALL (j_1: upto(k), i: upto(n(j_1))):
           nth[int]
               (nth[list[int]]
                    (array2list[list[int]]
                         (k + 1)
                         (LAMBDA (j: nat): array2list[int](n(j) + 1)(p(j))),
                     j_1),
                i)
            = p(j_1)(i));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 778 0 794 999
body:
  % Subtype TCC generated (at line 130, column 32) for  n
      % expected type  {n_1 |
                     %          FORALL (j: upto(k)):
                     %            pi(j)(n_1(j)) /= 0 AND n_1(j) > 0}
  tarski_TCC1: OBLIGATION
    FORALL (k: nat, pq: [nat -> [nat -> rat]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): pq(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)],
            pi:
              [j: nat ->
                 {ai: [nat -> int] |
                          EXISTS (cp: posrat):
                            FORALL (j_1: upto(n(j))):
                              ai(j_1) = cp * pq(j)(j_1)}]):
      (pi = (LAMBDA (j): rat_poly_to_int(pq(j), n(j)))) IMPLIES
       (FORALL (j: upto(k)): pi(j)(n(j)) /= 0 AND n(j) > 0);


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 796 0 822 999
body:
  % Subtype TCC generated (at line 131, column 82) for  i
      % expected type  below[length(pl)]
  tarski_TCC2: OBLIGATION
    FORALL (k: nat, pq: [nat -> [nat -> rat]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): pq(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)],
            pi:
              [j: nat ->
                 {ai: [nat -> int] |
                          EXISTS (cp: posrat):
                            FORALL (j_1: upto(n(j))):
                              ai(j_1) = cp * pq(j)(j_1)}]):
      (pi = (LAMBDA (j): rat_poly_to_int(pq(j), n(j)))) IMPLIES
       (FORALL (pl:
                  {lli: list[list[int]] |
                           length[list[int]](lli) = 1 + k AND
                            (FORALL (i: upto(k)):
                               length[int](nth[list[int]](lli, i)) =
                                1 + n(i))
                             AND
                             (FORALL (j: upto(k), i: upto(n(j))):
                                nth[int](nth[list[int]](lli, j), i) =
                                 pi(j)(i))}):
          pl = poly_system_list(k, pi, n) IMPLIES
           (FORALL (i: nat, j1: nat):
              i <= k AND j1 <= n(i) IMPLIES i < length[list[int]](pl)));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 824 0 851 999
body:
  % Subtype TCC generated (at line 131, column 85) for  j
      % expected type  below[length[int](nth[list[int]](pl, i))]
  tarski_TCC3: OBLIGATION
    FORALL (k: nat, pq: [nat -> [nat -> rat]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): pq(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)],
            pi:
              [j: nat ->
                 {ai: [nat -> int] |
                          EXISTS (cp: posrat):
                            FORALL (j_1: upto(n(j))):
                              ai(j_1) = cp * pq(j)(j_1)}]):
      (pi = (LAMBDA (j): rat_poly_to_int(pq(j), n(j)))) IMPLIES
       (FORALL (pl:
                  {lli: list[list[int]] |
                           length[list[int]](lli) = 1 + k AND
                            (FORALL (i: upto(k)):
                               length[int](nth[list[int]](lli, i)) =
                                1 + n(i))
                             AND
                             (FORALL (j: upto(k), i: upto(n(j))):
                                nth[int](nth[list[int]](lli, j), i) =
                                 pi(j)(i))}):
          pl = poly_system_list(k, pi, n) IMPLIES
           (FORALL (i: nat, j1: nat):
              i <= k AND j1 <= n(i) IMPLIES
               j1 < length[int](nth[list[int]](pl, i))));


decl_type: tcc
theory: poly_system_strategy
library: Tarski
signature: nil
location: 853 0 886 999
body:
  % Subtype TCC generated (at line 132, column 28) for  n
      % expected type  {n | FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0}
  tarski_TCC4: OBLIGATION
    FORALL (k: nat, pq: [nat -> [nat -> rat]],
            (n: [nat -> nat]
                 | FORALL (j: upto(k)): pq(j)(n(j)) /= 0 AND n(j) > 0),
            RelF6: [nat -> subrange(0, 5)],
            pi:
              [j: nat ->
                 {ai: [nat -> int] |
                          EXISTS (cp: posrat):
                            FORALL (j_1: upto(n(j))):
                              ai(j_1) = cp * pq(j)(j_1)}]):
      (pi = (LAMBDA (j): rat_poly_to_int(pq(j), n(j)))) IMPLIES
       (FORALL (pl:
                  {lli: list[list[int]] |
                           length[list[int]](lli) = 1 + k AND
                            (FORALL (i: upto(k)):
                               length[int](nth[list[int]](lli, i)) =
                                1 + n(i))
                             AND
                             (FORALL (j: upto(k), i: upto(n(j))):
                                nth[int](nth[list[int]](lli, j), i) =
                                 pi(j)(i))}):
          pl = poly_system_list(k, pi, n) IMPLIES
           (FORALL (p: [nat -> [nat -> int]]):
              (p =
                (LAMBDA (i):
                   LAMBDA (j):
                     IF i <= k AND j <= n(i)
                       THEN nth[int](nth[list[int]](pl, i), j)
                     ELSE 0
                     ENDIF))
               IMPLIES (FORALL (j: upto(k)): p(j)(n(j)) /= 0 AND n(j) > 0)));


decl_type: formula
theory: examples
library: Tarski
signature: nil
location: 18 2 21 31
body:
    example_1: LEMMA
      FORALL(y,x,z:real): (x-2)^2*(-x+4)>0 AND x^2*(x-3)^2>=0 AND x-1>=0 AND -(x-3)^2+1>0
      IMPLIES
      -(x-11/12)^3*(x-41/10)^3>=0 


decl_type: formula
theory: examples
library: Tarski
signature: nil
location: 32 2 35 34
body:
    example_3: LEMMA
      EXISTS (x:real): 
        (x-2)^2*(-x+4)>0 AND x^2*(x-3)^2>=0 AND x-1>=0 AND -(x-3)^2+1>0 AND
       -(x-11/12)^3*(x-41/10)^3<1/10


decl_type: formula
theory: examples
library: Tarski
signature: nil
location: 40 2 48 46
body:
    example_4 : LEMMA
      EXISTS (x:real):
        x^5 - x - 1 = 0
        AND 
        x^12 + 425/23*x^11 - 228/23*x^10 - 2*x^8 
        - 896/23*x^7 - 394/23*x^6 + 456/23*x^5 + x^4 
        + 471/23*x^3 + 645/23*x^2 - 31/23*x - 228/23= 0 
        AND x^3 + 22*x^2 -31 >=0 
        AND x^22 -234/567*x^20 -419*x^10+ 1948>0


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 64 0 66 999
body:
  % Subtype TCC generated (at line 7, column 23) for  3
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_fall_TCC1: OBLIGATION FORALL (x: real): x /= 0 OR 3 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 68 0 72 999
body:
  % Subtype TCC generated (at line 7, column 47) for  2
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_fall_TCC2: OBLIGATION
    FORALL (x: real):
      NOT x * x * x > 0 AND NOT x ^ 3 < 0 IMPLIES x /= 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 74 0 77 999
body:
  % Subtype TCC generated (at line 13, column 36) for  2
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_ex_TCC1: OBLIGATION
    FORALL (x: real): x ^ 3 = x IMPLIES x /= 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 79 0 81 999
body:
  % Subtype TCC generated (at line 19, column 30) for  2
      % expected type  {i: int | (x - 2) /= 0 OR i >= 0}
  example_1_TCC1: OBLIGATION FORALL (x: real): (x - 2) /= 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 83 0 86 999
body:
  % Subtype TCC generated (at line 19, column 47) for  2
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_1_TCC2: OBLIGATION
    FORALL (x: real): (x - 2) ^ 2 * (-x + 4) > 0 IMPLIES x /= 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 88 0 92 999
body:
  % Subtype TCC generated (at line 19, column 55) for  2
      % expected type  {i: int | (x - 3) /= 0 OR i >= 0}
  example_1_TCC3: OBLIGATION
    FORALL (x: real):
      (x - 2) ^ 2 * (-x + 4) > 0 IMPLIES (x - 3) /= 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 94 0 100 999
body:
  % Subtype TCC generated (at line 21, column 15) for  3
      % expected type  {i: int | NOT (x - 11/12) = 0 OR i >= 0}
  example_1_TCC4: OBLIGATION
    FORALL (x: real):
      (x - 2) ^ 2 * (-x + 4) > 0 AND
       x ^ 2 * (x - 3) ^ 2 >= 0 AND x - 1 >= 0 AND -(x - 3) ^ 2 + 1 > 0
       IMPLIES NOT (x - 11/12) = 0 OR 3 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 102 0 108 999
body:
  % Subtype TCC generated (at line 21, column 27) for  3
      % expected type  {i: int | NOT (x - 41/10) = 0 OR i >= 0}
  example_1_TCC5: OBLIGATION
    FORALL (x: real):
      (x - 2) ^ 2 * (-x + 4) > 0 AND
       x ^ 2 * (x - 3) ^ 2 >= 0 AND x - 1 >= 0 AND -(x - 3) ^ 2 + 1 > 0
       IMPLIES NOT (x - 41/10) = 0 OR 3 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 110 0 113 999
body:
  % Subtype TCC generated (at line 27, column 42) for  4
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_2_TCC1: OBLIGATION
    FORALL (x: real): x < 10 AND x >= -9 IMPLIES x /= 0 OR 4 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 115 0 119 999
body:
  % Subtype TCC generated (at line 27, column 56) for  12
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_2_TCC2: OBLIGATION
    FORALL (x: real):
      x >= -9 AND x < 10 AND x ^ 4 > 0 IMPLIES x /= 0 OR 12 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 121 0 123 999
body:
  % Subtype TCC generated (at line 42, column 8) for  5
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC1: OBLIGATION FORALL (x: real): x /= 0 OR 5 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 125 0 128 999
body:
  % Subtype TCC generated (at line 44, column 8) for  12
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC2: OBLIGATION
    FORALL (x: real): x ^ 5 - x - 1 = 0 IMPLIES x /= 0 OR 12 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 130 0 133 999
body:
  % Subtype TCC generated (at line 44, column 22) for  11
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC3: OBLIGATION
    FORALL (x: real): x ^ 5 - x - 1 = 0 IMPLIES x /= 0 OR 11 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 135 0 138 999
body:
  % Subtype TCC generated (at line 44, column 36) for  10
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC4: OBLIGATION
    FORALL (x: real): x ^ 5 - x - 1 = 0 IMPLIES x /= 0 OR 10 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 140 0 143 999
body:
  % Subtype TCC generated (at line 44, column 45) for  8
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC5: OBLIGATION
    FORALL (x: real): x ^ 5 - x - 1 = 0 IMPLIES x /= 0 OR 8 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 145 0 148 999
body:
  % Subtype TCC generated (at line 45, column 17) for  7
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC6: OBLIGATION
    FORALL (x: real): x ^ 5 - x - 1 = 0 IMPLIES x /= 0 OR 7 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 150 0 153 999
body:
  % Subtype TCC generated (at line 45, column 30) for  6
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC7: OBLIGATION
    FORALL (x: real): x ^ 5 - x - 1 = 0 IMPLIES x /= 0 OR 6 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 155 0 158 999
body:
  % Subtype TCC generated (at line 45, column 49) for  4
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC8: OBLIGATION
    FORALL (x: real): x ^ 5 - x - 1 = 0 IMPLIES x /= 0 OR 4 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 160 0 163 999
body:
  % Subtype TCC generated (at line 46, column 30) for  2
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC9: OBLIGATION
    FORALL (x: real): x ^ 5 - x - 1 = 0 IMPLIES x /= 0 OR 2 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 165 0 181 999
body:
  % Subtype TCC generated (at line 48, column 12) for  22
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC10: OBLIGATION
    FORALL (x: real):
      x ^ 3 + 22 * x ^ 2 - 31 >= 0 AND
       x ^ 12 + 425 / 23 * x ^ 11 - 228 / 23 * x ^ 10 - 2 * x ^ 8 -
        896 / 23 * x ^ 7
        - 394 / 23 * x ^ 6
        + 456 / 23 * x ^ 5
        + x ^ 4
        + 471 / 23 * x ^ 3
        + 645 / 23 * x ^ 2
        - 31 / 23 * x
        - 228 / 23
        = 0
        AND x ^ 5 - x - 1 = 0
       IMPLIES x /= 0 OR 22 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 183 0 199 999
body:
  % Subtype TCC generated (at line 48, column 26) for  20
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_4_TCC11: OBLIGATION
    FORALL (x: real):
      x ^ 3 + 22 * x ^ 2 - 31 >= 0 AND
       x ^ 12 + 425 / 23 * x ^ 11 - 228 / 23 * x ^ 10 - 2 * x ^ 8 -
        896 / 23 * x ^ 7
        - 394 / 23 * x ^ 6
        + 456 / 23 * x ^ 5
        + x ^ 4
        + 471 / 23 * x ^ 3
        + 645 / 23 * x ^ 2
        - 31 / 23 * x
        - 228 / 23
        = 0
        AND x ^ 5 - x - 1 = 0
       IMPLIES x /= 0 OR 20 >= 0;


decl_type: tcc
theory: examples
library: Tarski
signature: nil
location: 201 0 203 999
body:
  % Subtype TCC generated (at line 54, column 22) for  2
      % expected type  {i: int | x /= 0 OR i >= 0}
  example_5_TCC1: OBLIGATION FORALL (x: real): x /= 0 OR 2 >= 0;


decl_type: function
theory: operator_defs_more
library: algebra
signature: [set[T] -> [[[T, T] -> T] -> bool]]
location: 19 2 20 68
body:
    commutative_over?(S:set[T])(*) : bool
       = (FORALL x,y:   member(x,S) AND member(y,S) IMPLIES x*y = y*x)


decl_type: function
theory: operator_defs_more
library: algebra
signature: [set[T] -> [[[T, T] -> T] -> bool]]
location: 21 2 23 75
body:
    associative_over?(S:set[T])(*) : bool
       = (FORALL x,y,z: member(x,S) AND member(y,S) AND member(z,S) IMPLIES
                                                           (x*y)*z = x*(y*z))


decl_type: function
theory: groupoid_def
library: algebra
signature: [set[T] -> bool]
location: 23 2 25 56
body:
    finite_commutative_groupoid?(S): bool
                                    = finite_groupoid?(S) AND
                                      commutative?[(S)](*)


decl_type: tcc
theory: groupoid_def
library: algebra
signature: nil
location: 32 0 37 999
body:
  % Subtype TCC generated (at line 22, column 71) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  commutative_groupoid?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      star_closed?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: groupoid_def
library: algebra
signature: nil
location: 39 0 44 999
body:
  % Subtype TCC generated (at line 25, column 54) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  finite_commutative_groupoid?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      finite_groupoid?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: groupoid
library: algebra
signature: nil
location: 36 0 38 999
body:
  % Subtype TCC generated (at line 20, column 52) for  fullset[T]
      % expected type  groupoid
  groupoid_TCC1: OBLIGATION star_closed?[T, *](fullset[T]);


decl_type: function
theory: semigroup_def
library: algebra
signature: [set[T] -> bool]
location: 20 4 21 65
body:
      semigroup?(S): MACRO bool              = groupoid?(S) AND
                                               associative?[(S)](*)


decl_type: function
theory: semigroup_def
library: algebra
signature: [set[T] -> bool]
location: 23 4 24 65
body:
      commutative_semigroup?(S): bool        = semigroup?(S) AND
                                               commutative?[(S)](*)


decl_type: function
theory: semigroup_def
library: algebra
signature: [set[T] -> bool]
location: 25 4 26 65
body:
      finite_commutative_semigroup?(S): bool = finite_semigroup?(S) AND
                                               commutative?[(S)](*)


decl_type: tcc
theory: semigroup_def
library: algebra
signature: nil
location: 33 0 38 999
body:
  % Subtype TCC generated (at line 21, column 63) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  semigroup?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      star_closed?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: semigroup_def
library: algebra
signature: nil
location: 40 0 45 999
body:
  % Subtype TCC generated (at line 26, column 63) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  finite_commutative_semigroup?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      finite_semigroup?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: semigroup
library: algebra
signature: nil
location: 38 0 43 999
body:
  % Subtype TCC generated (at line 24, column 46) for  fullset[T]
      % expected type  semigroup
  semigroup_TCC1: OBLIGATION
    star_closed?[T, *](fullset[T]) AND
     associative?[(fullset[T])]
         (restrict[[T, T], [(fullset[T]), (fullset[T])], T](*));


decl_type: function
theory: monad_def
library: algebra
signature: [set[T] -> bool]
location: 20 2 22 61
body:
    monad?(S): bool                    = groupoid?(S) AND
                                         member(one,S) AND
                                         identity?[(S)](*)(one)


decl_type: function
theory: monad_def
library: algebra
signature: [set[T] -> bool]
location: 25 2 26 59
body:
    finite_commutative_monad?(S): bool = finite_monad?(S) AND
                                         commutative?[(S)](*)


decl_type: tcc
theory: monad_def
library: algebra
signature: nil
location: 33 0 36 999
body:
  % Subtype TCC generated (at line 22, column 57) for  one
      % expected type  (S)
  monad?_TCC1: OBLIGATION
    FORALL (S: set[T]): member(one, S) AND star_closed?(S) IMPLIES S(one);


decl_type: tcc
theory: monad_def
library: algebra
signature: nil
location: 38 0 44 999
body:
  % Subtype TCC generated (at line 22, column 54) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  monad?_TCC2: OBLIGATION
    FORALL (S: set[T]):
      member(one, S) AND star_closed?(S) IMPLIES
       (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: monad_def
library: algebra
signature: nil
location: 46 0 50 999
body:
  % Subtype TCC generated (at line 24, column 71) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  commutative_monad?_TCC1: OBLIGATION
    FORALL (S: set[T]): monad?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: monad_def
library: algebra
signature: nil
location: 52 0 57 999
body:
  % Subtype TCC generated (at line 26, column 57) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  finite_commutative_monad?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      finite_monad?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: judgement
theory: monad
library: algebra
signature: commutative_monad
location: 65 3 66 69
body:
     finite_commutative_monad_is_commutative_monad:
        JUDGEMENT finite_commutative_monad SUBTYPE_OF commutative_monad


decl_type: judgement
theory: monad
library: algebra
signature: finite_monad
location: 68 3 69 64
body:
     finite_commutative_monad_is_finite_monad:
        JUDGEMENT finite_commutative_monad SUBTYPE_OF finite_monad


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 76 0 78 999
body:
  % Subtype TCC generated (at line 24, column 38) for  fullset[T]
      % expected type  monad
  monad_TCC1: OBLIGATION monad?[T, *, one](fullset[T]);


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 80 0 82 999
body:
  % Subtype TCC generated (at line 38, column 26) for  singleton(one)
      % expected type  monad
  trivial_monad_TCC1: OBLIGATION monad?[T, *, one](singleton[T](one));


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 84 0 86 999
body:
  % Judgement subtype TCC generated (at line 40, column 32) for  x
      % expected type  groupoid[T, *]
  monad_is_groupoid: OBLIGATION FORALL (x: monad): star_closed?[T, *](x);


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 88 0 91 999
body:
  % Existence TCC generated (at line 51, column 3) for
      % finite_monad: TYPE+ = (finite_monad?)
  finite_monad_TCC1: OBLIGATION
    EXISTS (x: {x: set[T] | finite_monad?[T, *, one](x)}): TRUE;


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 93 0 96 999
body:
  % Existence TCC generated (at line 52, column 3) for
      % commutative_monad: TYPE+ = (commutative_monad?)
  commutative_monad_TCC1: OBLIGATION
    EXISTS (x: {x: set[T] | commutative_monad?[T, *, one](x)}): TRUE;


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 98 0 101 999
body:
  % Existence TCC generated (at line 53, column 3) for
      % finite_commutative_monad: TYPE+ = (finite_commutative_monad?)
  finite_commutative_monad_TCC1: OBLIGATION
    EXISTS (x: {x: set[T] | finite_commutative_monad?[T, *, one](x)}): TRUE;


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 103 0 105 999
body:
  % Subtype TCC generated (at line 57, column 27) for  F
      % expected type  S: finite_set[T]
  order_TCC1: OBLIGATION FORALL (F: finite_monad): is_finite[T](F);


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 107 0 109 999
body:
  % Subtype TCC generated (at line 57, column 22) for  card(F)
      % expected type  posnat
  order_TCC2: OBLIGATION FORALL (F: finite_monad): card[T](F) > 0;


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 111 0 114 999
body:
  % Judgement subtype TCC generated (at line 61, column 36) for  x
      % expected type  monad
  finite_monad_is_monad: OBLIGATION
    FORALL (x: finite_monad): monad?[T, *, one](x);


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 116 0 119 999
body:
  % Judgement subtype TCC generated (at line 63, column 44) for  x
      % expected type  monad
  commutative_monad_is_monad: OBLIGATION
    FORALL (x: commutative_monad): monad?[T, *, one](x);


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 121 0 124 999
body:
  % Judgement subtype TCC generated (at line 66, column 16) for  x
      % expected type  commutative_monad
  finite_commutative_monad_is_commutative_monad: OBLIGATION
    FORALL (x: finite_commutative_monad): commutative_monad?[T, *, one](x);


decl_type: tcc
theory: monad
library: algebra
signature: nil
location: 126 0 129 999
body:
  % Judgement subtype TCC generated (at line 69, column 16) for  x
      % expected type  finite_monad
  finite_commutative_monad_is_finite_monad: OBLIGATION
    FORALL (x: finite_commutative_monad): finite_monad?[T, *, one](x);


decl_type: function
theory: monoid_def
library: algebra
signature: [set[T] -> bool]
location: 32 3 33 61
body:
     finite_commutative_monoid?(S): bool = finite_monoid?(S) AND
                                           commutative?[(S)](*)


decl_type: tcc
theory: monoid_def
library: algebra
signature: nil
location: 43 0 45 999
body:
  % Subtype TCC generated (at line 22, column 59) for  n - 1
      % expected type  nat
  power_TCC1: OBLIGATION FORALL (n: nat): NOT n = 0 IMPLIES n - 1 >= 0;


decl_type: tcc
theory: monoid_def
library: algebra
signature: nil
location: 47 0 48 999
body:
  % Termination TCC generated (at line 22, column 51) for  power(a, n - 1)
  power_TCC2: OBLIGATION FORALL (n: nat): NOT n = 0 IMPLIES n - 1 < n;


decl_type: tcc
theory: monoid_def
library: algebra
signature: nil
location: 50 0 54 999
body:
  % Subtype TCC generated (at line 29, column 74) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  monoid?_TCC1: OBLIGATION
    FORALL (S: set[T]): monad?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: monoid_def
library: algebra
signature: nil
location: 56 0 61 999
body:
  % Subtype TCC generated (at line 31, column 74) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  commutative_monoid?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      monoid?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: monoid_def
library: algebra
signature: nil
location: 63 0 68 999
body:
  % Subtype TCC generated (at line 33, column 59) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  finite_commutative_monoid?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      finite_monoid?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: formula
theory: monoid
library: algebra
signature: nil
location: 52 3 53 78
body:
     generated_is_submonoid: LEMMA member(a,M) IMPLIES
                                                  submonoid?(generated_set(a),M)


decl_type: formula
theory: monoid
library: algebra
signature: nil
location: 56 3 60 74
body:
     generated_set_card_1: LEMMA member(a,M) AND 
                                 is_finite(generated_set(a)) AND
                                 card(generated_set(a)) = 1
                                   IMPLIES a = one AND
                                        generated_set(a) = singleton[T](one)


decl_type: judgement
theory: monoid
library: algebra
signature: finite_monad[T, *, one]
location: 67 3 68 73
body:
     finite_monoid_is_finite_monad:
                            JUDGEMENT finite_monoid SUBTYPE_OF finite_monad


decl_type: judgement
theory: monoid
library: algebra
signature: commutative_monad[T, *, one]
location: 75 3 76 75
body:
     commutative_monoid_is_commutative_monad:
                    JUDGEMENT commutative_monoid SUBTYPE_OF commutative_monad


decl_type: tcc
theory: monoid
library: algebra
signature: nil
location: 87 0 89 999
body:
  % Assuming TCC generated (at line 22, column 34) for  monad[T, *, one]
      % generated from assumption monad.fullset_is_monad
  IMP_monad_TCC1: OBLIGATION monad?[T, *, one](fullset[T]);


decl_type: tcc
theory: monoid
library: algebra
signature: nil
location: 91 0 96 999
body:
  % Assuming TCC generated (at line 22, column 50) for  semigroup[T, *]
      % generated from assumption semigroup.fullset_is_semigroup
  IMP_semigroup_TCC1: OBLIGATION
    star_closed?[T, *](fullset[T]) AND
     associative?[(fullset[T])]
         (restrict[[T, T], [(fullset[T]), (fullset[T])], T](*));


decl_type: tcc
theory: monoid
library: algebra
signature: nil
location: 98 0 100 999
body:
  % Subtype TCC generated (at line 24, column 40) for  fullset[T]
      % expected type  monoid
  monoid_TCC1: OBLIGATION monoid?[T, *, one](fullset[T]);


decl_type: tcc
theory: monoid
library: algebra
signature: nil
location: 102 0 104 999
body:
  % Judgement subtype TCC generated (at line 31, column 34) for  x
      % expected type  monad[T, *, one]
  monoid_is_monad: OBLIGATION FORALL (x: monoid): monad?[T, *, one](x);


decl_type: tcc
theory: monoid
library: algebra
signature: nil
location: 106 0 111 999
body:
  % Judgement subtype TCC generated (at line 32, column 34) for  x
      % expected type  semigroup[T, *]
  monoid_is_semigroup: OBLIGATION
    FORALL (x: monoid):
      star_closed?[T, *](x) AND
       associative?[(x)](restrict[[T, T], [(x), (x)], T](*));


decl_type: tcc
theory: monoid
library: algebra
signature: nil
location: 113 0 116 999
body:
  % Existence TCC generated (at line 62, column 3) for
      % finite_monoid: TYPE+ = (finite_monoid?)
  finite_monoid_TCC1: OBLIGATION
    EXISTS (x: {x: set[T] | finite_monoid?[T, *, one](x)}): TRUE;


decl_type: tcc
theory: monoid
library: algebra
signature: nil
location: 118 0 121 999
body:
  % Judgement subtype TCC generated (at line 66, column 38) for  x
      % expected type  monoid
  finite_monoid_is_monoid: OBLIGATION
    FORALL (x: finite_monoid): monoid?[T, *, one](x);


decl_type: tcc
theory: monoid
library: algebra
signature: nil
location: 123 0 126 999
body:
  % Judgement subtype TCC generated (at line 68, column 36) for  x
      % expected type  finite_monad[T, *, one]
  finite_monoid_is_finite_monad: OBLIGATION
    FORALL (x: finite_monoid): finite_monad?[T, *, one](x);


decl_type: tcc
theory: monoid
library: algebra
signature: nil
location: 128 0 131 999
body:
  % Existence TCC generated (at line 72, column 3) for
      % commutative_monoid: TYPE+ = (commutative_monoid?)
  commutative_monoid_TCC1: OBLIGATION
    EXISTS (x: {x: set[T] | commutative_monoid?[T, *, one](x)}): TRUE;


decl_type: tcc
theory: monoid
library: algebra
signature: nil
location: 133 0 136 999
body:
  % Judgement subtype TCC generated (at line 74, column 43) for  x
      % expected type  monoid
  commutative_monoid_is_monoid: OBLIGATION
    FORALL (x: commutative_monoid): monoid?[T, *, one](x);


decl_type: tcc
theory: monoid
library: algebra
signature: nil
location: 138 0 141 999
body:
  % Judgement subtype TCC generated (at line 76, column 28) for  x
      % expected type  commutative_monad[T, *, one]
  commutative_monoid_is_commutative_monad: OBLIGATION
    FORALL (x: commutative_monoid): commutative_monad?[T, *, one](x);


decl_type: formula
theory: group_def
library: algebra
signature: nil
location: 30 3 32 49
body:
     finite_group_surj: LEMMA group?(S) AND
                              (EXISTS (N: nat), (f: [below[N] -> (S)]): surjective?(f)) 
                           IMPLIES finite_group?(S)


decl_type: function
theory: group_def
library: algebra
signature: [set[T] -> bool]
location: 20 3 21 79
body:
     inv_exists?(S): bool
                        = FORALL (x:(S)): EXISTS (y:(S)): x*y = one AND y*x = one


decl_type: tcc
theory: group_def
library: algebra
signature: nil
location: 39 0 43 999
body:
  % Subtype TCC generated (at line 25, column 68) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  abelian_group?_TCC1: OBLIGATION
    FORALL (S: set[T]): group?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: group_def
library: algebra
signature: nil
location: 45 0 50 999
body:
  % Subtype TCC generated (at line 26, column 75) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  finite_abelian_group?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      finite_group?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: formula
theory: group
library: algebra
signature: nil
location: 64 3 65 79
body:
     finite_subgroups: LEMMA FORALL (S:set[T], H: finite_group): subgroup?(S,H) IMPLIES
                                                                 finite_group?(S)


decl_type: formula
theory: group
library: algebra
signature: nil
location: 125 3 126 75
body:
     subgroup_def: LEMMA subgroup?(S,G) IFF
       (nonempty?(S) AND subset?(S,G) AND star_closed?(S) AND inv_closed?(S))


decl_type: formula
theory: group
library: algebra
signature: nil
location: 163 3 164 74
body:
     generated_is_subgroup: LEMMA member(a,G) IMPLIES
                                                subgroup?(generated_by(a),G)


decl_type: formula
theory: group
library: algebra
signature: nil
location: 166 3 168 54
body:
     generated_by_is_finite: LEMMA S = generated_by(a) AND 
                                   (EXISTS (k: posnat): a^k = one)
                                IMPLIES finite_group?(S)


decl_type: judgement
theory: group
library: algebra
signature: finite_monoid[T, *, one]
location: 61 3 62 73
body:
     finite_group_is_finite_monoid:
                            JUDGEMENT finite_group SUBTYPE_OF finite_monoid


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 193 0 195 999
body:
  % Assuming TCC generated (at line 49, column 33) for  monoid[T, *, one]
      % generated from assumption monoid.fullset_is_monoid
  IMP_monoid_TCC1: OBLIGATION monoid?[T, *, one](fullset[T]);


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 197 0 199 999
body:
  % Subtype TCC generated (at line 51, column 38) for  fullset[T]
      % expected type  group
  group_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 201 0 203 999
body:
  % Judgement subtype TCC generated (at line 55, column 30) for  x
      % expected type  monoid[T, *, one]
  group_is_monoid: OBLIGATION FORALL (x: group): monoid?[T, *, one](x);


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 205 0 208 999
body:
  % Existence TCC generated (at line 58, column 3) for
      % finite_group: TYPE+ = (finite_group?)
  finite_group_TCC1: OBLIGATION
    EXISTS (x: {x: set[T] | finite_group?[T, *, one](x)}): TRUE;


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 210 0 213 999
body:
  % Judgement subtype TCC generated (at line 60, column 36) for  x
      % expected type  group
  finite_group_is_group: OBLIGATION
    FORALL (x: finite_group): group?[T, *, one](x);


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 215 0 218 999
body:
  % Judgement subtype TCC generated (at line 62, column 36) for  x
      % expected type  finite_monoid[T, *, one]
  finite_group_is_finite_monoid: OBLIGATION
    FORALL (x: finite_group): finite_monoid?[T, *, one](x);


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 220 0 222 999
body:
  % Subtype TCC generated (at line 72, column 29) for  singleton[T](one)
      % expected type  finite_group
  one_group_TCC1: OBLIGATION finite_group?[T, *, one](singleton[T](one));


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 224 0 226 999
body:
  % Subtype TCC generated (at line 74, column 57) for  G
      % expected type  S: finite_set[T]
  group_card_gt_0_TCC1: OBLIGATION FORALL (G: finite_group): is_finite[T](G);


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 228 0 231 999
body:
  % Existence TCC generated (at line 84, column 3) for
      % inv(x): {y | x * y = one AND y * x = one}
  inv_TCC1: OBLIGATION
    EXISTS (x1: [x: T -> {y | x * y = one AND y * x = one}]): TRUE;


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 233 0 235 999
body:
  % Subtype TCC generated (at line 135, column 42) for  -i
      % expected type  nat
  caret_TCC1: OBLIGATION FORALL (i: int): i < 0 IMPLIES -i >= 0;


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 237 0 239 999
body:
  % Subtype TCC generated (at line 135, column 59) for  i
      % expected type  nat
  caret_TCC2: OBLIGATION FORALL (i: int): NOT i < 0 IMPLIES i >= 0;


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 241 0 245 999
body:
  % Subtype TCC generated (at line 157, column 27) for
      % {t: T | EXISTS (i: int): t = a ^ i}
      % expected type  group
  generated_by_TCC1: OBLIGATION
    FORALL (a: T): group?[T, *, one]({t: T | EXISTS (i: int): t = a ^ i});


decl_type: tcc
theory: group
library: algebra
signature: nil
location: 247 0 255 999
body:
  % Subtype TCC generated (at line 173, column 43) for
      % extend[T, (G), bool, FALSE]({s: (G) | FORALL (x: (G)): x * s = s * x})
      % expected type  {s: set[T] | subset?(s, G)}
  center_TCC1: OBLIGATION
    FORALL (G: group):
      subset?[T]
          (extend[T, (G), bool, FALSE]
               ({s: (G) | FORALL (x: (G)): x * s = s * x}),
           G);


decl_type: formula
theory: abelian_group
library: algebra
signature: nil
location: 47 3 48 73
body:
     finite_abelian_subgroups:
                      LEMMA subgroup?(S,G) IMPLIES finite_abelian_group?(S)


decl_type: judgement
theory: abelian_group
library: algebra
signature: commutative_monoid[T, *, one]
location: 32 3 33 79
body:
     abelian_group_is_commutative_monoid:
                            JUDGEMENT abelian_group SUBTYPE_OF commutative_monoid


decl_type: judgement
theory: abelian_group
library: algebra
signature: abelian_group
location: 41 3 42 62
body:
     finite_abelian_group_is_abelian_group:
         JUDGEMENT finite_abelian_group SUBTYPE_OF abelian_group


decl_type: judgement
theory: abelian_group
library: algebra
signature: finite_group[T, *, one]
location: 44 3 45 61
body:
     finite_abelian_group_is_finite_group:
         JUDGEMENT finite_abelian_group SUBTYPE_OF finite_group


decl_type: tcc
theory: abelian_group
library: algebra
signature: nil
location: 57 0 59 999
body:
  % Assuming TCC generated (at line 23, column 13) for  group[T, *, one]
      % generated from assumption group.fullset_is_group
  IMP_group_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: tcc
theory: abelian_group
library: algebra
signature: nil
location: 61 0 63 999
body:
  % Subtype TCC generated (at line 25, column 62) for  fullset[T]
      % expected type  abelian_group
  abelian_group_TCC1: OBLIGATION abelian_group?[T, *, one](fullset[T]);


decl_type: tcc
theory: abelian_group
library: algebra
signature: nil
location: 65 0 68 999
body:
  % Judgement subtype TCC generated (at line 30, column 37) for  x
      % expected type  group[T, *, one]
  abelian_group_is_group: OBLIGATION
    FORALL (x: abelian_group): group?[T, *, one](x);


decl_type: tcc
theory: abelian_group
library: algebra
signature: nil
location: 70 0 73 999
body:
  % Judgement subtype TCC generated (at line 33, column 36) for  x
      % expected type  commutative_monoid[T, *, one]
  abelian_group_is_commutative_monoid: OBLIGATION
    FORALL (x: abelian_group): commutative_monoid?[T, *, one](x);


decl_type: tcc
theory: abelian_group
library: algebra
signature: nil
location: 75 0 78 999
body:
  % Existence TCC generated (at line 37, column 3) for
      % finite_abelian_group: TYPE+ = (finite_abelian_group?)
  finite_abelian_group_TCC1: OBLIGATION
    EXISTS (x: {x: set[T] | finite_abelian_group?[T, *, one](x)}): TRUE;


decl_type: tcc
theory: abelian_group
library: algebra
signature: nil
location: 80 0 83 999
body:
  % Judgement subtype TCC generated (at line 42, column 17) for  x
      % expected type  abelian_group
  finite_abelian_group_is_abelian_group: OBLIGATION
    FORALL (x: finite_abelian_group): abelian_group?[T, *, one](x);


decl_type: tcc
theory: abelian_group
library: algebra
signature: nil
location: 85 0 88 999
body:
  % Judgement subtype TCC generated (at line 45, column 17) for  x
      % expected type  finite_group[T, *, one]
  finite_abelian_group_is_finite_group: OBLIGATION
    FORALL (x: finite_abelian_group): finite_group?[T, *, one](x);


decl_type: function
theory: ring_def
library: algebra
signature: [set[T] -> bool]
location: 20 2 23 48
body:
    ring?(S): bool = abelian_group?[T,+,zero](S)  AND
                     semigroup?[T,*](S)           AND
                     left_distributive?[(S)](*,+) AND
                     right_distributive?[(S)](*,+)


decl_type: tcc
theory: ring_def
library: algebra
signature: nil
location: 36 0 44 999
body:
  % Subtype TCC generated (at line 22, column 43) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  ring?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      star_closed?(S) AND
       associative?[(S)](restrict[[T, T], [(S), (S)], T](*)) AND
        abelian_group?[T, +, zero](S)
       IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: ring_def
library: algebra
signature: nil
location: 46 0 54 999
body:
  % Subtype TCC generated (at line 22, column 45) for
      % restrict[[T, T], [(S), (S)], T](+)
      % expected type  [[(S), (S)] -> (S)]
  ring?_TCC2: OBLIGATION
    FORALL (S: set[T]):
      star_closed?(S) AND
       associative?[(S)](restrict[[T, T], [(S), (S)], T](*)) AND
        abelian_group?[T, +, zero](S)
       IMPLIES (FORALL (x1: [(S), (S)]): S(+x1));


decl_type: tcc
theory: ring_def
library: algebra
signature: nil
location: 56 0 60 999
body:
  % Subtype TCC generated (at line 26, column 70) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  commutative_ring?_TCC1: OBLIGATION
    FORALL (S: set[T]): ring?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: ring_def
library: algebra
signature: nil
location: 62 0 67 999
body:
  % Subtype TCC generated (at line 27, column 77) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  finite_commutative_ring?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      finite_ring?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: type
theory: ring
library: algebra
signature: nil
location: 25 3 28 1
body:
     ring: NONEMPTY_TYPE = (ring?) CONTAINING fullset[T]

  % To bring elegance into this theory we define unary and binary minus.
  ;


decl_type: tcc
theory: ring
library: algebra
signature: nil
location: 90 0 93 999
body:
  % Assuming TCC generated (at line 22, column 13) for
      % abelian_group[T, +, zero]
      % generated from assumption abelian_group.fullset_is_abelian_group
  IMP_abelian_group_TCC1: OBLIGATION abelian_group?[T, +, zero](fullset[T]);


decl_type: tcc
theory: ring
library: algebra
signature: nil
location: 95 0 97 999
body:
  % Subtype TCC generated (at line 25, column 44) for  fullset[T]
      % expected type  ring
  ring_TCC1: OBLIGATION ring?[T, +, *, zero](fullset[T]);


decl_type: tcc
theory: ring
library: algebra
signature: nil
location: 99 0 102 999
body:
  % Judgement subtype TCC generated (at line 61, column 38) for  x
      % expected type  abelian_group[T, +, zero]
  ring_is_abelian_group: OBLIGATION
    FORALL (x: ring): abelian_group?[T, +, zero](x);


decl_type: tcc
theory: commutative_ring
library: algebra
signature: nil
location: 43 0 45 999
body:
  % Assuming TCC generated (at line 22, column 35) for  ring[T, +, *, zero]
      % generated from assumption ring.fullset_is_ring
  IMP_ring_TCC1: OBLIGATION ring?[T, +, *, zero](fullset[T]);


decl_type: tcc
theory: commutative_ring
library: algebra
signature: nil
location: 47 0 50 999
body:
  % Subtype TCC generated (at line 24, column 68) for  fullset[T]
      % expected type  commutative_ring
  commutative_ring_TCC1: OBLIGATION
    commutative_ring?[T, +, *, zero](fullset[T]);


decl_type: tcc
theory: commutative_ring
library: algebra
signature: nil
location: 52 0 55 999
body:
  % Judgement subtype TCC generated (at line 32, column 39) for  x
      % expected type  ring[T, +, *, zero]
  commutative_ring_is_ring: OBLIGATION
    FORALL (x: commutative_ring): ring?[T, +, *, zero](x);


decl_type: judgement
theory: integral_domain
library: algebra
signature: commutative_ring[T, +, *, zero]
location: 32 3 33 75
body:
     integral_domain_is_ring: JUDGEMENT integral_domain SUBTYPE_OF 
                                                             commutative_ring


decl_type: tcc
theory: integral_domain
library: algebra
signature: nil
location: 40 0 44 999
body:
  % Assuming TCC generated (at line 24, column 13) for
      % commutative_ring[T, +, *, zero]
      % generated from assumption commutative_ring.fullset_is_commutative_ring
  IMP_commutative_ring_TCC1: OBLIGATION
    commutative_ring?[T, +, *, zero](fullset[T]);


decl_type: tcc
theory: integral_domain
library: algebra
signature: nil
location: 46 0 49 999
body:
  % Subtype TCC generated (at line 26, column 66) for  fullset[T]
      % expected type  integral_domain
  integral_domain_TCC1: OBLIGATION
    integral_domain?[T, +, *, zero](fullset[T]);


decl_type: tcc
theory: integral_domain
library: algebra
signature: nil
location: 51 0 54 999
body:
  % Judgement subtype TCC generated (at line 32, column 38) for  x
      % expected type  commutative_ring[T, +, *, zero]
  integral_domain_is_ring: OBLIGATION
    FORALL (x: integral_domain): commutative_ring?[T, +, *, zero](x);


decl_type: tcc
theory: ring_nz_closed
library: algebra
signature: nil
location: 55 0 57 999
body:
  % Assuming TCC generated (at line 29, column 13) for  ring[T, +, *, zero]
      % generated from assumption ring.fullset_is_ring
  IMP_ring_TCC1: OBLIGATION ring?[T, +, *, zero](fullset[T]);


decl_type: tcc
theory: ring_nz_closed
library: algebra
signature: nil
location: 59 0 61 999
body:
  % Subtype TCC generated (at line 31, column 56) for  fullset[T]
      % expected type  ring_nz_closed
  ring_nz_closed_TCC1: OBLIGATION ring_nz_closed?[T, +, *, zero](fullset[T]);


decl_type: tcc
theory: ring_nz_closed
library: algebra
signature: nil
location: 63 0 66 999
body:
  % Judgement subtype TCC generated (at line 38, column 42) for  x
      % expected type  ring[T, +, *, zero]
  ring_nz_closed_is_ring: OBLIGATION
    FORALL (x: ring_nz_closed): ring?[T, +, *, zero](x);


decl_type: tcc
theory: ring_nz_closed
library: algebra
signature: nil
location: 68 0 70 999
body:
  % Judgement subtype TCC generated (at line 40, column 42) for  nzx * nzy
      % expected type  nz_T[T, +, *, zero]
  nz_T_times_nz_T_is_nz_T: OBLIGATION FORALL (nzx, nzy): nzx * nzy /= zero;


decl_type: tcc
theory: ring_nz_closed
library: algebra
signature: nil
location: 72 0 74 999
body:
  % Judgement subtype TCC generated (at line 41, column 42) for  inv(nzx)
      % expected type  nz_T[T, +, *, zero]
  negate_nz_T_is_nz_T: OBLIGATION FORALL (nzx): inv[T, +, zero](nzx) /= zero;


decl_type: tcc
theory: ring_nz_closed
library: algebra
signature: nil
location: 76 0 78 999
body:
  % Judgement subtype TCC generated (at line 47, column 27) for  sq(nzx)
      % expected type  nz_T[T, +, *, zero]
  sq_nz_is_nz: OBLIGATION FORALL (nzx): sq[T, +, *, zero](nzx) /= zero;


decl_type: function
theory: ring_with_one_def
library: algebra
signature: [set[T] -> bool]
location: 22 3 23 61
body:
     commutative_ring_with_one?(S): bool = ring_with_one?(S) AND
                                           commutative?[(S)](*)


decl_type: function
theory: ring_with_one_def
library: algebra
signature: [set[T] -> bool]
location: 24 3 25 68
body:
     finite_commutative_ring_with_one?(S): bool = finite_ring_with_one?(S) AND
                                                  commutative?[(S)](*)


decl_type: tcc
theory: ring_with_one_def
library: algebra
signature: nil
location: 32 0 37 999
body:
  % Subtype TCC generated (at line 23, column 59) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  commutative_ring_with_one?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      ring_with_one?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: ring_with_one_def
library: algebra
signature: nil
location: 39 0 44 999
body:
  % Subtype TCC generated (at line 25, column 66) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  finite_commutative_ring_with_one?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      finite_ring_with_one?(S) IMPLIES (FORALL (x1: [(S), (S)]): S(*(x1)));


decl_type: tcc
theory: ring_with_one
library: algebra
signature: nil
location: 56 0 58 999
body:
  % Assuming TCC generated (at line 24, column 13) for  ring[T, +, *, zero]
      % generated from assumption ring.fullset_is_ring
  IMP_ring_TCC1: OBLIGATION ring?[T, +, *, zero](fullset[T]);


decl_type: tcc
theory: ring_with_one
library: algebra
signature: nil
location: 60 0 62 999
body:
  % Assuming TCC generated (at line 24, column 31) for  monoid[T, *, one]
      % generated from assumption monoid.fullset_is_monoid
  IMP_monoid_TCC1: OBLIGATION monoid?[T, *, one](fullset[T]);


decl_type: tcc
theory: ring_with_one
library: algebra
signature: nil
location: 64 0 67 999
body:
  % Subtype TCC generated (at line 26, column 62) for  fullset[T]
      % expected type  ring_with_one
  ring_with_one_TCC1: OBLIGATION
    ring_with_one?[T, +, *, zero, one](fullset[T]);


decl_type: tcc
theory: ring_with_one
library: algebra
signature: nil
location: 69 0 72 999
body:
  % Judgement subtype TCC generated (at line 40, column 38) for  x
      % expected type  ring[T, +, *, zero]
  ring_with_one_is_ring: OBLIGATION
    FORALL (x: ring_with_one): ring?[T, +, *, zero](x);


decl_type: tcc
theory: ring_with_one
library: algebra
signature: nil
location: 74 0 77 999
body:
  % Judgement subtype TCC generated (at line 41, column 38) for  x
      % expected type  monoid[T, *, one]
  ring_with_one_is_monoid: OBLIGATION
    FORALL (x: ring_with_one): monoid?[T, *, one](x);


decl_type: function
theory: division_ring_def
library: algebra
signature: [set[T] -> bool]
location: 18 3 19 66
body:
     division_ring?(S:set[T]):bool = ring_with_one?(S) AND
                                     group?[T,*,one](remove(zero,S))


decl_type: type
theory: division_ring
library: algebra
signature: nil
location: 28 3 32 1
body:
     division_ring: NONEMPTY_TYPE = (division_ring?) CONTAINING fullset[T]

  % To bring elegance into this theory we define unary and binary minus and
  % divide.
  ;


decl_type: judgement
theory: division_ring
library: algebra
signature: ring_with_one[T, +, *, zero, one]
location: 42 3 43 76
body:
     division_ring_is_ring_with_one:
                              JUDGEMENT division_ring SUBTYPE_OF ring_with_one


decl_type: judgement
theory: division_ring
library: algebra
signature: ring_nz_closed[T, +, *, zero]
location: 45 3 46 77
body:
     division_ring_is_ring_nz_closed:
                              JUDGEMENT division_ring SUBTYPE_OF ring_nz_closed


decl_type: tcc
theory: division_ring
library: algebra
signature: nil
location: 78 0 82 999
body:
  % Assuming TCC generated (at line 25, column 13) for
      % ring_with_one[T, +, *, zero, one]
      % generated from assumption ring_with_one.fullset_is_ring_with_one
  IMP_ring_with_one_TCC1: OBLIGATION
    ring_with_one?[T, +, *, zero, one](fullset[T]);


decl_type: tcc
theory: division_ring
library: algebra
signature: nil
location: 84 0 88 999
body:
  % Assuming TCC generated (at line 25, column 44) for
      % ring_nz_closed[T, +, *, zero]
      % generated from assumption ring_nz_closed.fullset_is_ring_nz_closed
  IMP_ring_nz_closed_TCC1: OBLIGATION
    ring_nz_closed?[T, +, *, zero](fullset[T]);


decl_type: tcc
theory: division_ring
library: algebra
signature: nil
location: 90 0 95 999
body:
  % Subtype TCC generated (at line 26, column 24) for
      % restrict[[T, T], [nz_T[T, +, *, zero], nz_T[T, +, *, zero]], T](*)
      % expected type  [[nz_T[T, +, *, zero], nz_T[T, +, *, zero]] ->
                     %    nz_T[T, +, *, zero]]
  IMP_group_TCC1: OBLIGATION
    FORALL (x1: [nz_T[T, +, *, zero], nz_T[T, +, *, zero]]): *(x1) /= zero;


decl_type: tcc
theory: division_ring
library: algebra
signature: nil
location: 97 0 99 999
body:
  % Subtype TCC generated (at line 26, column 26) for  one
      % expected type  nz_T[T, +, *, zero]
  IMP_group_TCC2: OBLIGATION one /= zero;


decl_type: tcc
theory: division_ring
library: algebra
signature: nil
location: 101 0 113 999
body:
  % Assuming TCC generated (at line 26, column 13) for
      % group
      %     [nz_T,
      %      restrict[[T, T], [nz_T[T, +, *, zero], nz_T[T, +, *, zero]], T]
      %          (*),
      %      one]
      % generated from assumption group.fullset_is_group
  IMP_group_TCC3: OBLIGATION
    group?
        [nz_T,
         restrict[[T, T], [nz_T[T, +, *, zero], nz_T[T, +, *, zero]], T](*),
         one]
        (fullset[nz_T[T, +, *, zero]]);


decl_type: tcc
theory: division_ring
library: algebra
signature: nil
location: 115 0 121 999
body:
  % Existence TCC generated (at line 26, column 13) for
      % group
      %     [nz_T,
      %      restrict[[T, T], [nz_T[T, +, *, zero], nz_T[T, +, *, zero]], T]
      %          (*),
      %      one]
  IMP_group_TCC4: OBLIGATION EXISTS (x: nz_T[T, +, *, zero]): TRUE;


decl_type: tcc
theory: division_ring
library: algebra
signature: nil
location: 123 0 126 999
body:
  % Subtype TCC generated (at line 28, column 62) for  fullset[T]
      % expected type  division_ring
  division_ring_TCC1: OBLIGATION
    division_ring?[T, +, *, zero, one](fullset[T]);


decl_type: tcc
theory: division_ring
library: algebra
signature: nil
location: 128 0 131 999
body:
  % Judgement subtype TCC generated (at line 43, column 38) for  x
      % expected type  ring_with_one[T, +, *, zero, one]
  division_ring_is_ring_with_one: OBLIGATION
    FORALL (x: division_ring): ring_with_one?[T, +, *, zero, one](x);


decl_type: tcc
theory: division_ring
library: algebra
signature: nil
location: 133 0 136 999
body:
  % Judgement subtype TCC generated (at line 46, column 38) for  x
      % expected type  ring_nz_closed[T, +, *, zero]
  division_ring_is_ring_nz_closed: OBLIGATION
    FORALL (x: division_ring): ring_nz_closed?[T, +, *, zero](x);


decl_type: tcc
theory: division_ring
library: algebra
signature: nil
location: 138 0 156 999
body:
  % Judgement subtype TCC generated (at line 34, column 55) for
      % n0x *
      %  inv
      %      [nz_T,
      %       restrict[[T, T], [nz_T[T, +, *, zero], nz_T[T, +, *, zero]], T]
      %           (*),
      %       one]
      %      (n0y)
      % expected type  nz_T[T, +, *, zero]
  nz_T_div_nz_T_is_nz_T: OBLIGATION
    FORALL (n0x, n0y):
      n0x *
       inv
           [nz_T[T, +, *, zero],
            restrict[[T, T], [nz_T[T, +, *, zero], nz_T[T, +, *, zero]], T]
                (*),
            one]
           (n0y)
       /= zero;


decl_type: tcc
theory: division_ring
library: algebra
signature: nil
location: 158 0 161 999
body:
  % Subtype TCC generated (at line 67, column 60) for  (n0z * n0y)
      % expected type  x: nz_T[T, +, *, zero]
  div_div2_TCC1: OBLIGATION
    FORALL (n0y, n0z: nz_T[T, +, *, zero]): (n0z * n0y) /= zero;


decl_type: tcc
theory: field_def
library: algebra
signature: nil
location: 27 0 32 999
body:
  % Subtype TCC generated (at line 18, column 68) for
      % restrict[[T, T], [(S), (S)], T](*)
      % expected type  [[(S), (S)] -> (S)]
  field?_TCC1: OBLIGATION
    FORALL (S: set[T]):
      division_ring?(S) IMPLIES (FORALL (x1: [(S), (S)]): (S)(*(x1)));


decl_type: formula
theory: field
library: algebra
signature: nil
location: 42 3 43 79
body:
     field_is_abelian_group:
                           LEMMA abelian_group?[nz_T,nz_star,one](remove(zero,F))


decl_type: function
theory: field
library: algebra
signature:
  [[nz_T[T, +, *, zero], nz_T[T, +, *, zero]] ->
  nz_T[T, +, *, zero]]

location: 32 3 33 79
body:
     nz_star:[nz_T,nz_T->nz_T]
                       = restrict[[T,T],[nz_T[T,+,*,zero],nz_T[T,+,*,zero]],T](*)


decl_type: tcc
theory: field
library: algebra
signature: nil
location: 59 0 63 999
body:
  % Assuming TCC generated (at line 27, column 13) for
      % division_ring[T, +, *, zero, one]
      % generated from assumption division_ring.fullset_is_division_ring
  IMP_division_ring_TCC1: OBLIGATION
    division_ring?[T, +, *, zero, one](fullset[T]);


decl_type: tcc
theory: field
library: algebra
signature: nil
location: 65 0 69 999
body:
  % Assuming TCC generated (at line 28, column 13) for
      % integral_domain[T, +, *, zero]
      % generated from assumption integral_domain.fullset_is_integral_domain
  IMP_integral_domain_TCC1: OBLIGATION
    integral_domain?[T, +, *, zero](fullset[T]);


decl_type: tcc
theory: field
library: algebra
signature: nil
location: 71 0 73 999
body:
  % Subtype TCC generated (at line 30, column 46) for  fullset[T]
      % expected type  field
  field_TCC1: OBLIGATION field?[T, +, *, zero, one](fullset[T]);


decl_type: tcc
theory: field
library: algebra
signature: nil
location: 75 0 82 999
body:
  % Subtype TCC generated (at line 33, column 23) for
      % restrict[[T, T], [nz_T[T, +, *, zero], nz_T[T, +, *, zero]], T](*)
      % expected type  [[nz_T[T, +, *, zero], nz_T[T, +, *, zero]] ->
                     %    nz_T[T, +, *, zero]]
  nz_star_TCC1: OBLIGATION
    FORALL (x1: [nz_T[T, +, *, zero], nz_T[T, +, *, zero]]):
      restrict[[T, T], [nz_T[T, +, *, zero], nz_T[T, +, *, zero]], T](*)(x1)
       /= zero;


decl_type: tcc
theory: field
library: algebra
signature: nil
location: 84 0 87 999
body:
  % Judgement subtype TCC generated (at line 40, column 39) for  x
      % expected type  division_ring[T, +, *, zero, one]
  field_is_division_ring: OBLIGATION
    FORALL (x: field): division_ring?[T, +, *, zero, one](x);


decl_type: tcc
theory: field
library: algebra
signature: nil
location: 89 0 92 999
body:
  % Judgement subtype TCC generated (at line 41, column 39) for  x
      % expected type  integral_domain[T, +, *, zero]
  field_is_integral_domain: OBLIGATION
    FORALL (x: field): integral_domain?[T, +, *, zero](x);


decl_type: tcc
theory: field
library: algebra
signature: nil
location: 94 0 96 999
body:
  % Subtype TCC generated (at line 43, column 59) for  one
      % expected type  nz_T[T, +, *, zero]
  field_is_abelian_group_TCC1: OBLIGATION one /= zero;


decl_type: tcc
theory: field
library: algebra
signature: nil
location: 98 0 101 999
body:
  % Existence TCC generated (at line 43, column 31) for
      % abelian_group?[nz_T, nz_star, one]
  field_is_abelian_group_TCC2: OBLIGATION
    EXISTS (x: nz_T[T, +, *, zero]): TRUE;


decl_type: tcc
theory: field
library: algebra
signature: nil
location: 103 0 108 999
body:
  % Subtype TCC generated (at line 26, column 24) for
      % restrict[[T, T], [nz_T[T, +, *, zero], nz_T[T, +, *, zero]], T](*)
      % expected type  [[nz_T[T, +, *, zero], nz_T[T, +, *, zero]] ->
                     %    nz_T[T, +, *, zero]]
  mult_div_TCC1: OBLIGATION
    FORALL (x1: [nz_T[T, +, *, zero], nz_T[T, +, *, zero]]): *(x1) /= zero;


decl_type: tcc
theory: field
library: algebra
signature: nil
location: 110 0 113 999
body:
  % Subtype TCC generated (at line 47, column 53) for  (n0x * n0y)
      % expected type  x: nz_T[T, +, *, zero]
  div_times_TCC1: OBLIGATION
    FORALL (n0x, n0y: nz_T[T, +, *, zero]): (n0x * n0y) /= zero;


decl_type: type
theory: commutative_ring_with_one
library: algebra
signature: nil
location: 26 3 27 79
body:
     commutative_ring_with_one: TYPE+ = (commutative_ring_with_one?)
                                                            CONTAINING fullset[T]


decl_type: judgement
theory: commutative_ring_with_one
library: algebra
signature: commutative_ring[T, +, *, zero]
location: 33 3 34 74
body:
     commutative_ring_with_one_is_commutative_ring: JUDGEMENT
                       commutative_ring_with_one SUBTYPE_OF commutative_ring


decl_type: judgement
theory: commutative_ring_with_one
library: algebra
signature: ring_with_one[T, +, *, zero, one]
location: 36 3 37 71
body:
     commutative_ring_with_one_is_ring_with_one: JUDGEMENT
                       commutative_ring_with_one SUBTYPE_OF ring_with_one


decl_type: judgement
theory: commutative_ring_with_one
library: algebra
signature: commutative_monoid[T, *, one]
location: 39 3 40 79
body:
     commutative_ring_with_one_is_commutative_monoid: JUDGEMENT
                 commutative_ring_with_one SUBTYPE_OF commutative_monoid[T,*,one]


decl_type: tcc
theory: commutative_ring_with_one
library: algebra
signature: nil
location: 47 0 51 999
body:
  % Assuming TCC generated (at line 23, column 36) for
      % ring_with_one[T, +, *, zero, one]
      % generated from assumption ring_with_one.fullset_is_ring_with_one
  IMP_ring_with_one_TCC1: OBLIGATION
    ring_with_one?[T, +, *, zero, one](fullset[T]);


decl_type: tcc
theory: commutative_ring_with_one
library: algebra
signature: nil
location: 59 0 62 999
body:
  % Subtype TCC generated (at line 27, column 69) for  fullset[T]
      % expected type  commutative_ring_with_one
  commutative_ring_with_one_TCC1: OBLIGATION
    commutative_ring_with_one?[T, +, *, zero, one](fullset[T]);


decl_type: tcc
theory: commutative_ring_with_one
library: algebra
signature: nil
location: 64 0 68 999
body:
  % Judgement subtype TCC generated (at line 34, column 21) for  x
      % expected type  commutative_ring[T, +, *, zero]
  commutative_ring_with_one_is_commutative_ring: OBLIGATION
    FORALL (x: commutative_ring_with_one):
      commutative_ring?[T, +, *, zero](x);


decl_type: tcc
theory: commutative_ring_with_one
library: algebra
signature: nil
location: 70 0 74 999
body:
  % Judgement subtype TCC generated (at line 37, column 21) for  x
      % expected type  ring_with_one[T, +, *, zero, one]
  commutative_ring_with_one_is_ring_with_one: OBLIGATION
    FORALL (x: commutative_ring_with_one):
      ring_with_one?[T, +, *, zero, one](x);


decl_type: tcc
theory: commutative_ring_with_one
library: algebra
signature: nil
location: 76 0 79 999
body:
  % Judgement subtype TCC generated (at line 40, column 15) for  x
      % expected type  commutative_monoid[T, *, one]
  commutative_ring_with_one_is_commutative_monoid: OBLIGATION
    FORALL (x: commutative_ring_with_one): commutative_monoid?[T, *, one](x);


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 42 3 48 4
body:
     congruence_is_equivalence: LEMMA 
          subgroup?(H,G) IMPLIES equivalence?[T](congruent_mod(G,H))


  % ---------- Special Coset Notation ------------

     ;


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 78 3 79 78
body:
     right_coset_image: LEMMA subgroup?(H,G) AND member(a,G) IMPLIES
                          right_coset(G,H)(a) = image((LAMBDA (h:(H)): h*a),(H))


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 81 3 82 78
body:
     right_coset_is: LEMMA subgroup?(H,G) AND member(a,G) IMPLIES
                          right_coset(G,H)(a) = {x: T | congruent_mod(G,H)(a,x)}


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 84 3 85 49
body:
     right_coset_def   : LEMMA subgroup?(H,G) AND member(a,G) IMPLIES
                          right_coset(G,H)(a) = H*a


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 89 3 90 79
body:
     nonempty_right_coset: LEMMA  subgroup?(H,G) AND member(a,G) IMPLIES
                                                   nonempty?(right_coset(G,H)(a))


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 92 3 95 43
body:
     right_coset_correspondence: LEMMA FORALL (A,B:set[T]):
       subgroup?(H,G) AND member(a,G) AND member(b,G) AND
           A = right_coset(G,H)(a) AND B = right_coset(G,H)(b) IMPLIES
         EXISTS (f:[(A)->(B)]): bijective?(f)


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 104 3 105 77
body:
     left_coset_image  : LEMMA subgroup?(H,G) AND member(a,G) IMPLIES
                          left_coset(G,H)(a) = image((LAMBDA (h:(H)): a*h),(H))


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 107 3 108 48
body:
     left_coset_def    : LEMMA subgroup?(H,G) AND member(a,G) IMPLIES
                          left_coset(G,H)(a) = a*H


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 125 3 126 48
body:
     lc_gen_def: LEMMA subgroup?(H,G) AND G(a) IMPLIES
                           lc_gen(G,H,a*H)*H = a*H


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 133 3 134 48
body:
     rc_gen_def: LEMMA subgroup?(H,G) AND G(a) IMPLIES
                           H*rc_gen(G,H,H*a) = H*a


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 138 3 139 55
body:
     lc_eq     : LEMMA subgroup?(H,G) AND a*H = b*H
                       IMPLIES (EXISTS (h: (H)): a = b*h) 


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 142 3 143 41
body:
     lc_is_eq  : LEMMA subgroup?(H,G) AND (EXISTS (h: (H)): a = b*h) 
                          IMPLIES a*H = b*H


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 147 3 148 55
body:
     rc_eq     : LEMMA subgroup?(H,G) AND H*a = H*b
                       IMPLIES (EXISTS (h: (H)): a = h*b) 


decl_type: formula
theory: cosets
library: algebra
signature: nil
location: 151 3 152 41
body:
     rc_is_eq  : LEMMA subgroup?(H,G) AND (EXISTS (h: (H)): a = h*b) 
                          IMPLIES H*a = H*b


decl_type: type
theory: cosets
library: algebra
signature: nil
location: 113 3 114 47
body:
     left_cosets(G:group,H:subgroup(G)): TYPE = {s: set[T] |
                        EXISTS (a: (G)): s = a*H}


decl_type: type
theory: cosets
library: algebra
signature: nil
location: 117 3 118 47
body:
     right_cosets(G:group,H:subgroup(G)): TYPE = {s: set[T] |
                        EXISTS (a: (G)): s = H*a}


decl_type: function
theory: cosets
library: algebra
signature: [[G: group, subgroup[T, *, one](G)] -> [[T, T] -> bool]]
location: 40 3 41 75
body:
     congruent_mod(G:group,H:subgroup(G))(a,b:T):bool
                                                         = member(a*inv(b),H)


decl_type: function
theory: cosets
library: algebra
signature:
  [d: [G: group, subgroup[T, *, one](G)] ->
  [(d`1) -> {s: set[T] | subset?(s, d`1)}]]

location: 72 3 74 29
body:
     right_coset(G:group,H:subgroup(G))(a:(G)): { s: set[T] | subset?(s,G)}  
                                                             %% was set[(G)]
                          = H*a


decl_type: function
theory: cosets
library: algebra
signature:
  [d: [G: group, subgroup[T, *, one](G)] ->
  [(d`1) -> {s: set[T] | subset?(s, d`1)}]]

location: 99 3 101 29
body:
     left_coset(G:group,H:subgroup(G))(a:(G)): { s: set[T] | subset?(s,G)}   
                                                            %% was set[(G)]
                          = a*H


decl_type: function
theory: cosets
library: algebra
location: 122 3 123 50
signature:
  [d: [G: group, H: subgroup[T, *, one](G), left_cosets(G, H)] ->
          {a: T | d`1(a) AND d`3 = a * d`2}]

body:
     lc_gen(G:group, H: subgroup(G),lc: left_cosets(G,H)): {a: T | G(a) AND lc = a*H} =
                  choose({a: T | G(a) AND lc = a*H})


decl_type: function
theory: cosets
library: algebra
location: 130 3 131 50
signature:
  [d: [G: group, H: subgroup[T, *, one](G), right_cosets(G, H)] ->
          {a: T | d`1(a) AND d`3 = d`2 * a}]

body:
     rc_gen(G:group, H: subgroup(G), rc: right_cosets(G,H)): {a: T | G(a) AND rc = H*a} =
                  choose({a: T | G(a) AND rc = H*a})


decl_type: tcc
theory: cosets
library: algebra
signature: nil
location: 160 0 162 999
body:
  % Assuming TCC generated (at line 30, column 13) for  group[T, *, one]
      % generated from assumption group.fullset_is_group
  IMP_group_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: tcc
theory: cosets
library: algebra
signature: nil
location: 164 0 168 999
body:
  % Subtype TCC generated (at line 74, column 26) for  H * a
      % expected type  {s: set[T] | subset?(s, G)}
  right_coset_TCC1: OBLIGATION
    FORALL (G: group[T, *, one], H: subgroup[T, *, one](G), a: (G)):
      subset?[T](H * a, G);


decl_type: tcc
theory: cosets
library: algebra
signature: nil
location: 170 0 174 999
body:
  % Subtype TCC generated (at line 79, column 41) for  a
      % expected type  (G)
  right_coset_image_TCC1: OBLIGATION
    FORALL (G, H: group[T, *, one], a: T):
      member(a, G) AND subgroup?(H, G) IMPLIES G(a);


decl_type: tcc
theory: cosets
library: algebra
signature: nil
location: 176 0 182 999
body:
  % Subtype TCC generated (at line 94, column 58) for  b
      % expected type  (G)
  right_coset_correspondence_TCC1: OBLIGATION
    FORALL (G, H: group[T, *, one], a, b: T, A: set[T]):
      A = right_coset(G, H)(a) AND
       member(b, G) AND member(a, G) AND subgroup?(H, G)
       IMPLIES G(b);


decl_type: tcc
theory: cosets
library: algebra
signature: nil
location: 184 0 188 999
body:
  % Subtype TCC generated (at line 101, column 26) for  a * H
      % expected type  {s: set[T] | subset?(s, G)}
  left_coset_TCC1: OBLIGATION
    FORALL (G: group[T, *, one], H: subgroup[T, *, one](G), a: (G)):
      subset?[T](a * H, G);


decl_type: tcc
theory: cosets
library: algebra
signature: nil
location: 190 0 196 999
body:
  % Subtype TCC generated (at line 123, column 23) for
      % {a: T | G(a) AND lc = a * H}
      % expected type  p: (nonempty?[T])
  lc_gen_TCC1: OBLIGATION
    FORALL (G: group[T, *, one], H: subgroup[T, *, one](G),
            lc: left_cosets(G, H)):
      nonempty?[T]({a: T | G(a) AND lc = a * H});


decl_type: tcc
theory: cosets
library: algebra
signature: nil
location: 198 0 202 999
body:
  % Subtype TCC generated (at line 126, column 36) for  a * H
      % expected type  left_cosets(G, H)
  lc_gen_def_TCC1: OBLIGATION
    FORALL (G, H: group[T, *, one], a: T):
      G(a) AND subgroup?(H, G) IMPLIES (EXISTS (a_1: (G)): a * H = a_1 * H);


decl_type: tcc
theory: cosets
library: algebra
signature: nil
location: 204 0 210 999
body:
  % Subtype TCC generated (at line 131, column 23) for
      % {a: T | G(a) AND rc = H * a}
      % expected type  p: (nonempty?[T])
  rc_gen_TCC1: OBLIGATION
    FORALL (G: group[T, *, one], H: subgroup[T, *, one](G),
            rc: right_cosets(G, H)):
      nonempty?[T]({a: T | G(a) AND rc = H * a});


decl_type: tcc
theory: cosets
library: algebra
signature: nil
location: 212 0 216 999
body:
  % Subtype TCC generated (at line 134, column 38) for  H * a
      % expected type  right_cosets(G, H)
  rc_gen_def_TCC1: OBLIGATION
    FORALL (G, H: group[T, *, one], a: T):
      G(a) AND subgroup?(H, G) IMPLIES (EXISTS (a_1: (G)): H * a = H * a_1);


decl_type: formula
theory: normal_subgroups
library: algebra
signature: nil
location: 21 3 22 61
body:
     normal_prep: LEMMA (FORALL (a: (G)): subset?(inv(a)*N*a,N) ) AND subgroup?(N,G) 
                        IMPLIES FORALL (a: (G)): a*N*inv(a) = N


decl_type: formula
theory: normal_subgroups
library: algebra
signature: nil
location: 28 3 30 62
body:
     normal_left_is_right: THEOREM normal_subgroup?(N,G) IFF 
                                    (subgroup?(N,G) AND 
                                    (FORALL (a:(G)): a*N = N*a))


decl_type: formula
theory: normal_subgroups
library: algebra
signature: nil
location: 38 3 39 60
body:
     nsg_prop      : LEMMA FORALL (G: group, H: normal_subgroup(G)): 
                           G(a) and H(h) IMPLIES H(a*h*inv(a))


decl_type: formula
theory: normal_subgroups
library: algebra
signature: nil
location: 42 3 43 60
body:
     nsg_prop2     : LEMMA FORALL (G: group, H: normal_subgroup(G)): 
                           G(a) and H(h) IMPLIES H(inv(a)*h*a)


decl_type: formula
theory: normal_subgroups
library: algebra
signature: nil
location: 46 3 47 65
body:
     lc_gen_normal : LEMMA normal_subgroup?(H,G) AND G(a) IMPLIES
                           (EXISTS (h: (H)): lc_gen(G,H,a*H) = h*a)


decl_type: formula
theory: normal_subgroups
library: algebra
signature: nil
location: 51 3 52 54
body:
     abelian_normal: LEMMA abelian_group?(G) and subgroup?(H,G)
                           IMPLIES normal_subgroup?(H,G)


decl_type: function
theory: normal_subgroups
library: algebra
signature: [[group[T, *, one], group[T, *, one]] -> boolean]
location: 25 3 26 82
body:
     normal_subgroup?(N: group[T,*,one], G: group[T,*,one]): boolean = subgroup?(N,G) AND
                                            FORALL (a: (G)): subset?(inv(a)*N*a,N) ;


decl_type: tcc
theory: normal_subgroups
library: algebra
signature: nil
location: 62 0 64 999
body:
  % Assuming TCC generated (at line 11, column 13) for  cosets[T, *, one]
      % generated from assumption cosets.fullset_is_group
  IMP_cosets_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: tcc
theory: normal_subgroups
library: algebra
signature: nil
location: 66 0 69 999
body:
  % Judgement subtype TCC generated (at line 34, column 42) for  x
      % expected type  subgroup[T, *, one](G)
  normal_subgroup_is_subgroup: OBLIGATION
    FORALL (G, x: normal_subgroup(G)): subgroup?[T, *, one](x, G);


decl_type: tcc
theory: normal_subgroups
library: algebra
signature: nil
location: 71 0 76 999
body:
  % Subtype TCC generated (at line 47, column 52) for  H
      % expected type  subgroup[T, *, one](G)
  lc_gen_normal_TCC1: OBLIGATION
    FORALL (G, H: group[T, *, one], a: T):
      G(a) AND normal_subgroup?(H, G) IMPLIES
       (FORALL (h: (H)): subgroup?[T, *, one](H, G));


decl_type: tcc
theory: normal_subgroups
library: algebra
signature: nil
location: 78 0 84 999
body:
  % Subtype TCC generated (at line 47, column 54) for  a * H
      % expected type  left_cosets[T, *, one](G, H)
  lc_gen_normal_TCC2: OBLIGATION
    FORALL (G, H: group[T, *, one], a: T):
      G(a) AND normal_subgroup?(H, G) IMPLIES
       (FORALL (h: (H)):
          EXISTS (a_1: (G)): *[T, *, one](a, H) = *[T, *, one](a_1, H));


decl_type: formula
theory: factor_groups
library: algebra
signature: nil
location: 25 3 27 74
body:
     p0: LEMMA FORALL (G: group, H: normal_subgroup(G), A,B: left_cosets(G, H)):
                      nonempty?[set[T]]({S: set[T] | EXISTS (a, b: (G)):
                                    A = a*H AND B = b*H AND S = (a * b)*H })


decl_type: formula
theory: factor_groups
library: algebra
signature: nil
location: 30 3 31 64
body:
     prep: LEMMA FORALL (a1,a2,b1,b2: (G)): FORALL (H: normal_subgroup(G)):
         a1*H = a2*H AND b1*H = b2*H IMPLIES (a1*b1)*H = (a2*b2)*H


decl_type: formula
theory: factor_groups
library: algebra
signature: nil
location: 33 3 35 90
body:
     mult_prep: LEMMA FORALL (G: group, H: normal_subgroup(G), A,B: left_cosets(G, H)):
                      singleton?[set[T]] ({S: set[T] | EXISTS (a, b: (G)):
                                                    A = a*H AND B = b*H AND S = (a * b)*H })


decl_type: formula
theory: factor_groups
library: algebra
signature: nil
location: 43 3 44 52
body:
     mult_lem  : LEMMA FORALL (G: group, H: normal_subgroup(G), a,b: (G)): 
                          mult(G,H)(a*H,b*H) = (a*b)*H


decl_type: formula
theory: factor_groups
library: algebra
signature: nil
location: 46 3 47 60
body:
     mult_in   : LEMMA FORALL (G: group, H: normal_subgroup(G)),(A,B: left_cosets(G,H)):
                               mult(G, H)(A,B)(a) IMPLIES G(a)     


decl_type: formula
theory: factor_groups
library: algebra
signature: nil
location: 49 3 50 65
body:
     mult_is_coset: LEMMA FORALL (G: group, H: normal_subgroup(G)),(A,B: left_cosets(G,H)):
                             EXISTS (a: (G)): mult(G, H)(A,B) = a*H                    


decl_type: formula
theory: factor_groups
library: algebra
signature: nil
location: 54 3 55 72
body:
     N_is_identity: LEMMA FORALL (G: group, N: normal_subgroup(G)), (A: left_cosets(G,N)):
                                 mult(G,N)(N,A) = A AND mult(G,N)(A,N) = A


decl_type: formula
theory: factor_groups
library: algebra
signature: nil
location: 60 3 64 4
body:
     left_cosets_group: THEOREM FORALL (G: group, N: normal_subgroup(G)):
                group?[left_cosets(G, N), mult(G, N), N](fullset[left_cosets(G, N)])


     ; %% ----- define G/N as set of all left_cosets


decl_type: function
theory: factor_groups
library: algebra
location: 39 3 40 41
signature:
  [d: [G: group, normal_subgroup[T, *, one](G)] ->
          [[left_cosets[T, *, one](d`1, d`2),
            left_cosets[T, *, one](d`1, d`2)] ->
             left_cosets[T, *, one](d`1, d`2)]]

body:
     mult(G:group,H:normal_subgroup(G))(A,B: left_cosets(G,H)): left_cosets(G,H)  = 
              lc_gen(G,H,A)*lc_gen(G,H,B)*H


decl_type: function
theory: factor_groups
library: algebra
location: 66 3 67 45
signature:
  [d: [G: group[T, *, one], normal_subgroup[T, *, one](G)] ->
          group
              [left_cosets[T, *, one](d`1, d`2), mult(d`1, d`2), d`2]]

body:
     /(G: group[T,*,one], N: normal_subgroup(G)): group[left_cosets(G,N),mult(G,N),N] 
                   = fullset[left_cosets(G, N)]


decl_type: function
theory: factor_groups
library: algebra
location: 70 3 71 45
signature:
  [d: [G: group[T, *, one], normal_subgroup[T, *, one](G)] ->
          group
              [left_cosets[T, *, one](d`1, d`2), mult(d`1, d`2), d`2]]

body:
     over(G: group[T,*,one], N: normal_subgroup(G)): group[left_cosets(G,N),mult(G,N),N] 
                   = fullset[left_cosets(G, N)]


decl_type: tcc
theory: factor_groups
library: algebra
signature: nil
location: 80 0 83 999
body:
  % Assuming TCC generated (at line 16, column 13) for
      % normal_subgroups[T, *, one]
      % generated from assumption normal_subgroups.fullset_is_group
  IMP_normal_subgroups_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: tcc
theory: factor_groups
library: algebra
signature: nil
location: 85 0 88 999
body:
  % Subtype TCC generated (at line 39, column 57) for  H
      % expected type  subgroup[T, *, one](G)
  mult_TCC1: OBLIGATION
    FORALL (G: group, H: normal_subgroup(G)): subgroup?[T, *, one](H, G);


decl_type: tcc
theory: factor_groups
library: algebra
signature: nil
location: 90 0 99 999
body:
  % Subtype TCC generated (at line 40, column 12) for
      % lc_gen(G, H, A) * lc_gen(G, H, B) * H
      % expected type  left_cosets[T, *, one](G, H)
  mult_TCC2: OBLIGATION
    FORALL (G: group[T, *, one], H: normal_subgroup[T, *, one](G),
            A, B: left_cosets[T, *, one](G, H)):
      EXISTS (a: (G)):
        *[T, *, one]
            (lc_gen[T, *, one](G, H, A) * lc_gen[T, *, one](G, H, B), H)
         = *[T, *, one](a, H);


decl_type: tcc
theory: factor_groups
library: algebra
signature: nil
location: 101 0 106 999
body:
  % Subtype TCC generated (at line 44, column 34) for  a * H
      % expected type  left_cosets[T, *, one](G, H)
  mult_lem_TCC1: OBLIGATION
    FORALL (G: group[T, *, one], H: normal_subgroup[T, *, one](G),
            a, b: (G)):
      EXISTS (a_1: (G)): *[T, *, one](a, H) = *[T, *, one](a_1, H);


decl_type: tcc
theory: factor_groups
library: algebra
signature: nil
location: 108 0 113 999
body:
  % Subtype TCC generated (at line 44, column 38) for  b * H
      % expected type  left_cosets[T, *, one](G, H)
  mult_lem_TCC2: OBLIGATION
    FORALL (G: group[T, *, one], H: normal_subgroup[T, *, one](G),
            a, b: (G)):
      EXISTS (a: (G)): *[T, *, one](b, H) = *[T, *, one](a, H);


decl_type: tcc
theory: factor_groups
library: algebra
signature: nil
location: 115 0 120 999
body:
  % Subtype TCC generated (at line 55, column 41) for  N
      % expected type  left_cosets[T, *, one](G, N)
  N_is_identity_TCC1: OBLIGATION
    FORALL (G: group[T, *, one], N: normal_subgroup[T, *, one](G),
            A: left_cosets[T, *, one](G, N)):
      EXISTS (a: (G)): N = *[T, *, one](a, N);


decl_type: tcc
theory: factor_groups
library: algebra
signature: nil
location: 122 0 126 999
body:
  % Subtype TCC generated (at line 61, column 52) for  N
      % expected type  left_cosets[T, *, one](G, N)
  left_cosets_group_TCC1: OBLIGATION
    FORALL (G: group[T, *, one], N: normal_subgroup[T, *, one](G)):
      EXISTS (a: (G)): N = *[T, *, one](a, N);


decl_type: tcc
theory: factor_groups
library: algebra
signature: nil
location: 128 0 132 999
body:
  % Existence TCC generated (at line 61, column 14) for
      % group?[left_cosets(G, N), mult(G, N), N]
  left_cosets_group_TCC2: OBLIGATION
    FORALL (G: group[T, *, one], N: normal_subgroup[T, *, one](G)):
      EXISTS (x: left_cosets[T, *, one](G, N)): TRUE;


decl_type: tcc
theory: factor_groups
library: algebra
signature: nil
location: 134 0 139 999
body:
  % Assuming TCC generated (at line 66, column 48) for
      % group[left_cosets(G, N), mult(G, N), N]
      % generated from assumption group.fullset_is_group
  divide_TCC1: OBLIGATION
    FORALL (G: group[T, *, one], N: normal_subgroup(G)):
      group?[left_cosets(G, N), mult(G, N), N](fullset[left_cosets(G, N)]);


decl_type: tcc
theory: group_rew
library: algebra
signature: nil
location: 38 0 40 999
body:
  % Assuming TCC generated (at line 10, column 13) for  group[T, *, one]
      % generated from assumption group.fullset_is_group
  IMP_group_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: constant
theory: zn
library: algebra
location: 43 2 43 45
body: nZ: group[nZ_TYPE, +, 0] = fullset[nZ_TYPE]
signature:
  group
           [nZ_TYPE,
            restrict[[numfield, numfield], [nZ_TYPE, nZ_TYPE], numfield]
                (+),
            0]


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 66 0 71 999
body:
  % Assuming TCC generated (at line 23, column 5) for
      % group[int, restrict[[numfield, numfield], [int, int], numfield](+), 0]
      % generated from assumption group.fullset_is_group
  Z_TCC1: OBLIGATION
    group?[int, restrict[[numfield, numfield], [int, int], numfield](+), 0]
        (fullset[int]);


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 73 0 75 999
body:
  % Subtype TCC generated (at line 25, column 37) for  0
      % expected type  below(N)
  Z_prep_TCC1: OBLIGATION 0 < N;


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 77 0 79 999
body:
  % Existence TCC generated (at line 25, column 16) for
      % group?[below(N), ++, 0]
  Z_prep_TCC2: OBLIGATION EXISTS (x: below(N)): TRUE;


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 81 0 83 999
body:
  % Assuming TCC generated (at line 28, column 6) for  group[below(N), ++, 0]
      % generated from assumption group.fullset_is_group
  Z__TCC1: OBLIGATION group?[below(N), ++, 0](fullset[below(N)]);


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 85 0 88 999
body:
  % Subtype TCC generated (at line 39, column 35) for  x + y
      % expected type  nZ_TYPE
  nZ_plus_TCC1: OBLIGATION
    FORALL (x, y: nZ_TYPE): EXISTS (k: int): x + y = k * N;


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 90 0 92 999
body:
  % Subtype TCC generated (at line 41, column 42) for  0
      % expected type  nZ_TYPE
  nZ_prep_TCC1: OBLIGATION EXISTS (k: int): 0 = k * N;


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 94 0 96 999
body:
  % Existence TCC generated (at line 41, column 17) for
      % group?[nZ_TYPE, nZ_plus, 0]
  nZ_prep_TCC2: OBLIGATION EXISTS (x: nZ_TYPE): TRUE;


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 98 0 105 999
body:
  % Subtype TCC generated (at line 43, column 6) for
      % group
      %     [nZ_TYPE,
      %      restrict[[numfield, numfield], [nZ_TYPE, nZ_TYPE], numfield](+),
      %      0]
      % expected type  [[nZ_TYPE, nZ_TYPE] -> nZ_TYPE]
  nZ_TCC1: OBLIGATION
    FORALL (x1: [nZ_TYPE, nZ_TYPE]): EXISTS (k: int): +x1 = k * N;


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 107 0 117 999
body:
  % Assuming TCC generated (at line 43, column 6) for
      % group
      %     [nZ_TYPE,
      %      restrict[[numfield, numfield], [nZ_TYPE, nZ_TYPE], numfield](+),
      %      0]
      % generated from assumption group.fullset_is_group
  nZ_TCC2: OBLIGATION
    group?
        [nZ_TYPE,
         restrict[[numfield, numfield], [nZ_TYPE, nZ_TYPE], numfield](+), 0]
        (fullset[nZ_TYPE]);


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 119 0 132 999
body:
  % Subtype TCC generated (at line 48, column 39) for
      % restrict[int, nZ_TYPE, boolean](Z)
      % expected type  group
                     %     [nZ_TYPE,
                     %      restrict
                     %          [[numfield, numfield], [nZ_TYPE, nZ_TYPE],
                     %           numfield]
                     %          (+),
                     %      0]
  nZ_normal_TCC1: OBLIGATION
    group?
        [nZ_TYPE,
         restrict[[numfield, numfield], [nZ_TYPE, nZ_TYPE], numfield](+), 0]
        (restrict[int, nZ_TYPE, boolean](Z));


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 134 0 148 999
body:
  % Subtype TCC generated (at line 55, column 63) for
      % extend[int, nZ_TYPE, bool, FALSE](nZ)
      % expected type  normal_subgroup
                     %     [int,
                     %      restrict
                     %          [[numfield, numfield], [int, int], numfield]
                     %          (+),
                     %      0](Z)
  Z_fact_test_TCC1: OBLIGATION
    group?[int, restrict[[numfield, numfield], [int, int], numfield](+), 0]
        (extend[int, nZ_TYPE, bool, FALSE](nZ))
     AND
     normal_subgroup?
         [int, restrict[[numfield, numfield], [int, int], numfield](+), 0]
         (extend[int, nZ_TYPE, bool, FALSE](nZ), Z);


decl_type: tcc
theory: zn
library: algebra
signature: nil
location: 150 0 162 999
body:
  % Subtype TCC generated (at line 55, column 57) for
      % extend[int, nZ_TYPE, bool, FALSE](nZ)
      % expected type  factor_type
                     %     [int,
                     %      restrict
                     %          [[numfield, numfield], [int, int], numfield]
                     %          (+),
                     %      0](Z, extend[int, nZ_TYPE, bool, FALSE](nZ))
  Z_fact_test_TCC2: OBLIGATION
    EXISTS (a: (Z)):
      extend[int, nZ_TYPE, bool, FALSE](nZ) =
       *[int, restrict[[numfield, numfield], [int, int], numfield](+), 0]
           (a, extend[int, nZ_TYPE, bool, FALSE](nZ));


decl_type: tcc
theory: A_group
library: algebra
signature: nil
location: 44 0 52 999
body:
  % Subtype TCC generated (at line 28, column 41) for
      % restrict
      %     [[[(S) -> (S)], [(S) -> (S)]], [maps(S), maps(S)], [(S) -> (S)]]
      %     (function_props[(S), (S), (S)].o)
      % expected type  [[maps(S), maps(S)] -> maps(S)]
  op_TCC1: OBLIGATION
    FORALL (S: (nonempty?[T])):
      FORALL (x1: [maps(S), maps(S)]):
        bijective?[(S), (S)](function_props[(S), (S), (S)].o(x1));


decl_type: tcc
theory: A_group
library: algebra
signature: nil
location: 54 0 57 999
body:
  % Existence TCC generated (at line 33, column 21) for
      % group?[maps(S), op(S), id(S)]
  A_is_group_TCC1: OBLIGATION
    FORALL (S: (nonempty?[T])): EXISTS (x: maps(S)): TRUE;


decl_type: function
theory: homomorphisms
library: algebra
signature:
  [[G1: group[T1, *, one1], G2: group[T2, o, one2],
  [(G1) -> (G2)]] ->
  bool]

location: 27 3 30 68
body:
     homomorphism?(G1: group[T1,*,one1],
                   G2: group[T2,o,one2],
                    phi: [(G1) -> (G2)]): bool  =
                      (FORALL (a,b: (G1)): phi(a*b) = phi(a) o phi(b))


decl_type: function
theory: homomorphisms
library: algebra
signature:
  [[G1: group[T1, *, one1], G2: group[T2, o, one2],
  [(G1) -> (G2)]] ->
  bool]

location: 33 3 36 72
body:
     isomorphism?(G1: group[T1,*,one1],
                  G2: group[T2,o,one2],
                    phi: [(G1) -> (G2)]): bool  = bijective?(phi) AND
                                                  homomorphism?(G1,G2,phi)


decl_type: function
theory: homomorphisms
library: algebra
signature: [[group[T1, *, one1], group[T2, o, one2]] -> bool]
location: 38 3 40 74
body:
     homomorphic?(G1: group[T1,*,one1],
                  G2: group[T2,o,one2]): bool = 
                      EXISTS (phi: [(G1) -> (G2)]): homomorphism?(G1,G2,phi)


decl_type: function
theory: homomorphisms
library: algebra
signature: [[group[T1, *, one1], group[T2, o, one2]] -> bool]
location: 44 3 46 73
body:
     isomorphic?(G1: group[T1,*,one1],
                 G2: group[T2,o,one2]): bool = 
                      EXISTS (phi: [(G1) -> (G2)]): isomorphism?(G1,G2,phi)


decl_type: function
theory: homomorphisms
library: algebra
location: 61 3 63 46
signature:
  [d: [group[T1, *, one1], group[T2, o, one2]] ->
          [homomorphism(d`1, d`2) -> subgroup[T1, *, one1](d`1)]]

body:
     kernel(G: group[T1,*,one1],
            GP: group[T2,o,one2])(phi: homomorphism(G,GP)): subgroup[T1,*,one1](G) =
                {a: T1 | G(a) AND phi(a) = one2}


decl_type: tcc
theory: homomorphisms
library: algebra
signature: nil
location: 72 0 74 999
body:
  % Assuming TCC generated (at line 24, column 13) for  group[T1, *, one1]
      % generated from assumption group.fullset_is_group
  IMP_group_TCC1: OBLIGATION group?[T1, *, one1](fullset[T1]);


decl_type: tcc
theory: homomorphisms
library: algebra
signature: nil
location: 76 0 78 999
body:
  % Assuming TCC generated (at line 24, column 31) for  group[T2, o, one2]
      % generated from assumption group.fullset_is_group
  IMP_group_TCC2: OBLIGATION group?[T2, o, one2](fullset[T2]);


decl_type: tcc
theory: homomorphisms
library: algebra
signature: nil
location: 80 0 85 999
body:
  % Subtype TCC generated (at line 30, column 45) for  a * b
      % expected type  (G1)
  homomorphism?_TCC1: OBLIGATION
    FORALL (G1: group[T1, *, one1], G2: group[T2, o, one2],
            phi: [(G1) -> (G2)], a, b: (G1)):
      G1(a * b);


decl_type: tcc
theory: homomorphisms
library: algebra
signature: nil
location: 87 0 92 999
body:
  % Subtype TCC generated (at line 58, column 57) for  one1
      % expected type  (G)
  homo_one_TCC1: OBLIGATION
    FORALL (G: group[T1, *, one1], GP: group[T2, o, one2],
            phi: homomorphism(G, GP)):
      G(one1);


decl_type: tcc
theory: homomorphisms
library: algebra
signature: nil
location: 94 0 101 999
body:
  % Subtype TCC generated (at line 63, column 14) for
      % {a: T1 | G(a) AND phi(a) = one2}
      % expected type  subgroup[T1, *, one1](G)
  kernel_TCC1: OBLIGATION
    FORALL (G: group[T1, *, one1], GP: group[T2, o, one2],
            phi: homomorphism(G, GP)):
      group?[T1, *, one1]({a: T1 | G(a) AND phi(a) = one2}) AND
       subgroup?[T1, *, one1]({a: T1 | G(a) AND phi(a) = one2}, G);


decl_type: formula
theory: cayleys
library: algebra
signature: nil
location: 29 3 30 66
body:
     cayley_prep: LEMMA FORALL (G: group[T,*,one]): FORALL (a: (G)):
                        bijective?[(G), (G)](LAMBDA (s: (G)): a * s)


decl_type: formula
theory: cayleys
library: algebra
signature: nil
location: 32 3 33 67
body:
     trans_is_group: LEMMA FORALL (G: group[T,*,one]): 
                              group?[maps[T](G), op(G), id(G)](ML(G))


decl_type: formula
theory: cayleys
library: algebra
signature: nil
location: 35 3 36 77
body:
     Cayleys: THEOREM FORALL (G: group[T,*,one]): 
                             isomorphic?[T,*,one,maps(G),op(G),id(G)](G, ML(G))


decl_type: tcc
theory: cayleys
library: algebra
signature: nil
location: 44 0 49 999
body:
  % Assuming TCC generated (at line 22, column 10) for  semigroup[T, *]
      % generated from assumption semigroup.fullset_is_semigroup
  S_TCC1: OBLIGATION
    star_closed?[T, *](fullset[T]) AND
     associative?[(fullset[T])]
         (restrict[[T, T], [(fullset[T]), (fullset[T])], T](*));


decl_type: tcc
theory: cayleys
library: algebra
signature: nil
location: 51 0 53 999
body:
  % Assuming TCC generated (at line 45, column 7) for  group[T, *, one]
      % generated from assumption group.fullset_is_group
  cayley_prep_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: tcc
theory: cayleys
library: algebra
signature: nil
location: 55 0 58 999
body:
  % Subtype TCC generated (at line 30, column 60) for  a * s
      % expected type  (G)
  cayley_prep_TCC2: OBLIGATION
    FORALL (G: group[T, *, one], a: (G), s: (G)): (G)(a * s);


decl_type: tcc
theory: cayleys
library: algebra
signature: nil
location: 60 0 65 999
body:
  % Subtype TCC generated (at line 33, column 64) for  G
      % expected type  S: semigroup[T, *]
  trans_is_group_TCC1: OBLIGATION
    FORALL (G: group[T, *, one]):
      star_closed?[T, *](G) AND
       associative?[(G)](restrict[[T, T], [(G), (G)], T](*));


decl_type: tcc
theory: cayleys
library: algebra
signature: nil
location: 67 0 70 999
body:
  % Subtype TCC generated (at line 33, column 50) for  G
      % expected type  S: (nonempty?[T])
  trans_is_group_TCC2: OBLIGATION
    FORALL (G: group[T, *, one]): nonempty?[T](G);


decl_type: tcc
theory: cayleys
library: algebra
signature: nil
location: 72 0 75 999
body:
  % Existence TCC generated (at line 33, column 28) for
      % group?[maps[T](G), op(G), id(G)]
  trans_is_group_TCC3: OBLIGATION
    FORALL (G: group[T, *, one]): EXISTS (x: maps[T](G)): TRUE;


decl_type: tcc
theory: cayleys
library: algebra
signature: nil
location: 77 0 80 999
body:
  % Subtype TCC generated (at line 36, column 71) for  ML(G)
      % expected type  group[maps(G), op(G), id(G)]
  Cayleys_TCC1: OBLIGATION
    FORALL (G: group[T, *, one]): group?[maps(G), op[T](G), id[T](G)](ML(G));


decl_type: tcc
theory: cayleys
library: algebra
signature: nil
location: 82 0 87 999
body:
  % Assuming TCC generated (at line 19, column 7) for
      % homomorphisms[T, *, one, maps(G), op(G), id(G)]
      % generated from assumption homomorphisms.T2_is_group
  Cayleys_TCC2: OBLIGATION
    FORALL (G: group[T, *, one]):
      group?[maps(G), op[T](G), id[T](G)](fullset[maps(G)]);


decl_type: tcc
theory: infinite_cyclic_groups
library: algebra
signature: nil
location: 39 0 44 999
body:
  % Assuming TCC generated (at line 14, column 6) for
      % group[int, restrict[[numfield, numfield], [int, int], numfield](+), 0]
      % generated from assumption group.fullset_is_group
  Z_TCC1: OBLIGATION
    group?[int, restrict[[numfield, numfield], [int, int], numfield](+), 0]
        (fullset[int]);


decl_type: tcc
theory: infinite_cyclic_groups
library: algebra
signature: nil
location: 46 0 48 999
body:
  % Assuming TCC generated (at line 18, column 12) for  group[T, *, one]
      % generated from assumption group.fullset_is_group
  F_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: formula
theory: cyclic_group
library: algebra
signature: nil
location: 42 3 44 43
body:
     is_cyclic   : LEMMA (EXISTS (a:(G)): FORALL (x: (G)): 
                            EXISTS (n: nat): x = a^n) IMPLIES
                                   cyclic?(G)


decl_type: tcc
theory: cyclic_group
library: algebra
signature: nil
location: 53 0 55 999
body:
  % Assuming TCC generated (at line 15, column 13) for  group[T, *, one]
      % generated from assumption group.fullset_is_group
  IMP_group_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: formula
theory: lagrange_scaf
library: algebra
signature: nil
location: 50 2 54 55
body:
    card_equal_partition: LEMMA card(PP) = n AND
                                (FORALL (A: (PP)): card(A) = m) AND
                                (FORALL (A,B: (PP)): A = B OR disjoint?(A,B))
                                IMPLIES
                                    card(Union(PP)) = n*m


decl_type: formula
theory: lagrange_scaf
library: algebra
signature: nil
location: 58 2 62 57
body:
    card_eq_part: LEMMA (FORALL (A,B: (PP)): card(A) = card(B)) AND
                        (FORALL (A,B: (PP)): A = B OR disjoint?(A,B)) AND
                        PP(H)
                      IMPLIES
                         card(Union(PP)) = card(PP)*card(H)


decl_type: type
theory: lagrange_scaf
library: algebra
signature: nil
location: 33 2 34 74
body:
    finite_partition: TYPE = (finite_partition?) CONTAINING
                                                    emptyset[(nonempty?[T])]


decl_type: tcc
theory: lagrange_scaf
library: algebra
signature: nil
location: 69 0 75 999
body:
  % Subtype TCC generated (at line 24, column 44) for
      % extend[setof[T], (nonempty?[T]), bool, FALSE]
      %     (emptyset[(nonempty?[T])])
      % expected type  partition
  partition_TCC1: OBLIGATION
    partition?(extend[setof[T], (nonempty?[T]), bool, FALSE]
                   (emptyset[(nonempty?[T])]));


decl_type: tcc
theory: lagrange_scaf
library: algebra
signature: nil
location: 77 0 83 999
body:
  % Subtype TCC generated (at line 34, column 50) for
      % extend[setof[T], (nonempty?[T]), bool, FALSE]
      %     (emptyset[(nonempty?[T])])
      % expected type  finite_partition
  finite_partition_TCC1: OBLIGATION
    finite_partition?(extend[setof[T], (nonempty?[T]), bool, FALSE]
                          (emptyset[(nonempty?[T])]));


decl_type: tcc
theory: lagrange_scaf
library: algebra
signature: nil
location: 85 0 88 999
body:
  % Judgement subtype TCC generated (at line 37, column 42) for  x
      % expected type  partition
  finite_partition_is_partition: OBLIGATION
    FORALL (x: finite_partition): partition?(x);


decl_type: tcc
theory: lagrange_scaf
library: algebra
signature: nil
location: 90 0 93 999
body:
  % Subtype TCC generated (at line 50, column 35) for  PP
      % expected type  S: finite_set[setof[T]]
  card_equal_partition_TCC1: OBLIGATION
    FORALL (PP: finite_partition): is_finite[setof[T]](PP);


decl_type: tcc
theory: lagrange_scaf
library: algebra
signature: nil
location: 95 0 99 999
body:
  % Subtype TCC generated (at line 51, column 54) for  A
      % expected type  S: finite_set[T]
  card_equal_partition_TCC2: OBLIGATION
    FORALL (PP: finite_partition, n: nat):
      card(PP) = n IMPLIES (FORALL (A: (PP)): is_finite[T](A));


decl_type: tcc
theory: lagrange_scaf
library: algebra
signature: nil
location: 101 0 107 999
body:
  % Subtype TCC generated (at line 54, column 39) for  Union(PP)
      % expected type  S: finite_set[T]
  card_equal_partition_TCC3: OBLIGATION
    FORALL (PP: finite_partition, m, n: nat):
      (FORALL (A, B: (PP)): A = B OR disjoint?(A, B)) AND
       (FORALL (A: (PP)): card(A) = m) AND card(PP) = n
       IMPLIES is_finite[T](Union[T](PP));


decl_type: tcc
theory: lagrange_scaf
library: algebra
signature: nil
location: 109 0 112 999
body:
  % Subtype TCC generated (at line 58, column 48) for  A
      % expected type  S: finite_set[T]
  card_eq_part_TCC1: OBLIGATION
    FORALL (PP: finite_partition, A, B: (PP)): is_finite[T](A);


decl_type: tcc
theory: lagrange_scaf
library: algebra
signature: nil
location: 114 0 117 999
body:
  % Subtype TCC generated (at line 58, column 58) for  B
      % expected type  S: finite_set[T]
  card_eq_part_TCC2: OBLIGATION
    FORALL (PP: finite_partition, A, B: (PP)): is_finite[T](B);


decl_type: tcc
theory: lagrange_scaf
library: algebra
signature: nil
location: 119 0 126 999
body:
  % Subtype TCC generated (at line 62, column 28) for  Union(PP)
      % expected type  S: finite_set[T]
  card_eq_part_TCC3: OBLIGATION
    FORALL (H: set[T], PP: finite_partition):
      (PP(H) AND
        (FORALL (A, B: (PP)): A = B OR disjoint?(A, B)) AND
         (FORALL (A, B: (PP)): card(A) = card(B)))
       IMPLIES is_finite[T](Union[T](PP));


decl_type: tcc
theory: lagrange_scaf
library: algebra
signature: nil
location: 128 0 135 999
body:
  % Subtype TCC generated (at line 62, column 55) for  H
      % expected type  S: finite_set[T]
  card_eq_part_TCC4: OBLIGATION
    FORALL (H: set[T], PP: finite_partition):
      (PP(H) AND
        (FORALL (A, B: (PP)): A = B OR disjoint?(A, B)) AND
         (FORALL (A, B: (PP)): card(A) = card(B)))
       IMPLIES is_finite[T](H);


decl_type: formula
theory: lagrange
library: algebra
signature: nil
location: 35 3 36 61
body:
     right_coset_finite: LEMMA subgroup?(H,G) AND member(a,G) IMPLIES
                                 is_finite(right_coset(G,H)(a))


decl_type: formula
theory: lagrange
library: algebra
signature: nil
location: 38 3 40 68
body:
     finite_right_coset_correspondence: LEMMA
                 subgroup?(H,G) AND member(a,G) AND member(b,G) IMPLIES
                 card(right_coset(G,H)(a)) = card(right_coset(G,H)(b))


decl_type: formula
theory: lagrange
library: algebra
signature: nil
location: 44 2 45 67
body:
    set_right_cosets_full: LEMMA FORALL (G: group, H: subgroup(G)):
                                Union(fullset[right_cosets(G,H)]) = G


decl_type: formula
theory: lagrange
library: algebra
signature: nil
location: 48 2 49 60
body:
    right_cosets_disjoint: LEMMA FORALL (G: group, H: subgroup(G), A,B: right_cosets(G, H)):
                                       A = B OR disjoint?(A,B)


decl_type: formula
theory: lagrange
library: algebra
signature: nil
location: 52 2 53 85
body:
    right_cosets_partition: LEMMA FORALL (G: finite_group, H: subgroup(G)):
                                      finite_partition?[T](fullset[right_cosets(G, H)])


decl_type: tcc
theory: lagrange
library: algebra
signature: nil
location: 65 0 67 999
body:
  % Assuming TCC generated (at line 22, column 13) for  group[T, *, one]
      % generated from assumption group.fullset_is_group
  IMP_group_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: tcc
theory: lagrange
library: algebra
signature: nil
location: 69 0 73 999
body:
  % Subtype TCC generated (at line 36, column 58) for  a
      % expected type  (G)
  right_coset_finite_TCC1: OBLIGATION
    FORALL (G, H: finite_group[T, *, one], a: T):
      member(a, G) AND subgroup?(H, G) IMPLIES G(a);


decl_type: tcc
theory: lagrange
library: algebra
signature: nil
location: 75 0 80 999
body:
  % Subtype TCC generated (at line 40, column 20) for  right_coset(G, H)(a)
      % expected type  S: finite_set[T]
  finite_right_coset_correspondence_TCC1: OBLIGATION
    FORALL (G, H: finite_group[T, *, one], a, b: T):
      member(b, G) AND member(a, G) AND subgroup?(H, G) IMPLIES
       is_finite[T](right_coset[T, *, one](G, H)(a));


decl_type: tcc
theory: lagrange
library: algebra
signature: nil
location: 82 0 86 999
body:
  % Subtype TCC generated (at line 40, column 65) for  b
      % expected type  (G)
  finite_right_coset_correspondence_TCC2: OBLIGATION
    FORALL (G, H: finite_group[T, *, one], a, b: T):
      member(b, G) AND member(a, G) AND subgroup?(H, G) IMPLIES G(b);


decl_type: tcc
theory: lagrange
library: algebra
signature: nil
location: 88 0 93 999
body:
  % Subtype TCC generated (at line 40, column 48) for  right_coset(G, H)(b)
      % expected type  S: finite_set[T]
  finite_right_coset_correspondence_TCC3: OBLIGATION
    FORALL (G, H: finite_group[T, *, one], a, b: T):
      member(b, G) AND member(a, G) AND subgroup?(H, G) IMPLIES
       is_finite[T](right_coset[T, *, one](G, H)(b));


decl_type: formula
theory: finite_groups
library: algebra
signature: nil
location: 34 3 35 60
body:
     finite_generated_by: LEMMA member(a,G) IMPLIES 
                                    is_finite(generated_by(a))   %% RWB


decl_type: formula
theory: finite_groups
library: algebra
signature: nil
location: 37 3 38 97
body:
     finite_generated_by_def: LEMMA member(a,G) AND S = generated_by(a) 
                                    IMPLIES S = {t:T | EXISTS (n:posnat): n <= card(S) AND t = a^n}


decl_type: formula
theory: finite_groups
library: algebra
signature: nil
location: 40 3 41 57
body:
     finite_generated_by_one: LEMMA member(a,G) AND S = generated_by(a) 
                                    IMPLIES a^card(S) = one


decl_type: formula
theory: finite_groups
library: algebra
signature: nil
location: 44 3 47 76
body:
     generated_by_card_1: LEMMA member(a,G) AND 
                                card(generated_by(a)) = 1
                                   IMPLIES a = one AND
                                           generated_by(a) = singleton[T](one)


decl_type: formula
theory: finite_groups
library: algebra
signature: nil
location: 57 3 58 74
body:
     finite_subgroup_def: LEMMA
                       subgroup?(S,G) IFF (subset?(S,G) AND star_closed?(S))


decl_type: formula
theory: finite_groups
library: algebra
signature: nil
location: 66 3 67 77
body:
     period_is_generated_order: LEMMA member(a,G) IMPLIES 
                                           period(G,a) = order(generated_by(a))


decl_type: formula
theory: finite_groups
library: algebra
signature: nil
location: 69 3 70 79
body:
     period_element_divides_group: COROLLARY member(a,G) IMPLIES
                                                    divides(period(G,a),order(G))


decl_type: tcc
theory: finite_groups
library: algebra
signature: nil
location: 80 0 82 999
body:
  % Assuming TCC generated (at line 24, column 13) for  group[T, *, one]
      % generated from assumption group.fullset_is_group
  IMP_group_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: tcc
theory: finite_groups
library: algebra
signature: nil
location: 84 0 88 999
body:
  % Subtype TCC generated (at line 38, column 82) for  S
      % expected type  S: finite_set[T]
  finite_generated_by_def_TCC1: OBLIGATION
    FORALL (G: finite_group[T, *, one], S: (nonempty?[T]), a: T):
      S = generated_by(a) AND member(a, G) IMPLIES is_finite[T](S);


decl_type: tcc
theory: finite_groups
library: algebra
signature: nil
location: 90 0 94 999
body:
  % Subtype TCC generated (at line 45, column 35) for  generated_by(a)
      % expected type  S: finite_set[T]
  generated_by_card_1_TCC1: OBLIGATION
    FORALL (G: finite_group[T, *, one], a: T):
      member(a, G) IMPLIES is_finite[T](generated_by[T, *, one](a));


decl_type: tcc
theory: finite_groups
library: algebra
signature: nil
location: 96 0 101 999
body:
  % Subtype TCC generated (at line 52, column 45) for
      % {n: posnat | a ^ n = one}
      % expected type  S: (nonempty?[posnat])
  period_TCC1: OBLIGATION
    FORALL (G: finite_group[T, *, one], a: (G)):
      nonempty?[posnat]({n: posnat | ^[T, *, one](a, n) = one});


decl_type: tcc
theory: finite_groups
library: algebra
signature: nil
location: 103 0 106 999
body:
  % Subtype TCC generated (at line 54, column 59) for  a
      % expected type  (G)
  a_hat_period_TCC1: OBLIGATION
    FORALL (G: finite_group[T, *, one], a: T): member(a, G) IMPLIES G(a);


decl_type: tcc
theory: finite_groups
library: algebra
signature: nil
location: 108 0 113 999
body:
  % Subtype TCC generated (at line 67, column 61) for  generated_by(a)
      % expected type  finite_monad[T, *, one]
  period_is_generated_order_TCC1: OBLIGATION
    FORALL (G: finite_group[T, *, one], a: T):
      member(a, G) IMPLIES
       finite_monad?[T, *, one](generated_by[T, *, one](a));


decl_type: tcc
theory: finite_cyclic_groups
library: algebra
signature: nil
location: 44 0 47 999
body:
  % Assuming TCC generated (at line 24, column 13) for
      % finite_groups[T, *, one]
      % generated from assumption finite_groups.fullset_is_group
  IMP_finite_groups_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: constant
theory: group_test
library: algebra
location: 19 2 19 63
body: nz_rational_mult: abelian_group[nzrat,*,1] = fullset[nzrat]
signature:
  abelian_group
           [nzrat,
            restrict[[numfield, numfield], [nzrat, nzrat], numfield](*),
            1]


decl_type: constant
theory: group_test
library: algebra
location: 20 2 20 64
body: pos_rational_mult: abelian_group[posrat,*,1] = fullset[posrat]
signature:
  abelian_group
           [posrat,
            restrict[[numfield, numfield], [posrat, posrat], numfield]
                (*),
            1]


decl_type: tcc
theory: group_test
library: algebra
signature: nil
location: 27 0 34 999
body:
  % Assuming TCC generated (at line 18, column 21) for
      % abelian_group
      %     [int, restrict[[numfield, numfield], [int, int], numfield](+), 0]
      % generated from assumption abelian_group.fullset_is_abelian_group
  integer_plus_TCC1: OBLIGATION
    abelian_group?
        [int, restrict[[numfield, numfield], [int, int], numfield](+), 0]
        (fullset[int]);


decl_type: tcc
theory: group_test
library: algebra
signature: nil
location: 36 0 45 999
body:
  % Assuming TCC generated (at line 19, column 21) for
      % abelian_group
      %     [nzrat,
      %      restrict[[numfield, numfield], [nzrat, nzrat], numfield](*), 1]
      % generated from assumption abelian_group.fullset_is_abelian_group
  nz_rational_mult_TCC1: OBLIGATION
    abelian_group?
        [nzrat, restrict[[numfield, numfield], [nzrat, nzrat], numfield](*),
         1]
        (fullset[nzrat]);


decl_type: tcc
theory: group_test
library: algebra
signature: nil
location: 47 0 56 999
body:
  % Assuming TCC generated (at line 20, column 21) for
      % abelian_group
      %     [posrat,
      %      restrict[[numfield, numfield], [posrat, posrat], numfield](*), 1]
      % generated from assumption abelian_group.fullset_is_abelian_group
  pos_rational_mult_TCC1: OBLIGATION
    abelian_group?
        [posrat,
         restrict[[numfield, numfield], [posrat, posrat], numfield](*), 1]
        (fullset[posrat]);


decl_type: tcc
theory: symmetric_groups
library: algebra
signature: nil
location: 36 0 42 999
body:
  % Subtype TCC generated (at line 17, column 29) for
      % restrict[[[(S) -> (S)], [(S) -> (S)]], [perm, perm], [(S) -> (S)]]
      %     (function_props[(S), (S), (S)].o)
      % expected type  [[perm, perm] -> perm]
  op_TCC1: OBLIGATION
    FORALL (x1: [perm, perm]):
      bijective?[(S), (S)](function_props[(S), (S), (S)].o(x1));


decl_type: formula
theory: subgroups
library: algebra
signature: nil
location: 24 3 26 47
body:
     pg64_1: LEMMA 
        subgroup?(A,G) AND subgroup?(B,G) 
           IMPLIES subgroup?(intersection(A,B),G)


decl_type: tcc
theory: subgroups
library: algebra
signature: nil
location: 38 0 40 999
body:
  % Assuming TCC generated (at line 17, column 10) for  group[T, *, one]
      % generated from assumption group.fullset_is_group
  G_TCC1: OBLIGATION group?[T, *, one](fullset[T]);


decl_type: tcc
theory: subgroups
library: algebra
signature: nil
location: 42 0 45 999
body:
  % Subtype TCC generated (at line 31, column 42) for  center(G)
      % expected type  group[T, *, one]
  center_normal_TCC1: OBLIGATION
    FORALL (G: group[T, *, one]): group?[T, *, one](center[T, *, one](G));


decl_type: judgement
theory: cyclic_monoid
library: algebra
signature: commutative_monoid[T, *, one]
location: 34 3 35 77
body:
     cyclic_monoid_is_commutative_monoid:
                          JUDGEMENT cyclic_monoid SUBTYPE_OF commutative_monoid


decl_type: tcc
theory: cyclic_monoid
library: algebra
signature: nil
location: 42 0 44 999
body:
  % Assuming TCC generated (at line 22, column 13) for  monoid[T, *, one]
      % generated from assumption monoid.fullset_is_monoid
  IMP_monoid_TCC1: OBLIGATION monoid?[T, *, one](fullset[T]);


decl_type: tcc
theory: cyclic_monoid
library: algebra
signature: nil
location: 46 0 48 999
body:
  % Subtype TCC generated (at line 24, column 54) for  fullset[T]
      % expected type  cyclic_monoid
  cyclic_monoid_TCC1: OBLIGATION cyclic_monoid?[T, *, one](fullset[T]);


decl_type: tcc
theory: cyclic_monoid
library: algebra
signature: nil
location: 50 0 53 999
body:
  % Judgement subtype TCC generated (at line 32, column 38) for  x
      % expected type  monoid[T, *, one]
  cyclic_monoid_is_monoid: OBLIGATION
    FORALL (x: cyclic_monoid): monoid?[T, *, one](x);


decl_type: tcc
theory: cyclic_monoid
library: algebra
signature: nil
location: 55 0 58 999
body:
  % Judgement subtype TCC generated (at line 35, column 34) for  x
      % expected type  commutative_monoid[T, *, one]
  cyclic_monoid_is_commutative_monoid: OBLIGATION
    FORALL (x: cyclic_monoid): commutative_monoid?[T, *, one](x);


decl_type: judgement
theory: commutative_groupoid
library: algebra
signature: groupoid[T, *]
location: 32 3 33 79
body:
     commutative_groupoid_is_groupoid:
                               JUDGEMENT commutative_groupoid SUBTYPE_OF groupoid


decl_type: tcc
theory: commutative_groupoid
library: algebra
signature: nil
location: 40 0 43 999
body:
  % Subtype TCC generated (at line 25, column 68) for  fullset[T]
      % expected type  commutative_groupoid
  commutative_groupoid_TCC1: OBLIGATION
    commutative_groupoid?[T, *](fullset[T]);


decl_type: tcc
theory: commutative_groupoid
library: algebra
signature: nil
location: 45 0 48 999
body:
  % Judgement subtype TCC generated (at line 33, column 39) for  x
      % expected type  groupoid[T, *]
  commutative_groupoid_is_groupoid: OBLIGATION
    FORALL (x: commutative_groupoid): star_closed?[T, *](x);


decl_type: type
theory: commutative_semigroup
library: algebra
signature: nil
location: 25 3 26 79
body:
     commutative_semigroup: TYPE+ = (commutative_semigroup?)
                                                            CONTAINING fullset[T]


decl_type: judgement
theory: commutative_semigroup
library: algebra
signature: semigroup[T, *]
location: 28 3 29 67
body:
     commutative_semigroup_is_semigroup:
                 JUDGEMENT commutative_semigroup SUBTYPE_OF semigroup


decl_type: judgement
theory: commutative_semigroup
library: algebra
signature: commutative_groupoid[T, *]
location: 30 3 31 78
body:
     commutative_semigroup_is_commutative_groupoid:
                 JUDGEMENT commutative_semigroup SUBTYPE_OF commutative_groupoid


decl_type: tcc
theory: commutative_semigroup
library: algebra
signature: nil
location: 38 0 42 999
body:
  % Assuming TCC generated (at line 23, column 28) for
      % commutative_groupoid[T, *]
      % generated from assumption commutative_groupoid.fullset_is_commutative_groupoid
  IMP_commutative_groupoid_TCC1: OBLIGATION
    commutative_groupoid?[T, *](fullset[T]);


decl_type: tcc
theory: commutative_semigroup
library: algebra
signature: nil
location: 44 0 49 999
body:
  % Assuming TCC generated (at line 23, column 55) for  semigroup[T, *]
      % generated from assumption semigroup.fullset_is_semigroup
  IMP_semigroup_TCC1: OBLIGATION
    star_closed?[T, *](fullset[T]) AND
     associative?[(fullset[T])]
         (restrict[[T, T], [(fullset[T]), (fullset[T])], T](*));


decl_type: tcc
theory: commutative_semigroup
library: algebra
signature: nil
location: 51 0 54 999
body:
  % Subtype TCC generated (at line 26, column 69) for  fullset[T]
      % expected type  commutative_semigroup
  commutative_semigroup_TCC1: OBLIGATION
    commutative_semigroup?[T, *](fullset[T]);


decl_type: tcc
theory: commutative_semigroup
library: algebra
signature: nil
location: 56 0 61 999
body:
  % Judgement subtype TCC generated (at line 29, column 25) for  x
      % expected type  semigroup[T, *]
  commutative_semigroup_is_semigroup: OBLIGATION
    FORALL (x: commutative_semigroup):
      star_closed?[T, *](x) AND
       associative?[(x)](restrict[[T, T], [(x), (x)], T](*));


decl_type: tcc
theory: commutative_semigroup
library: algebra
signature: nil
location: 63 0 66 999
body:
  % Judgement subtype TCC generated (at line 31, column 25) for  x
      % expected type  commutative_groupoid[T, *]
  commutative_semigroup_is_commutative_groupoid: OBLIGATION
    FORALL (x: commutative_semigroup): commutative_groupoid?[T, *](x);


decl_type: formula
theory: csequence_props
library: co_structures
signature: nil
location: 32 2 34 63
body:
    has_length_injective: THEOREM
      FORALL cseq, n, m:
        has_length(cseq, n) AND has_length(cseq, m) IMPLIES n = m


decl_type: formula
theory: csequence_props
library: co_structures
signature: nil
location: 98 0 101 999
body:
  is_finite_weak_induction: AXIOM
    FORALL (P: [csequence[T] -> boolean]):
      (FORALL (cseq): empty?(cseq) OR P(rest(cseq)) IMPLIES P(cseq)) IMPLIES
       (FORALL (cseq): is_finite(cseq) IMPLIES P(cseq));


decl_type: formula
theory: csequence_props
library: co_structures
signature: nil
location: 103 0 108 999
body:
  is_finite_induction: AXIOM
    FORALL (P: [csequence[T] -> boolean]):
      (FORALL (cseq):
         empty?(cseq) OR is_finite(rest(cseq)) AND P(rest(cseq)) IMPLIES
          P(cseq))
       IMPLIES (FORALL (cseq): is_finite(cseq) IMPLIES P(cseq));


decl_type: formula
theory: csequence_props
library: co_structures
signature: nil
location: 83 2 86 20
body:
    some_implies: THEOREM
      FORALL cseq, p, q:
        (FORALL t: pred_IMPLIES(p, q)(t)) AND some(p)(cseq) IMPLIES
         some(q)(cseq)


decl_type: formula
theory: csequence_props
library: co_structures
signature: nil
location: 88 2 91 21
body:
    every_implies: THEOREM
      FORALL cseq, p, q:
        (FORALL t: pred_IMPLIES(p, q)(t)) AND every(p)(cseq) IMPLIES
         every(q)(cseq)


decl_type: function
theory: csequence_props
library: co_structures
signature: [[csequence[T], nat] -> bool]
location: 26 2 30 14
body:
    has_length(cseq, n): RECURSIVE bool =
      IF empty?(cseq) THEN n = 0
      ELSE n > 0 AND has_length(rest(cseq), n - 1)
      ENDIF
       MEASURE n


decl_type: tcc
theory: csequence_props
library: co_structures
signature: nil
location: 110 0 114 999
body:
  % Subtype TCC generated (at line 28, column 35) for  cseq
      % expected type  (nonempty?)
  has_length_TCC1: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      n > 0 AND NOT empty?(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_props
library: co_structures
signature: nil
location: 116 0 120 999
body:
  % Subtype TCC generated (at line 28, column 42) for  n - 1
      % expected type  nat
  has_length_TCC2: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      n > 0 AND NOT empty?(cseq) IMPLIES n - 1 >= 0;


decl_type: tcc
theory: csequence_props
library: co_structures
signature: nil
location: 122 0 126 999
body:
  % Termination TCC generated (at line 28, column 19) for
      % has_length(rest(cseq), n - 1)
  has_length_TCC3: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      n > 0 AND NOT empty?(cseq) IMPLIES n - 1 < n;


decl_type: tcc
theory: csequence_props
library: co_structures
signature: nil
location: 128 0 131 999
body:
  % Subtype TCC generated (at line 37, column 67) for  cseq
      % expected type  (nonempty?)
  is_finite_TCC1: OBLIGATION
    FORALL (cseq: csequence[T]): NOT empty?(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_props
library: co_structures
signature: nil
location: 133 0 135 999
body:
  % Subtype TCC generated (at line 47, column 51) for  empty_cseq
      % expected type  finite_csequence
  finite_csequence_TCC1: OBLIGATION is_finite(empty_cseq[T]);


decl_type: tcc
theory: csequence_props
library: co_structures
signature: nil
location: 137 0 140 999
body:
  % Judgement subtype TCC generated (at line 61, column 4) for  x
      % expected type  finite_csequence
  empty_csequence_is_finite: OBLIGATION
    FORALL (x: empty_csequence): is_finite(x);


decl_type: tcc
theory: csequence_props
library: co_structures
signature: nil
location: 142 0 145 999
body:
  % Judgement subtype TCC generated (at line 64, column 4) for  x
      % expected type  nonempty_csequence
  infinite_csequence_is_nonempty: OBLIGATION
    FORALL (x: infinite_csequence): nonempty?[T](x);


decl_type: formula
theory: csequence_length
library: co_structures
signature: nil
location: 35 2 36 74
body:
    length_nonempty?_rew: COROLLARY
      FORALL cseq: nonempty?(cseq) IFF is_infinite(cseq) OR length(cseq) > 0


decl_type: function
theory: csequence_length
library: co_structures
signature: [fseq: finite_csequence[T] -> {n | has_length(fseq, n)}]
location: 25 2 27 46
body:
    length(fseq): RECURSIVE {n | has_length(fseq, n)} =
      IF empty?(fseq) THEN 0 ELSE 1 + length(rest(fseq)) ENDIF
       MEASURE choose({n | has_length(fseq, n)})


decl_type: tcc
theory: csequence_length
library: co_structures
signature: nil
location: 45 0 50 999
body:
  % Subtype TCC generated (at line 27, column 20) for
      % {n | has_length(fseq, n)}
      % expected type  p: (nonempty?[nat])
  length_TCC1: OBLIGATION
    FORALL (fseq: finite_csequence[T]):
      nonempty?[nat]({n | has_length[T](fseq, n)});


decl_type: tcc
theory: csequence_length
library: co_structures
signature: nil
location: 52 0 56 999
body:
  % Subtype TCC generated (at line 26, column 25) for  0
      % expected type  {n | has_length(fseq, n)}
  length_TCC2: OBLIGATION
    FORALL (fseq: finite_csequence[T]):
      empty?(fseq) IMPLIES has_length[T](fseq, 0);


decl_type: tcc
theory: csequence_length
library: co_structures
signature: nil
location: 58 0 62 999
body:
  % Subtype TCC generated (at line 26, column 48) for  fseq
      % expected type  (nonempty?[T])
  length_TCC3: OBLIGATION
    FORALL (fseq: finite_csequence[T]):
      NOT empty?(fseq) IMPLIES nonempty?[T](fseq);


decl_type: tcc
theory: csequence_length
library: co_structures
signature: nil
location: 64 0 68 999
body:
  % Subtype TCC generated (at line 26, column 43) for  rest(fseq)
      % expected type  fseq: finite_csequence[T]
  length_TCC4: OBLIGATION
    FORALL (fseq: finite_csequence[T]):
      NOT empty?(fseq) IMPLIES is_finite[T](rest[T](fseq));


decl_type: tcc
theory: csequence_length
library: co_structures
signature: nil
location: 70 0 75 999
body:
  % Termination TCC generated (at line 26, column 36) for  length(rest(fseq))
  length_TCC5: OBLIGATION
    FORALL (fseq: finite_csequence[T]):
      NOT empty?(fseq) IMPLIES
       choose[nat]({n | has_length[T](rest[T](fseq), n)}) <
        choose[nat]({n | has_length[T](fseq, n)});


decl_type: tcc
theory: csequence_length
library: co_structures
signature: nil
location: 77 0 87 999
body:
  % Subtype TCC generated (at line 26, column 32) for  1 + length(rest(fseq))
      % expected type  {n | has_length(fseq, n)}
  length_TCC6: OBLIGATION
    FORALL (fseq: finite_csequence[T],
            v:
              [fseq1:
                 {z: finite_csequence[T] |
                          choose({n | has_length(z, n)}) <
                           choose({n | has_length(fseq, n)})} ->
                 {n | has_length(fseq1, n)}]):
      NOT empty?(fseq) IMPLIES has_length[T](fseq, 1 + v(rest[T](fseq)));


decl_type: tcc
theory: csequence_length
library: co_structures
signature: nil
location: 89 0 91 999
body:
  % Subtype TCC generated (at line 38, column 44) for  rest(nfseq)
      % expected type  fseq: finite_csequence[T]
  length_rest_TCC1: OBLIGATION FORALL (nfseq): is_finite[T](rest[T](nfseq));


decl_type: formula
theory: csequence_length_comp
library: co_structures
signature: nil
location: 51 2 53 61
body:
    length_lt_le: THEOREM
      FORALL cseq1, cseq2:
        length_lt(cseq1, cseq2) IMPLIES length_le(cseq1, cseq2)


decl_type: formula
theory: csequence_length_comp
library: co_structures
signature: nil
location: 55 2 57 61
body:
    length_gt_ge: THEOREM
      FORALL cseq1, cseq2:
        length_gt(cseq1, cseq2) IMPLIES length_ge(cseq1, cseq2)


decl_type: formula
theory: csequence_length_comp
library: co_structures
signature: nil
location: 59 2 61 61
body:
    length_eq_le: THEOREM
      FORALL cseq1, cseq2:
        length_eq(cseq1, cseq2) IMPLIES length_le(cseq1, cseq2)


decl_type: formula
theory: csequence_length_comp
library: co_structures
signature: nil
location: 63 2 65 61
body:
    length_eq_ge: THEOREM
      FORALL cseq1, cseq2:
        length_eq(cseq1, cseq2) IMPLIES length_ge(cseq1, cseq2)


decl_type: formula
theory: csequence_length_comp
library: co_structures
signature: nil
location: 67 2 69 65
body:
    length_lt_neq: THEOREM
      FORALL cseq1, cseq2:
        length_lt(cseq1, cseq2) IMPLIES NOT length_eq(cseq1, cseq2)


decl_type: formula
theory: csequence_length_comp
library: co_structures
signature: nil
location: 71 2 73 65
body:
    length_gt_neq: THEOREM
      FORALL cseq1, cseq2:
        length_gt(cseq1, cseq2) IMPLIES NOT length_eq(cseq1, cseq2)


decl_type: formula
theory: csequence_length_comp
library: co_structures
signature: nil
location: 75 2 77 71
body:
    length_eq_empty: THEOREM
      FORALL cseq1, cseq2:
        length_eq(cseq1, cseq2) IMPLIES (empty?(cseq1) IFF empty?(cseq2))


decl_type: formula
theory: csequence_length_comp
library: co_structures
signature: nil
location: 79 2 81 69
body:
    length_eq_rest: THEOREM
      FORALL nseq1, nseq2:
        length_eq(nseq1, nseq2) IFF length_eq(rest(nseq1), rest(nseq2))


decl_type: function
theory: csequence_length_comp
library: co_structures
signature: [[csequence[T1], csequence[T2]] -> bool]
location: 30 2 32 63
body:
    length_lt(cseq1, cseq2): bool =
        is_finite(cseq1) AND
         (is_finite(cseq2) IMPLIES length(cseq1) < length(cseq2))


decl_type: function
theory: csequence_length_comp
library: co_structures
signature: [[csequence[T1], csequence[T2]] -> bool]
location: 34 2 36 58
body:
    length_le(cseq1, cseq2): bool =
        is_finite(cseq2) IMPLIES
         is_finite(cseq1) AND length(cseq1) <= length(cseq2)


decl_type: function
theory: csequence_length_comp
library: co_structures
signature: [[csequence[T1], csequence[T2]] -> bool]
location: 38 2 41 60
body:
    length_eq(cseq1, cseq2): bool =
        (is_infinite(cseq1) AND is_infinite(cseq2)) OR
         (is_finite(cseq1) AND
           is_finite(cseq2) AND length(cseq1) = length(cseq2))


decl_type: function
theory: csequence_length_comp
library: co_structures
signature: [[csequence[T1], csequence[T2]] -> bool]
location: 43 2 45 58
body:
    length_ge(cseq1, cseq2): bool =
        is_finite(cseq1) IMPLIES
         is_finite(cseq2) AND length(cseq1) >= length(cseq2)


decl_type: function
theory: csequence_length_comp
library: co_structures
signature: [[csequence[T1], csequence[T2]] -> bool]
location: 47 2 49 63
body:
    length_gt(cseq1, cseq2): bool =
        is_finite(cseq2) AND
         (is_finite(cseq1) IMPLIES length(cseq1) > length(cseq2))


decl_type: formula
theory: csequence_nth
library: co_structures
signature: nil
location: 51 2 53 68
body:
    index?_prop: THEOREM
      FORALL cseq, n:
        index?(cseq)(n) IFF (is_finite(cseq) IMPLIES n < length(cseq))


decl_type: formula
theory: csequence_nth
library: co_structures
signature: nil
location: 62 2 66 28
body:
    nth_extensionality: THEOREM
      FORALL cseq1, cseq2:
        index?(cseq1) = index?(cseq2) AND
         (FORALL (n: indexes(cseq1)): nth(cseq1, n) = nth(cseq2, n))
         IMPLIES cseq1 = cseq2


decl_type: formula
theory: csequence_nth
library: co_structures
signature: nil
location: 68 2 70 69
body:
    nth_every: THEOREM
      FORALL cseq, p:
        every(p)(cseq) IFF (FORALL (i: indexes(cseq)): p(nth(cseq, i)))


decl_type: formula
theory: csequence_nth
library: co_structures
signature: nil
location: 72 2 74 68
body:
    nth_some: THEOREM
      FORALL cseq, p:
        some(p)(cseq) IFF (EXISTS (i: indexes(cseq)): p(nth(cseq, i)))


decl_type: function
theory: csequence_nth
library: co_structures
signature: [csequence[T] -> [nat -> bool]]
location: 29 2 31 14
body:
    index?(cseq)(n): RECURSIVE bool =
      nonempty?(cseq) AND (n = 0 OR index?(rest(cseq))(n - 1))
       MEASURE n


decl_type: function
theory: csequence_nth
library: co_structures
signature: [[cseq: csequence[T], indexes(cseq)] -> T]
location: 58 2 60 14
body:
    nth(cseq, (n: indexes(cseq))): RECURSIVE T =
      IF n = 0 THEN first(cseq) ELSE nth(rest(cseq), n - 1) ENDIF
       MEASURE n


decl_type: tcc
theory: csequence_nth
library: co_structures
signature: nil
location: 87 0 91 999
body:
  % Subtype TCC generated (at line 30, column 53) for  n - 1
      % expected type  nat
  index?_TCC1: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      NOT n = 0 AND nonempty?(cseq) IMPLIES n - 1 >= 0;


decl_type: tcc
theory: csequence_nth
library: co_structures
signature: nil
location: 93 0 97 999
body:
  % Termination TCC generated (at line 30, column 34) for
      % index?(rest(cseq))(n - 1)
  index?_TCC2: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      NOT n = 0 AND nonempty?(cseq) IMPLIES n - 1 < n;


decl_type: tcc
theory: csequence_nth
library: co_structures
signature: nil
location: 99 0 103 999
body:
  % Subtype TCC generated (at line 59, column 24) for  cseq
      % expected type  (nonempty?[T])
  nth_TCC1: OBLIGATION
    FORALL (cseq: csequence[T], (n: indexes(cseq))):
      n = 0 IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_nth
library: co_structures
signature: nil
location: 105 0 109 999
body:
  % Subtype TCC generated (at line 59, column 44) for  cseq
      % expected type  (nonempty?[T])
  nth_TCC2: OBLIGATION
    FORALL (cseq: csequence[T], (n: indexes(cseq))):
      NOT n = 0 IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_nth
library: co_structures
signature: nil
location: 111 0 115 999
body:
  % Subtype TCC generated (at line 59, column 51) for  n - 1
      % expected type  indexes(rest(cseq))
  nth_TCC3: OBLIGATION
    FORALL (cseq: csequence[T], (n: indexes(cseq))):
      NOT n = 0 IMPLIES n - 1 >= 0 AND index?(rest[T](cseq))(n - 1);


decl_type: tcc
theory: csequence_nth
library: co_structures
signature: nil
location: 117 0 121 999
body:
  % Termination TCC generated (at line 59, column 35) for
      % nth(rest(cseq), n - 1)
  nth_TCC4: OBLIGATION
    FORALL (cseq: csequence[T], (n: indexes(cseq))):
      NOT n = 0 IMPLIES n - 1 < n;


decl_type: tcc
theory: csequence_nth
library: co_structures
signature: nil
location: 123 0 128 999
body:
  % Subtype TCC generated (at line 65, column 63) for  n
      % expected type  indexes(cseq2)
  nth_extensionality_TCC1: OBLIGATION
    FORALL (cseq1, cseq2):
      index?(cseq1) = index?(cseq2) IMPLIES
       (FORALL (n: indexes(cseq1)): index?(cseq2)(n));


decl_type: tcc
theory: csequence_nth
library: co_structures
signature: nil
location: 130 0 134 999
body:
  % Subtype TCC generated (at line 77, column 30) for  length(nfseq) - 1
      % expected type  indexes(nfseq)
  last_TCC1: OBLIGATION
    FORALL (nfseq: nonempty_finite_csequence[T]):
      length[T](nfseq) - 1 >= 0 AND index?(nfseq)(length[T](nfseq) - 1);


decl_type: tcc
theory: csequence_nth
library: co_structures
signature: nil
location: 136 0 141 999
body:
  % Subtype TCC generated (at line 80, column 46) for  rest(nfseq)
      % expected type  nonempty_finite_csequence[T]
  last_rest_TCC1: OBLIGATION
    FORALL (nfseq):
      NOT empty?(rest(nfseq)) IMPLIES
       is_finite[T](rest[T](nfseq)) AND nonempty?[T](rest[T](nfseq));


decl_type: formula
theory: csequence_zip
library: co_structures
signature: nil
location: 58 2 60 66
body:
    zip_empty: THEOREM
      FORALL cseq1, cseq2:
        empty?(zip(cseq1, cseq2)) IFF empty?(cseq1) OR empty?(cseq2)


decl_type: formula
theory: csequence_zip
library: co_structures
signature: nil
location: 62 2 64 61
body:
    zip_first: THEOREM
      FORALL nseq1, nseq2:
        first(zip(nseq1, nseq2)) = (first(nseq1), first(nseq2))


decl_type: formula
theory: csequence_zip
library: co_structures
signature: nil
location: 66 2 68 61
body:
    zip_rest: THEOREM
      FORALL nseq1, nseq2:
        rest(zip(nseq1, nseq2)) = zip(rest(nseq1), rest(nseq2))


decl_type: formula
theory: csequence_zip
library: co_structures
signature: nil
location: 70 2 72 72
body:
    zip_add: THEOREM
      FORALL cseq1, cseq2, (a: T1), (b: T2):
        zip(add(a, cseq1), add(b, cseq2)) = add((a, b), zip(cseq1, cseq2))


decl_type: formula
theory: csequence_zip
library: co_structures
signature: nil
location: 74 2 83 13
body:
    zip_length: THEOREM
      FORALL cseq1, cseq2:
        is_finite(zip(cseq1, cseq2)) IMPLIES
         length(zip(cseq1, cseq2)) =
          IF is_finite(cseq1)
            THEN IF is_finite(cseq2) THEN min(length(cseq1), length(cseq2))
                 ELSE length(cseq1)
                 ENDIF
          ELSE length(cseq2)
          ENDIF


decl_type: formula
theory: csequence_zip
library: co_structures
signature: nil
location: 85 2 87 76
body:
    zip_index: THEOREM
      FORALL cseq1, cseq2, n:
        index?(zip(cseq1, cseq2))(n) IFF index?(cseq1)(n) AND index?(cseq2)(n)


decl_type: formula
theory: csequence_zip
library: co_structures
signature: nil
location: 89 2 91 64
body:
    zip_nth: THEOREM
      FORALL cseq1, cseq2, (n: indexes(zip(cseq1, cseq2))):
        nth(zip(cseq1, cseq2), n) = (nth(cseq1, n), nth(cseq2, n))


decl_type: formula
theory: csequence_zip
library: co_structures
signature: nil
location: 93 2 102 15
body:
    zip_last: THEOREM
      FORALL nseq1, nseq2:
        is_finite(zip(nseq1, nseq2)) IMPLIES
         last(zip(nseq1, nseq2)) =
          COND length_lt(nseq1, nseq2) ->
                 (last(nseq1), nth(nseq2, length(nseq1) - 1)),
               length_gt(nseq1, nseq2) ->
                 (nth(nseq1, length(nseq2) - 1), last(nseq2)),
               ELSE -> (last(nseq1), last(nseq2))
          ENDCOND


decl_type: formula
theory: csequence_zip
library: co_structures
signature: nil
location: 104 2 108 46
body:
    zip_extensionality: THEOREM
      FORALL (cseq1, cseq3: csequence[T1]), (cseq2, cseq4: csequence[T2]):
        length_eq(cseq1, cseq2) AND
         length_eq(cseq3, cseq4) AND zip(cseq1, cseq2) = zip(cseq3, cseq4)
         IMPLIES cseq1 = cseq3 AND cseq2 = cseq4


decl_type: formula
theory: csequence_zip
library: co_structures
signature: nil
location: 110 2 122 14
body:
    zip_some: THEOREM
      FORALL cseq1, cseq2, p1, p2:
        some(LAMBDA t: p1(t`1) OR p2(t`2))(zip(cseq1, cseq2)) IFF
         COND length_lt(cseq1, cseq2) ->
                some(p1)(cseq1) OR
                 (EXISTS (i: indexes(cseq2)):
                    i < length(cseq1) AND p2(nth(cseq2, i))),
              length_gt(cseq1, cseq2) ->
                (EXISTS (i: indexes(cseq1)):
                   i < length(cseq2) AND p1(nth(cseq1, i)))
                 OR some(p2)(cseq2),
              ELSE -> some(p1)(cseq1) OR some(p2)(cseq2)
         ENDCOND


decl_type: formula
theory: csequence_zip
library: co_structures
signature: nil
location: 124 2 136 14
body:
    zip_every: THEOREM
      FORALL cseq1, cseq2, p1, p2:
        every(LAMBDA t: p1(t`1) AND p2(t`2))(zip(cseq1, cseq2)) IFF
         COND length_lt(cseq1, cseq2) ->
                every(p1)(cseq1) AND
                 (FORALL (i: indexes(cseq2)):
                    i < length(cseq1) IMPLIES p2(nth(cseq2, i))),
              length_gt(cseq1, cseq2) ->
                (FORALL (i: indexes(cseq1)):
                   i < length(cseq2) IMPLIES p1(nth(cseq1, i)))
                 AND every(p2)(cseq2),
              ELSE -> every(p1)(cseq1) AND every(p2)(cseq2)
         ENDCOND


decl_type: function
theory: csequence_zip
library: co_structures
location: 39 2 44 11
signature:
  [[csequence[T1], csequence[T2]] ->
          csequence_struct[[T1, T2], [csequence[T1], csequence[T2]]]]

body:
    zip_struct(state):
          csequence_struct[[T1, T2], [csequence[T1], csequence[T2]]] =
        IF empty?(state`1) OR empty?(state`2) THEN inj_empty_cseq
        ELSE inj_add((first(state`1), first(state`2)),
                     (rest(state`1), rest(state`2)))
        ENDIF


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 143 0 148 999
body:
  % Subtype TCC generated (at line 42, column 26) for  state`1
      % expected type  (nonempty?[T1])
  zip_struct_TCC1: OBLIGATION
    FORALL (state: [csequence[T1], csequence[T2]]):
      NOT empty?(state`1) AND NOT empty?(state`2) IMPLIES
       nonempty?[T1](state`1);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 150 0 155 999
body:
  % Subtype TCC generated (at line 42, column 42) for  state`2
      % expected type  (nonempty?[T2])
  zip_struct_TCC2: OBLIGATION
    FORALL (state: [csequence[T1], csequence[T2]]):
      NOT empty?(state`1) AND NOT empty?(state`2) IMPLIES
       nonempty?[T2](state`2);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 157 0 161 999
body:
  % Judgement subtype TCC generated (at line 49, column 25) for
      % zip(fseq1, cseq2)
      % expected type  finite_csequence[[T1, T2]]
  zip_finite1: OBLIGATION
    FORALL (cseq2, fseq1): is_finite[[T1, T2]](zip(fseq1, cseq2));


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 163 0 167 999
body:
  % Judgement subtype TCC generated (at line 50, column 25) for
      % zip(cseq1, fseq2)
      % expected type  finite_csequence[[T1, T2]]
  zip_finite2: OBLIGATION
    FORALL (cseq1, fseq2): is_finite[[T1, T2]](zip(cseq1, fseq2));


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 169 0 173 999
body:
  % Judgement subtype TCC generated (at line 53, column 4) for
      % zip(iseq1, iseq2)
      % expected type  infinite_csequence[[T1, T2]]
  zip_infinite: OBLIGATION
    FORALL (iseq1, iseq2): NOT is_finite[[T1, T2]](zip(iseq1, iseq2));


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 175 0 179 999
body:
  % Judgement subtype TCC generated (at line 56, column 5) for
      % zip(nseq1, nseq2)
      % expected type  nonempty_csequence[[T1, T2]]
  zip_nonempty: OBLIGATION
    FORALL (nseq1, nseq2): nonempty?[[T1, T2]](zip(nseq1, nseq2));


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 181 0 186 999
body:
  % Subtype TCC generated (at line 82, column 20) for  cseq2
      % expected type  fseq: finite_csequence[T2]
  zip_length_TCC1: OBLIGATION
    FORALL (cseq1, cseq2):
      NOT is_finite(cseq1) AND is_finite(zip(cseq1, cseq2)) IMPLIES
       is_finite[T2](cseq2);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 188 0 192 999
body:
  % Subtype TCC generated (at line 91, column 46) for  n
      % expected type  indexes[T1](cseq1)
  zip_nth_TCC1: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[[T1, T2]](zip(cseq1, cseq2))):
      index?[T1](cseq1)(n);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 194 0 198 999
body:
  % Subtype TCC generated (at line 91, column 61) for  n
      % expected type  indexes[T2](cseq2)
  zip_nth_TCC2: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[[T1, T2]](zip(cseq1, cseq2))):
      index?[T2](cseq2)(n);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 200 0 205 999
body:
  % Subtype TCC generated (at line 98, column 21) for  nseq1
      % expected type  nonempty_finite_csequence[T1]
  zip_last_TCC1: OBLIGATION
    FORALL (nseq1, nseq2):
      length_lt(nseq1, nseq2) AND is_finite(zip(nseq1, nseq2)) IMPLIES
       is_finite[T1](nseq1) AND nonempty?[T1](nseq1);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 207 0 212 999
body:
  % Subtype TCC generated (at line 98, column 47) for  nseq1
      % expected type  fseq: finite_csequence[T1]
  zip_last_TCC2: OBLIGATION
    FORALL (nseq1, nseq2):
      length_lt(nseq1, nseq2) AND is_finite(zip(nseq1, nseq2)) IMPLIES
       is_finite[T1](nseq1);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 214 0 220 999
body:
  % Subtype TCC generated (at line 98, column 40) for  length(nseq1) - 1
      % expected type  indexes[T2](nseq2)
  zip_last_TCC3: OBLIGATION
    FORALL (nseq1, nseq2):
      length_lt(nseq1, nseq2) AND is_finite(zip(nseq1, nseq2)) IMPLIES
       length[T1](nseq1) - 1 >= 0 AND
        index?[T2](nseq2)(length[T1](nseq1) - 1);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 222 0 228 999
body:
  % Subtype TCC generated (at line 100, column 34) for  nseq2
      % expected type  fseq: finite_csequence[T2]
  zip_last_TCC4: OBLIGATION
    FORALL (nseq1, nseq2):
      length_gt(nseq1, nseq2) AND
       NOT length_lt(nseq1, nseq2) AND is_finite(zip(nseq1, nseq2))
       IMPLIES is_finite[T2](nseq2);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 230 0 238 999
body:
  % Subtype TCC generated (at line 100, column 27) for  length(nseq2) - 1
      % expected type  indexes[T1](nseq1)
  zip_last_TCC5: OBLIGATION
    FORALL (nseq1, nseq2):
      length_gt(nseq1, nseq2) AND
       NOT length_lt(nseq1, nseq2) AND is_finite(zip(nseq1, nseq2))
       IMPLIES
       length[T2](nseq2) - 1 >= 0 AND
        index?[T1](nseq1)(length[T2](nseq2) - 1);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 240 0 246 999
body:
  % Subtype TCC generated (at line 100, column 52) for  nseq2
      % expected type  nonempty_finite_csequence[T2]
  zip_last_TCC6: OBLIGATION
    FORALL (nseq1, nseq2):
      length_gt(nseq1, nseq2) AND
       NOT length_lt(nseq1, nseq2) AND is_finite(zip(nseq1, nseq2))
       IMPLIES is_finite[T2](nseq2) AND nonempty?[T2](nseq2);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 248 0 254 999
body:
  % Subtype TCC generated (at line 101, column 27) for  nseq1
      % expected type  nonempty_finite_csequence[T1]
  zip_last_TCC7: OBLIGATION
    FORALL (nseq1, nseq2):
      NOT length_gt(nseq1, nseq2) AND
       NOT length_lt(nseq1, nseq2) AND is_finite(zip(nseq1, nseq2))
       IMPLIES is_finite[T1](nseq1) AND nonempty?[T1](nseq1);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 256 0 262 999
body:
  % Subtype TCC generated (at line 101, column 40) for  nseq2
      % expected type  nonempty_finite_csequence[T2]
  zip_last_TCC8: OBLIGATION
    FORALL (nseq1, nseq2):
      NOT length_gt(nseq1, nseq2) AND
       NOT length_lt(nseq1, nseq2) AND is_finite(zip(nseq1, nseq2))
       IMPLIES is_finite[T2](nseq2) AND nonempty?[T2](nseq2);


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 264 0 275 999
body:
  % Disjointness TCC generated (at line 97, column 8) for
      % COND length_lt(nseq1, nseq2) ->
      %        (last(nseq1), nth(nseq2, length(nseq1) - 1)),
      %      length_gt(nseq1, nseq2) ->
      %        (nth(nseq1, length(nseq2) - 1), last(nseq2)),
      %      ELSE -> (last(nseq1), last(nseq2))
      % ENDCOND
  zip_last_TCC9: OBLIGATION
    FORALL (nseq1, nseq2):
      is_finite(zip(nseq1, nseq2)) IMPLIES
       NOT (length_lt[T1, T2](nseq1, nseq2) AND
             length_gt[T1, T2](nseq1, nseq2));


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 277 0 282 999
body:
  % Subtype TCC generated (at line 116, column 29) for  cseq1
      % expected type  fseq: finite_csequence[T1]
  zip_some_TCC1: OBLIGATION
    FORALL (cseq1, cseq2, p1):
      NOT some(p1)(cseq1) AND length_lt(cseq1, cseq2) IMPLIES
       (FORALL (i: indexes[T2](cseq2)): is_finite[T1](cseq1));


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 284 0 289 999
body:
  % Subtype TCC generated (at line 119, column 28) for  cseq2
      % expected type  fseq: finite_csequence[T2]
  zip_some_TCC2: OBLIGATION
    FORALL (cseq1, cseq2):
      length_gt(cseq1, cseq2) AND NOT length_lt(cseq1, cseq2) IMPLIES
       (FORALL (i: indexes[T1](cseq1)): is_finite[T2](cseq2));


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 291 0 305 999
body:
  % Disjointness TCC generated (at line 113, column 7) for
      % COND length_lt(cseq1, cseq2) ->
      %        some(p1)(cseq1) OR
      %         (EXISTS (i: indexes(cseq2)):
      %            i < length(cseq1) AND p2(nth(cseq2, i))),
      %      length_gt(cseq1, cseq2) ->
      %        (EXISTS (i: indexes(cseq1)):
      %           i < length(cseq2) AND p1(nth(cseq1, i)))
      %         OR some(p2)(cseq2),
      %      ELSE -> some(p1)(cseq1) OR some(p2)(cseq2)
      % ENDCOND
  zip_some_TCC3: OBLIGATION
    FORALL (cseq1, cseq2):
      NOT (length_lt[T1, T2](cseq1, cseq2) AND
            length_gt[T1, T2](cseq1, cseq2));


decl_type: tcc
theory: csequence_zip
library: co_structures
signature: nil
location: 307 0 312 999
body:
  % Subtype TCC generated (at line 130, column 29) for  cseq1
      % expected type  fseq: finite_csequence[T1]
  zip_every_TCC1: OBLIGATION
    FORALL (cseq1, cseq2, p1):
      every(p1)(cseq1) AND length_lt(cseq1, cseq2) IMPLIES
       (FORALL (i: indexes[T2](cseq2)): is_finite[T1](cseq1));


decl_type: formula
theory: csequence_unzip
library: co_structures
signature: nil
location: 86 2 87 75
body:
    unzip_nth_left: THEOREM
      FORALL cseq, (n: indexes(cseq)): nth(unzip(cseq)`1, n) = nth(cseq, n)`1


decl_type: formula
theory: csequence_unzip
library: co_structures
signature: nil
location: 89 2 90 75
body:
    unzip_nth_right: THEOREM
      FORALL cseq, (n: indexes(cseq)): nth(unzip(cseq)`2, n) = nth(cseq, n)`2


decl_type: formula
theory: csequence_unzip
library: co_structures
signature: nil
location: 92 2 95 73
body:
    unzip_map: THEOREM
      FORALL cseq:
        unzip(cseq) =
         (map[[T1, T2], T1](PROJ_1, cseq), map[[T1, T2], T2](PROJ_2, cseq))


decl_type: formula
theory: csequence_unzip
library: co_structures
signature: nil
location: 97 2 98 74
body:
    unzip_extensionality: THEOREM
      FORALL cseq1, cseq2: unzip(cseq1) = unzip(cseq2) IMPLIES cseq1 = cseq2


decl_type: formula
theory: csequence_unzip
library: co_structures
signature: nil
location: 100 2 103 61
body:
    unzip_add: THEOREM
      FORALL cseq, t12:
        unzip(add(t12, cseq)) =
         (add(t12`1, unzip(cseq)`1), add(t12`2, unzip(cseq)`2))


decl_type: formula
theory: csequence_unzip
library: co_structures
signature: nil
location: 111 2 114 53
body:
    unzip_some: THEOREM
      FORALL cseq, p1, p2:
        some(p1)(unzip(cseq)`1) OR some(p2)(unzip(cseq)`2) IFF
         some(LAMBDA t12: p1(t12`1) OR p2(t12`2))(cseq)


decl_type: formula
theory: csequence_unzip
library: co_structures
signature: nil
location: 116 2 119 55
body:
    unzip_every: THEOREM
      FORALL cseq, p1, p2:
        every(p1)(unzip(cseq)`1) AND every(p2)(unzip(cseq)`2) IFF
         every(LAMBDA t12: p1(t12`1) AND p2(t12`2))(cseq)


decl_type: judgement
theory: csequence_unzip
library: co_structures
signature: [infinite_csequence[T1], infinite_csequence[T2]]
location: 50 2 51 73
body:
    unzip_infinite: JUDGEMENT
      unzip(iseq) HAS_TYPE [infinite_csequence[T1], infinite_csequence[T2]]


decl_type: judgement
theory: csequence_unzip
library: co_structures
signature: [nonempty_csequence[T1], nonempty_csequence[T2]]
location: 53 2 54 73
body:
    unzip_nonempty: JUDGEMENT
      unzip(nseq) HAS_TYPE [nonempty_csequence[T1], nonempty_csequence[T2]]


decl_type: function
theory: csequence_unzip
library: co_structures
signature:
  [csequence[[T1, T2]] ->
  csequence_struct[T1, csequence[[T1, T2]]]]

location: 33 2 36 11
body:
    unzip_left_struct(cseq): csequence_struct[T1, csequence[[T1, T2]]] =
        IF empty?(cseq) THEN inj_empty_cseq
        ELSE inj_add(first(cseq)`1, rest(cseq))
        ENDIF


decl_type: function
theory: csequence_unzip
library: co_structures
signature:
  [csequence[[T1, T2]] ->
  csequence_struct[T2, csequence[[T1, T2]]]]

location: 38 2 41 11
body:
    unzip_right_struct(cseq): csequence_struct[T2, csequence[[T1, T2]]] =
        IF empty?(cseq) THEN inj_empty_cseq
        ELSE inj_add(first(cseq)`2, rest(cseq))
        ENDIF


decl_type: function
theory: csequence_unzip
library: co_structures
signature: [csequence[[T1, T2]] -> [csequence[T1], csequence[T2]]]
location: 43 2 45 42
body:
    unzip(cseq): [csequence[T1], csequence[T2]] =
        (coreduce(unzip_left_struct)(cseq),
         coreduce(unzip_right_struct)(cseq))


decl_type: tcc
theory: csequence_unzip
library: co_structures
signature: nil
location: 126 0 130 999
body:
  % Subtype TCC generated (at line 35, column 25) for  cseq
      % expected type  (nonempty?[[T1, T2]])
  unzip_left_struct_TCC1: OBLIGATION
    FORALL (cseq: csequence[[T1, T2]]):
      NOT empty?(cseq) IMPLIES nonempty?[[T1, T2]](cseq);


decl_type: tcc
theory: csequence_unzip
library: co_structures
signature: nil
location: 132 0 136 999
body:
  % Judgement subtype TCC generated (at line 48, column 4) for  unzip(fseq)
      % expected type  [finite_csequence[T1], finite_csequence[T2]]
  unzip_finite: OBLIGATION
    FORALL (fseq):
      is_finite[T2](unzip(fseq)`2) AND is_finite[T1](unzip(fseq)`1);


decl_type: tcc
theory: csequence_unzip
library: co_structures
signature: nil
location: 138 0 142 999
body:
  % Judgement subtype TCC generated (at line 51, column 4) for  unzip(iseq)
      % expected type  [infinite_csequence[T1], infinite_csequence[T2]]
  unzip_infinite: OBLIGATION
    FORALL (iseq):
      NOT is_finite[T2](unzip(iseq)`2) AND NOT is_finite[T1](unzip(iseq)`1);


decl_type: tcc
theory: csequence_unzip
library: co_structures
signature: nil
location: 144 0 148 999
body:
  % Judgement subtype TCC generated (at line 54, column 4) for  unzip(nseq)
      % expected type  [nonempty_csequence[T1], nonempty_csequence[T2]]
  unzip_nonempty: OBLIGATION
    FORALL (nseq):
      nonempty?[T2](unzip(nseq)`2) AND nonempty?[T1](unzip(nseq)`1);


decl_type: tcc
theory: csequence_unzip
library: co_structures
signature: nil
location: 150 0 153 999
body:
  % Subtype TCC generated (at line 87, column 56) for  n
      % expected type  indexes[T1](unzip(cseq)`1)
  unzip_nth_left_TCC1: OBLIGATION
    FORALL (cseq, n: indexes[[T1, T2]](cseq)): index?[T1](unzip(cseq)`1)(n);


decl_type: tcc
theory: csequence_unzip
library: co_structures
signature: nil
location: 155 0 158 999
body:
  % Subtype TCC generated (at line 90, column 56) for  n
      % expected type  indexes[T2](unzip(cseq)`2)
  unzip_nth_right_TCC1: OBLIGATION
    FORALL (cseq, n: indexes[[T1, T2]](cseq)): index?[T2](unzip(cseq)`2)(n);


decl_type: tcc
theory: csequence_unzip
library: co_structures
signature: nil
location: 160 0 163 999
body:
  % Subtype TCC generated (at line 106, column 23) for  unzip(nfseq)`1
      % expected type  nonempty_finite_csequence[T1]
  unzip_last_left_TCC1: OBLIGATION
    FORALL (nfseq): nonempty?[T1](unzip(nfseq)`1);


decl_type: tcc
theory: csequence_unzip
library: co_structures
signature: nil
location: 165 0 168 999
body:
  % Subtype TCC generated (at line 109, column 23) for  unzip(nfseq)`2
      % expected type  nonempty_finite_csequence[T2]
  unzip_last_right_TCC1: OBLIGATION
    FORALL (nfseq): nonempty?[T2](unzip(nfseq)`2);


decl_type: formula
theory: csequence_zip_unzip
library: co_structures
signature: nil
location: 26 2 29 48
body:
    unzip_zip_eta: THEOREM
      FORALL cseq1, cseq2:
        length_eq(cseq1, cseq2) IMPLIES
         unzip(zip(cseq1, cseq2)) = (cseq1, cseq2)


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 45 2 47 76
body:
    o_finiteness: LEMMA
      FORALL cseq1, cseq2:
        is_finite(cseq1 o cseq2) IMPLIES is_finite(cseq1) AND is_finite(cseq2)


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 52 2 54 63
body:
    o_empty: THEOREM
      FORALL cseq1, cseq2:
        empty?(cseq1 o cseq2) IFF empty?(cseq1) AND empty?(cseq2)


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 56 2 58 71
body:
    o_nonempty: COROLLARY
      FORALL cseq1, cseq2:
        nonempty?(cseq1 o cseq2) IFF nonempty?(cseq1) OR nonempty?(cseq2)


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 66 2 70 66
body:
    o_first: THEOREM
      FORALL cseq1, cseq2:
        nonempty?(cseq1 o cseq2) IMPLIES
         first(cseq1 o cseq2) =
          IF empty?(cseq1) THEN first(cseq2) ELSE first(cseq1) ENDIF


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 72 2 76 72
body:
    o_rest: THEOREM
      FORALL cseq1, cseq2:
        nonempty?(cseq1 o cseq2) IMPLIES
         rest(cseq1 o cseq2) =
          IF empty?(cseq1) THEN rest(cseq2) ELSE rest(cseq1) o cseq2 ENDIF


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 78 2 81 35
body:
    o_first_rest: THEOREM
      FORALL nseq1, nseq2, cseq:
        first(nseq1) = first(nseq2) AND rest(nseq1) o cseq = rest(nseq2)
         IMPLIES nseq1 o cseq = nseq2


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 83 2 85 59
body:
    o_length: THEOREM
      FORALL fseq1, fseq2:
        length(fseq1 o fseq2) = length(fseq1) + length(fseq2)


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 87 2 91 43
body:
    o_index: THEOREM
      FORALL cseq1, cseq2, n:
        index?(cseq1 o cseq2)(n) IFF
         (is_finite(cseq1) AND is_finite(cseq2) IMPLIES
           n < length(cseq1) + length(cseq2))


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 93 2 99 12
body:
    o_nth: THEOREM
      FORALL cseq1, cseq2, (n: indexes(cseq1 o cseq2)):
        nth(cseq1 o cseq2, n) =
         IF is_finite(cseq1) AND n >= length(cseq1)
           THEN nth(cseq2, n - length(cseq1))
         ELSE nth(cseq1, n)
         ENDIF


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 104 2 108 64
body:
    o_last: THEOREM
      FORALL cseq1, cseq2:
        is_finite(cseq1 o cseq2) AND nonempty?(cseq1 o cseq2) IMPLIES
         last(cseq1 o cseq2) =
          IF empty?(cseq2) THEN last(cseq1) ELSE last(cseq2) ENDIF


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 112 2 114 53
body:
    o_assoc: THEOREM
      FORALL cseq, cseq1, cseq2:
        cseq o (cseq1 o cseq2) = (cseq o cseq1) o cseq2


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 116 2 118 55
body:
    o_extensionality_left: THEOREM
      FORALL fseq, cseq1, cseq2:
        fseq o cseq1 = fseq o cseq2 IMPLIES cseq1 = cseq2


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 120 2 122 55
body:
    o_extensionality_right: THEOREM
      FORALL fseq, cseq1, cseq2:
        cseq1 o fseq = cseq2 o fseq IMPLIES cseq1 = cseq2


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 124 2 127 62
body:
    o_some: THEOREM
      FORALL cseq1, cseq2, p:
        some(p)(cseq1 o cseq2) IFF
         some(p)(cseq1) OR (is_finite(cseq1) AND some(p)(cseq2))


decl_type: formula
theory: csequence_concatenate
library: co_structures
signature: nil
location: 129 2 132 66
body:
    o_every: THEOREM
      FORALL cseq1, cseq2, p:
        every(p)(cseq1 o cseq2) IFF
         every(p)(cseq1) AND (is_infinite(cseq1) OR every(p)(cseq2))


decl_type: function
theory: csequence_concatenate
library: co_structures
signature:
  [[csequence[T], csequence[T]] ->
  csequence_struct[T, [csequence, csequence]]]

location: 32 2 38 12
body:
    concatenate_struct(cseq1, cseq2): csequence_struct =
        IF empty?(cseq1)
          THEN IF empty?(cseq2) THEN inj_empty_cseq
               ELSE inj_add(first(cseq2), (cseq1, rest(cseq2)))
               ENDIF
        ELSE inj_add(first(cseq1), (rest(cseq1), cseq2))
        ENDIF;


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 139 0 143 999
body:
  % Subtype TCC generated (at line 35, column 32) for  cseq2
      % expected type  (nonempty?[T])
  concatenate_struct_TCC1: OBLIGATION
    FORALL (cseq1: csequence[T], cseq2: csequence[T]):
      NOT empty?(cseq2) AND empty?(cseq1) IMPLIES nonempty?[T](cseq2);


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 145 0 149 999
body:
  % Subtype TCC generated (at line 37, column 25) for  cseq1
      % expected type  (nonempty?[T])
  concatenate_struct_TCC2: OBLIGATION
    FORALL (cseq1: csequence[T]):
      NOT empty?(cseq1) IMPLIES nonempty?[T](cseq1);


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 151 0 153 999
body:
  % Judgement subtype TCC generated (at line 42, column 22) for  fseq1 o fseq2
      % expected type  finite_csequence[T]
  o_finite: OBLIGATION FORALL (fseq1, fseq2): is_finite[T](fseq1 o fseq2);


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 155 0 157 999
body:
  % Judgement subtype TCC generated (at line 49, column 25) for  iseq o cseq
      % expected type  infinite_csequence[T]
  o_infinite1: OBLIGATION FORALL (cseq, iseq): NOT is_finite[T](iseq o cseq);


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 159 0 161 999
body:
  % Judgement subtype TCC generated (at line 50, column 25) for  cseq o iseq
      % expected type  infinite_csequence[T]
  o_infinite2: OBLIGATION FORALL (cseq, iseq): NOT is_finite[T](cseq o iseq);


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 163 0 165 999
body:
  % Judgement subtype TCC generated (at line 60, column 30) for  nseq o cseq
      % expected type  nonempty_csequence[T]
  o_nonempty_left: OBLIGATION FORALL (cseq, nseq): nonempty?[T](nseq o cseq);


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 167 0 169 999
body:
  % Judgement subtype TCC generated (at line 61, column 30) for  cseq o nseq
      % expected type  nonempty_csequence[T]
  o_nonempty_right: OBLIGATION FORALL (cseq, nseq): nonempty?[T](cseq o nseq);


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 171 0 175 999
body:
  % Subtype TCC generated (at line 70, column 36) for  cseq2
      % expected type  (nonempty?[T])
  o_first_TCC1: OBLIGATION
    FORALL (cseq1, cseq2):
      empty?(cseq1) AND nonempty?(cseq1 o cseq2) IMPLIES nonempty?[T](cseq2);


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 177 0 182 999
body:
  % Subtype TCC generated (at line 97, column 25) for  n - length(cseq1)
      % expected type  indexes[T](cseq2)
  o_nth_TCC1: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[T](cseq1 o cseq2)):
      is_finite(cseq1) AND n >= length(cseq1) IMPLIES
       n - length[T](cseq1) >= 0 AND index?[T](cseq2)(n - length[T](cseq1));


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 184 0 189 999
body:
  % Subtype TCC generated (at line 98, column 23) for  n
      % expected type  indexes[T](cseq1)
  o_nth_TCC2: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[T](cseq1 o cseq2)):
      NOT (is_finite(cseq1) AND n >= length(cseq1)) IMPLIES
       index?[T](cseq1)(n);


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 191 0 196 999
body:
  % Subtype TCC generated (at line 108, column 35) for  cseq1
      % expected type  nonempty_finite_csequence[T]
  o_last_TCC1: OBLIGATION
    FORALL (cseq1, cseq2):
      empty?(cseq2) AND is_finite(cseq1 o cseq2) AND nonempty?(cseq1 o cseq2)
       IMPLIES is_finite[T](cseq1) AND nonempty?[T](cseq1);


decl_type: tcc
theory: csequence_concatenate
library: co_structures
signature: nil
location: 198 0 204 999
body:
  % Subtype TCC generated (at line 108, column 52) for  cseq2
      % expected type  nonempty_finite_csequence[T]
  o_last_TCC2: OBLIGATION
    FORALL (cseq1, cseq2):
      NOT empty?(cseq2) AND
       is_finite(cseq1 o cseq2) AND nonempty?(cseq1 o cseq2)
       IMPLIES is_finite[T](cseq2) AND nonempty?[T](cseq2);


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 166 0 171 999
body:
  suffix?_weak_induction: AXIOM
    FORALL (cseq1, P: [csequence[T] -> boolean]):
      (FORALL (cseq2):
         cseq1 = cseq2 OR (nonempty?(cseq2) AND P(rest(cseq2))) IMPLIES
          P(cseq2))
       IMPLIES (FORALL (cseq2): suffix?(cseq1, cseq2) IMPLIES P(cseq2));


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 173 0 180 999
body:
  suffix?_induction: AXIOM
    FORALL (cseq1, P: [csequence[T] -> boolean]):
      (FORALL (cseq2):
         cseq1 = cseq2 OR
          (nonempty?(cseq2) AND
            suffix?(cseq1, rest(cseq2)) AND P(rest(cseq2)))
          IMPLIES P(cseq2))
       IMPLIES (FORALL (cseq2): suffix?(cseq1, cseq2) IMPLIES P(cseq2));


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 35 2 36 76
body:
    suffix?_rest_left: THEOREM
      FORALL nseq, cseq: suffix?(nseq, cseq) IMPLIES suffix?(rest(nseq), cseq)


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 38 2 39 76
body:
    suffix?_rest_right: THEOREM
      FORALL cseq, nseq: suffix?(cseq, rest(nseq)) IMPLIES suffix?(cseq, nseq)


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 47 2 48 68
body:
    suffix?_infinite_left: THEOREM
      FORALL iseq, cseq: suffix?(iseq, cseq) IMPLIES is_infinite(cseq)


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 50 2 51 68
body:
    suffix?_infinite_right: THEOREM
      FORALL cseq, iseq: suffix?(cseq, iseq) IMPLIES is_infinite(cseq)


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 53 2 55 66
body:
    suffix?_length: THEOREM
      FORALL fseq1, fseq2:
        suffix?(fseq1, fseq2) IMPLIES length(fseq1) <= length(fseq2)


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 57 2 60 20
body:
    suffix?_length_eq: THEOREM
      FORALL fseq1, fseq2:
        suffix?(fseq1, fseq2) AND length(fseq1) = length(fseq2) IMPLIES
         fseq1 = fseq2


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 62 2 64 73
body:
    suffix?_index: THEOREM
      FORALL cseq1, cseq2, n:
        suffix?(cseq1, cseq2) AND index?(cseq1)(n) IMPLIES index?(cseq2)(n)


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 68 2 70 67
body:
    suffix?_def: THEOREM
      FORALL cseq1, cseq2:
        suffix?(cseq1, cseq2) IFF (EXISTS fseq: fseq o cseq1 = cseq2)


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 84 2 89 23
body:
    suffix?_finite_antisymmetric: THEOREM
      partial_order?[finite_csequence]
          (restrict
               [[csequence, csequence], [finite_csequence, finite_csequence],
                bool]
               (suffix?))


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 92 2 95 53
body:
    suffix?_order: THEOREM
      FORALL cseq, cseq1, cseq2:
        suffix?(cseq1, cseq) AND suffix?(cseq2, cseq) IMPLIES
         suffix?(cseq1, cseq2) OR suffix?(cseq2, cseq1)


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 114 2 116 49
body:
    suffix_rest2: THEOREM
      FORALL cseq, (n: indexes(cseq)):
        rest(suffix(cseq, n)) = suffix(cseq, n + 1)


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 130 2 132 48
body:
    suffix_nth: THEOREM
      FORALL cseq, n, (m: indexes(suffix(cseq, n))):
        nth(suffix(cseq, n), m) = nth(cseq, n + m)


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 140 2 145 12
body:
    suffix_concatenate: THEOREM
      FORALL cseq1, cseq2, n:
        suffix(cseq1 o cseq2, n) =
         IF index?(cseq1)(n) THEN suffix(cseq1, n) o cseq2
         ELSE suffix(cseq2, n - length(cseq1))
         ENDIF


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 147 2 149 68
body:
    suffix?_suffix: THEOREM
      FORALL cseq1, cseq2:
        suffix?(cseq1, cseq2) IFF (EXISTS n: cseq1 = suffix(cseq2, n))


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 151 2 154 62
body:
    suffix_some: THEOREM
      FORALL cseq, n, p:
        some(p)(suffix(cseq, n)) IFF
         (EXISTS (i: indexes(cseq)): i >= n AND p(nth(cseq, i)))


decl_type: formula
theory: csequence_suffix
library: co_structures
signature: nil
location: 156 2 159 66
body:
    suffix_every: THEOREM
      FORALL cseq, n, p:
        every(p)(suffix(cseq, n)) IFF
         (FORALL (i: indexes(cseq)): i >= n IMPLIES p(nth(cseq, i)))


decl_type: function
theory: csequence_suffix
library: co_structures
signature: [[csequence[T], csequence[T]] -> bool]
location: 27 2 28 73
body:
    suffix?(cseq1, cseq2): INDUCTIVE bool =
        cseq1 = cseq2 OR (nonempty?(cseq2) AND suffix?(cseq1, rest(cseq2)))


decl_type: function
theory: csequence_suffix
library: co_structures
signature:
  [d: [csequence[T], nat] ->
  (LAMBDA (cseq1): suffix?(cseq1, d`1))]

location: 99 2 101 14
body:
    suffix(cseq, n): RECURSIVE (suffix?(cseq)) =
      IF n = 0 OR empty?(cseq) THEN cseq ELSE suffix(rest(cseq), n - 1) ENDIF
       MEASURE n


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 182 0 184 999
body:
  % Judgement subtype TCC generated (at line 79, column 33) for  suffix?
      % expected type  (preorder?[csequence])
  suffix?_is_preorder: OBLIGATION preorder?[csequence[T]](suffix?);


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 186 0 190 999
body:
  % Subtype TCC generated (at line 100, column 34) for  cseq
      % expected type  (LAMBDA (cseq1): suffix?(cseq1, cseq))
  suffix_TCC1: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      n = 0 OR empty?(cseq) IMPLIES suffix?(cseq, cseq);


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 192 0 196 999
body:
  % Subtype TCC generated (at line 100, column 56) for  cseq
      % expected type  (nonempty?[T])
  suffix_TCC2: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      NOT n = 0 AND NOT empty?(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 198 0 202 999
body:
  % Subtype TCC generated (at line 100, column 63) for  n - 1
      % expected type  nat
  suffix_TCC3: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      NOT n = 0 AND NOT empty?(cseq) IMPLIES n - 1 >= 0;


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 204 0 208 999
body:
  % Termination TCC generated (at line 100, column 44) for
      % suffix(rest(cseq), n - 1)
  suffix_TCC4: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      NOT n = 0 AND NOT empty?(cseq) IMPLIES n - 1 < n;


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 210 0 219 999
body:
  % Subtype TCC generated (at line 100, column 44) for
      % suffix(rest(cseq), n - 1)
      % expected type  (LAMBDA (cseq1): suffix?(cseq1, cseq))
  suffix_TCC5: OBLIGATION
    FORALL (cseq: csequence[T], n: nat,
            v:
              [d1: {z: [csequence[T], nat] | z`2 < n} ->
                 (LAMBDA (cseq1): suffix?(cseq1, d1`1))]):
      NOT n = 0 AND NOT empty?(cseq) IMPLIES
       suffix?(v(rest[T](cseq), n - 1), cseq);


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 221 0 225 999
body:
  % Judgement subtype TCC generated (at line 103, column 30) for
      % suffix(fseq, n)
      % expected type  finite_csequence[T]
  suffix_is_finite: OBLIGATION
    FORALL (fseq, n): is_finite[T](suffix(fseq, n));


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 227 0 231 999
body:
  % Judgement subtype TCC generated (at line 105, column 32) for
      % suffix(iseq, n)
      % expected type  infinite_csequence[T]
  suffix_is_infinite: OBLIGATION
    FORALL (iseq, n): NOT is_finite[T](suffix(iseq, n));


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 233 0 236 999
body:
  % Subtype TCC generated (at line 116, column 11) for  suffix(cseq, n)
      % expected type  (nonempty?[T])
  suffix_rest2_TCC1: OBLIGATION
    FORALL (cseq, n: indexes[T](cseq)): nonempty?[T](suffix(cseq, n));


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 238 0 241 999
body:
  % Subtype TCC generated (at line 125, column 43) for  suffix(nseq, n)
      % expected type  (nonempty?[T])
  suffix_first_TCC1: OBLIGATION
    FORALL (nseq, n: indexes[T](nseq)): nonempty?[T](suffix(nseq, n));


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 243 0 246 999
body:
  % Subtype TCC generated (at line 132, column 42) for  n + m
      % expected type  indexes[T](cseq)
  suffix_nth_TCC1: OBLIGATION
    FORALL (cseq, n, m: indexes[T](suffix(cseq, n))): index?[T](cseq)(n + m);


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 248 0 251 999
body:
  % Subtype TCC generated (at line 144, column 37) for  cseq1
      % expected type  fseq: finite_csequence[T]
  suffix_concatenate_TCC1: OBLIGATION
    FORALL (cseq1, n): NOT index?(cseq1)(n) IMPLIES is_finite[T](cseq1);


decl_type: tcc
theory: csequence_suffix
library: co_structures
signature: nil
location: 253 0 256 999
body:
  % Subtype TCC generated (at line 144, column 26) for  n - length(cseq1)
      % expected type  nat
  suffix_concatenate_TCC2: OBLIGATION
    FORALL (cseq1, n): NOT index?(cseq1)(n) IMPLIES n - length[T](cseq1) >= 0;


decl_type: formula
theory: csequence_add
library: co_structures
signature: nil
location: 34 2 36 62
body:
    add_index: THEOREM
      FORALL t, cseq, n:
        index?(add(t, cseq))(n) IFF n = 0 OR index?(cseq)(n - 1)


decl_type: formula
theory: csequence_add
library: co_structures
signature: nil
location: 38 2 40 45
body:
    add_nth: THEOREM
      FORALL t, cseq, (n: indexes(cseq)):
        nth(add(t, cseq), n + 1) = nth(cseq, n)


decl_type: formula
theory: csequence_add
library: co_structures
signature: nil
location: 42 2 44 71
body:
    add_last: THEOREM
      FORALL t, fseq:
        last(add(t, fseq)) = IF empty?(fseq) THEN t ELSE last(fseq) ENDIF


decl_type: tcc
theory: csequence_add
library: co_structures
signature: nil
location: 57 0 61 999
body:
  % Judgement subtype TCC generated (at line 27, column 24) for  add(t, fseq)
      % expected type  nonempty_finite_csequence[T]
  add_finite: OBLIGATION
    FORALL (fseq, t):
      is_finite[T](add[T](t, fseq)) AND nonempty?[T](add[T](t, fseq));


decl_type: tcc
theory: csequence_add
library: co_structures
signature: nil
location: 63 0 66 999
body:
  % Judgement subtype TCC generated (at line 29, column 26) for  add(t, iseq)
      % expected type  infinite_csequence[T]
  add_infinite: OBLIGATION
    FORALL (iseq, t): NOT is_finite[T](add[T](t, iseq));


decl_type: tcc
theory: csequence_add
library: co_structures
signature: nil
location: 68 0 70 999
body:
  % Subtype TCC generated (at line 36, column 56) for  n - 1
      % expected type  nat
  add_index_TCC1: OBLIGATION FORALL (t, n): NOT n = 0 IMPLIES n - 1 >= 0;


decl_type: tcc
theory: csequence_add
library: co_structures
signature: nil
location: 72 0 75 999
body:
  % Subtype TCC generated (at line 40, column 24) for  n + 1
      % expected type  indexes[T](add(t, cseq))
  add_nth_TCC1: OBLIGATION
    FORALL (t, cseq, n: indexes[T](cseq)): index?[T](add[T](t, cseq))(n + 1);


decl_type: tcc
theory: csequence_add
library: co_structures
signature: nil
location: 77 0 80 999
body:
  % Subtype TCC generated (at line 44, column 60) for  fseq
      % expected type  nonempty_finite_csequence[T]
  add_last_TCC1: OBLIGATION
    FORALL (t, fseq): NOT empty?(fseq) IMPLIES nonempty?[T](fseq);


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 37 2 40 75
body:
    extract_empty: THEOREM
      FORALL cseq, range:
        empty?(cseq ^ range) IFF
         range`1 > range`2 OR (is_finite(cseq) AND NOT index?(cseq)(range`1))


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 42 2 45 74
body:
    extract_nonempty: COROLLARY
      FORALL cseq, range:
        nonempty?(cseq ^ range) IFF
         range`1 <= range`2 AND (is_infinite(cseq) OR index?(cseq)(range`1))


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 47 2 55 12
body:
    extract_length: THEOREM
      FORALL cseq, range:
        length(cseq ^ range) =
         IF (range`1 > range`2 OR (is_finite(cseq) AND range`1 >= length(cseq)))
           THEN 0
         ELSIF is_finite(cseq) AND range`2 >= length(cseq)
           THEN length(cseq) - range`1
         ELSE range`2 - range`1 + 1
         ENDIF


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 63 2 66 46
body:
    extract_rest2: THEOREM
      FORALL cseq, m, n:
        nonempty?(cseq ^ (m, n)) IMPLIES
         rest(cseq ^ (m, n)) = cseq ^ (m + 1, n)


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 68 2 71 68
body:
    extract_extract: THEOREM
      FORALL cseq, range, range2:
        (cseq ^ range) ^ range2 =
         cseq ^ (range`1 + range2`1, min(range`2, range`1 + range2`2))


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 73 2 76 49
body:
    extract_index: THEOREM
      FORALL cseq, m, n, index:
        index?(cseq ^ (m, n))(index) IFF
         m + index <= n AND index?(cseq)(m + index)


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 78 2 80 74
body:
    extract_first: THEOREM
      FORALL cseq, m, n:
        nonempty?(cseq ^ (m, n)) IMPLIES first(cseq ^ (m, n)) = nth(cseq, m)


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 82 2 84 46
body:
    extract_nth: THEOREM
      FORALL cseq, (m: indexes(cseq)), (n: nat), (i: indexes(cseq ^ (m, n))):
        nth(cseq ^ (m, n), i) = nth(cseq, m + i)


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 86 2 93 12
body:
    extract_add: THEOREM
      FORALL cseq, t, m, n:
        add(t, cseq) ^ (m, n) =
         IF m > n THEN empty_cseq
         ELSIF m > 0 THEN cseq ^ (m - 1, max(0, n - 1))
         ELSIF n > 0 THEN add(t, cseq ^ (m, n - 1))
         ELSE add(t, empty_cseq)
         ENDIF


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 95 2 99 66
body:
    extract_last: THEOREM
      FORALL cseq, m, n:
        nonempty?(cseq ^ (m, n)) IMPLIES
         last(cseq ^ (m, n)) =
          IF index?(cseq)(n) THEN nth(cseq, n) ELSE last(cseq) ENDIF


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 101 2 103 73
body:
    extract_extensionality: THEOREM
      FORALL cseq1, cseq2:
        (FORALL range: cseq1 ^ range = cseq2 ^ range) IMPLIES cseq1 = cseq2


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 105 2 110 70
body:
    extract_some: THEOREM
      FORALL cseq, m, n, p:
        some(p)(cseq ^ (m, n)) IFF
         (EXISTS index:
            m <= index AND
             index <= n AND index?(cseq)(index) AND p(nth(cseq, index)))


decl_type: formula
theory: csequence_extract
library: co_structures
signature: nil
location: 112 2 117 31
body:
    extract_every: THEOREM
      FORALL cseq, m, n, p:
        every(p)(cseq ^ (m, n)) IFF
         (FORALL index:
            m <= index AND index <= n AND index?(cseq)(index) IMPLIES
             p(nth(cseq, index)))


decl_type: function
theory: csequence_extract
library: co_structures
signature: [[csequence[T], [nat, nat]] -> finite_csequence[T]]
location: 28 2 35 20
body:
    ^(cseq, range): RECURSIVE finite_csequence =
      LET (m, n) = range IN
        IF empty?(cseq) OR m > n THEN empty_cseq
        ELSIF m > 0 THEN rest(cseq) ^ (m - 1, n - 1)
        ELSE add(first(cseq),
                 IF n = 0 THEN empty_cseq ELSE rest(cseq) ^ (m, n - 1) ENDIF)
        ENDIF
       MEASURE range`2


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 124 0 130 999
body:
  % Subtype TCC generated (at line 31, column 28) for  cseq
      % expected type  (nonempty?[T])
  caret_TCC1: OBLIGATION
    FORALL (cseq: csequence[T], range: [nat, nat], m: nat, n: nat):
           m > 0 AND NOT empty?(cseq) AND NOT m > n AND n = range`2
       AND m = range`1
       IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 132 0 138 999
body:
  % Subtype TCC generated (at line 31, column 37) for  m - 1
      % expected type  nat
  caret_TCC2: OBLIGATION
    FORALL (cseq: csequence[T], range: [nat, nat], m: nat, n: nat):
           m > 0 AND NOT empty?(cseq) AND NOT m > n AND n = range`2
       AND m = range`1
       IMPLIES m - 1 >= 0;


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 140 0 146 999
body:
  % Subtype TCC generated (at line 31, column 44) for  n - 1
      % expected type  nat
  caret_TCC3: OBLIGATION
    FORALL (cseq: csequence[T], range: [nat, nat], m: nat, n: nat):
           m > 0 AND NOT empty?(cseq) AND NOT m > n AND n = range`2
       AND m = range`1
       IMPLIES n - 1 >= 0;


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 148 0 154 999
body:
  % Termination TCC generated (at line 31, column 23) for
      % rest(cseq) ^ (m - 1, n - 1)
  caret_TCC4: OBLIGATION
    FORALL (cseq: csequence[T], range: [nat, nat], m: nat, n: nat):
           m > 0 AND NOT empty?(cseq) AND NOT m > n AND n = range`2
       AND m = range`1
       IMPLIES n - 1 < range`2;


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 156 0 162 999
body:
  % Subtype TCC generated (at line 32, column 21) for  cseq
      % expected type  (nonempty?[T])
  caret_TCC5: OBLIGATION
    FORALL (cseq: csequence[T], range: [nat, nat], m: nat, n: nat):
           NOT m > 0 AND NOT empty?(cseq) AND NOT m > n AND n = range`2
       AND m = range`1
       IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 164 0 170 999
body:
  % Subtype TCC generated (at line 33, column 62) for  n - 1
      % expected type  nat
  caret_TCC6: OBLIGATION
    FORALL (cseq: csequence[T], range: [nat, nat], m: nat, n: nat):
           NOT n = 0 AND NOT m > 0 AND NOT empty?(cseq) AND NOT m > n
       AND n = range`2 AND m = range`1
       IMPLIES n - 1 >= 0;


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 172 0 178 999
body:
  % Termination TCC generated (at line 33, column 45) for
      % rest(cseq) ^ (m, n - 1)
  caret_TCC7: OBLIGATION
    FORALL (cseq: csequence[T], range: [nat, nat], m: nat, n: nat):
           NOT n = 0 AND NOT m > 0 AND NOT empty?(cseq) AND NOT m > n
       AND n = range`2 AND m = range`1
       IMPLIES n - 1 < range`2;


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 180 0 198 999
body:
  % Subtype TCC generated (at line 32, column 11) for
      % add(first(cseq),
      %     IF n = 0 THEN empty_cseq ELSE rest(cseq) ^ (m, n - 1) ENDIF)
      % expected type  finite_csequence[T]
  caret_TCC8: OBLIGATION
    FORALL (cseq: csequence[T], range: [nat, nat],
            v:
              [{z: [csequence[T], [nat, nat]] | z`2`2 < range`2} ->
                 finite_csequence[T]],
            m: nat, n: nat):
           NOT m > 0 AND NOT empty?(cseq) AND NOT m > n AND n = range`2
       AND m = range`1
       IMPLIES
       is_finite[T]
           (add[T]
                (first[T](cseq),
                 IF n = 0 THEN empty_cseq[T]
                 ELSE v(rest[T](cseq), (m, n - 1))
                 ENDIF));


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 200 0 202 999
body:
  % Subtype TCC generated (at line 61, column 30) for  length(nfseq) - 1
      % expected type  nat
  extract_rest_TCC1: OBLIGATION FORALL (nfseq): length[T](nfseq) - 1 >= 0;


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 204 0 207 999
body:
  % Subtype TCC generated (at line 80, column 72) for  m
      % expected type  indexes[T](cseq)
  extract_first_TCC1: OBLIGATION
    FORALL (cseq, m, n): nonempty?(cseq ^ (m, n)) IMPLIES index?[T](cseq)(m);


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 209 0 213 999
body:
  % Subtype TCC generated (at line 84, column 40) for  m + i
      % expected type  indexes[T](cseq)
  extract_nth_TCC1: OBLIGATION
    FORALL (cseq, m: indexes[T](cseq), n: nat, i: indexes[T](cseq ^ (m, n))):
      index?[T](cseq)(m + i);


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 215 0 218 999
body:
  % Subtype TCC generated (at line 90, column 32) for  m - 1
      % expected type  nat
  extract_add_TCC1: OBLIGATION
    FORALL (t, m, n): m > 0 AND NOT m > n IMPLIES m - 1 >= 0;


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 220 0 223 999
body:
  % Subtype TCC generated (at line 90, column 39) for  max(0, n - 1)
      % expected type  nat
  extract_add_TCC2: OBLIGATION
    FORALL (t, m, n): m > 0 AND NOT m > n IMPLIES max(0, n - 1) >= 0;


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 225 0 228 999
body:
  % Subtype TCC generated (at line 91, column 42) for  n - 1
      % expected type  nat
  extract_add_TCC3: OBLIGATION
    FORALL (t, m, n): n > 0 AND NOT m > 0 AND NOT m > n IMPLIES n - 1 >= 0;


decl_type: tcc
theory: csequence_extract
library: co_structures
signature: nil
location: 230 0 235 999
body:
  % Subtype TCC generated (at line 99, column 55) for  cseq
      % expected type  nonempty_finite_csequence[T]
  extract_last_TCC1: OBLIGATION
    FORALL (cseq, m, n):
      NOT index?(cseq)(n) AND nonempty?(cseq ^ (m, n)) IMPLIES
       is_finite[T](cseq) AND nonempty?[T](cseq);


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 152 0 160 999
body:
  prefix?_weak_coinduction: AXIOM
    FORALL (P: [[csequence[T], csequence[T]] -> boolean]):
      (FORALL (cseq1, cseq2):
         P(cseq1, cseq2) IMPLIES
          empty?(cseq1) OR
           (nonempty?(cseq2) AND
             first(cseq1) = first(cseq2) AND P(rest(cseq1), rest(cseq2))))
       IMPLIES
       (FORALL (cseq1, cseq2): P(cseq1, cseq2) IMPLIES prefix?(cseq1, cseq2));


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 162 0 172 999
body:
  prefix?_coinduction: AXIOM
    FORALL (P: [[csequence[T], csequence[T]] -> boolean]):
      (FORALL (cseq1, cseq2):
         P(cseq1, cseq2) IMPLIES
          empty?(cseq1) OR
           (nonempty?(cseq2) AND
             first(cseq1) = first(cseq2) AND
              (prefix?(rest(cseq1), rest(cseq2)) OR
                P(rest(cseq1), rest(cseq2)))))
       IMPLIES
       (FORALL (cseq1, cseq2): P(cseq1, cseq2) IMPLIES prefix?(cseq1, cseq2));


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 45 2 47 63
body:
    prefix?_first: THEOREM
      FORALL nseq1, nseq2:
        prefix?(nseq1, nseq2) IMPLIES first(nseq1) = first(nseq2)


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 49 2 51 69
body:
    prefix?_rest: THEOREM
      FORALL nseq1, nseq2:
        prefix?(nseq1, nseq2) IMPLIES prefix?(rest(nseq1), rest(nseq2))


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 53 2 55 66
body:
    prefix?_length: THEOREM
      FORALL fseq1, fseq2:
        prefix?(fseq1, fseq2) IMPLIES length(fseq1) <= length(fseq2)


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 57 2 60 20
body:
    prefix?_length_eq: THEOREM
      FORALL fseq1, fseq2:
        prefix?(fseq1, fseq2) AND length(fseq1) = length(fseq2) IMPLIES
         fseq1 = fseq2


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 62 2 64 73
body:
    prefix?_index: THEOREM
      FORALL cseq1, cseq2, n:
        prefix?(cseq1, cseq2) AND index?(cseq1)(n) IMPLIES index?(cseq2)(n)


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 66 2 68 65
body:
    prefix?_nth: THEOREM
      FORALL cseq1, cseq2, (n: indexes(cseq1)):
        prefix?(cseq1, cseq2) IMPLIES nth(cseq1, n) = nth(cseq2, n)


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 73 2 75 67
body:
    prefix?_def: THEOREM
      FORALL cseq1, cseq2:
        prefix?(cseq1, cseq2) IFF (EXISTS cseq: cseq1 o cseq = cseq2)


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 82 2 87 33
body:
    prefix?_total_order: THEOREM
      FORALL cseq:
        total_order?(restrict
                         [[csequence, csequence],
                          [(prefix?(cseq)), (prefix?(cseq))], bool]
                         (prefix?))


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 105 2 106 75
body:
    prefix_prefix: THEOREM
      FORALL cseq, n, m: prefix(prefix(cseq, n), m) = prefix(cseq, min(n, m))


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 108 2 111 64
body:
    prefix_length: THEOREM
      FORALL cseq, n:
        length(prefix(cseq, n)) =
         IF is_finite(cseq) THEN min(n, length(cseq)) ELSE n ENDIF


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 113 2 115 62
body:
    prefix_index: THEOREM
      FORALL cseq, n, m:
        index?(prefix(cseq, n))(m) IFF index?(cseq)(m) AND m < n


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 120 2 125 12
body:
    prefix_concatenate: THEOREM
      FORALL cseq1, cseq2, n:
        prefix(cseq1 o cseq2, n) =
         IF index?(cseq1)(n) THEN prefix(cseq1, n)
         ELSE cseq1 o prefix(cseq2, n - length(cseq1))
         ENDIF


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 127 2 130 60
body:
    prefix?_prefix: THEOREM
      FORALL cseq1, cseq2:
        prefix?(cseq1, cseq2) IFF
         cseq1 = cseq2 OR (EXISTS n: cseq1 = prefix(cseq2, n))


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 132 2 135 61
body:
    prefix_some: THEOREM
      FORALL cseq, n, p:
        some(p)(prefix(cseq, n)) IFF
         (EXISTS (i: indexes(cseq)): i < n AND p(nth(cseq, i)))


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 137 2 140 65
body:
    prefix_every: THEOREM
      FORALL cseq, n, p:
        every(p)(prefix(cseq, n)) IFF
         (FORALL (i: indexes(cseq)): i < n IMPLIES p(nth(cseq, i)))


decl_type: formula
theory: csequence_prefix
library: co_structures
signature: nil
location: 143 2 145 62
body:
    prefix?_order: THEOREM
      FORALL cseq, n, m:
        n <= m IMPLIES prefix?(prefix(cseq, n), prefix(cseq, m))


decl_type: function
theory: csequence_prefix
library: co_structures
signature: [[csequence[T], csequence[T]] -> bool]
location: 27 2 30 75
body:
    prefix?(cseq1, cseq2): COINDUCTIVE bool =
        empty?(cseq1) OR
         (nonempty?(cseq2) AND
           first(cseq1) = first(cseq2) AND prefix?(rest(cseq1), rest(cseq2)))


decl_type: function
theory: csequence_prefix
library: co_structures
signature: [d: [csequence[T], nat] -> {fseq | prefix?(fseq, d`1)}]
location: 91 2 95 14
body:
    prefix(cseq, n): RECURSIVE {fseq | prefix?(fseq, cseq)} =
      IF n = 0 OR empty?(cseq) THEN empty_cseq
      ELSE add(first(cseq), prefix(rest(cseq), n - 1))
      ENDIF
       MEASURE n


decl_type: tcc
theory: csequence_prefix
library: co_structures
signature: nil
location: 174 0 178 999
body:
  % Subtype TCC generated (at line 30, column 15) for  cseq1
      % expected type  (nonempty?[T])
  prefix?_TCC1: OBLIGATION
    FORALL (cseq1: csequence[T], cseq2: csequence[T]):
      nonempty?(cseq2) AND NOT empty?(cseq1) IMPLIES nonempty?[T](cseq1);


decl_type: tcc
theory: csequence_prefix
library: co_structures
signature: nil
location: 180 0 184 999
body:
  % Subtype TCC generated (at line 68, column 63) for  n
      % expected type  indexes[T](cseq2)
  prefix?_nth_TCC1: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[T](cseq1)):
      prefix?(cseq1, cseq2) IMPLIES index?[T](cseq2)(n);


decl_type: tcc
theory: csequence_prefix
library: co_structures
signature: nil
location: 186 0 188 999
body:
  % Judgement subtype TCC generated (at line 79, column 4) for  prefix?
      % expected type  (partial_order?[csequence])
  prefix?_is_partial_order: OBLIGATION partial_order?[csequence[T]](prefix?);


decl_type: tcc
theory: csequence_prefix
library: co_structures
signature: nil
location: 190 0 194 999
body:
  % Subtype TCC generated (at line 92, column 34) for  empty_cseq
      % expected type  {fseq | prefix?(fseq, cseq)}
  prefix_TCC1: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      n = 0 OR empty?(cseq) IMPLIES prefix?(empty_cseq[T], cseq);


decl_type: tcc
theory: csequence_prefix
library: co_structures
signature: nil
location: 196 0 200 999
body:
  % Subtype TCC generated (at line 93, column 19) for  cseq
      % expected type  (nonempty?[T])
  prefix_TCC2: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      NOT n = 0 AND NOT empty?(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_prefix
library: co_structures
signature: nil
location: 202 0 206 999
body:
  % Subtype TCC generated (at line 93, column 45) for  n - 1
      % expected type  nat
  prefix_TCC3: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      NOT n = 0 AND NOT empty?(cseq) IMPLIES n - 1 >= 0;


decl_type: tcc
theory: csequence_prefix
library: co_structures
signature: nil
location: 208 0 212 999
body:
  % Termination TCC generated (at line 93, column 26) for
      % prefix(rest(cseq), n - 1)
  prefix_TCC4: OBLIGATION
    FORALL (cseq: csequence[T], n: nat):
      NOT n = 0 AND NOT empty?(cseq) IMPLIES n - 1 < n;


decl_type: tcc
theory: csequence_prefix
library: co_structures
signature: nil
location: 214 0 223 999
body:
  % Subtype TCC generated (at line 93, column 9) for
      % add(first(cseq), prefix(rest(cseq), n - 1))
      % expected type  {fseq | prefix?(fseq, cseq)}
  prefix_TCC5: OBLIGATION
    FORALL (cseq: csequence[T], n: nat,
            v:
              [d1: {z: [csequence[T], nat] | z`2 < n} ->
                 {fseq | prefix?(fseq, d1`1)}]):
      NOT n = 0 AND NOT empty?(cseq) IMPLIES
       prefix?(add[T](first[T](cseq), v(rest[T](cseq), n - 1)), cseq);


decl_type: tcc
theory: csequence_prefix
library: co_structures
signature: nil
location: 225 0 228 999
body:
  % Subtype TCC generated (at line 103, column 49) for  prefix(nseq, n + 1)
      % expected type  (nonempty?[T])
  prefix_rest_TCC1: OBLIGATION
    FORALL (nseq, n): nonempty?[T](prefix(nseq, n + 1));


decl_type: tcc
theory: csequence_prefix
library: co_structures
signature: nil
location: 230 0 233 999
body:
  % Subtype TCC generated (at line 124, column 45) for  cseq1
      % expected type  fseq: finite_csequence[T]
  prefix_concatenate_TCC1: OBLIGATION
    FORALL (cseq1, n): NOT index?(cseq1)(n) IMPLIES is_finite[T](cseq1);


decl_type: tcc
theory: csequence_prefix
library: co_structures
signature: nil
location: 235 0 238 999
body:
  % Subtype TCC generated (at line 124, column 34) for  n - length(cseq1)
      % expected type  nat
  prefix_concatenate_TCC2: OBLIGATION
    FORALL (cseq1, n): NOT index?(cseq1)(n) IMPLIES n - length[T](cseq1) >= 0;


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 167 0 177 999
body:
  subsequence?_weak_coinduction: AXIOM
    FORALL (P: [[csequence[T], csequence[T]] -> boolean]):
      (FORALL (cseq1, cseq2):
         P(cseq1, cseq2) IMPLIES
          empty?(cseq1) OR
           (EXISTS (n: indexes(cseq2)):
              first(cseq1) = nth(cseq2, n) AND
               P(rest(cseq1), suffix(cseq2, n + 1))))
       IMPLIES
       (FORALL (cseq1, cseq2):
          P(cseq1, cseq2) IMPLIES subsequence?(cseq1, cseq2));


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 179 0 190 999
body:
  subsequence?_coinduction: AXIOM
    FORALL (P: [[csequence[T], csequence[T]] -> boolean]):
      (FORALL (cseq1, cseq2):
         P(cseq1, cseq2) IMPLIES
          empty?(cseq1) OR
           (EXISTS (n: indexes(cseq2)):
              first(cseq1) = nth(cseq2, n) AND
               (subsequence?(rest(cseq1), suffix(cseq2, n + 1)) OR
                 P(rest(cseq1), suffix(cseq2, n + 1)))))
       IMPLIES
       (FORALL (cseq1, cseq2):
          P(cseq1, cseq2) IMPLIES subsequence?(cseq1, cseq2));


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 36 2 37 64
body:
    subsequence?_empty_right: THEOREM
      FORALL cseq: subsequence?(cseq, empty_cseq) IFF empty?(cseq)


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 39 2 42 45
body:
    subsequence?_rest1: THEOREM
      FORALL nseq1, nseq2:
        subsequence?(nseq1, nseq2) IMPLIES
         subsequence?(rest(nseq1), rest(nseq2))


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 44 2 46 69
body:
    subsequence?_rest2: THEOREM
      FORALL cseq, nseq:
        subsequence?(cseq, rest(nseq)) IMPLIES subsequence?(cseq, nseq)


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 48 2 52 41
body:
    subsequence?_extensionality: THEOREM
      FORALL nseq1, nseq2:
        subsequence?(rest(nseq1), rest(nseq2)) AND
         first(nseq1) = first(nseq2)
         IMPLIES subsequence?(nseq1, nseq2)


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 54 2 55 71
body:
    subsequence?_finite: THEOREM
      FORALL cseq, fseq: subsequence?(cseq, fseq) IMPLIES is_finite(cseq)


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 57 2 63 70
body:
    subsequence?_nth: THEOREM
      FORALL cseq1, cseq2:
        subsequence?(cseq1, cseq2) IMPLIES
         (FORALL (n: indexes(cseq1)):
            EXISTS (m: indexes(cseq2)):
              nth(cseq1, n) = nth(cseq2, m) AND
               subsequence?(suffix(cseq1, n + 1), suffix(cseq2, m + 1)))


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 65 2 68 55
body:
    subsequence?_concatenate_left: THEOREM
      FORALL cseq1, cseq2:
        subsequence?(cseq1, cseq2) IMPLIES
         (FORALL fseq: subsequence?(cseq1, fseq o cseq2))


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 70 2 73 55
body:
    subsequence?_concatenate_right: THEOREM
      FORALL cseq1, cseq2:
        subsequence?(cseq1, cseq2) IMPLIES
         (FORALL cseq: subsequence?(cseq1, cseq2 o cseq))


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 75 2 77 67
body:
    subsequence?_prefix: THEOREM
      FORALL cseq, n, m:
        n <= m IMPLIES subsequence?(prefix(cseq, n), prefix(cseq, m))


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 79 2 81 67
body:
    subsequence?_suffix: THEOREM
      FORALL cseq, n, m:
        n <= m IMPLIES subsequence?(suffix(cseq, m), suffix(cseq, n))


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 83 2 85 71
body:
    subsequence?_length: THEOREM
      FORALL fseq1, fseq2:
        subsequence?(fseq1, fseq2) IMPLIES length(fseq1) <= length(fseq2)


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 87 2 90 20
body:
    subsequence?_length_eq: THEOREM
      FORALL fseq1, fseq2:
        subsequence?(fseq1, fseq2) AND length(fseq1) = length(fseq2) IMPLIES
         fseq1 = fseq2


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 105 2 110 28
body:
    subsequence?_finite_antisymmetric: THEOREM
      partial_order?[finite_csequence]
          (restrict
               [[csequence, csequence], [finite_csequence, finite_csequence],
                bool]
               (subsequence?))


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 118 2 120 74
body:
    subsequence?_some: THEOREM
      FORALL cseq1, cseq2, p:
        subsequence?(cseq1, cseq2) AND some(p)(cseq1) IMPLIES some(p)(cseq2)


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 122 2 124 76
body:
    subsequence?_every: THEOREM
      FORALL cseq1, cseq2, p:
        subsequence?(cseq1, cseq2) AND every(p)(cseq2) IMPLIES every(p)(cseq1)


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 144 2 147 76
body:
    subsequence_func_monotonic: LEMMA
      FORALL cseq1, cseq2, (n, m: indexes(cseq1)):
        subsequence?(cseq1, cseq2) AND n < m IMPLIES
         subsequence_func(cseq2, cseq1)(n) < subsequence_func(cseq2, cseq1)(m)


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 149 2 152 68
body:
    subsequence_func_nth: LEMMA
      FORALL cseq1, cseq2, (n: indexes(cseq1)):
        subsequence?(cseq1, cseq2) IMPLIES
         nth(cseq1, n) = nth(cseq2, subsequence_func(cseq2, cseq1)(n))


decl_type: formula
theory: csequence_subsequence
library: co_structures
signature: nil
location: 154 2 160 74
body:
    subsequence?_def: THEOREM
      FORALL cseq1, cseq2:
        subsequence?(cseq1, cseq2) IFF
         (EXISTS (f: [indexes(cseq1) -> indexes(cseq2)]):
            (FORALL (i1, i2: indexes(cseq1)): i1 < i2 IMPLIES f(i1) < f(i2))
             AND
             (FORALL (i: indexes(cseq1)): nth(cseq1, i) = nth(cseq2, f(i))))


decl_type: function
theory: csequence_subsequence
library: co_structures
signature: [[csequence[T], csequence[T]] -> bool]
location: 25 2 29 59
body:
    subsequence?(cseq1, cseq2): COINDUCTIVE bool =
        empty?(cseq1) OR
         (EXISTS (n: indexes(cseq2)):
            first(cseq1) = nth(cseq2, n) AND
             subsequence?(rest(cseq1), suffix(cseq2, n + 1)))


decl_type: function
theory: csequence_subsequence
library: co_structures
location: 131 2 142 14
signature:
  [d:
          [cseq2: csequence[T],
           (LAMBDA (cseq1): subsequence?(cseq1, cseq2))] ->
          [indexes[T](d`2) -> indexes[T](d`1)]]

body:
    subsequence_func(cseq2, (cseq1: (subsequence?(cseq2))))
                    (n: indexes(cseq1)): RECURSIVE
          indexes(cseq2) =
      LET index =
            min[indexes(cseq2)]
                ({i: indexes(cseq2) | first(cseq1) = nth(cseq2, i)})
        IN
        IF n = 0 THEN index
        ELSE index + 1 +
              subsequence_func(suffix(cseq2, index + 1), rest(cseq1))(n - 1)
        ENDIF
       MEASURE n


decl_type: tcc
theory: csequence_subsequence
library: co_structures
signature: nil
location: 192 0 197 999
body:
  % Subtype TCC generated (at line 28, column 16) for  cseq1
      % expected type  (nonempty?[T])
  subsequence?_TCC1: OBLIGATION
    FORALL (cseq1: csequence[T], cseq2: csequence[T]):
      NOT empty?(cseq1) IMPLIES
       (FORALL (n: indexes[T](cseq2)): nonempty?[T](cseq1));


decl_type: tcc
theory: csequence_subsequence
library: co_structures
signature: nil
location: 199 0 201 999
body:
  % Judgement subtype TCC generated (at line 100, column 4) for  subsequence?
      % expected type  (preorder?[csequence])
  subsequence?_is_preorder: OBLIGATION preorder?[csequence[T]](subsequence?);


decl_type: tcc
theory: csequence_subsequence
library: co_structures
signature: nil
location: 203 0 208 999
body:
  % Judgement subtype TCC generated (at line 113, column 4) for  x
      % expected type  (LAMBDA (cseq1): subsequence?(cseq1, cseq))
  prefix?_is_subsequence?: OBLIGATION
    FORALL (cseq: csequence[T],
            x: (LAMBDA (cseq1: csequence[T]): prefix?(cseq1, cseq))):
      subsequence?(x, cseq);


decl_type: tcc
theory: csequence_subsequence
library: co_structures
signature: nil
location: 210 0 215 999
body:
  % Judgement subtype TCC generated (at line 116, column 4) for  x
      % expected type  (LAMBDA (cseq1): subsequence?(cseq1, cseq))
  suffix?_is_subsequence?: OBLIGATION
    FORALL (cseq: csequence[T],
            x: (LAMBDA (cseq1: csequence[T]): suffix?(cseq1, cseq))):
      subsequence?(x, cseq);


decl_type: tcc
theory: csequence_subsequence
library: co_structures
signature: nil
location: 217 0 233 999
body:
  % Subtype TCC generated (at line 140, column 68) for  n - 1
      % expected type  indexes[T](rest(cseq1))
  subsequence_func_TCC1: OBLIGATION
    FORALL (cseq2: csequence[T],
            (cseq1: (LAMBDA (cseq1): subsequence?(cseq1, cseq2))),
            n: indexes[T](cseq1),
            index:
              {a |
                       first[T](cseq1) = nth[T](cseq2, a) AND
                        (FORALL (x: indexes[T](cseq2)):
                           first[T](cseq1) = nth[T](cseq2, x) IMPLIES
                            a <= x)}):
      NOT n = 0 AND
       index =
        min[indexes[T](cseq2)]
            ({i: indexes(cseq2) | first(cseq1) = nth(cseq2, i)})
       IMPLIES n - 1 >= 0 AND index?[T](rest[T](cseq1))(n - 1);


decl_type: tcc
theory: csequence_subsequence
library: co_structures
signature: nil
location: 235 0 251 999
body:
  % Subtype TCC generated (at line 140, column 60) for  cseq1
      % expected type  (nonempty?[T])
  subsequence_func_TCC2: OBLIGATION
    FORALL (cseq2: csequence[T],
            (cseq1: (LAMBDA (cseq1): subsequence?(cseq1, cseq2))),
            n: indexes[T](cseq1),
            index:
              {a |
                       first[T](cseq1) = nth[T](cseq2, a) AND
                        (FORALL (x: indexes[T](cseq2)):
                           first[T](cseq1) = nth[T](cseq2, x) IMPLIES
                            a <= x)}):
      NOT n = 0 AND
       index =
        min[indexes[T](cseq2)]
            ({i: indexes(cseq2) | first(cseq1) = nth(cseq2, i)})
       IMPLIES nonempty?[T](cseq1);


decl_type: tcc
theory: csequence_subsequence
library: co_structures
signature: nil
location: 253 0 270 999
body:
  % Subtype TCC generated (at line 140, column 55) for  rest(cseq1)
      % expected type  (LAMBDA (cseq1_1: csequence[T]):
                     %    subsequence?(cseq1_1, suffix(cseq2, index + 1)))
  subsequence_func_TCC3: OBLIGATION
    FORALL (cseq2: csequence[T],
            (cseq1: (LAMBDA (cseq1): subsequence?(cseq1, cseq2))),
            n: indexes[T](cseq1),
            index:
              {a |
                       first[T](cseq1) = nth[T](cseq2, a) AND
                        (FORALL (x: indexes[T](cseq2)):
                           first[T](cseq1) = nth[T](cseq2, x) IMPLIES
                            a <= x)}):
      NOT n = 0 AND
       index =
        min[indexes[T](cseq2)]
            ({i: indexes(cseq2) | first(cseq1) = nth(cseq2, i)})
       IMPLIES subsequence?(rest[T](cseq1), suffix[T](cseq2, 1 + index));


decl_type: tcc
theory: csequence_subsequence
library: co_structures
signature: nil
location: 272 0 288 999
body:
  % Termination TCC generated (at line 140, column 12) for
      % subsequence_func(suffix(cseq2, index + 1), rest(cseq1))(n - 1)
  subsequence_func_TCC4: OBLIGATION
    FORALL (cseq2: csequence[T],
            (cseq1: (LAMBDA (cseq1): subsequence?(cseq1, cseq2))),
            n: indexes[T](cseq1),
            index:
              {a |
                       first[T](cseq1) = nth[T](cseq2, a) AND
                        (FORALL (x: indexes[T](cseq2)):
                           first[T](cseq1) = nth[T](cseq2, x) IMPLIES
                            a <= x)}):
      NOT n = 0 AND
       index =
        min[indexes[T](cseq2)]
            ({i: indexes(cseq2) | first(cseq1) = nth(cseq2, i)})
       IMPLIES n - 1 < n;


decl_type: tcc
theory: csequence_subsequence
library: co_structures
signature: nil
location: 290 0 317 999
body:
  % Subtype TCC generated (at line 139, column 11) for
      % index + 1 +
      %  subsequence_func(suffix(cseq2, index + 1), rest(cseq1))(n - 1)
      % expected type  indexes[T](cseq2)
  subsequence_func_TCC5: OBLIGATION
    FORALL (cseq2: csequence[T],
            (cseq1: (LAMBDA (cseq1): subsequence?(cseq1, cseq2))),
            n: indexes[T](cseq1),
            v:
              [d1:
                 [cseq2: csequence[T],
                  (LAMBDA (cseq1): subsequence?(cseq1, cseq2))] ->
                 [{z: indexes[T](d1`2) | z < n} -> indexes[T](d1`1)]],
            index:
              {a |
                       first[T](cseq1) = nth[T](cseq2, a) AND
                        (FORALL (x: indexes[T](cseq2)):
                           first[T](cseq1) = nth[T](cseq2, x) IMPLIES
                            a <= x)}):
      NOT n = 0 AND
       index =
        min[indexes[T](cseq2)]
            ({i: indexes(cseq2) | first(cseq1) = nth(cseq2, i)})
       IMPLIES
       index?[T]
           (cseq2)
           (index + 1 +
             v(suffix[T](cseq2, index + 1), rest[T](cseq1))(n - 1));


decl_type: tcc
theory: csequence_subsequence
library: co_structures
signature: nil
location: 319 0 334 999
body:
  % Subtype TCC generated (at line 136, column 42) for  cseq1
      % expected type  (nonempty?[T])
  subsequence_func_TCC6: OBLIGATION
    FORALL (cseq2: csequence[T],
            (cseq1: (LAMBDA (cseq1): subsequence?(cseq1, cseq2))),
            n: indexes[T](cseq1), i: indexes[T](cseq2),
            index:
              {a |
                       first[T](cseq1) = nth[T](cseq2, a) AND
                        (FORALL (x: indexes[T](cseq2)):
                           first[T](cseq1) = nth[T](cseq2, x) IMPLIES
                            a <= x)}):
      index =
       min[indexes[T](cseq2)]
           ({i: indexes(cseq2) | first(cseq1) = nth(cseq2, i)})
       IMPLIES nonempty?[T](cseq1);


decl_type: tcc
theory: csequence_subsequence
library: co_structures
signature: nil
location: 336 0 344 999
body:
  % Subtype TCC generated (at line 136, column 15) for
      % {i: indexes(cseq2) | first(cseq1) = nth(cseq2, i)}
      % expected type  S: (nonempty?[indexes(cseq2)])
  subsequence_func_TCC7: OBLIGATION
    FORALL (cseq2: csequence[T],
            (cseq1: (LAMBDA (cseq1): subsequence?(cseq1, cseq2))),
            n: indexes[T](cseq1)):
      nonempty?[indexes[T](cseq2)]
          ({i: indexes[T](cseq2) | first[T](cseq1) = nth[T](cseq2, i)});


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 96 0 105 999
body:
  strict_prefix?_weak_induction: AXIOM
    FORALL (P: [[csequence[T], csequence[T]] -> boolean]):
      (FORALL (cseq1, cseq2):
         nonempty?(cseq2) AND
          (empty?(cseq1) OR
            (first(cseq1) = first(cseq2) AND P(rest(cseq1), rest(cseq2))))
          IMPLIES P(cseq1, cseq2))
       IMPLIES
       (FORALL (cseq1, cseq2):
          strict_prefix?(cseq1, cseq2) IMPLIES P(cseq1, cseq2));


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 107 0 118 999
body:
  strict_prefix?_induction: AXIOM
    FORALL (P: [[csequence[T], csequence[T]] -> boolean]):
      (FORALL (cseq1, cseq2):
         nonempty?(cseq2) AND
          (empty?(cseq1) OR
            (first(cseq1) = first(cseq2) AND
              strict_prefix?(rest(cseq1), rest(cseq2)) AND
               P(rest(cseq1), rest(cseq2))))
          IMPLIES P(cseq1, cseq2))
       IMPLIES
       (FORALL (cseq1, cseq2):
          strict_prefix?(cseq1, cseq2) IMPLIES P(cseq1, cseq2));


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 33 2 36 47
body:
    strict_prefix?_prefix?: THEOREM
      FORALL cseq1, cseq2:
        strict_prefix?(cseq1, cseq2) IFF
         prefix?(cseq1, cseq2) AND cseq1 /= cseq2


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 38 2 40 59
body:
    strict_prefix?_finite: THEOREM
      FORALL cseq1, cseq2:
        strict_prefix?(cseq1, cseq2) IMPLIES is_finite(cseq1)


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 42 2 44 66
body:
    strict_prefix?_first: THEOREM
      FORALL nseq, cseq:
        strict_prefix?(nseq, cseq) IMPLIES first(nseq) = first(cseq)


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 46 2 49 45
body:
    strict_prefix?_rest: THEOREM
      FORALL nseq, cseq:
        strict_prefix?(nseq, cseq) IMPLIES
         strict_prefix?(rest(nseq), rest(cseq))


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 51 2 53 68
body:
    strict_prefix?_length: THEOREM
      FORALL cseq, fseq:
        strict_prefix?(cseq, fseq) IMPLIES length(cseq) < length(fseq)


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 55 2 58 23
body:
    strict_prefix?_index: THEOREM
      FORALL cseq1, cseq2, n:
        strict_prefix?(cseq1, cseq2) AND index?(cseq1)(n) IMPLIES
         index?(cseq2)(n)


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 60 2 62 72
body:
    strict_prefix?_nth: THEOREM
      FORALL cseq1, cseq2, (n: indexes(cseq1)):
        strict_prefix?(cseq1, cseq2) IMPLIES nth(cseq1, n) = nth(cseq2, n)


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 67 2 70 63
body:
    strict_prefix?_def: THEOREM
      FORALL cseq1, cseq2:
        strict_prefix?(cseq1, cseq2) IFF
         is_finite(cseq1) AND (EXISTS nseq: cseq1 o nseq = cseq2)


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 76 2 82 41
body:
    strict_prefix?_well_ordered: THEOREM
      FORALL cseq:
        well_ordered?(restrict
                          [[csequence, csequence],
                           [(strict_prefix?(cseq)), (strict_prefix?(cseq))],
                           bool]
                          (strict_prefix?))


decl_type: formula
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 84 2 89 56
body:
    strict_prefix?_prefix: THEOREM
      FORALL cseq1, cseq2:
        strict_prefix?(cseq1, cseq2) IFF
         (EXISTS n:
            cseq1 = prefix(cseq2, n) AND
             (is_finite(cseq2) IMPLIES n < length(cseq2)))


decl_type: function
theory: csequence_strict_prefix
library: co_structures
signature: [[csequence[T], csequence[T]] -> bool]
location: 25 2 29 53
body:
    strict_prefix?(cseq1, cseq2): INDUCTIVE bool =
        nonempty?(cseq2) AND
         (empty?(cseq1) OR
           (first(cseq1) = first(cseq2) AND
             strict_prefix?(rest(cseq1), rest(cseq2))))


decl_type: tcc
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 120 0 124 999
body:
  % Subtype TCC generated (at line 28, column 16) for  cseq1
      % expected type  (nonempty?[T])
  strict_prefix?_TCC1: OBLIGATION
    FORALL (cseq1: csequence[T], cseq2: csequence[T]):
      NOT empty?(cseq1) AND nonempty?(cseq2) IMPLIES nonempty?[T](cseq1);


decl_type: tcc
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 126 0 130 999
body:
  % Subtype TCC generated (at line 44, column 61) for  cseq
      % expected type  (nonempty?[T])
  strict_prefix?_first_TCC1: OBLIGATION
    FORALL (nseq, cseq):
      strict_prefix?(nseq, cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 132 0 136 999
body:
  % Subtype TCC generated (at line 53, column 48) for  cseq
      % expected type  fseq: finite_csequence[T]
  strict_prefix?_length_TCC1: OBLIGATION
    FORALL (cseq, fseq):
      strict_prefix?(cseq, fseq) IMPLIES is_finite[T](cseq);


decl_type: tcc
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 138 0 142 999
body:
  % Subtype TCC generated (at line 62, column 70) for  n
      % expected type  indexes[T](cseq2)
  strict_prefix?_nth_TCC1: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[T](cseq1)):
      strict_prefix?(cseq1, cseq2) IMPLIES index?[T](cseq2)(n);


decl_type: tcc
theory: csequence_strict_prefix
library: co_structures
signature: nil
location: 144 0 147 999
body:
  % Judgement subtype TCC generated (at line 73, column 4) for  strict_prefix?
      % expected type  (strict_order?[csequence])
  strict_prefix?_is_strict_order: OBLIGATION
    strict_order?[csequence[T]](strict_prefix?);


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 48 2 50 66
body:
    split_empty_right: THEOREM
      FORALL cseq:
        empty?(split(cseq)`2) IFF empty?(cseq) OR empty?(rest(cseq))


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 55 2 57 76
body:
    split_nonempty_right: THEOREM
      FORALL cseq:
        nonempty?(split(cseq)`2) IFF nonempty?(cseq) AND nonempty?(rest(cseq))


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 61 2 63 76
body:
    split_first_right: THEOREM
      FORALL nseq:
        nonempty?(rest(nseq)) IMPLIES first(split(nseq)`2) = first(rest(nseq))


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 65 2 70 12
body:
    split_rest_left: THEOREM
      FORALL nseq:
        rest(split(nseq)`1) =
         IF empty?(rest(nseq)) THEN empty_cseq
         ELSE split(rest(rest(nseq)))`1
         ENDIF


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 72 2 75 54
body:
    split_rest_right: THEOREM
      FORALL nseq:
        nonempty?(rest(nseq)) IMPLIES
         rest(split(nseq)`2) = split(rest(rest(nseq)))`2


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 95 2 97 66
body:
    split_length: THEOREM
      FORALL fseq:
        length(fseq) = length(split(fseq)`1) + length(split(fseq)`2)


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 102 2 103 72
body:
    split_index_right: THEOREM
      FORALL cseq, n: index?(split(cseq)`2)(n) IFF index?(cseq)(2 * n + 1)


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 105 2 107 46
body:
    split_nth_left: THEOREM
      FORALL cseq, (n: indexes(split(cseq)`1)):
        nth(split(cseq)`1, n) = nth(cseq, 2 * n)


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 109 2 111 50
body:
    split_nth_right: THEOREM
      FORALL cseq, (n: indexes(split(cseq)`2)):
        nth(split(cseq)`2, n) = nth(cseq, 2 * n + 1)


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 113 2 115 66
body:
    split_add: THEOREM
      FORALL cseq, t:
        split(add(t, cseq)) = (add(t, split(cseq)`2), split(cseq)`1)


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 117 2 123 13
body:
    split_last_left: THEOREM
      FORALL fseq:
        nonempty?(split(fseq)`1) IMPLIES
         last(split(fseq)`1) =
          IF odd?(length(fseq)) THEN last(fseq)
          ELSE nth(fseq, length(fseq) - 2)
          ENDIF


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 125 2 131 13
body:
    split_last_right: THEOREM
      FORALL fseq:
        nonempty?(split(fseq)`2) IMPLIES
         last(split(fseq)`2) =
          IF even?(length(fseq)) THEN last(fseq)
          ELSE nth(fseq, length(fseq) - 2)
          ENDIF


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 133 2 134 74
body:
    split_extensionality: THEOREM
      FORALL cseq1, cseq2: split(cseq1) = split(cseq2) IMPLIES cseq1 = cseq2


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 136 2 138 72
body:
    split_some: THEOREM
      FORALL cseq, p:
        some(p)(cseq) IFF some(p)(split(cseq)`1) OR some(p)(split(cseq)`2)


decl_type: formula
theory: csequence_split
library: co_structures
signature: nil
location: 140 2 142 76
body:
    split_every: THEOREM
      FORALL cseq, p:
        every(p)(cseq) IFF every(p)(split(cseq)`1) AND every(p)(split(cseq)`2)


decl_type: function
theory: csequence_split
library: co_structures
signature: [csequence[T] -> csequence_struct[T, csequence]]
location: 28 2 34 11
body:
    split_left_struct(cseq): csequence_struct =
        IF empty?(cseq) THEN inj_empty_cseq
        ELSE inj_add(first(cseq),
                     IF empty?(rest(cseq)) THEN empty_cseq
                     ELSE rest(rest(cseq))
                     ENDIF)
        ENDIF


decl_type: function
theory: csequence_split
library: co_structures
signature: [csequence[T] -> csequence_struct[T, csequence]]
location: 36 2 39 11
body:
    split_right_struct(cseq): csequence_struct =
        IF empty?(cseq) OR empty?(rest(cseq)) THEN inj_empty_cseq
        ELSE inj_add(first(rest(cseq)), rest(rest(cseq)))
        ENDIF


decl_type: function
theory: csequence_split
library: co_structures
signature: [csequence[T] -> [csequence[T], csequence[T]]]
location: 41 2 43 42
body:
    split(cseq): [csequence, csequence] =
        (coreduce(split_left_struct)(cseq),
         coreduce(split_right_struct)(cseq))


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 149 0 152 999
body:
  % Subtype TCC generated (at line 30, column 25) for  cseq
      % expected type  (nonempty?[T])
  split_left_struct_TCC1: OBLIGATION
    FORALL (cseq: csequence[T]): NOT empty?(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 154 0 159 999
body:
  % Subtype TCC generated (at line 32, column 29) for  rest(cseq)
      % expected type  (nonempty?[T])
  split_left_struct_TCC2: OBLIGATION
    FORALL (cseq: csequence[T]):
      NOT empty?(rest(cseq)) AND NOT empty?(cseq) IMPLIES
       nonempty?[T](rest[T](cseq));


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 161 0 164 999
body:
  % Subtype TCC generated (at line 59, column 47) for  split(nseq)`1
      % expected type  (nonempty?[T])
  split_first_left_TCC1: OBLIGATION
    FORALL (nseq): nonempty?[T](split(nseq)`1);


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 166 0 169 999
body:
  % Subtype TCC generated (at line 63, column 42) for  split(nseq)`2
      % expected type  (nonempty?[T])
  split_first_right_TCC1: OBLIGATION
    FORALL (nseq): nonempty?(rest(nseq)) IMPLIES nonempty?[T](split(nseq)`2);


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 171 0 174 999
body:
  % Subtype TCC generated (at line 69, column 23) for  rest(nseq)
      % expected type  (nonempty?[T])
  split_rest_left_TCC1: OBLIGATION
    FORALL (nseq): NOT empty?(rest(nseq)) IMPLIES nonempty?[T](rest[T](nseq));


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 176 0 180 999
body:
  % Judgement subtype TCC generated (at line 84, column 4) for  split(fseq)
      % expected type  [finite_csequence[T], finite_csequence[T]]
  split_finite: OBLIGATION
    FORALL (fseq):
      is_finite[T](split(fseq)`2) AND is_finite[T](split(fseq)`1);


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 182 0 186 999
body:
  % Judgement subtype TCC generated (at line 87, column 4) for  split(iseq)
      % expected type  [infinite_csequence[T], infinite_csequence[T]]
  split_infinite: OBLIGATION
    FORALL (iseq):
      NOT is_finite[T](split(iseq)`2) AND NOT is_finite[T](split(iseq)`1);


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 188 0 191 999
body:
  % Subtype TCC generated (at line 107, column 40) for  2 * n
      % expected type  indexes[T](cseq)
  split_nth_left_TCC1: OBLIGATION
    FORALL (cseq, n: indexes[T](split(cseq)`1)): index?[T](cseq)(2 * n);


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 193 0 196 999
body:
  % Subtype TCC generated (at line 111, column 40) for  2 * n + 1
      % expected type  indexes[T](cseq)
  split_nth_right_TCC1: OBLIGATION
    FORALL (cseq, n: indexes[T](split(cseq)`2)): index?[T](cseq)(2 * n + 1);


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 198 0 203 999
body:
  % Subtype TCC generated (at line 121, column 40) for  fseq
      % expected type  nonempty_finite_csequence[T]
  split_last_left_TCC1: OBLIGATION
    FORALL (fseq):
      odd?(length(fseq)) AND nonempty?(split(fseq)`1) IMPLIES
       nonempty?[T](fseq);


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 205 0 210 999
body:
  % Subtype TCC generated (at line 122, column 23) for  length(fseq) - 2
      % expected type  indexes[T](fseq)
  split_last_left_TCC2: OBLIGATION
    FORALL (fseq):
      NOT odd?(length(fseq)) AND nonempty?(split(fseq)`1) IMPLIES
       length[T](fseq) - 2 >= 0 AND index?[T](fseq)(length[T](fseq) - 2);


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 212 0 217 999
body:
  % Subtype TCC generated (at line 129, column 41) for  fseq
      % expected type  nonempty_finite_csequence[T]
  split_last_right_TCC1: OBLIGATION
    FORALL (fseq):
      even?(length(fseq)) AND nonempty?(split(fseq)`2) IMPLIES
       nonempty?[T](fseq);


decl_type: tcc
theory: csequence_split
library: co_structures
signature: nil
location: 219 0 224 999
body:
  % Subtype TCC generated (at line 130, column 23) for  length(fseq) - 2
      % expected type  indexes[T](fseq)
  split_last_right_TCC2: OBLIGATION
    FORALL (fseq):
      NOT even?(length(fseq)) AND nonempty?(split(fseq)`2) IMPLIES
       length[T](fseq) - 2 >= 0 AND index?[T](fseq)(length[T](fseq) - 2);


decl_type: formula
theory: csequence_singleton
library: co_structures
signature: nil
location: 32 2 33 70
body:
    singleton_cseq_index: THEOREM
      FORALL (single: (singleton_cseq?)), n: index?(single)(n) IFF n = 0


decl_type: formula
theory: csequence_singleton
library: co_structures
signature: nil
location: 37 2 39 70
body:
    singleton_def: THEOREM
      FORALL cseq:
        singleton_cseq?(cseq) IMPLIES cseq = singleton_cseq(first(cseq))


decl_type: judgement
theory: csequence_singleton
library: co_structures
signature: nonempty_finite_csequence[T]
location: 26 2 27 58
body:
    singleton_is_nonempty_finite: JUDGEMENT
      (singleton_cseq?) SUBTYPE_OF nonempty_finite_csequence


decl_type: tcc
theory: csequence_singleton
library: co_structures
signature: nil
location: 58 0 61 999
body:
  % Judgement subtype TCC generated (at line 27, column 4) for  x
      % expected type  nonempty_finite_csequence[T]
  singleton_is_nonempty_finite: OBLIGATION
    FORALL (x: (singleton_cseq?)): is_finite[T](x) AND nonempty?[T](x);


decl_type: tcc
theory: csequence_singleton
library: co_structures
signature: nil
location: 63 0 66 999
body:
  % Subtype TCC generated (at line 30, column 54) for  cseq
      % expected type  fseq: finite_csequence[T]
  singleton_cseq_length_TCC1: OBLIGATION
    FORALL (cseq): singleton_cseq?(cseq) IMPLIES is_finite[T](cseq);


decl_type: tcc
theory: csequence_singleton
library: co_structures
signature: nil
location: 68 0 71 999
body:
  % Subtype TCC generated (at line 35, column 41) for  add(t, empty_cseq)
      % expected type  (singleton_cseq?)
  singleton_cseq_TCC1: OBLIGATION
    FORALL (t: T): singleton_cseq?(add[T](t, empty_cseq[T]));


decl_type: tcc
theory: csequence_singleton
library: co_structures
signature: nil
location: 73 0 76 999
body:
  % Subtype TCC generated (at line 39, column 64) for  cseq
      % expected type  (nonempty?[T])
  singleton_def_TCC1: OBLIGATION
    FORALL (cseq): singleton_cseq?(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_sequence
library: co_structures
signature: nil
location: 54 0 59 999
body:
  % Subtype TCC generated (at line 30, column 6) for
      % coreduce(from_sequence_struct)(seq)
      % expected type  infinite_csequence[T]
  from_sequence_TCC1: OBLIGATION
    FORALL (seq: sequence[T]):
      NOT is_finite[T](coreduce[T, sequence](from_sequence_struct)(seq));


decl_type: tcc
theory: csequence_sequence
library: co_structures
signature: nil
location: 61 0 64 999
body:
  % Subtype TCC generated (at line 33, column 43) for  n
      % expected type  indexes[T](from_sequence(seq))
  from_sequence_nth_TCC1: OBLIGATION
    FORALL (seq, n): index?[T](from_sequence(seq))(n);


decl_type: tcc
theory: csequence_sequence
library: co_structures
signature: nil
location: 66 0 69 999
body:
  % Subtype TCC generated (at line 36, column 52) for  n
      % expected type  indexes[T](iseq)
  to_sequence_TCC1: OBLIGATION
    FORALL (iseq: infinite_csequence[T], n): index?[T](iseq)(n);


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 41 2 44 65
body:
    insert_first: THEOREM
      FORALL t, index, cseq:
        first(insert(t, index, cseq)) =
         IF index = 0 OR empty?(cseq) THEN t ELSE first(cseq) ENDIF


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 46 2 51 12
body:
    insert_rest: THEOREM
      FORALL t, index, cseq:
        rest(insert(t, index, cseq)) =
         IF index = 0 OR empty?(cseq) THEN cseq
         ELSE insert(t, index - 1, rest(cseq))
         ENDIF


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 53 2 54 76
body:
    insert_length: THEOREM
      FORALL fseq, t, index: length(insert(t, index, fseq)) = length(fseq) + 1


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 56 2 58 72
body:
    insert_index: THEOREM
      FORALL t, index, cseq, n:
        index?(insert(t, index, cseq))(n) IFF n = 0 OR index?(cseq)(n - 1)


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 60 2 63 72
body:
    insert_nth: THEOREM
      FORALL cseq, t, index, (n: indexes(cseq)):
        nth(cseq, n) =
         nth(insert(t, index, cseq), n + IF n < index THEN 0 ELSE 1 ENDIF)


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 67 2 69 73
body:
    insert_add: THEOREM
      FORALL t, u, index, cseq:
        add(u, insert(t, index, cseq)) = insert(t, index + 1, add(u, cseq))


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 71 2 74 58
body:
    insert_last: THEOREM
      FORALL t, index, fseq:
        last(insert(t, index, fseq)) =
         IF index?(fseq)(index) THEN last(fseq) ELSE t ENDIF


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 76 2 79 61
body:
    insert_beyond: THEOREM
      FORALL t, index, fseq:
        index > length(fseq) IMPLIES
         insert(t, index, fseq) = insert(t, length(fseq), fseq)


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 81 2 88 12
body:
    insert_insert: THEOREM
      FORALL t, u, n, m, cseq:
        insert(t, n, insert(u, m, cseq)) =
         IF is_finite(cseq) AND n > length(cseq) AND m > length(cseq)
           THEN insert(u, length(cseq), insert(t, n, cseq))
         ELSIF n <= m THEN insert(u, m + 1, insert(t, n, cseq))
         ELSE insert(u, m, insert(t, n - 1, cseq))
         ENDIF


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 90 2 93 20
body:
    insert_extensionality: THEOREM
      FORALL t, index, cseq1, cseq2:
        insert(t, index, cseq1) = insert(t, index, cseq2) IMPLIES
         cseq1 = cseq2


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 95 2 97 63
body:
    insert_some: THEOREM
      FORALL t, index, cseq:
        some(p)(insert(t, index, cseq)) IFF p(t) OR some(p)(cseq)


decl_type: formula
theory: csequence_insert
library: co_structures
signature: nil
location: 99 2 101 66
body:
    insert_every: THEOREM
      FORALL t, index, cseq:
        every(p)(insert(t, index, cseq)) IFF p(t) AND every(p)(cseq)


decl_type: function
theory: csequence_insert
library: co_structures
signature: [[T, nat, csequence[T]] -> nonempty_csequence[T]]
location: 29 2 33 18
body:
    insert(t, index, cseq): RECURSIVE nonempty_csequence =
      IF index = 0 OR empty?(cseq) THEN add(t, cseq)
      ELSE add(first(cseq), insert(t, index - 1, rest(cseq)))
      ENDIF
       MEASURE index


decl_type: tcc
theory: csequence_insert
library: co_structures
signature: nil
location: 108 0 112 999
body:
  % Subtype TCC generated (at line 31, column 19) for  cseq
      % expected type  (nonempty?[T])
  insert_TCC1: OBLIGATION
    FORALL (t: T, index: nat, cseq: csequence[T]):
      NOT index = 0 AND NOT empty?(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_insert
library: co_structures
signature: nil
location: 114 0 118 999
body:
  % Subtype TCC generated (at line 31, column 36) for  index - 1
      % expected type  nat
  insert_TCC2: OBLIGATION
    FORALL (t: T, index: nat, cseq: csequence[T]):
      NOT index = 0 AND NOT empty?(cseq) IMPLIES index - 1 >= 0;


decl_type: tcc
theory: csequence_insert
library: co_structures
signature: nil
location: 120 0 124 999
body:
  % Termination TCC generated (at line 31, column 26) for
      % insert(t, index - 1, rest(cseq))
  insert_TCC3: OBLIGATION
    FORALL (t: T, index: nat, cseq: csequence[T]):
      NOT index = 0 AND NOT empty?(cseq) IMPLIES index - 1 < index;


decl_type: tcc
theory: csequence_insert
library: co_structures
signature: nil
location: 126 0 132 999
body:
  % Judgement subtype TCC generated (at line 36, column 4) for
      % insert(t, index, fseq)
      % expected type  nonempty_finite_csequence[T]
  insert_finite: OBLIGATION
    FORALL (fseq, index, t):
      is_finite[T](insert(t, index, fseq)) AND
       nonempty?[T](insert(t, index, fseq));


decl_type: tcc
theory: csequence_insert
library: co_structures
signature: nil
location: 134 0 138 999
body:
  % Judgement subtype TCC generated (at line 39, column 4) for
      % insert(t, index, iseq)
      % expected type  infinite_csequence[T]
  insert_infinite: OBLIGATION
    FORALL (index, iseq, t): NOT is_finite[T](insert(t, index, iseq));


decl_type: tcc
theory: csequence_insert
library: co_structures
signature: nil
location: 140 0 142 999
body:
  % Subtype TCC generated (at line 58, column 66) for  n - 1
      % expected type  nat
  insert_index_TCC1: OBLIGATION FORALL (t, n): NOT n = 0 IMPLIES n - 1 >= 0;


decl_type: tcc
theory: csequence_insert
library: co_structures
signature: nil
location: 144 0 149 999
body:
  % Subtype TCC generated (at line 63, column 35) for
      % n + IF n < index THEN 0 ELSE 1 ENDIF
      % expected type  indexes[T](insert(t, index, cseq))
  insert_nth_TCC1: OBLIGATION
    FORALL (cseq, t, index, n: indexes[T](cseq)):
      index?[T](insert(t, index, cseq))(n + IF n < index THEN 0 ELSE 1 ENDIF);


decl_type: tcc
theory: csequence_insert
library: co_structures
signature: nil
location: 151 0 154 999
body:
  % Subtype TCC generated (at line 74, column 40) for  fseq
      % expected type  nonempty_finite_csequence[T]
  insert_last_TCC1: OBLIGATION
    FORALL (t, index, fseq): index?(fseq)(index) IMPLIES nonempty?[T](fseq);


decl_type: tcc
theory: csequence_insert
library: co_structures
signature: nil
location: 156 0 162 999
body:
  % Subtype TCC generated (at line 87, column 35) for  n - 1
      % expected type  nat
  insert_insert_TCC1: OBLIGATION
    FORALL (t, u, n, m, cseq):
      NOT n <= m AND
       NOT (is_finite(cseq) AND n > length(cseq) AND m > length(cseq))
       IMPLIES n - 1 >= 0;


decl_type: formula
theory: csequence_append
library: co_structures
signature: nil
location: 45 2 47 76
body:
    append_first: THEOREM
      FORALL t, cseq:
        first(append(t, cseq)) = IF empty?(cseq) THEN t ELSE first(cseq) ENDIF


decl_type: formula
theory: csequence_append
library: co_structures
signature: nil
location: 60 2 63 64
body:
    append_index: THEOREM
      FORALL t, cseq, n:
        index?(append(t, cseq))(n) IFF
         (is_finite(cseq) AND n = length(cseq)) OR index?(cseq)(n)


decl_type: formula
theory: csequence_append
library: co_structures
signature: nil
location: 65 2 67 44
body:
    append_nth: THEOREM
      FORALL t, cseq, (n: indexes(cseq)):
        nth(append(t, cseq), n) = nth(cseq, n)


decl_type: formula
theory: csequence_append
library: co_structures
signature: nil
location: 74 2 76 63
body:
    append_extensionality: THEOREM
      FORALL t, cseq1, cseq2:
        append(t, cseq1) = append(t, cseq2) IMPLIES cseq1 = cseq2


decl_type: formula
theory: csequence_append
library: co_structures
signature: nil
location: 78 2 81 50
body:
    append_some: THEOREM
      FORALL t, cseq, p:
        some(p)(append(t, cseq)) IFF
         some(p)(cseq) OR (is_finite(cseq) AND p(t))


decl_type: formula
theory: csequence_append
library: co_structures
signature: nil
location: 83 2 86 53
body:
    append_every: THEOREM
      FORALL t, cseq, p:
        every(p)(append(t, cseq)) IFF
         every(p)(cseq) AND (is_infinite(cseq) OR p(t))


decl_type: function
theory: csequence_append
library: co_structures
signature:
  [[csequence[T], T, bool] ->
  csequence_struct[T, [csequence, T, bool]]]

location: 33 2 38 11
body:
    append_struct(state): csequence_struct =
        IF state`3 THEN inj_empty_cseq
        ELSIF empty?(state`1)
          THEN inj_add(state`2, (state`1, state`2, TRUE))
        ELSE inj_add(first(state`1), (rest(state`1), state`2, FALSE))
        ENDIF


decl_type: tcc
theory: csequence_append
library: co_structures
signature: nil
location: 93 0 97 999
body:
  % Subtype TCC generated (at line 37, column 25) for  state`1
      % expected type  (nonempty?[T])
  append_struct_TCC1: OBLIGATION
    FORALL (state: [csequence[T], T, bool]):
      NOT empty?(state`1) AND NOT state`3 IMPLIES nonempty?[T](state`1);


decl_type: tcc
theory: csequence_append
library: co_structures
signature: nil
location: 99 0 105 999
body:
  % Subtype TCC generated (at line 41, column 6) for
      % coreduce(append_struct)(cseq, t, FALSE)
      % expected type  nonempty_csequence[T]
  append_TCC1: OBLIGATION
    FORALL (t: T, cseq: csequence[T]):
      nonempty?[T]
          (coreduce[T, [csequence, T, bool]](append_struct)(cseq, t, FALSE));


decl_type: tcc
theory: csequence_append
library: co_structures
signature: nil
location: 107 0 112 999
body:
  % Judgement subtype TCC generated (at line 43, column 27) for
      % append(t, fseq)
      % expected type  nonempty_finite_csequence[T]
  append_finite: OBLIGATION
    FORALL (fseq, t):
      is_finite[T](append(t, fseq)) AND nonempty?[T](append(t, fseq));


decl_type: tcc
theory: csequence_append
library: co_structures
signature: nil
location: 114 0 117 999
body:
  % Subtype TCC generated (at line 47, column 65) for  cseq
      % expected type  (nonempty?[T])
  append_first_TCC1: OBLIGATION
    FORALL (t, cseq): NOT empty?(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_append
library: co_structures
signature: nil
location: 119 0 122 999
body:
  % Subtype TCC generated (at line 67, column 27) for  n
      % expected type  indexes[T](append(t, cseq))
  append_nth_TCC1: OBLIGATION
    FORALL (t, cseq, n: indexes[T](cseq)): index?[T](append(t, cseq))(n);


decl_type: formula
theory: csequence_reverse
library: co_structures
signature: nil
location: 44 2 46 61
body:
    reverse_nth: THEOREM
      FORALL fseq, (n: indexes(reverse(fseq))):
        nth(reverse(fseq), n) = nth(fseq, length(fseq) - n - 1)


decl_type: formula
theory: csequence_reverse
library: co_structures
signature: nil
location: 56 2 58 59
body:
    reverse_extensionality: THEOREM
      FORALL fseq1, fseq2:
        reverse(fseq1) = reverse(fseq2) IMPLIES fseq1 = fseq2


decl_type: function
theory: csequence_reverse
library: co_structures
signature: [finite_csequence[T] -> finite_csequence[T]]
location: 25 2 29 25
body:
    reverse(fseq): RECURSIVE finite_csequence =
      IF empty?(fseq) THEN fseq
      ELSE append(first(fseq), reverse(rest(fseq)))
      ENDIF
       MEASURE length(fseq)


decl_type: tcc
theory: csequence_reverse
library: co_structures
signature: nil
location: 71 0 75 999
body:
  % Subtype TCC generated (at line 27, column 22) for  fseq
      % expected type  (nonempty?[T])
  reverse_TCC1: OBLIGATION
    FORALL (fseq: finite_csequence[T]):
      NOT empty?(fseq) IMPLIES nonempty?[T](fseq);


decl_type: tcc
theory: csequence_reverse
library: co_structures
signature: nil
location: 77 0 81 999
body:
  % Subtype TCC generated (at line 27, column 37) for  rest(fseq)
      % expected type  finite_csequence[T]
  reverse_TCC2: OBLIGATION
    FORALL (fseq: finite_csequence[T]):
      NOT empty?(fseq) IMPLIES is_finite[T](rest[T](fseq));


decl_type: tcc
theory: csequence_reverse
library: co_structures
signature: nil
location: 83 0 86 999
body:
  % Termination TCC generated (at line 27, column 29) for  reverse(rest(fseq))
  reverse_TCC3: OBLIGATION
    FORALL (fseq: finite_csequence[T]):
      NOT empty?(fseq) IMPLIES length[T](rest[T](fseq)) < length[T](fseq);


decl_type: tcc
theory: csequence_reverse
library: co_structures
signature: nil
location: 88 0 90 999
body:
  % Subtype TCC generated (at line 36, column 45) for  reverse(nfseq)
      % expected type  (nonempty?[T])
  reverse_first_TCC1: OBLIGATION FORALL (nfseq): nonempty?[T](reverse(nfseq));


decl_type: tcc
theory: csequence_reverse
library: co_structures
signature: nil
location: 92 0 97 999
body:
  % Subtype TCC generated (at line 46, column 40) for  length(fseq) - n - 1
      % expected type  indexes[T](fseq)
  reverse_nth_TCC1: OBLIGATION
    FORALL (fseq, n: indexes[T](reverse(fseq))):
      length[T](fseq) - n - 1 >= 0 AND
       index?[T](fseq)(length[T](fseq) - n - 1);


decl_type: tcc
theory: csequence_reverse
library: co_structures
signature: nil
location: 99 0 102 999
body:
  % Subtype TCC generated (at line 52, column 28) for  add(t, fseq)
      % expected type  finite_csequence[T]
  reverse_add2_TCC1: OBLIGATION
    FORALL (fseq, t): is_finite[T](add[T](t, fseq));


decl_type: formula
theory: csequence_rest
library: co_structures
signature: nil
location: 31 2 33 66
body:
    rest_empty_add: THEOREM
      FORALL nseq:
        empty?(rest(nseq)) IFF (EXISTS t: nseq = add(t, empty_cseq))


decl_type: formula
theory: csequence_rest
library: co_structures
signature: nil
location: 38 2 40 69
body:
    rest_nonempty: THEOREM
      FORALL nseq:
        nonempty?(rest(nseq)) IFF is_infinite(nseq) OR length(nseq) > 1


decl_type: formula
theory: csequence_rest
library: co_structures
signature: nil
location: 42 2 44 68
body:
    rest_first: THEOREM
      FORALL nseq:
        nonempty?(rest(nseq)) IMPLIES first(rest(nseq)) = nth(nseq, 1)


decl_type: formula
theory: csequence_rest
library: co_structures
signature: nil
location: 51 2 53 43
body:
    rest_nth: THEOREM
      FORALL nseq, (n: indexes(rest(nseq))):
        nth(rest(nseq), n) = nth(nseq, n + 1)


decl_type: formula
theory: csequence_rest
library: co_structures
signature: nil
location: 58 2 60 64
body:
    rest_every: THEOREM
      FORALL nseq, p:
        every(p)(nseq) IFF p(first(nseq)) AND every(p)(rest(nseq))


decl_type: tcc
theory: csequence_rest
library: co_structures
signature: nil
location: 68 0 70 999
body:
  % Judgement subtype TCC generated (at line 27, column 25) for  rest(nfseq)
      % expected type  finite_csequence[T]
  rest_finite: OBLIGATION FORALL (nfseq): is_finite[T](rest[T](nfseq));


decl_type: tcc
theory: csequence_rest
library: co_structures
signature: nil
location: 72 0 74 999
body:
  % Judgement subtype TCC generated (at line 29, column 27) for  rest(iseq)
      % expected type  infinite_csequence[T]
  rest_infinite: OBLIGATION FORALL (iseq): NOT is_finite[T](rest[T](iseq));


decl_type: tcc
theory: csequence_rest
library: co_structures
signature: nil
location: 76 0 79 999
body:
  % Subtype TCC generated (at line 44, column 66) for  1
      % expected type  indexes[T](nseq)
  rest_first_TCC1: OBLIGATION
    FORALL (nseq): nonempty?(rest(nseq)) IMPLIES index?[T](nseq)(1);


decl_type: tcc
theory: csequence_rest
library: co_structures
signature: nil
location: 81 0 84 999
body:
  % Subtype TCC generated (at line 53, column 37) for  n + 1
      % expected type  indexes[T](nseq)
  rest_nth_TCC1: OBLIGATION
    FORALL (nseq, n: indexes[T](rest[T](nseq))): index?[T](nseq)(n + 1);


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 42 2 45 57
body:
    remove_empty: THEOREM
      FORALL cseq, index:
        empty?(remove(cseq, index)) IFF
         empty?(cseq) OR (index = 0 AND empty?(rest(cseq)))


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 47 2 50 63
body:
    remove_nonempty: THEOREM
      FORALL cseq, index:
        nonempty?(remove(cseq, index)) IFF
         nonempty?(cseq) AND (index > 0 OR nonempty?(rest(cseq)))


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 52 2 56 66
body:
    remove_first: THEOREM
      FORALL cseq, index:
        nonempty?(remove(cseq, index)) IMPLIES
         first(remove(cseq, index)) =
          IF index = 0 THEN first(rest(cseq)) ELSE first(cseq) ENDIF


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 58 2 64 13
body:
    remove_rest: THEOREM
      FORALL nseq, index:
        nonempty?(remove(nseq, index)) IMPLIES
         rest(remove(nseq, index)) =
          IF index = 0 THEN rest(rest(nseq))
          ELSE remove(rest(nseq), index - 1)
          ENDIF


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 66 2 67 74
body:
    remove_upfrom_length: THEOREM
      FORALL fseq, (index: upfrom[length(fseq)]): remove(fseq, index) = fseq


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 69 2 72 64
body:
    remove_length: THEOREM
      FORALL fseq, index:
        length(remove(fseq, index)) =
         length(fseq) - IF index?(fseq)(index) THEN 1 ELSE 0 ENDIF


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 74 2 79 59
body:
    remove_index: THEOREM
      FORALL index, cseq, n:
        index?(remove(cseq, index))(n) IFF
         index?(cseq)(n) AND
          NOT (is_finite(cseq) AND
                n = length(cseq) - 1 AND index?(cseq)(index))


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 81 2 83 75
body:
    remove_nth: THEOREM
      FORALL cseq, n, (m: indexes(remove(cseq, n))):
        nth(remove(cseq, n), m) = nth(cseq, m + IF m < n THEN 0 ELSE 1 ENDIF)


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 85 2 87 67
body:
    remove_add: THEOREM
      FORALL cseq, index, t:
        add(t, remove(cseq, index)) = remove(add(t, cseq), index + 1)


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 89 2 95 13
body:
    remove_last: THEOREM
      FORALL fseq, index:
        nonempty?(remove(fseq, index)) IMPLIES
         last(remove(fseq, index)) =
          IF index = length(fseq) - 1 THEN nth(fseq, index - 1)
          ELSE last(fseq)
          ENDIF


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 97 2 102 12
body:
    remove_remove: THEOREM
      FORALL cseq, n, m:
        remove(remove(cseq, n), m) =
         IF n <= m THEN remove(remove(cseq, m + 1), n)
         ELSE remove(remove(cseq, m), n - 1)
         ENDIF


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 104 2 110 28
body:
    remove_extensionality: THEOREM
      FORALL cseq1, cseq2, n:
        remove(cseq1, n) = remove(cseq2, n) AND
         ((NOT index?(cseq1)(n) AND NOT index?(cseq2)(n)) OR
           (index?(cseq1)(n) AND
             index?(cseq2)(n) AND nth(cseq1, n) = nth(cseq2, n)))
         IMPLIES cseq1 = cseq2


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 112 2 115 66
body:
    remove_some: THEOREM
      FORALL cseq, index, p:
        some(p)(remove(cseq, index)) IFF
         (EXISTS (n: indexes(cseq)): n /= index AND p(nth(cseq, n)))


decl_type: formula
theory: csequence_remove
library: co_structures
signature: nil
location: 117 2 120 64
body:
    remove_every: THEOREM
      FORALL cseq, index, p:
        every(p)(remove(cseq, index)) IFF
         (FORALL (n: indexes(cseq)): n = index OR p(nth(cseq, n)))


decl_type: function
theory: csequence_remove
library: co_structures
signature: [[csequence[T], nat] -> csequence[T]]
location: 29 2 34 18
body:
    remove(cseq, index): RECURSIVE csequence =
      IF empty?(cseq) THEN cseq
      ELSIF index = 0 THEN rest(cseq)
      ELSE add(first(cseq), remove(rest(cseq), index - 1))
      ENDIF
       MEASURE index


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 127 0 131 999
body:
  % Subtype TCC generated (at line 31, column 30) for  cseq
      % expected type  (nonempty?[T])
  remove_TCC1: OBLIGATION
    FORALL (cseq: csequence[T], index: nat):
      index = 0 AND NOT empty?(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 133 0 137 999
body:
  % Subtype TCC generated (at line 32, column 19) for  cseq
      % expected type  (nonempty?[T])
  remove_TCC2: OBLIGATION
    FORALL (cseq: csequence[T], index: nat):
      NOT index = 0 AND NOT empty?(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 139 0 143 999
body:
  % Subtype TCC generated (at line 32, column 45) for  index - 1
      % expected type  nat
  remove_TCC3: OBLIGATION
    FORALL (cseq: csequence[T], index: nat):
      NOT index = 0 AND NOT empty?(cseq) IMPLIES index - 1 >= 0;


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 145 0 149 999
body:
  % Termination TCC generated (at line 32, column 26) for
      % remove(rest(cseq), index - 1)
  remove_TCC4: OBLIGATION
    FORALL (cseq: csequence[T], index: nat):
      NOT index = 0 AND NOT empty?(cseq) IMPLIES index - 1 < index;


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 151 0 155 999
body:
  % Judgement subtype TCC generated (at line 36, column 27) for
      % remove(fseq, index)
      % expected type  finite_csequence[T]
  remove_finite: OBLIGATION
    FORALL (fseq, index): is_finite[T](remove(fseq, index));


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 157 0 161 999
body:
  % Judgement subtype TCC generated (at line 38, column 29) for
      % remove(iseq, index)
      % expected type  infinite_csequence[T]
  remove_infinite: OBLIGATION
    FORALL (index, iseq): NOT is_finite[T](remove(iseq, index));


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 163 0 167 999
body:
  % Subtype TCC generated (at line 56, column 37) for  cseq
      % expected type  (nonempty?[T])
  remove_first_TCC1: OBLIGATION
    FORALL (cseq, index):
      index = 0 AND nonempty?(remove(cseq, index)) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 169 0 174 999
body:
  % Subtype TCC generated (at line 56, column 32) for  rest(cseq)
      % expected type  (nonempty?[T])
  remove_first_TCC2: OBLIGATION
    FORALL (cseq, index):
      index = 0 AND nonempty?(remove(cseq, index)) IMPLIES
       nonempty?[T](rest[T](cseq));


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 176 0 181 999
body:
  % Subtype TCC generated (at line 56, column 55) for  cseq
      % expected type  (nonempty?[T])
  remove_first_TCC3: OBLIGATION
    FORALL (cseq, index):
      NOT index = 0 AND nonempty?(remove(cseq, index)) IMPLIES
       nonempty?[T](cseq);


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 183 0 188 999
body:
  % Subtype TCC generated (at line 62, column 31) for  rest(nseq)
      % expected type  (nonempty?[T])
  remove_rest_TCC1: OBLIGATION
    FORALL (nseq, index):
      index = 0 AND nonempty?(remove(nseq, index)) IMPLIES
       nonempty?[T](rest[T](nseq));


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 190 0 194 999
body:
  % Subtype TCC generated (at line 63, column 32) for  index - 1
      % expected type  nat
  remove_rest_TCC2: OBLIGATION
    FORALL (nseq, index):
      NOT index = 0 AND nonempty?(remove(nseq, index)) IMPLIES index - 1 >= 0;


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 196 0 201 999
body:
  % Subtype TCC generated (at line 83, column 42) for
      % m + IF m < n THEN 0 ELSE 1 ENDIF
      % expected type  indexes[T](cseq)
  remove_nth_TCC1: OBLIGATION
    FORALL (cseq, n, m: indexes[T](remove(cseq, n))):
      index?[T](cseq)(m + IF m < n THEN 0 ELSE 1 ENDIF);


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 203 0 208 999
body:
  % Subtype TCC generated (at line 93, column 51) for  index - 1
      % expected type  indexes[T](fseq)
  remove_last_TCC1: OBLIGATION
    FORALL (fseq, index):
      index = length(fseq) - 1 AND nonempty?(remove(fseq, index)) IMPLIES
       index - 1 >= 0 AND index?[T](fseq)(index - 1);


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 210 0 215 999
body:
  % Subtype TCC generated (at line 94, column 18) for  fseq
      % expected type  nonempty_finite_csequence[T]
  remove_last_TCC2: OBLIGATION
    FORALL (fseq, index):
      NOT index = length(fseq) - 1 AND nonempty?(remove(fseq, index)) IMPLIES
       nonempty?[T](fseq);


decl_type: tcc
theory: csequence_remove
library: co_structures
signature: nil
location: 217 0 219 999
body:
  % Subtype TCC generated (at line 101, column 36) for  n - 1
      % expected type  nat
  remove_remove_TCC1: OBLIGATION FORALL (n, m): NOT n <= m IMPLIES n - 1 >= 0;


decl_type: formula
theory: csequence_prefix_suffix
library: co_structures
signature: nil
location: 25 2 29 28
body:
    prefix_suffix_extensionality: THEOREM
      FORALL cseq1, cseq2, n:
        prefix(cseq1, n) = prefix(cseq2, n) AND
         suffix(cseq1, n) = suffix(cseq2, n)
         IMPLIES cseq1 = cseq2


decl_type: formula
theory: csequence_prefix_append
library: co_structures
signature: nil
location: 19 2 21 50
body:
    prefix_append_eta: THEOREM
      FORALL (fseq: finite_csequence), (t: T):
        prefix(append(t, fseq), length(fseq)) = fseq


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 41 2 43 69
body:
    merge_empty: THEOREM
      FORALL cseq1, cseq2:
        empty?(merge(cseq1, cseq2)) IFF empty?(cseq1) AND empty?(cseq2)


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 45 2 48 43
body:
    merge_nonempty: THEOREM
      FORALL cseq1, cseq2:
        nonempty?(merge(cseq1, cseq2)) IFF
         nonempty?(cseq1) OR nonempty?(cseq2)


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 54 2 58 69
body:
    merge_first: THEOREM
      FORALL cseq1, cseq2:
        nonempty?(merge(cseq1, cseq2)) IMPLIES
         first(merge(cseq1, cseq2)) =
          IF nonempty?(cseq1) THEN first(cseq1) ELSE first(cseq2) ENDIF


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 60 2 66 13
body:
    merge_rest: THEOREM
      FORALL cseq1, cseq2:
        nonempty?(merge(cseq1, cseq2)) IMPLIES
         rest(merge(cseq1, cseq2)) =
          IF nonempty?(cseq1) THEN merge(cseq2, rest(cseq1))
          ELSE rest(cseq2)
          ENDIF


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 71 2 74 44
body:
    merge_finiteness: THEOREM
      FORALL cseq1, cseq2:
        is_finite(merge(cseq1, cseq2)) IMPLIES
         is_finite(cseq1) AND is_finite(cseq2)


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 79 2 81 65
body:
    merge_length: THEOREM
      FORALL fseq1, fseq2:
        length(merge(fseq1, fseq2)) = length(fseq1) + length(fseq2)


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 83 2 87 67
body:
    merge_index: THEOREM
      FORALL cseq1, cseq2, n:
        index?(merge(cseq1, cseq2))(n) IFF
         index?(cseq1)(n) OR
          (is_finite(cseq1) IMPLIES index?(cseq2)(n - length(cseq1)))


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 89 2 98 12
body:
    merge_nth: THEOREM
      FORALL cseq1, cseq2, (n: indexes(merge(cseq1, cseq2))):
        nth(merge(cseq1, cseq2), n) =
         IF length_lt(cseq1, cseq2) AND n >= length(cseq1) * 2
           THEN nth(cseq2, n - length(cseq1))
         ELSIF length_lt(cseq2, cseq1) AND n >= length(cseq2) * 2
           THEN nth(cseq1, n - length(cseq2))
         ELSIF even?(n) THEN nth(cseq1, n / 2)
         ELSE nth(cseq2, (n - 1) / 2)
         ENDIF


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 100 2 102 63
body:
    merge_add: THEOREM
      FORALL t, cseq1, cseq2:
        add(t, merge(cseq1, cseq2)) = merge(add(t, cseq2), cseq1)


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 104 2 110 13
body:
    merge_last: THEOREM
      FORALL fseq1, fseq2:
        nonempty?(merge(fseq1, fseq2)) IMPLIES
         last(merge(fseq1, fseq2)) =
          IF length(fseq1) <= length(fseq2) THEN last(fseq2)
          ELSE last(fseq1)
          ENDIF


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 112 2 117 46
body:
    merge_extensionality: THEOREM
      FORALL cseq1, cseq2, cseq3, cseq4:
        length_eq(cseq1, cseq2) AND
         length_eq(cseq3, cseq4) AND
          merge(cseq1, cseq2) = merge(cseq3, cseq4)
         IMPLIES cseq1 = cseq3 AND cseq2 = cseq4


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 119 2 121 71
body:
    merge_some: THEOREM
      FORALL p, cseq1, cseq2:
        some(p)(merge(cseq1, cseq2)) IFF some(p)(cseq1) OR some(p)(cseq2)


decl_type: formula
theory: csequence_merge
library: co_structures
signature: nil
location: 123 2 125 75
body:
    merge_every: THEOREM
      FORALL p, cseq1, cseq2:
        every(p)(merge(cseq1, cseq2)) IFF every(p)(cseq1) AND every(p)(cseq2)


decl_type: function
theory: csequence_merge
library: co_structures
signature:
  [[csequence[T], csequence[T]] ->
  csequence_struct[T, [csequence, csequence]]]

location: 31 2 37 11
body:
    merge_struct(state): csequence_struct =
        IF empty?(state`1)
          THEN IF empty?(state`2) THEN inj_empty_cseq
               ELSE inj_add(first(state`2), (rest(state`2), state`1))
               ENDIF
        ELSE inj_add(first(state`1), (state`2, rest(state`1)))
        ENDIF


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 132 0 136 999
body:
  % Subtype TCC generated (at line 34, column 32) for  state`2
      % expected type  (nonempty?[T])
  merge_struct_TCC1: OBLIGATION
    FORALL (state: [csequence[T], csequence[T]]):
      NOT empty?(state`2) AND empty?(state`1) IMPLIES nonempty?[T](state`2);


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 138 0 142 999
body:
  % Subtype TCC generated (at line 36, column 25) for  state`1
      % expected type  (nonempty?[T])
  merge_struct_TCC2: OBLIGATION
    FORALL (state: [csequence[T], csequence[T]]):
      NOT empty?(state`1) IMPLIES nonempty?[T](state`1);


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 144 0 149 999
body:
  % Subtype TCC generated (at line 58, column 57) for  cseq2
      % expected type  (nonempty?[T])
  merge_first_TCC1: OBLIGATION
    FORALL (cseq1, cseq2):
      NOT nonempty?(cseq1) AND nonempty?(merge(cseq1, cseq2)) IMPLIES
       nonempty?[T](cseq2);


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 151 0 155 999
body:
  % Judgement subtype TCC generated (at line 68, column 26) for
      % merge(fseq1, fseq2)
      % expected type  finite_csequence[T]
  merge_finite: OBLIGATION
    FORALL (fseq1, fseq2): is_finite[T](merge(fseq1, fseq2));


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 157 0 161 999
body:
  % Judgement subtype TCC generated (at line 76, column 29) for
      % merge(iseq, cseq)
      % expected type  infinite_csequence[T]
  merge_infinite1: OBLIGATION
    FORALL (cseq, iseq): NOT is_finite[T](merge(iseq, cseq));


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 163 0 167 999
body:
  % Judgement subtype TCC generated (at line 77, column 29) for
      % merge(cseq, iseq)
      % expected type  infinite_csequence[T]
  merge_infinite2: OBLIGATION
    FORALL (cseq, iseq): NOT is_finite[T](merge(cseq, iseq));


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 169 0 174 999
body:
  % Subtype TCC generated (at line 87, column 48) for  n - length(cseq1)
      % expected type  nat
  merge_index_TCC1: OBLIGATION
    FORALL (cseq1, n):
      is_finite(cseq1) AND NOT index?(cseq1)(n) IMPLIES
       n - length[T](cseq1) >= 0;


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 176 0 180 999
body:
  % Subtype TCC generated (at line 92, column 50) for  cseq1
      % expected type  fseq: finite_csequence[T]
  merge_nth_TCC1: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[T](merge(cseq1, cseq2))):
      length_lt(cseq1, cseq2) IMPLIES is_finite[T](cseq1);


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 182 0 187 999
body:
  % Subtype TCC generated (at line 93, column 25) for  n - length(cseq1)
      % expected type  indexes[T](cseq2)
  merge_nth_TCC2: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[T](merge(cseq1, cseq2))):
      length_lt(cseq1, cseq2) AND n >= length(cseq1) * 2 IMPLIES
       n - length[T](cseq1) >= 0 AND index?[T](cseq2)(n - length[T](cseq1));


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 189 0 195 999
body:
  % Subtype TCC generated (at line 94, column 53) for  cseq2
      % expected type  fseq: finite_csequence[T]
  merge_nth_TCC3: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[T](merge(cseq1, cseq2))):
      length_lt(cseq2, cseq1) AND
       NOT (length_lt(cseq1, cseq2) AND n >= length(cseq1) * 2)
       IMPLIES is_finite[T](cseq2);


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 197 0 205 999
body:
  % Subtype TCC generated (at line 95, column 25) for  n - length(cseq2)
      % expected type  indexes[T](cseq1)
  merge_nth_TCC4: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[T](merge(cseq1, cseq2))):
      length_lt(cseq2, cseq1) AND
       n >= length(cseq2) * 2 AND
        NOT (length_lt(cseq1, cseq2) AND n >= length(cseq1) * 2)
       IMPLIES
       n - length[T](cseq2) >= 0 AND index?[T](cseq1)(n - length[T](cseq2));


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 207 0 214 999
body:
  % Subtype TCC generated (at line 96, column 38) for  n / 2
      % expected type  indexes[T](cseq1)
  merge_nth_TCC5: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[T](merge(cseq1, cseq2))):
      even?(n) AND
       NOT (length_lt(cseq2, cseq1) AND n >= length(cseq2) * 2) AND
        NOT (length_lt(cseq1, cseq2) AND n >= length(cseq1) * 2)
       IMPLIES integer_pred(n / 2) AND n / 2 >= 0 AND index?[T](cseq1)(n / 2);


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 216 0 225 999
body:
  % Subtype TCC generated (at line 97, column 23) for  (n - 1) / 2
      % expected type  indexes[T](cseq2)
  merge_nth_TCC6: OBLIGATION
    FORALL (cseq1, cseq2, n: indexes[T](merge(cseq1, cseq2))):
      NOT even?(n) AND
       NOT (length_lt(cseq2, cseq1) AND n >= length(cseq2) * 2) AND
        NOT (length_lt(cseq1, cseq2) AND n >= length(cseq1) * 2)
       IMPLIES
       integer_pred((n - 1) / 2) AND
        (n - 1) / 2 >= 0 AND index?[T](cseq2)((n - 1) / 2);


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 227 0 232 999
body:
  % Subtype TCC generated (at line 108, column 52) for  fseq2
      % expected type  nonempty_finite_csequence[T]
  merge_last_TCC1: OBLIGATION
    FORALL (fseq1, fseq2):
      length(fseq1) <= length(fseq2) AND nonempty?(merge(fseq1, fseq2))
       IMPLIES nonempty?[T](fseq2);


decl_type: tcc
theory: csequence_merge
library: co_structures
signature: nil
location: 234 0 239 999
body:
  % Subtype TCC generated (at line 109, column 18) for  fseq1
      % expected type  nonempty_finite_csequence[T]
  merge_last_TCC2: OBLIGATION
    FORALL (fseq1, fseq2):
      NOT length(fseq1) <= length(fseq2) AND nonempty?(merge(fseq1, fseq2))
       IMPLIES nonempty?[T](fseq1);


decl_type: formula
theory: csequence_merge_split
library: co_structures
signature: nil
location: 24 2 27 50
body:
    split_merge_eta: THEOREM
      FORALL cseq1, cseq2:
        length_eq(cseq1, cseq2) IMPLIES
         split(merge(cseq1, cseq2)) = (cseq1, cseq2)


decl_type: formula
theory: csequence_map_props
library: co_structures
signature: nil
location: 46 2 48 44
body:
    map_nth: THEOREM
      FORALL f, cseq, (n: indexes(cseq)):
        nth(map(f, cseq), n) = f(nth(cseq, n))


decl_type: formula
theory: csequence_map_props
library: co_structures
signature: nil
location: 61 2 63 75
body:
    map_extensionality: THEOREM
      FORALL f, cseq1, cseq2:
        injective?(f) AND map(f, cseq1) = map(f, cseq2) IMPLIES cseq1 = cseq2


decl_type: tcc
theory: csequence_map_props
library: co_structures
signature: nil
location: 76 0 79 999
body:
  % Judgement subtype TCC generated (at line 34, column 24) for  map(f, fseq)
      % expected type  finite_csequence[T2]
  map_finite: OBLIGATION
    FORALL (f, fseq): is_finite[T2](map[T1, T2](f, fseq));


decl_type: tcc
theory: csequence_map_props
library: co_structures
signature: nil
location: 81 0 84 999
body:
  % Judgement subtype TCC generated (at line 36, column 26) for  map(f, iseq)
      % expected type  infinite_csequence[T2]
  map_infinite: OBLIGATION
    FORALL (f, iseq): NOT is_finite[T2](map[T1, T2](f, iseq));


decl_type: tcc
theory: csequence_map_props
library: co_structures
signature: nil
location: 86 0 89 999
body:
  % Subtype TCC generated (at line 38, column 43) for  map(f, nseq)
      % expected type  (nonempty?[T2])
  map_first_TCC1: OBLIGATION
    FORALL (f, nseq): nonempty?[T2](map[T1, T2](f, nseq));


decl_type: tcc
theory: csequence_map_props
library: co_structures
signature: nil
location: 91 0 95 999
body:
  % Subtype TCC generated (at line 48, column 24) for  n
      % expected type  indexes[T2](map(f, cseq))
  map_nth_TCC1: OBLIGATION
    FORALL (f, cseq, n: indexes[T1](cseq)):
      index?[T2](map[T1, T2](f, cseq))(n);


decl_type: tcc
theory: csequence_map_props
library: co_structures
signature: nil
location: 97 0 100 999
body:
  % Subtype TCC generated (at line 53, column 42) for  map(f, nfseq)
      % expected type  nonempty_finite_csequence[T2]
  map_last_TCC1: OBLIGATION
    FORALL (f, nfseq): nonempty?[T2](map[T1, T2](f, nfseq));


decl_type: formula
theory: csequence_map_composition
library: co_structures
signature: nil
location: 21 2 24 35
body:
    map_composition: THEOREM
      FORALL (f12: [T1 -> T2]), (f23: [T2 -> T3]), (cseq: csequence[T1]):
        map[T2, T3](f23)(map[T1, T2](f12)(cseq)) =
         map[T1, T3](f23 o f12)(cseq)


decl_type: function
theory: csequence_list
library: co_structures
signature: [list[T] -> finite_csequence[T]]
location: 24 2 26 20
body:
    from_list(l): RECURSIVE finite_csequence =
      IF null?(l) THEN empty_cseq ELSE add(car(l), from_list(cdr(l))) ENDIF
       MEASURE l BY <<


decl_type: function
theory: csequence_list
library: co_structures
signature: [finite_csequence[T] -> list[T]]
location: 37 2 41 25
body:
    to_list(fseq): RECURSIVE list =
      IF empty?(fseq) THEN null
      ELSE cons(first(fseq), to_list(rest(fseq)))
      ENDIF
       MEASURE length(fseq)


decl_type: tcc
theory: csequence_list
library: co_structures
signature: nil
location: 62 0 65 999
body:
  % Subtype TCC generated (at line 25, column 45) for  l
      % expected type  (cons?)
  from_list_TCC1: OBLIGATION
    FORALL (l: list[T]): NOT null?(l) IMPLIES cons?[T](l);


decl_type: tcc
theory: csequence_list
library: co_structures
signature: nil
location: 67 0 69 999
body:
  % Termination TCC generated (at line 25, column 49) for  from_list(cdr(l))
  from_list_TCC2: OBLIGATION
    FORALL (l: list[T]): NOT null?(l) IMPLIES <<[T](cdr[T](l), l);


decl_type: tcc
theory: csequence_list
library: co_structures
signature: nil
location: 71 0 76 999
body:
  % Subtype TCC generated (at line 25, column 37) for
      % add(car(l), from_list(cdr(l)))
      % expected type  finite_csequence[T]
  from_list_TCC3: OBLIGATION
    FORALL (l: list[T], v: [{z: list[T] | z << l} -> finite_csequence[T]]):
      NOT null?(l) IMPLIES is_finite[T](add[T](car[T](l), v(cdr[T](l))));


decl_type: tcc
theory: csequence_list
library: co_structures
signature: nil
location: 78 0 81 999
body:
  % Subtype TCC generated (at line 34, column 55) for  n
      % expected type  indexes[T](from_list(l))
  from_list_nth_TCC1: OBLIGATION
    FORALL (l, n: below[length[T](l)]): index?[T](from_list(l))(n);


decl_type: tcc
theory: csequence_list
library: co_structures
signature: nil
location: 83 0 87 999
body:
  % Subtype TCC generated (at line 39, column 20) for  fseq
      % expected type  (nonempty?[T])
  to_list_TCC1: OBLIGATION
    FORALL (fseq: finite_csequence[T]):
      NOT empty?(fseq) IMPLIES nonempty?[T](fseq);


decl_type: tcc
theory: csequence_list
library: co_structures
signature: nil
location: 89 0 93 999
body:
  % Subtype TCC generated (at line 39, column 35) for  rest(fseq)
      % expected type  finite_csequence[T]
  to_list_TCC2: OBLIGATION
    FORALL (fseq: finite_csequence[T]):
      NOT empty?(fseq) IMPLIES is_finite[T](rest[T](fseq));


decl_type: tcc
theory: csequence_list
library: co_structures
signature: nil
location: 95 0 98 999
body:
  % Termination TCC generated (at line 39, column 27) for  to_list(rest(fseq))
  to_list_TCC3: OBLIGATION
    FORALL (fseq: finite_csequence[T]):
      NOT empty?(fseq) IMPLIES length[T](rest[T](fseq)) < length[T](fseq);


decl_type: tcc
theory: csequence_list
library: co_structures
signature: nil
location: 100 0 103 999
body:
  % Subtype TCC generated (at line 49, column 56) for  n
      % expected type  below[length(to_list(fseq))]
  to_list_nth_TCC1: OBLIGATION
    FORALL (fseq, n: indexes[T](fseq)): n < length[T](to_list(fseq));


decl_type: formula
theory: ascending_chains
library: co_structures
signature: nil
location: 38 2 41 12
body:
    least_upperbound_inj: THEOREM
      FORALL chain, t, u:
        least_upperbound?(chain)(t) AND least_upperbound?(chain)(u) IMPLIES
         t = u


decl_type: function
theory: ascending_chains
library: co_structures
signature: [ascending_chain -> [T -> bool]]
location: 34 2 36 55
body:
    least_upperbound?(chain)(t): bool =
        upperbound?(chain)(t) AND
         (FORALL u: upperbound?(chain)(u) IMPLIES t <= u)


decl_type: formula
theory: csequence_limit
library: co_structures
signature: nil
location: 39 2 42 66
body:
    ascending_chain?_nth: THEOREM
      FORALL chain, n, m, k:
        n <= m AND index?(chain(n))(k) IMPLIES
         index?(chain(m))(k) AND nth(chain(n), k) = nth(chain(m), k)


decl_type: formula
theory: csequence_limit
library: co_structures
signature: nil
location: 55 2 57 65
body:
    limit_nonempty: THEOREM
      FORALL chain:
        nonempty?(limit(chain)) IFF (EXISTS n: nonempty?(chain(n)))


decl_type: formula
theory: csequence_limit
library: co_structures
signature: nil
location: 59 2 61 71
body:
    limit_first: THEOREM
      FORALL chain, n:
        nonempty?(chain(n)) IMPLIES first(chain(n)) = first(limit(chain))


decl_type: formula
theory: csequence_limit
library: co_structures
signature: nil
location: 63 2 66 52
body:
    limit_rest_chain: THEOREM
      FORALL chain:
        nonempty?(limit(chain)) IMPLIES
         rest(limit(chain)) = limit(rest_chain(chain))


decl_type: formula
theory: csequence_limit
library: co_structures
signature: nil
location: 68 2 69 76
body:
    limit_suffix_chain: THEOREM
      FORALL chain, n: suffix(limit(chain), n) = limit(suffix_chain(chain, n))


decl_type: formula
theory: csequence_limit
library: co_structures
signature: nil
location: 73 2 76 74
body:
    limit_nth: THEOREM
      FORALL chain, cseq, n, m:
        index?(chain(n))(m) IMPLIES
         index?(limit(chain))(m) AND nth(chain(n), m) = nth(limit(chain), m)


decl_type: formula
theory: csequence_limit
library: co_structures
signature: nil
location: 78 2 83 68
body:
    limit_def: THEOREM
      FORALL chain, cseq:
        limit(chain) = cseq IFF
         (FORALL t, n:
            index?(cseq)(n) AND nth(cseq, n) = t IFF
             (EXISTS m: index?(chain(m))(n) AND nth(chain(m), n) = t))


decl_type: formula
theory: csequence_limit
library: co_structures
signature: nil
location: 87 2 91 56
body:
    limit_prefix_compact: THEOREM
      FORALL cseq, n, chain:
        (n = 0 OR index?(cseq)(n - 1)) IMPLIES
         (prefix?(prefix(cseq, n), limit(chain)) IMPLIES
           (EXISTS m: prefix?(prefix(cseq, n), chain(m))))


decl_type: formula
theory: csequence_limit
library: co_structures
signature: nil
location: 93 2 98 47
body:
    limit_finite_compact: THEOREM
      FORALL cseq:
        is_finite(cseq) IFF
         (FORALL chain:
            prefix?(cseq, limit(chain)) IMPLIES
             (EXISTS m: prefix?(cseq, chain(m))))


decl_type: formula
theory: csequence_limit
library: co_structures
signature: nil
location: 103 2 106 29
body:
    continuous?_infinite: THEOREM
      FORALL p:
        continuous?(p) AND (FORALL fseq: p(fseq)) IMPLIES
         (FORALL cseq: p(cseq))


decl_type: function
theory: csequence_limit
library: co_structures
signature:
  [ascending_chain[csequence, prefix?] ->
  ascending_chain[csequence, prefix?]]

location: 35 2 37 69
body:
    rest_chain(chain): ascending_chain =
        LAMBDA n:
          IF empty?(chain(n)) THEN empty_cseq ELSE rest(chain(n)) ENDIF


decl_type: function
theory: csequence_limit
library: co_structures
signature:
  [ascending_chain[csequence, prefix?] ->
  csequence_struct[T, ascending_chain]]

location: 44 2 48 11
body:
    limit_struct(chain): csequence_struct[T, ascending_chain] =
        IF (FORALL n: empty?(chain(n))) THEN inj_empty_cseq
        ELSE inj_add(first(chain(min({n | nonempty?(chain(n))}))),
                     rest_chain(chain))
        ENDIF


decl_type: tcc
theory: csequence_limit
library: co_structures
signature: nil
location: 113 0 119 999
body:
  % Subtype TCC generated (at line 31, column 40) for
      % LAMBDA n: prefix(cseq, n)
      % expected type  ascending_chain[csequence, prefix?]
  prefix_chain_TCC1: OBLIGATION
    FORALL (cseq: csequence[T]):
      ascending_chain?[csequence[T], prefix?[T]]
          (LAMBDA n: prefix[T](cseq, n));


decl_type: tcc
theory: csequence_limit
library: co_structures
signature: nil
location: 121 0 127 999
body:
  % Subtype TCC generated (at line 33, column 44) for
      % LAMBDA m: suffix(chain(m), n)
      % expected type  ascending_chain[csequence, prefix?]
  suffix_chain_TCC1: OBLIGATION
    FORALL (chain: ascending_chain[csequence[T], prefix?[T]], n: nat):
      ascending_chain?[csequence[T], prefix?[T]]
          (LAMBDA m: suffix[T](chain(m), n));


decl_type: tcc
theory: csequence_limit
library: co_structures
signature: nil
location: 129 0 133 999
body:
  % Subtype TCC generated (at line 37, column 54) for  chain(n)
      % expected type  (nonempty?[T])
  rest_chain_TCC1: OBLIGATION
    FORALL (chain: ascending_chain[csequence[T], prefix?[T]], n):
      NOT empty?(chain(n)) IMPLIES nonempty?[T](chain(n));


decl_type: tcc
theory: csequence_limit
library: co_structures
signature: nil
location: 135 0 145 999
body:
  % Subtype TCC generated (at line 36, column 6) for
      % LAMBDA n:
      %   IF empty?(chain(n)) THEN empty_cseq ELSE rest(chain(n)) ENDIF
      % expected type  ascending_chain[csequence, prefix?]
  rest_chain_TCC2: OBLIGATION
    FORALL (chain: ascending_chain[csequence[T], prefix?[T]]):
      ascending_chain?[csequence[T], prefix?[T]]
          (LAMBDA n:
             IF empty?[T](chain(n)) THEN empty_cseq[T]
             ELSE rest[T](chain(n))
             ENDIF);


decl_type: tcc
theory: csequence_limit
library: co_structures
signature: nil
location: 147 0 153 999
body:
  % Subtype TCC generated (at line 46, column 35) for
      % {n | nonempty?(chain(n))}
      % expected type  S: (nonempty?[nat])
  limit_struct_TCC1: OBLIGATION
    FORALL (chain: ascending_chain[csequence[T], prefix?[T]]):
      NOT (FORALL n: empty?(chain(n))) IMPLIES
       nonempty?[nat]({n | nonempty?[T](chain(n))});


decl_type: tcc
theory: csequence_limit
library: co_structures
signature: nil
location: 155 0 161 999
body:
  % Subtype TCC generated (at line 46, column 25) for
      % chain(min({n | nonempty?(chain(n))}))
      % expected type  (nonempty?[T])
  limit_struct_TCC2: OBLIGATION
    FORALL (chain: ascending_chain[csequence[T], prefix?[T]]):
      NOT (FORALL n: empty?(chain(n))) IMPLIES
       nonempty?[T](chain(min[nat]({n | nonempty?[T](chain(n))})));


decl_type: tcc
theory: csequence_limit
library: co_structures
signature: nil
location: 163 0 166 999
body:
  % Subtype TCC generated (at line 61, column 58) for  limit(chain)
      % expected type  (nonempty?[T])
  limit_first_TCC1: OBLIGATION
    FORALL (chain, n): nonempty?(chain(n)) IMPLIES nonempty?[T](limit(chain));


decl_type: tcc
theory: csequence_limit
library: co_structures
signature: nil
location: 168 0 171 999
body:
  % Subtype TCC generated (at line 89, column 29) for  n - 1
      % expected type  nat
  limit_prefix_compact_TCC1: OBLIGATION
    FORALL (n, chain): NOT n = 0 IMPLIES n - 1 >= 0;


decl_type: formula
theory: csequence_insert_remove
library: co_structures
signature: nil
location: 20 2 22 53
body:
    insert_remove_eta: THEOREM
      FORALL (cseq: csequence), (n: indexes(cseq)):
        insert(nth(cseq, n), n, remove(cseq, n)) = cseq


decl_type: formula
theory: csequence_induction
library: co_structures
signature: nil
location: 33 2 38 29
body:
    cseq_induction: THEOREM
      FORALL cseq, p:
        p_if_exists(p, cseq, 0) AND
         (FORALL n:
            p_if_exists(p, cseq, n) IMPLIES p_if_exists(p, cseq, n + 1))
         IMPLIES every(p)(cseq)


decl_type: formula
theory: csequence_induction
library: co_structures
signature: nil
location: 41 2 45 29
body:
    cseq_infinite_induction: THEOREM
      FORALL iseq, p:
        p(nth(iseq, 0)) AND
         (FORALL n: p(nth(iseq, n)) IMPLIES p(nth(iseq, n + 1)))
         IMPLIES every(p)(iseq)


decl_type: formula
theory: csequence_induction
library: co_structures
signature: nil
location: 48 2 53 29
body:
    CSEQ_induction: THEOREM
      FORALL cseq, p:
        (FORALL n:
           (FORALL m: m < n IMPLIES p_if_exists(p, cseq, m)) IMPLIES
            p_if_exists(p, cseq, n))
         IMPLIES every(p)(cseq)


decl_type: formula
theory: csequence_induction
library: co_structures
signature: nil
location: 56 2 61 29
body:
    CSEQ_infinite_induction: THEOREM
      FORALL iseq, p:
        (FORALL n:
           (FORALL m: m < n IMPLIES p(nth(iseq, m))) IMPLIES
            p(nth(iseq, n)))
         IMPLIES every(p)(iseq)


decl_type: formula
theory: csequence_induction
library: co_structures
signature: nil
location: 64 2 70 38
body:
    finite_sequence_induction: THEOREM
      FORALL sp:
        sp(empty_cseq) AND
         (FORALL n:
            (FORALL fseq: length(fseq) = n IMPLIES sp(fseq)) IMPLIES
             (FORALL fseq: length(fseq) = n + 1 IMPLIES sp(fseq)))
         IMPLIES (FORALL fseq: sp(fseq))


decl_type: formula
theory: csequence_induction
library: co_structures
signature: nil
location: 73 2 78 38
body:
    FINITE_SEQUENCE_induction: THEOREM
      FORALL sp:
        (FORALL n:
           (FORALL fseq: length(fseq) < n IMPLIES sp(fseq)) IMPLIES
            (FORALL fseq: length(fseq) = n IMPLIES sp(fseq)))
         IMPLIES (FORALL fseq: sp(fseq))


decl_type: formula
theory: csequence_induction
library: co_structures
signature: nil
location: 82 2 89 38
body:
    sequence_induction: THEOREM
      FORALL sp:
        sp(empty_cseq) AND
         (FORALL iseq: sp(iseq)) AND
          (FORALL n:
             (FORALL fseq: length(fseq) = n IMPLIES sp(fseq)) IMPLIES
              (FORALL fseq: length(fseq) = n + 1 IMPLIES sp(fseq)))
         IMPLIES (FORALL cseq: sp(cseq))


decl_type: formula
theory: csequence_induction
library: co_structures
signature: nil
location: 92 2 98 38
body:
    SEQUENCE_induction: THEOREM
      FORALL sp:
        (FORALL iseq: sp(iseq)) AND
         (FORALL n:
            (FORALL fseq: length(fseq) < n IMPLIES sp(fseq)) IMPLIES
             (FORALL fseq: length(fseq) = n IMPLIES sp(fseq)))
         IMPLIES (FORALL cseq: sp(cseq))


decl_type: tcc
theory: csequence_induction
library: co_structures
signature: nil
location: 105 0 107 999
body:
  % Subtype TCC generated (at line 43, column 18) for  0
      % expected type  indexes[T](iseq)
  cseq_infinite_induction_TCC1: OBLIGATION FORALL (iseq): index?[T](iseq)(0);


decl_type: tcc
theory: csequence_induction
library: co_structures
signature: nil
location: 109 0 113 999
body:
  % Subtype TCC generated (at line 44, column 30) for  n
      % expected type  indexes[T](iseq)
  cseq_infinite_induction_TCC2: OBLIGATION
    FORALL (iseq, p):
      p(nth(iseq, 0)) IMPLIES (FORALL (n): index?[T](iseq)(n));


decl_type: tcc
theory: csequence_induction
library: co_structures
signature: nil
location: 115 0 120 999
body:
  % Subtype TCC generated (at line 44, column 54) for  n + 1
      % expected type  indexes[T](iseq)
  cseq_infinite_induction_TCC3: OBLIGATION
    FORALL (iseq, p):
      p(nth(iseq, 0)) IMPLIES
       (FORALL (n): p(nth(iseq, n)) IMPLIES index?[T](iseq)(n + 1));


decl_type: tcc
theory: csequence_induction
library: co_structures
signature: nil
location: 122 0 125 999
body:
  % Subtype TCC generated (at line 59, column 46) for  m
      % expected type  indexes[T](iseq)
  CSEQ_infinite_induction_TCC1: OBLIGATION
    FORALL (iseq, n, m): m < n IMPLIES index?[T](iseq)(m);


decl_type: tcc
theory: csequence_induction
library: co_structures
signature: nil
location: 127 0 131 999
body:
  % Subtype TCC generated (at line 60, column 22) for  n
      % expected type  indexes[T](iseq)
  CSEQ_infinite_induction_TCC2: OBLIGATION
    FORALL (iseq, p, n):
      (FORALL m: m < n IMPLIES p(nth(iseq, m))) IMPLIES index?[T](iseq)(n);


decl_type: formula
theory: csequence_generate_limit
library: co_structures
signature: nil
location: 44 2 46 72
body:
    generate_rest: THEOREM
      FORALL f, t, stop?:
        stop?(t) OR rest(generate(f, t, stop?)) = generate(f, f(t), stop?)


decl_type: formula
theory: csequence_generate_limit
library: co_structures
signature: nil
location: 49 2 53 61
body:
    generate_has_length: LEMMA
      FORALL f, t, stop?, n:
        has_length(generate(f, t, stop?), n) IFF
         (stop?(iterate(f, n)(t)) AND
           (FORALL (m: below[n]): NOT stop?(iterate(f, m)(t))))


decl_type: formula
theory: csequence_generate_limit
library: co_structures
signature: nil
location: 55 2 57 78
body:
    generate_finite: THEOREM
      FORALL f, t, stop?:
        is_finite(generate(f, t, stop?)) IFF (EXISTS n: stop?(iterate(f, n)(t)))


decl_type: formula
theory: csequence_generate_limit
library: co_structures
signature: nil
location: 59 2 61 54
body:
    generate_nth: THEOREM
      FORALL f, t, stop?, (n: indexes(generate(f, t, stop?))):
        nth(generate(f, t, stop?), n) = iterate(f, n)(t)


decl_type: formula
theory: csequence_generate_limit
library: co_structures
signature: nil
location: 63 2 66 60
body:
    generate_add: THEOREM
      FORALL f, t, stop?, u:
        t = f(u) AND NOT stop?(u) IMPLIES
         add(u, generate(f, t, stop?)) = generate(f, u, stop?)


decl_type: formula
theory: csequence_generate_limit
library: co_structures
signature: nil
location: 68 2 71 72
body:
    generate_some: THEOREM
      FORALL f, t, stop?, p:
        some(p)(generate(f, t, stop?)) IFF
         (EXISTS (n: indexes(generate(f, t, stop?))): p(iterate(f, n)(t)))


decl_type: formula
theory: csequence_generate_limit
library: co_structures
signature: nil
location: 73 2 76 72
body:
    generate_every: THEOREM
      FORALL f, t, stop?, p:
        every(p)(generate(f, t, stop?)) IFF
         (FORALL (n: indexes(generate(f, t, stop?))): p(iterate(f, n)(t)))


decl_type: function
theory: csequence_generate_limit
library: co_structures
signature:
  [[[T -> T], T, pred[T]] ->
  csequence_struct[T, [[T -> T], T, pred[T]]]]

location: 30 2 33 11
body:
    generate_limit_struct(state): csequence_struct =
        IF state`3(state`2) THEN inj_empty_cseq
        ELSE inj_add(state`2, (state`1, state`1(state`2), state`3))
        ENDIF


decl_type: tcc
theory: csequence_generate_limit
library: co_structures
signature: nil
location: 83 0 87 999
body:
  % Subtype TCC generated (at line 42, column 42) for  generate(f, t, stop?)
      % expected type  (nonempty?[T])
  generate_first_TCC1: OBLIGATION
    FORALL (f, t, stop?):
      NOT stop?(t) IMPLIES nonempty?[T](generate(f, t, stop?));


decl_type: formula
theory: csequence_generate
library: co_structures
signature: nil
location: 41 2 42 76
body:
    generate_add: THEOREM
      FORALL f, t, u: t = f(u) IMPLIES add(u, generate(f, t)) = generate(f, u)


decl_type: formula
theory: csequence_generate
library: co_structures
signature: nil
location: 44 2 46 65
body:
    generate_some: THEOREM
      FORALL f, t, p:
        some(p)(generate(f, t)) IFF (EXISTS n: p(iterate(f, n)(t)))


decl_type: formula
theory: csequence_generate
library: co_structures
signature: nil
location: 48 2 50 66
body:
    generate_every: THEOREM
      FORALL f, t, p:
        every(p)(generate(f, t)) IFF (FORALL n: p(iterate(f, n)(t)))


decl_type: tcc
theory: csequence_generate
library: co_structures
signature: nil
location: 57 0 62 999
body:
  % Subtype TCC generated (at line 31, column 39) for
      % coreduce(generate_struct)(f, t)
      % expected type  infinite_csequence[T]
  generate_TCC1: OBLIGATION
    FORALL (f: [T -> T], t: T):
      NOT is_finite[T](coreduce[T, [[T -> T], T]](generate_struct)(f, t));


decl_type: tcc
theory: csequence_generate
library: co_structures
signature: nil
location: 64 0 67 999
body:
  % Subtype TCC generated (at line 39, column 40) for  n
      % expected type  indexes[T](generate(f, t))
  generate_nth_TCC1: OBLIGATION
    FORALL (f, t, n): index?[T](generate(f, t))(n);


decl_type: formula
theory: csequence_first_p
library: co_structures
signature: nil
location: 36 2 40 70
body:
    first_p_rest: LEMMA
      FORALL cseq, p:
        some(p)(cseq) IMPLIES
         first_p(p, cseq) =
          IF p(first(cseq)) THEN 0 ELSE first_p(p, rest(cseq)) + 1 ENDIF


decl_type: tcc
theory: csequence_first_p
library: co_structures
signature: nil
location: 47 0 51 999
body:
  % Subtype TCC generated (at line 31, column 10) for  p_indexes(cseq, p)
      % expected type  S: (nonempty?[indexes[T](cseq)])
  first_p_TCC1: OBLIGATION
    FORALL (p: pred[T], (cseq: (csequence_codt[T].some(p)))):
      nonempty?[indexes[T](cseq)](p_indexes(cseq, p));


decl_type: tcc
theory: csequence_first_p
library: co_structures
signature: nil
location: 53 0 56 999
body:
  % Subtype TCC generated (at line 40, column 19) for  cseq
      % expected type  (nonempty?[T])
  first_p_rest_TCC1: OBLIGATION
    FORALL (cseq, p): some(p)(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_first_p
library: co_structures
signature: nil
location: 58 0 63 999
body:
  % Subtype TCC generated (at line 40, column 49) for  rest(cseq)
      % expected type  (csequence_codt[T].some(p))
  first_p_rest_TCC2: OBLIGATION
    FORALL (cseq, p):
      NOT p(first(cseq)) AND some(p)(cseq) IMPLIES
       csequence_codt[T].some(p)(rest[T](cseq));


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 102 0 116 999
body:
  filter_of?_weak_coinduction: AXIOM
    FORALL (p, P: [[csequence[T], csequence[T]] -> boolean]):
      (FORALL (filt_seq, cseq):
         P(filt_seq, cseq) IMPLIES
          (empty?(filt_seq) AND NOT some(p)(cseq)) OR
           (nonempty?(filt_seq) AND
             some(p)(cseq) AND
              IF p(first(cseq))
                THEN first(filt_seq) = first(cseq) AND
                      P(rest(filt_seq), rest(cseq))
              ELSE P(filt_seq, rest(cseq))
              ENDIF))
       IMPLIES
       (FORALL (filt_seq, cseq):
          P(filt_seq, cseq) IMPLIES filter_of?(filt_seq, cseq, p));


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 118 0 134 999
body:
  filter_of?_coinduction: AXIOM
    FORALL (p, P: [[csequence[T], csequence[T]] -> boolean]):
      (FORALL (filt_seq, cseq):
         P(filt_seq, cseq) IMPLIES
          (empty?(filt_seq) AND NOT some(p)(cseq)) OR
           (nonempty?(filt_seq) AND
             some(p)(cseq) AND
              IF p(first(cseq))
                THEN first(filt_seq) = first(cseq) AND
                      (filter_of?(rest(filt_seq), rest(cseq), p) OR
                        P(rest(filt_seq), rest(cseq)))
              ELSE filter_of?(filt_seq, rest(cseq), p) OR
                    P(filt_seq, rest(cseq))
              ENDIF))
       IMPLIES
       (FORALL (filt_seq, cseq):
          P(filt_seq, cseq) IMPLIES filter_of?(filt_seq, cseq, p));


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 33 2 36 47
body:
    filter_of?_empty: THEOREM
      FORALL filt_seq, cseq, p:
        filter_of?(filt_seq, cseq, p) IMPLIES
         (empty?(filt_seq) IFF NOT some(p)(cseq))


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 38 2 41 46
body:
    filter_of?_nonempty: THEOREM
      FORALL filt_seq, cseq, p:
        filter_of?(filt_seq, cseq, p) IMPLIES
         (nonempty?(filt_seq) IFF some(p)(cseq))


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 43 2 46 26
body:
    filter_of?_finite: THEOREM
      FORALL filt_seq, cseq, p:
        filter_of?(filt_seq, cseq, p) AND is_finite(cseq) IMPLIES
         is_finite(filt_seq)


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 48 2 50 62
body:
    filter_of?_def: THEOREM
      FORALL filt_seq, cseq, p:
        filter_of?(filt_seq, cseq, p) IMPLIES every(p)(filt_seq)


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 52 2 55 52
body:
    filter_of?_first_p: THEOREM
      FORALL filt_seq, cseq, p:
        some(p)(cseq) AND filter_of?(filt_seq, cseq, p) IMPLIES
         nth(cseq, first_p(p, cseq)) = first(filt_seq)


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 57 2 60 72
body:
    filter_of?_suffix: THEOREM
      FORALL filt_seq, cseq, p:
        some(p)(cseq) AND filter_of?(filt_seq, cseq, p) IMPLIES
         filter_of?(rest(filt_seq), suffix(cseq, 1 + first_p(p, cseq)), p)


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 62 2 65 36
body:
    filter_of?_injective: THEOREM
      FORALL filt_seq1, filt_seq2, cseq, p:
        filter_of?(filt_seq1, cseq, p) AND filter_of?(filt_seq2, cseq, p)
         IMPLIES filt_seq1 = filt_seq2


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 67 2 71 66
body:
    filter_of?_concatenate: THEOREM
      FORALL filt_seq1, filt_seq2, cseq1, cseq2, p:
        is_finite(cseq1) AND
         filter_of?(filt_seq1, cseq1, p) AND filter_of?(filt_seq2, cseq2, p)
         IMPLIES filter_of?(filt_seq1 o filt_seq2, cseq1 o cseq2, p)


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 73 2 77 32
body:
    filter_of?_implication: THEOREM
      FORALL filt_seq, cseq, p, q:
        (FORALL t: pred_IMPLIES(p, q)(t)) AND
         some(p)(cseq) AND filter_of?(filt_seq, cseq, q)
         IMPLIES some(p)(filt_seq)


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 79 2 82 20
body:
    filter_of?_implication_rev: THEOREM
      FORALL filt_seq, cseq, p, q:
        filter_of?(filt_seq, cseq, p) AND some(q)(filt_seq) IMPLIES
         some(q)(cseq)


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 84 2 89 76
body:
    filter_of?_some: THEOREM
      FORALL filt_seq1, filt_seq2, cseq, p, q:
        filter_of?(filt_seq1, cseq, p) AND
         filter_of?(filt_seq2, filt_seq1, q)
         IMPLIES
         (some(p)(cseq) AND some(q)(filt_seq1) IFF some(pred_AND(p, q))(cseq))


decl_type: formula
theory: csequence_filter_of
library: co_structures
signature: nil
location: 91 2 95 58
body:
    filter_of?_filter_of?: THEOREM
      FORALL filt_seq1, filt_seq2, cseq, p, q:
        filter_of?(filt_seq1, cseq, p) AND
         filter_of?(filt_seq2, filt_seq1, q)
         IMPLIES filter_of?(filt_seq2, cseq, pred_AND(p, q))


decl_type: function
theory: csequence_filter_of
library: co_structures
signature: [[csequence[T], csequence[T], pred[T]] -> bool]
location: 23 2 31 16
body:
    filter_of?(filt_seq, cseq, p): COINDUCTIVE bool =
        (empty?(filt_seq) AND NOT some(p)(cseq)) OR
         (nonempty?(filt_seq) AND
           some(p)(cseq) AND
            IF p(first(cseq))
              THEN first(filt_seq) = first(cseq) AND
                    filter_of?(rest(filt_seq), rest(cseq), p)
            ELSE filter_of?(filt_seq, rest(cseq), p)
            ENDIF)


decl_type: tcc
theory: csequence_filter_of
library: co_structures
signature: nil
location: 136 0 142 999
body:
  % Subtype TCC generated (at line 27, column 21) for  cseq
      % expected type  (nonempty?[T])
  filter_of?_TCC1: OBLIGATION
    FORALL (filt_seq: csequence[T], cseq: csequence[T], p: pred[T]):
      some(p)(cseq) AND
       nonempty?(filt_seq) AND NOT (empty?(filt_seq) AND NOT some(p)(cseq))
       IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_filter_of
library: co_structures
signature: nil
location: 144 0 149 999
body:
  % Subtype TCC generated (at line 55, column 43) for  filt_seq
      % expected type  (nonempty?[T])
  filter_of?_first_p_TCC1: OBLIGATION
    FORALL (filt_seq, cseq, p):
      some(p)(cseq) AND filter_of?(filt_seq, cseq, p) IMPLIES
       nonempty?[T](filt_seq);


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 55 2 57 75
body:
    filter_length_eq: THEOREM
      FORALL fseq, p:
        length(filter(fseq, p)) = length(fseq) IMPLIES filter(fseq, p) = fseq


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 59 2 62 64
body:
    filter_reduce: THEOREM
      FORALL cseq, p:
        empty?(cseq) OR
         p(first(cseq)) OR filter(cseq, p) = filter(rest(cseq), p)


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 64 2 67 70
body:
    filter_add: THEOREM
      FORALL cseq, p, t:
        filter(add(t, cseq), p) =
         IF p(t) THEN add(t, filter(cseq, p)) ELSE filter(cseq, p) ENDIF


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 69 2 74 12
body:
    filter_rest: THEOREM
      FORALL nseq, p:
        filter(rest(nseq), p) =
         IF p(first(nseq)) THEN rest(filter(nseq, p))
         ELSE filter(nseq, p)
         ENDIF


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 76 2 79 76
body:
    filter_suffix: THEOREM
      FORALL cseq, p:
        empty?(filter(cseq, p)) OR
         rest(filter(cseq, p)) = filter(suffix(cseq, first_p(p, cseq) + 1), p)


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 81 2 84 59
body:
    filter_first: THEOREM
      FORALL cseq, p:
        some(p)(cseq) IMPLIES
         first(filter(cseq, p)) = nth(cseq, first_p(p, cseq))


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 86 2 89 43
body:
    filter_first_first: COROLLARY
      FORALL cseq, p:
        some(p)(cseq) AND p(first(cseq)) IMPLIES
         first(filter(cseq, p)) = first(cseq)


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 97 2 99 61
body:
    filter_some: THEOREM
      FORALL cseq, p, q:
        some(q)(filter(cseq, p)) IFF some(pred_AND(p, q))(cseq)


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 101 2 103 67
body:
    filter_every: THEOREM
      FORALL cseq, p, q:
        every(q)(filter(cseq, p)) IFF every(pred_IMPLIES(p, q))(cseq)


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 108 2 110 66
body:
    filter_filter_of: THEOREM
      FORALL cseq, filt_seq, p:
        filter(cseq, p) = filt_seq IFF filter_of?(filt_seq, cseq, p)


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 112 2 117 12
body:
    filter_concatenate: THEOREM
      FORALL cseq1, cseq2, p:
        filter(cseq1 o cseq2, p) =
         IF is_finite(cseq1) THEN filter(cseq1, p) o filter(cseq2, p)
         ELSE filter(cseq1, p)
         ENDIF


decl_type: formula
theory: csequence_filter
library: co_structures
signature: nil
location: 119 2 121 63
body:
    filter_filter: THEOREM
      FORALL cseq, p, q:
        filter(filter(cseq, p), q) = filter(cseq, pred_AND(p, q))


decl_type: function
theory: csequence_filter
library: co_structures
signature:
  [[csequence[T], pred[T]] ->
  csequence_struct[T, [csequence, pred[T]]]]

location: 33 2 39 11
body:
    filter_struct(state): csequence_struct[T, [csequence, pred[T]]] =
        IF some(state`2)(state`1)
          THEN LET n = first_p(state`2, state`1) IN
                 inj_add[T, [csequence, pred[T]]]
                     (nth(state`1, n), (suffix(state`1, n + 1), state`2))
        ELSE inj_empty_cseq[T, [csequence, pred[T]]]
        ENDIF


decl_type: tcc
theory: csequence_filter
library: co_structures
signature: nil
location: 128 0 135 999
body:
  % Subtype TCC generated (at line 41, column 42) for
      % coreduce(filter_struct)(cseq, p)
      % expected type  (LAMBDA (cseq1: csequence[T]):
                     %    subsequence?(cseq1, cseq))
  filter_TCC1: OBLIGATION
    FORALL (cseq: csequence[T], p: pred[T]):
      subsequence?[T]
          (coreduce[T, [csequence, pred[T]]](filter_struct)(cseq, p), cseq);


decl_type: tcc
theory: csequence_filter
library: co_structures
signature: nil
location: 137 0 140 999
body:
  % Judgement subtype TCC generated (at line 50, column 27) for
      % filter(fseq, p)
      % expected type  finite_csequence[T]
  filter_finite: OBLIGATION FORALL (fseq, p): is_finite[T](filter(fseq, p));


decl_type: tcc
theory: csequence_filter
library: co_structures
signature: nil
location: 142 0 145 999
body:
  % Subtype TCC generated (at line 62, column 15) for  cseq
      % expected type  (nonempty?[T])
  filter_reduce_TCC1: OBLIGATION
    FORALL (cseq): NOT empty?(cseq) IMPLIES nonempty?[T](cseq);


decl_type: tcc
theory: csequence_filter
library: co_structures
signature: nil
location: 147 0 150 999
body:
  % Subtype TCC generated (at line 72, column 35) for  filter(nseq, p)
      % expected type  (nonempty?[T])
  filter_rest_TCC1: OBLIGATION
    FORALL (nseq, p): p(first(nseq)) IMPLIES nonempty?[T](filter(nseq, p));


decl_type: tcc
theory: csequence_filter
library: co_structures
signature: nil
location: 152 0 156 999
body:
  % Subtype TCC generated (at line 79, column 12) for  filter(cseq, p)
      % expected type  (nonempty?[T])
  filter_suffix_TCC1: OBLIGATION
    FORALL (cseq, p):
      NOT empty?(filter(cseq, p)) IMPLIES nonempty?[T](filter(cseq, p));


decl_type: tcc
theory: csequence_filter
library: co_structures
signature: nil
location: 158 0 162 999
body:
  % Subtype TCC generated (at line 79, column 62) for  cseq
      % expected type  (csequence_codt[T].some(p))
  filter_suffix_TCC2: OBLIGATION
    FORALL (cseq, p):
      NOT empty?(filter(cseq, p)) IMPLIES csequence_codt[T].some(p)(cseq);


decl_type: tcc
theory: csequence_filter
library: co_structures
signature: nil
location: 164 0 167 999
body:
  % Subtype TCC generated (at line 84, column 13) for  filter(cseq, p)
      % expected type  (nonempty?[T])
  filter_first_TCC1: OBLIGATION
    FORALL (cseq, p): some(p)(cseq) IMPLIES nonempty?[T](filter(cseq, p));


decl_type: tcc
theory: csequence_filter
library: co_structures
signature: nil
location: 169 0 172 999
body:
  % Subtype TCC generated (at line 88, column 32) for  cseq
      % expected type  (nonempty?[T])
  filter_first_first_TCC1: OBLIGATION
    FORALL (cseq, p): some(p)(cseq) IMPLIES nonempty?[T](cseq);


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 56 2 59 68
body:
    flatten_reduce: THEOREM
      FORALL cseq:
        empty?(cseq) OR
         nonempty?(first(cseq)) OR flatten(cseq) = flatten(rest(cseq))


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 61 2 66 51
body:
    flatten_rest: THEOREM
      FORALL cseq:
        nonempty?(flatten(cseq)) IMPLIES
         rest(flatten(cseq)) =
          flatten(add(rest(first(filter(cseq, nonempty?))),
                      rest(filter(cseq, nonempty?))))


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 68 2 72 73
body:
    flatten_rest2: THEOREM
      FORALL cseq:
        empty?(cseq) OR
         empty?(first(cseq)) OR
          rest(flatten(cseq)) = flatten(add(rest(first(cseq)), rest(cseq)))


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 74 2 77 67
body:
    flatten_first: THEOREM
      FORALL cseq:
        nonempty?(flatten(cseq)) IMPLIES
         first(flatten(cseq)) = first(first(filter(cseq, nonempty?)))


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 79 2 82 70
body:
    flatten_suffix: THEOREM
      FORALL cseq:
        some(nonempty?)(cseq) IMPLIES
         flatten(cseq) = flatten(suffix(cseq, first_p(nonempty?, cseq)))


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 87 2 90 56
body:
    flatten_concatenate: THEOREM
      FORALL cseq:
        nonempty?(cseq) IMPLIES
         flatten(cseq) = first(cseq) o flatten(rest(cseq))


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 92 2 97 71
body:
    flatten_rest_suffix: THEOREM
      FORALL cseq:
        nonempty?(flatten(cseq)) IMPLIES
         LET first = first_p(nonempty?, cseq) IN
           rest(flatten(cseq)) =
            flatten(add(rest(nth(cseq, first)), suffix(cseq, first + 1)))


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 99 2 102 68
body:
    flatten_finite: THEOREM
      FORALL cseq:
        is_finite(flatten(cseq)) IFF
         is_finite(filter(cseq, nonempty?)) AND every(is_finite)(cseq)


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 104 2 107 70
body:
    flatten_infinite: THEOREM
      FORALL cseq:
        is_infinite(flatten(cseq)) IFF
         is_infinite(filter(cseq, nonempty?)) OR some(is_infinite)(cseq)


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 119 2 123 46
body:
    length_of_flatten_add: THEOREM
      FORALL fseq, tseq:
        is_finite(tseq) IMPLIES
         length_of_flatten(add(tseq, fseq)) =
          length(tseq) + length_of_flatten(fseq)


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 125 2 128 54
body:
    flatten_length: THEOREM
      FORALL cseq:
        is_finite(flatten(cseq)) IMPLIES
         length(flatten(cseq)) = length_of_flatten(cseq)


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 133 2 136 55
body:
    flatten_some_finite: THEOREM
      FORALL cseq, p:
        every(is_finite)(cseq) IMPLIES
         (some(p)(flatten(cseq)) IFF some(some(p))(cseq))


decl_type: formula
theory: csequence_flatten
library: co_structures
signature: nil
location: 141 2 144 58
body:
    flatten_every_finite: THEOREM
      FORALL cseq, p:
        every(is_finite)(cseq) IMPLIES
         (every(p)(flatten(cseq)) IFF every(every(p))(cseq))


decl_type: function
theory: csequence_flatten
library: co_structures
signature: [nonempty_seq_seq -> csequence_struct[T, nonempty_seq_seq]]
location: 33 2 40 11
body:
    flatten_struct(nseq): csequence_struct[T, nonempty_seq_seq] =
        IF empty?(nseq) THEN inj_empty_cseq[T, nonempty_seq_seq]
        ELSE inj_add[T, nonempty_seq_seq]
                 (first(first(nseq)),
                  IF empty?(rest(first(nseq))) THEN rest(nseq)
                  ELSE add(rest(first(nseq)), rest(nseq))
                  ENDIF)
        ENDIF


decl_type: function
theory: csequence_flatten
library: co_structures
signature: [finite_flatten_csequence -> nat]
location: 112 2 117 44
body:
    length_of_flatten(fseq): RECURSIVE nat =
      IF empty?(flatten(fseq)) THEN 0
      ELSE length(nth(fseq, first_p(nonempty?, fseq))) +
            length_of_flatten(suffix(fseq, first_p(nonempty?, fseq) + 1))
      ENDIF
       MEASURE length(filter(fseq, nonempty?))


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 171 0 175 999
body:
  % Subtype TCC generated (at line 36, column 28) for  nseq
      % expected type  (nonempty?[csequence[T]])
  flatten_struct_TCC1: OBLIGATION
    FORALL (nseq: nonempty_seq_seq):
      NOT empty?(nseq) IMPLIES nonempty?[csequence[T]](nseq);


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 177 0 181 999
body:
  % Subtype TCC generated (at line 36, column 22) for  first(nseq)
      % expected type  (nonempty?[T])
  flatten_struct_TCC2: OBLIGATION
    FORALL (nseq: nonempty_seq_seq):
      NOT empty?(nseq) IMPLIES nonempty?[T](first[csequence[T]](nseq));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 183 0 188 999
body:
  % Subtype TCC generated (at line 37, column 50) for  rest(nseq)
      % expected type  nonempty_seq_seq
  flatten_struct_TCC3: OBLIGATION
    FORALL (nseq: nonempty_seq_seq):
      empty?(rest(first(nseq))) AND NOT empty?(nseq) IMPLIES
       every[csequence[T]](nonempty?[T])(rest[csequence[T]](nseq));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 190 0 200 999
body:
  % Subtype TCC generated (at line 38, column 21) for
      % add(rest(first(nseq)), rest(nseq))
      % expected type  nonempty_seq_seq
  flatten_struct_TCC4: OBLIGATION
    FORALL (nseq: nonempty_seq_seq):
      NOT empty?(rest(first(nseq))) AND NOT empty?(nseq) IMPLIES
       every[csequence[T]]
           (nonempty?[T])
           (add[csequence[T]]
                (rest[T](first[csequence[T]](nseq)),
                 rest[csequence[T]](nseq)));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 202 0 207 999
body:
  % Subtype TCC generated (at line 43, column 31) for  filter(cseq, nonempty?)
      % expected type  x: nonempty_seq_seq
  flatten_TCC1: OBLIGATION
    FORALL (cseq: csequence[csequence[T]]):
      every[csequence[T]]
          (nonempty?[T])(filter[csequence[T]](cseq, nonempty?[T]));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 209 0 212 999
body:
  % Subtype TCC generated (at line 59, column 23) for  cseq
      % expected type  (nonempty?[csequence[T]])
  flatten_reduce_TCC1: OBLIGATION
    FORALL (cseq): NOT empty?(cseq) IMPLIES nonempty?[csequence[T]](cseq);


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 214 0 219 999
body:
  % Subtype TCC generated (at line 65, column 31) for  filter(cseq, nonempty?)
      % expected type  (nonempty?[csequence[T]])
  flatten_rest_TCC1: OBLIGATION
    FORALL (cseq):
      nonempty?(flatten(cseq)) IMPLIES
       nonempty?[csequence[T]](filter[csequence[T]](cseq, nonempty?[T]));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 221 0 228 999
body:
  % Subtype TCC generated (at line 65, column 25) for
      % first(filter(cseq, nonempty?))
      % expected type  (nonempty?[T])
  flatten_rest_TCC2: OBLIGATION
    FORALL (cseq):
      nonempty?(flatten(cseq)) IMPLIES
       nonempty?[T]
           (first[csequence[T]](filter[csequence[T]](cseq, nonempty?[T])));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 230 0 235 999
body:
  % Subtype TCC generated (at line 72, column 13) for  flatten(cseq)
      % expected type  (nonempty?[T])
  flatten_rest2_TCC1: OBLIGATION
    FORALL (cseq):
      NOT empty?(first(cseq)) AND NOT empty?(cseq) IMPLIES
       nonempty?[T](flatten(cseq));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 237 0 242 999
body:
  % Subtype TCC generated (at line 72, column 47) for  first(cseq)
      % expected type  (nonempty?[T])
  flatten_rest2_TCC2: OBLIGATION
    FORALL (cseq):
      NOT empty?(first(cseq)) AND NOT empty?(cseq) IMPLIES
       nonempty?[T](first[csequence[T]](cseq));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 244 0 249 999
body:
  % Subtype TCC generated (at line 95, column 38) for  cseq
      % expected type  (csequence_codt[csequence[T]].some(nonempty?))
  flatten_rest_suffix_TCC1: OBLIGATION
    FORALL (cseq):
      nonempty?(flatten(cseq)) IMPLIES
       csequence_codt[csequence[T]].some(nonempty?[T])(cseq);


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 251 0 258 999
body:
  % Subtype TCC generated (at line 97, column 27) for  nth(cseq, first)
      % expected type  (nonempty?[T])
  flatten_rest_suffix_TCC2: OBLIGATION
    FORALL (cseq):
      nonempty?(flatten(cseq)) IMPLIES
       (FORALL (first: indexes[csequence[T]](cseq)):
          first = first_p(nonempty?, cseq) IMPLIES
           nonempty?[T](nth[csequence[T]](cseq, first)));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 260 0 265 999
body:
  % Subtype TCC generated (at line 117, column 20) for
      % filter(fseq, nonempty?)
      % expected type  fseq: finite_csequence[csequence[T]]
  length_of_flatten_TCC1: OBLIGATION
    FORALL (fseq: finite_flatten_csequence):
      is_finite[csequence[T]](filter[csequence[T]](fseq, nonempty?[T]));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 267 0 272 999
body:
  % Subtype TCC generated (at line 114, column 45) for  fseq
      % expected type  (csequence_codt[csequence[T]].some(nonempty?))
  length_of_flatten_TCC2: OBLIGATION
    FORALL (fseq: finite_flatten_csequence):
      NOT empty?(flatten(fseq)) IMPLIES
       csequence_codt[csequence[T]].some(nonempty?[T])(fseq);


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 274 0 282 999
body:
  % Subtype TCC generated (at line 114, column 16) for
      % nth(fseq, first_p(nonempty?, fseq))
      % expected type  fseq: finite_csequence[T]
  length_of_flatten_TCC3: OBLIGATION
    FORALL (fseq: finite_flatten_csequence):
      NOT empty?(flatten(fseq)) IMPLIES
       is_finite[T]
           (nth[csequence[T]]
                (fseq, first_p[csequence[T]](nonempty?[T], fseq)));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 284 0 293 999
body:
  % Subtype TCC generated (at line 115, column 28) for
      % suffix(fseq, first_p(nonempty?, fseq) + 1)
      % expected type  finite_flatten_csequence
  length_of_flatten_TCC4: OBLIGATION
    FORALL (fseq: finite_flatten_csequence):
      NOT empty?(flatten(fseq)) IMPLIES
       is_finite[T]
           (flatten(suffix[csequence[T]]
                        (fseq,
                         first_p[csequence[T]](nonempty?[T], fseq) + 1)));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 295 0 305 999
body:
  % Termination TCC generated (at line 115, column 10) for
      % length_of_flatten(suffix(fseq, first_p(nonempty?, fseq) + 1))
  length_of_flatten_TCC5: OBLIGATION
    FORALL (fseq: finite_flatten_csequence):
      NOT empty?(flatten(fseq)) IMPLIES
       length[csequence[T]]
           (filter[csequence[T]]
                (suffix[csequence[T]]
                     (fseq, first_p[csequence[T]](nonempty?[T], fseq) + 1),
                 nonempty?[T]))
        < length[csequence[T]](filter[csequence[T]](fseq, nonempty?[T]));


decl_type: tcc
theory: csequence_flatten
library: co_structures
signature: nil
location: 307 0 312 999
body:
  % Subtype TCC generated (at line 122, column 25) for  add(tseq, fseq)
      % expected type  finite_flatten_csequence
  length_of_flatten_add_TCC1: OBLIGATION
    FORALL (fseq, tseq):
      is_finite(tseq) IMPLIES
       is_finite[T](flatten(add[csequence[T]](tseq, fseq)));


decl_type: formula
theory: csequence_finseq
library: co_structures
signature: nil
location: 40 2 41 73
body:
    from_finseq_nth: THEOREM
      FORALL fs, (n: below[fs`length]): nth(from_finseq(fs), n) = fs`seq(n)


decl_type: function
theory: csequence_finseq
library: co_structures
signature: [finseq[T] -> finite_csequence[T]]
location: 25 2 33 22
body:
    from_finseq(fs): RECURSIVE finite_csequence =
      IF fs`length = 0 THEN empty_cseq
      ELSE add(fs`seq(0),
               from_finseq((# length := fs`length - 1,
                              seq
                                := LAMBDA (x: below[fs`length - 1]):
                                     fs`seq(x + 1) #)))
      ENDIF
       MEASURE fs`length


decl_type: function
theory: csequence_finseq
library: co_structures
signature: [finite_csequence[T] -> finseq[T]]
location: 44 2 46 64
body:
    to_finseq(fseq): finseq =
        (# length := length(fseq),
           seq := LAMBDA (x: below[length(fseq)]): nth(fseq, x) #)


decl_type: tcc
theory: csequence_finseq
library: co_structures
signature: nil
location: 68 0 71 999
body:
  % Subtype TCC generated (at line 27, column 20) for  0
      % expected type  below[fs`length]
  from_finseq_TCC1: OBLIGATION
    FORALL (fs: finseq[T]): NOT fs`length = 0 IMPLIES 0 < fs`length;


decl_type: tcc
theory: csequence_finseq
library: co_structures
signature: nil
location: 73 0 76 999
body:
  % Subtype TCC generated (at line 28, column 38) for  fs`length - 1
      % expected type  nat
  from_finseq_TCC2: OBLIGATION
    FORALL (fs: finseq[T]): NOT fs`length = 0 IMPLIES fs`length - 1 >= 0;


decl_type: tcc
theory: csequence_finseq
library: co_structures
signature: nil
location: 78 0 83 999
body:
  % Subtype TCC generated (at line 31, column 42) for  x + 1
      % expected type  below[fs`length]
  from_finseq_TCC3: OBLIGATION
    FORALL (fs: finseq[T]):
      NOT fs`length = 0 IMPLIES
       (FORALL (x: below[fs`length - 1]): x + 1 < fs`length);


decl_type: tcc
theory: csequence_finseq
library: co_structures
signature: nil
location: 85 0 92 999
body:
  % Termination TCC generated (at line 28, column 13) for
      % from_finseq((# length := fs`length - 1,
      %                seq
      %                  := LAMBDA (x: below[fs`length - 1]):
      %                       fs`seq(x + 1) #))
  from_finseq_TCC4: OBLIGATION
    FORALL (fs: finseq[T]):
      NOT fs`length = 0 IMPLIES fs`length - 1 < fs`length;


decl_type: tcc
theory: csequence_finseq
library: co_structures
signature: nil
location: 94 0 113 999
body:
  % Subtype TCC generated (at line 27, column 9) for
      % add(fs`seq(0),
      %     from_finseq((# length := fs`length - 1,
      %                    seq
      %                      := LAMBDA (x: below[fs`length - 1]):
      %                           fs`seq(x + 1) #)))
      % expected type  finite_csequence[T]
  from_finseq_TCC5: OBLIGATION
    FORALL (fs: finseq[T],
            v:
              [{z: finseq[T] | z`length < fs`length} ->
                 finite_csequence[T]]):
      NOT fs`length = 0 IMPLIES
       is_finite[T]
           (add[T]
                (fs`seq(0),
                 v((# length := fs`length - 1,
                      seq
                        := LAMBDA (x: below[fs`length - 1]):
                             fs`seq(x + 1) #))));


decl_type: tcc
theory: csequence_finseq
library: co_structures
signature: nil
location: 115 0 118 999
body:
  % Subtype TCC generated (at line 41, column 59) for  n
      % expected type  indexes[T](from_finseq(fs))
  from_finseq_nth_TCC1: OBLIGATION
    FORALL (fs, n: below[fs`length]): index?[T](from_finseq(fs))(n);


decl_type: tcc
theory: csequence_finseq
library: co_structures
signature: nil
location: 120 0 124 999
body:
  % Subtype TCC generated (at line 46, column 59) for  x
      % expected type  indexes[T](fseq)
  to_finseq_TCC1: OBLIGATION
    FORALL (fseq: finite_csequence[T], x: below[length[T](fseq)]):
      index?[T](fseq)(x);


decl_type: tcc
theory: csequence_finseq
library: co_structures
signature: nil
location: 126 0 129 999
body:
  % Subtype TCC generated (at line 55, column 57) for  n
      % expected type  below[to_finseq(fseq)`length]
  to_finseq_nth_TCC1: OBLIGATION
    FORALL (fseq, n: indexes[T](fseq)): n < to_finseq(fseq)`length;


decl_type: formula
theory: csequence_filter_map
library: co_structures
signature: nil
location: 26 2 29 54
body:
    map_first_p: THEOREM
      FORALL f, p, cseq:
        some(p)(map(f, cseq)) IMPLIES
         first_p(p, map(f, cseq)) = first_p(p o f, cseq)


decl_type: formula
theory: csequence_filter_map
library: co_structures
signature: nil
location: 31 2 33 65
body:
    map_suffix_empty: THEOREM
      FORALL f, cseq, n:
        empty?(suffix(map(f, cseq), n)) IFF empty?(suffix(cseq, n))


decl_type: tcc
theory: csequence_filter_map
library: co_structures
signature: nil
location: 46 0 51 999
body:
  % Subtype TCC generated (at line 29, column 49) for  cseq
      % expected type  (csequence_codt[T1].some(p o f))
  map_first_p_TCC1: OBLIGATION
    FORALL (f, p, cseq):
      some(p)(map(f, cseq)) IMPLIES
       csequence_codt[T1].some(o[T1, T2, boolean](p, f))(cseq);


decl_type: formula
theory: csequence_constant
library: co_structures
signature: nil
location: 37 2 39 71
body:
    constant_cseq_rest: THEOREM
      FORALL t, n:
        n > 0 IMPLIES rest(constant_cseq(t, n)) = constant_cseq(t, n - 1)


decl_type: function
theory: csequence_constant
library: co_structures
signature: [[T, nat] -> finite_csequence[T]]
location: 25 2 27 14
body:
    constant_cseq(t, n): RECURSIVE finite_csequence =
      IF n = 0 THEN empty_cseq ELSE add(t, constant_cseq(t, n - 1)) ENDIF
       MEASURE n


decl_type: tcc
theory: csequence_constant
library: co_structures
signature: nil
location: 88 0 91 999
body:
  % Subtype TCC generated (at line 26, column 58) for  n - 1
      % expected type  nat
  constant_cseq_TCC1: OBLIGATION
    FORALL (t: T, n: nat): NOT n = 0 IMPLIES n - 1 >= 0;


decl_type: tcc
theory: csequence_constant
library: co_structures
signature: nil
location: 93 0 96 999
body:
  % Termination TCC generated (at line 26, column 41) for
      % constant_cseq(t, n - 1)
  constant_cseq_TCC2: OBLIGATION
    FORALL (t: T, n: nat): NOT n = 0 IMPLIES n - 1 < n;


decl_type: tcc
theory: csequence_constant
library: co_structures
signature: nil
location: 98 0 104 999
body:
  % Subtype TCC generated (at line 26, column 34) for
      % add(t, constant_cseq(t, n - 1))
      % expected type  finite_csequence[T]
  constant_cseq_TCC3: OBLIGATION
    FORALL (t: T, n: nat,
            v: [{z: [T, nat] | z`2 < n} -> finite_csequence[T]]):
      NOT n = 0 IMPLIES is_finite[T](add[T](t, v(t, n - 1)));


decl_type: tcc
theory: csequence_constant
library: co_structures
signature: nil
location: 106 0 109 999
body:
  % Subtype TCC generated (at line 35, column 37) for  constant_cseq(t, n)
      % expected type  (nonempty?[T])
  constant_cseq_first_TCC1: OBLIGATION
    FORALL (t, n): n > 0 IMPLIES nonempty?[T](constant_cseq(t, n));


decl_type: tcc
theory: csequence_constant
library: co_structures
signature: nil
location: 111 0 113 999
body:
  % Subtype TCC generated (at line 39, column 65) for  n - 1
      % expected type  nat
  constant_cseq_rest_TCC1: OBLIGATION FORALL (t, n): n > 0 IMPLIES n - 1 >= 0;


decl_type: tcc
theory: csequence_constant
library: co_structures
signature: nil
location: 115 0 118 999
body:
  % Subtype TCC generated (at line 47, column 57) for  m
      % expected type  indexes[T](constant_cseq(t, n))
  constant_cseq_nth_TCC1: OBLIGATION
    FORALL (t, n, m: below[n]): index?[T](constant_cseq(t, n))(m);


decl_type: tcc
theory: csequence_constant
library: co_structures
signature: nil
location: 120 0 124 999
body:
  % Subtype TCC generated (at line 65, column 41) for
      % coreduce(constant_cseq_struct)(t)
      % expected type  infinite_csequence[T]
  constant_cseq_TCC4: OBLIGATION
    FORALL (t: T): NOT is_finite[T](coreduce[T, T](constant_cseq_struct)(t));


decl_type: tcc
theory: csequence_constant
library: co_structures
signature: nil
location: 126 0 129 999
body:
  % Subtype TCC generated (at line 72, column 68) for  n
      % expected type  indexes[T](constant_cseq(t))
  constant_cseq_inf_nth_TCC1: OBLIGATION
    FORALL (t, n): index?[T](constant_cseq(t))(n);


decl_type: formula
theory: csequence_concatenate_extract
library: co_structures
signature: nil
location: 23 2 26 60
body:
    o_extract: THEOREM
      FORALL fseq, i, j, k:
        i <= j AND j <= k IMPLIES
         (fseq ^ (i, j)) o (fseq ^ (j + 1, k)) = fseq ^ (i, k)


decl_type: formula
theory: csequence_concatenate_extract
library: co_structures
signature: nil
location: 28 2 31 51
body:
    o_extract_eta: THEOREM
      FORALL fseq, i, j:
        i < j AND j >= length(fseq) - 1 IMPLIES
         (fseq ^ (0, i)) o (fseq ^ (i + 1, j)) = fseq


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 20 2 23 45
body:
    csequence_ord_defaxiom: AXIOM
      csequence_ord(empty_cseq) = 0 AND
       (FORALL (first: T, rest: csequence):
          csequence_ord(add(first, rest)) = 1);


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 28 2 30 31
body:
    csequence_empty_cseq_extensionality: AXIOM
      FORALL (empty?_var: (empty?), empty?_var2: (empty?)):
        empty?_var = empty?_var2;


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 32 2 36 46
body:
    csequence_add_extensionality: AXIOM
      FORALL (nonempty?_var: (nonempty?), nonempty?_var2: (nonempty?)):
        first(nonempty?_var) = first(nonempty?_var2) AND
         rest(nonempty?_var) = rest(nonempty?_var2)
         IMPLIES nonempty?_var = nonempty?_var2;


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 38 2 40 69
body:
    csequence_add_eta: AXIOM
      FORALL (nonempty?_var: (nonempty?)):
        add(first(nonempty?_var), rest(nonempty?_var)) = nonempty?_var;


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 42 2 44 48
body:
    csequence_first_add: AXIOM
      FORALL (add1_var: T, add2_var: csequence):
        first(add(add1_var, add2_var)) = add1_var;


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 46 2 48 47
body:
    csequence_rest_add: AXIOM
      FORALL (add1_var: T, add2_var: csequence):
        rest(add(add1_var, add2_var)) = add2_var;


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 50 2 52 56
body:
    csequence_inclusive: AXIOM
      FORALL (csequence_var: csequence):
        empty?(csequence_var) OR nonempty?(csequence_var);


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 61 2 63 23
body:
    coinduction: AXIOM
      FORALL (B: (bisimulation?), x: csequence, y: csequence):
        B(x, y) => x = y;


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 71 2 79 65
body:
    every_weak_coinduction: AXIOM
      FORALL (p: PRED[T], P: [csequence -> boolean]):
        (FORALL (a: csequence):
           P(a) IMPLIES
            CASES a
              OF empty_cseq: TRUE,
                 add(add1_var, add2_var): p(add1_var) AND P(add2_var)
              ENDCASES)
         IMPLIES (FORALL (a: csequence): P(a) IMPLIES every(p)(a));


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 81 2 90 65
body:
    every_coinduction: AXIOM
      FORALL (p: PRED[T], P: [csequence -> boolean]):
        (FORALL (a: csequence):
           P(a) IMPLIES
            CASES a
              OF empty_cseq: TRUE,
                 add(add1_var, add2_var):
                   p(add1_var) AND (every(p)(add2_var) OR P(add2_var))
              ENDCASES)
         IMPLIES (FORALL (a: csequence): P(a) IMPLIES every(p)(a));


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 98 2 106 64
body:
    some_weak_induction: AXIOM
      FORALL (p: PRED[T], P: [csequence -> boolean]):
        (FORALL (a: csequence):
           CASES a
             OF empty_cseq: FALSE,
                add(add1_var, add2_var): p(add1_var) OR P(add2_var)
             ENDCASES
            IMPLIES P(a))
         IMPLIES (FORALL (a: csequence): some(p)(a) IMPLIES P(a));


decl_type: formula
theory: csequence_codt
library: co_structures
signature: nil
location: 108 2 117 64
body:
    some_induction: AXIOM
      FORALL (p: PRED[T], P: [csequence -> boolean]):
        (FORALL (a: csequence):
           CASES a
             OF empty_cseq: FALSE,
                add(add1_var, add2_var):
                  p(add1_var) OR some(p)(add2_var) AND P(add2_var)
             ENDCASES
            IMPLIES P(a))
         IMPLIES (FORALL (a: csequence): some(p)(a) IMPLIES P(a));


decl_type: function
theory: csequence_codt
library: co_structures
signature: [csequence -> upto(1)]
location: 25 2 26 67
body:
    ord(x: csequence): [csequence -> upto(1)] =
        CASES x OF empty_cseq: 0, add(add1_var, add2_var): 1 ENDCASES


decl_type: function
theory: csequence_codt
library: co_structures
signature: [PRED[[csequence, csequence]] -> boolean]
location: 54 2 59 72
body:
    bisimulation?(R: PRED[[csequence, csequence]]):  boolean =
        FORALL (x: csequence, y: csequence):
          R(x, y) IMPLIES
           empty?(x) AND empty?(y) OR
            nonempty?(x) AND
             nonempty?(y) AND first(x) = first(y) AND R(rest(x), rest(y));


decl_type: function
theory: csequence_codt
library: co_structures
signature: [PRED[T] -> [csequence -> boolean]]
location: 65 2 69 19
body:
    every(p: PRED[T])(a: csequence):  COINDUCTIVE boolean =
          CASES a
            OF empty_cseq: TRUE,
               add(add1_var, add2_var): p(add1_var) AND every(p)(add2_var)
            ENDCASES;


decl_type: function
theory: csequence_codt
library: co_structures
signature: [PRED[T] -> [csequence -> boolean]]
location: 92 2 96 19
body:
    some(p: PRED[T])(a: csequence):  INDUCTIVE boolean =
          CASES a
            OF empty_cseq: FALSE,
               add(add1_var, add2_var): p(add1_var) OR some(p)(add2_var)
            ENDCASES;


decl_type: function
theory: csequence_codt_map
library: co_structures
signature: [[T -> T1] -> [csequence[T] -> csequence[T1]]]
location: 6 2 10 17
body:
    map(f: [T -> T1])(a: csequence[T]):  csequence[T1] =
        CASES a
          OF empty_cseq: empty_cseq,
             add(add1_var, add2_var): add(f(add1_var), map(f)(add2_var))
          ENDCASES;


decl_type: function
theory: csequence_codt_map
library: co_structures
signature: [[[T -> T1], csequence[T]] -> csequence[T1]]
location: 12 2 16 17
body:
    map(f: [T -> T1], a: csequence[T]):  csequence[T1] =
        CASES a
          OF empty_cseq: empty_cseq,
             add(add1_var, add2_var): add(f(add1_var), map(f, add2_var))
          ENDCASES;


decl_type: function
theory: csequence_codt_map
library: co_structures
signature:
  [[[T, T1] -> boolean] ->
  [[csequence[T], csequence[T1]] -> boolean]]

location: 18 2 23 62
body:
    every(R: [[T, T1] -> boolean])(x: csequence[T], y: csequence[T1]):
          boolean =
        empty?(x) AND empty?(y) OR
         nonempty?(x) AND
          nonempty?(y) AND
           R(first(x), first(y)) AND every(R)(rest(x), rest(y));


decl_type: formula
theory: csequence_codt_coreduce
library: co_structures
signature: nil
location: 26 2 29 64
body:
    csequence_struct_ord_defaxiom: AXIOM
      csequence_struct_ord(inj_empty_cseq) = 0 AND
       (FORALL (inj_first: T, inj_rest: domain):
          csequence_struct_ord(inj_add(inj_first, inj_rest)) = 1);


decl_type: formula
theory: csequence_codt_coreduce
library: co_structures
signature: nil
location: 35 2 37 39
body:
    csequence_struct_inj_empty_cseq_extensionality: AXIOM
      FORALL (inj_empty?_var: (inj_empty?), inj_empty?_var2: (inj_empty?)):
        inj_empty?_var = inj_empty?_var2;


decl_type: formula
theory: csequence_codt_coreduce
library: co_structures
signature: nil
location: 39 2 44 54
body:
    csequence_struct_inj_add_extensionality: AXIOM
      FORALL (inj_nonempty?_var: (inj_nonempty?),
              inj_nonempty?_var2: (inj_nonempty?)):
        inj_first(inj_nonempty?_var) = inj_first(inj_nonempty?_var2) AND
         inj_rest(inj_nonempty?_var) = inj_rest(inj_nonempty?_var2)
         IMPLIES inj_nonempty?_var = inj_nonempty?_var2;


decl_type: formula
theory: csequence_codt_coreduce
library: co_structures
signature: nil
location: 46 2 49 25
body:
    csequence_struct_inj_add_eta: AXIOM
      FORALL (inj_nonempty?_var: (inj_nonempty?)):
        inj_add(inj_first(inj_nonempty?_var), inj_rest(inj_nonempty?_var)) =
         inj_nonempty?_var;


decl_type: formula
theory: csequence_codt_coreduce
library: co_structures
signature: nil
location: 51 2 53 68
body:
    csequence_struct_inj_first_inj_add: AXIOM
      FORALL (inj_add1_var: T, inj_add2_var: domain):
        inj_first(inj_add(inj_add1_var, inj_add2_var)) = inj_add1_var;


decl_type: formula
theory: csequence_codt_coreduce
library: co_structures
signature: nil
location: 55 2 57 67
body:
    csequence_struct_inj_rest_inj_add: AXIOM
      FORALL (inj_add1_var: T, inj_add2_var: domain):
        inj_rest(inj_add(inj_add1_var, inj_add2_var)) = inj_add2_var;


decl_type: formula
theory: csequence_codt_coreduce
library: co_structures
signature: nil
location: 59 2 62 43
body:
    csequence_struct_inclusive: AXIOM
      FORALL (csequence_struct_var: csequence_struct):
        inj_empty?(csequence_struct_var) OR
         inj_nonempty?(csequence_struct_var);


decl_type: formula
theory: csequence_codt_coreduce
library: co_structures
signature: nil
location: 64 2 71 35
body:
    csequence_struct_induction: AXIOM
      FORALL (p: [csequence_struct -> boolean]):
        (p(inj_empty_cseq) AND
          (FORALL (inj_add1_var: T, inj_add2_var: domain):
             p(inj_add(inj_add1_var, inj_add2_var))))
         IMPLIES
         (FORALL (csequence_struct_var: csequence_struct):
            p(csequence_struct_var));


decl_type: function
theory: csequence_codt_coreduce
library: co_structures
signature: [csequence_struct -> upto(1)]
location: 31 2 33 16
body:
    ord(x: csequence_struct): [csequence_struct -> upto(1)] =
        CASES x OF inj_empty_cseq: 0, inj_add(inj_add1_var, inj_add2_var): 1
          ENDCASES


decl_type: function
theory: csequence_codt_coreduce
library: co_structures
signature: [[nat, [[T, domain] -> nat]] -> [csequence_struct -> nat]]
location: 81 2 92 21
body:
    reduce_nat(inj_empty?_fun: nat,
               inj_nonempty?_fun: [[T, domain] -> nat]):
          [csequence_struct -> nat] =
        LAMBDA (csequence_struct_adtvar: csequence_struct):
          LET red: [csequence_struct -> nat] =
                reduce_nat(inj_empty?_fun, inj_nonempty?_fun)
            IN
            CASES csequence_struct_adtvar
              OF inj_empty_cseq: inj_empty?_fun,
                 inj_add(inj_add1_var, inj_add2_var):
                   inj_nonempty?_fun(inj_add1_var, inj_add2_var)
              ENDCASES;


decl_type: function
theory: csequence_codt_coreduce
library: co_structures
location: 94 2 106 21
signature:
  [[[csequence_struct -> nat],
         [[T, domain, csequence_struct] -> nat]] ->
          [csequence_struct -> nat]]

body:
    REDUCE_nat(inj_empty?_fun: [csequence_struct -> nat],
               inj_nonempty?_fun: [[T, domain, csequence_struct] -> nat]):
          [csequence_struct -> nat] =
        LAMBDA (csequence_struct_adtvar: csequence_struct):
          LET red: [csequence_struct -> nat] =
                REDUCE_nat(inj_empty?_fun, inj_nonempty?_fun)
            IN
            CASES csequence_struct_adtvar
              OF inj_empty_cseq: inj_empty?_fun(csequence_struct_adtvar),
                 inj_add(inj_add1_var, inj_add2_var):
                   inj_nonempty?_fun(inj_add1_var, inj_add2_var,
                                     csequence_struct_adtvar)
              ENDCASES;


decl_type: function
theory: csequence_codt_coreduce
library: co_structures
signature:
  [[ordinal, [[T, domain] -> ordinal]] ->
  [csequence_struct -> ordinal]]

location: 108 2 119 21
body:
    reduce_ordinal(inj_empty?_fun: ordinal,
                   inj_nonempty?_fun: [[T, domain] -> ordinal]):
          [csequence_struct -> ordinal] =
        LAMBDA (csequence_struct_adtvar: csequence_struct):
          LET red: [csequence_struct -> ordinal] =
                reduce_ordinal(inj_empty?_fun, inj_nonempty?_fun)
            IN
            CASES csequence_struct_adtvar
              OF inj_empty_cseq: inj_empty?_fun,
                 inj_add(inj_add1_var, inj_add2_var):
                   inj_nonempty?_fun(inj_add1_var, inj_add2_var)
              ENDCASES;


decl_type: function
theory: csequence_codt_coreduce
library: co_structures
location: 121 2 134 21
signature:
  [[[csequence_struct -> ordinal],
         [[T, domain, csequence_struct] -> ordinal]] ->
          [csequence_struct -> ordinal]]

body:
    REDUCE_ordinal(inj_empty?_fun: [csequence_struct -> ordinal],
                   inj_nonempty?_fun:
                     [[T, domain, csequence_struct] -> ordinal]):
          [csequence_struct -> ordinal] =
        LAMBDA (csequence_struct_adtvar: csequence_struct):
          LET red: [csequence_struct -> ordinal] =
                REDUCE_ordinal(inj_empty?_fun, inj_nonempty?_fun)
            IN
            CASES csequence_struct_adtvar
              OF inj_empty_cseq: inj_empty?_fun(csequence_struct_adtvar),
                 inj_add(inj_add1_var, inj_add2_var):
                   inj_nonempty?_fun(inj_add1_var, inj_add2_var,
                                     csequence_struct_adtvar)
              ENDCASES;


decl_type: function
theory: csequence_codt_coreduce
library: co_structures
location: 136 2 144 17
signature:
  [op: [domain -> csequence_struct] ->
          [x: domain ->
             {c: csequence[T] |
                      inj_empty?(op(x)) AND empty?(c) OR
                       inj_nonempty?(op(x)) AND nonempty?(c)}]]

body:
    coreduce(op: [domain -> csequence_struct])(x: domain):
          {c: csequence[T] |
                   inj_empty?(op(x)) AND empty?(c) OR
                    inj_nonempty?(op(x)) AND nonempty?(c)} =
        CASES op(x)
          OF inj_empty_cseq: empty_cseq,
             inj_add(inj_add1_var, inj_add2_var):
               add(inj_add1_var, coreduce(op)(inj_add2_var))
          ENDCASES;


decl_type: datatype
theory: csequence_codt_coreduce
library: co_structures
signature: nil
location: 6 20 10 23
body:
    csequence_struct: DATATYPE
     BEGIN
      inj_empty_cseq: inj_empty?
      inj_add(inj_first: T, inj_rest: domain): inj_nonempty?
     END csequence_struct


decl_type: formula
theory: trig_aux
library: complex
signature: nil
location: 15 2 16 49
body:
    eq_iff_periodic: LEMMA sin(a) = sin(b) AND cos(a) = cos(b) IFF
                           EXISTS i: a = b + 2*i*pi


decl_type: tcc
theory: number_fields_bis
library: complex
signature: nil
location: 126 0 128 999
body:
  % Judgement subtype TCC generated (at line 58, column 40) for  nzx * nzy
      % expected type  nznum
  nznum_times_nznum_is_nznum: OBLIGATION FORALL (nzx, nzy): nzx * nzy /= 0;


decl_type: tcc
theory: number_fields_bis
library: complex
signature: nil
location: 130 0 132 999
body:
  % Judgement subtype TCC generated (at line 59, column 40) for  -nzx
      % expected type  nznum
  minus_nznum_is_nznum: OBLIGATION FORALL (nzx): -nzx /= 0;


decl_type: tcc
theory: number_fields_bis
library: complex
signature: nil
location: 134 0 136 999
body:
  % Judgement subtype TCC generated (at line 68, column 40) for  nzx / nzy
      % expected type  nznum
  nznum_div_nznum_is_nznum: OBLIGATION FORALL (nzx, nzy): nzx / nzy /= 0;


decl_type: tcc
theory: number_fields_sq
library: complex
signature: nil
location: 33 0 35 999
body:
  % Judgement subtype TCC generated (at line 11, column 32) for  sq(nz)
      % expected type  nznum
  sq_nz_pos: OBLIGATION FORALL (nz): sq(nz) /= 0;


decl_type: judgement
theory: complex_types
library: complex
signature: nzcomplex
location: 77 2 78 79
body:
    nzcomplex_times_nzcomplex_is_nzcomplex:
                                          JUDGEMENT *(nzx,nzy) HAS_TYPE nzcomplex


decl_type: tcc
theory: complex_types
library: complex
signature: nil
location: 91 0 93 999
body:
  % Judgement subtype TCC generated (at line 49, column 29) for  x
      % expected type  complex
  real_is_complex: OBLIGATION FORALL (x: real): complex_pred(x);


decl_type: tcc
theory: complex_types
library: complex
signature: nil
location: 95 0 98 999
body:
  % Existence TCC generated (at line 51, column 2) for
      % Re(z): {x | EXISTS y: z = x + y * i}
  Re_TCC1: OBLIGATION
    EXISTS (x1: [z: complex -> {x | EXISTS y: z = x + y * i}]): TRUE;


decl_type: tcc
theory: complex_types
library: complex
signature: nil
location: 100 0 103 999
body:
  % Existence TCC generated (at line 52, column 2) for
      % Im(z): {y | EXISTS x: z = x + y * i}
  Im_TCC1: OBLIGATION
    EXISTS (x1: [z: complex -> {y | EXISTS x: z = x + y * i}]): TRUE;


decl_type: tcc
theory: complex_types
library: complex
signature: nil
location: 105 0 108 999
body:
  % Judgement subtype TCC generated (at line 71, column 52) for  z1 + z2
      % expected type  complex
  complex_plus_complex_is_complex: OBLIGATION
    FORALL (z1, z2): complex_pred(z1 + z2);


decl_type: tcc
theory: complex_types
library: complex
signature: nil
location: 110 0 113 999
body:
  % Judgement subtype TCC generated (at line 72, column 52) for  z1 - z2
      % expected type  complex
  complex_minus_complex_is_complex: OBLIGATION
    FORALL (z1, z2): complex_pred(z1 - z2);


decl_type: tcc
theory: complex_types
library: complex
signature: nil
location: 115 0 118 999
body:
  % Judgement subtype TCC generated (at line 73, column 52) for  z1 * z2
      % expected type  complex
  complex_times_complex_is_complex: OBLIGATION
    FORALL (z1, z2): complex_pred(z1 * z2);


decl_type: tcc
theory: complex_types
library: complex
signature: nil
location: 120 0 123 999
body:
  % Judgement subtype TCC generated (at line 74, column 52) for  z / n0z
      % expected type  complex
  complex_div_nzcomplex_is_complex: OBLIGATION
    FORALL (n0z, z): complex_pred(z / n0z);


decl_type: tcc
theory: complex_types
library: complex
signature: nil
location: 125 0 127 999
body:
  % Judgement subtype TCC generated (at line 75, column 52) for  -z
      % expected type  complex
  minus_complex_is_complex: OBLIGATION FORALL (z): complex_pred(-z);


decl_type: tcc
theory: complex_types
library: complex
signature: nil
location: 129 0 132 999
body:
  % Judgement subtype TCC generated (at line 78, column 50) for  nzx * nzy
      % expected type  nzcomplex
  nzcomplex_times_nzcomplex_is_nzcomplex: OBLIGATION
    FORALL (nzx, nzy): nzx * nzy /= 0;


decl_type: tcc
theory: complex_types
library: complex
signature: nil
location: 134 0 137 999
body:
  % Judgement subtype TCC generated (at line 79, column 50) for  nzx / nzy
      % expected type  nzcomplex
  nzcomplex_div_nzcomplex_is_nzcomplex: OBLIGATION
    FORALL (nzx, nzy): nzx / nzy /= 0;


decl_type: tcc
theory: complex_types
library: complex
signature: nil
location: 139 0 141 999
body:
  % Judgement subtype TCC generated (at line 80, column 50) for  -nzx
      % expected type  nzcomplex
  minus_nzcomplex_is_nzcomplex: OBLIGATION FORALL (nzx): -nzx /= 0;


decl_type: formula
theory: arithmetic
library: complex
signature: nil
location: 50 2 51 58
body:
    Re_div          : LEMMA Re(z/n0z) = (Re(z)*Re(n0z) + Im(z)*Im(n0z))/
                                        (n0z*conjugate(n0z))


decl_type: formula
theory: arithmetic
library: complex
signature: nil
location: 52 2 53 58
body:
    Im_div          : LEMMA Im(z/n0z) = (Im(z)*Re(n0z) - Re(z)*Im(n0z))/
                                        (n0z*conjugate(n0z))


decl_type: tcc
theory: arithmetic
library: complex
signature: nil
location: 70 0 73 999
body:
  % Subtype TCC generated (at line 35, column 26) for  n0z * conjugate(n0z)
      % expected type  real
  nz_sq_abs_pos_TCC1: OBLIGATION
    FORALL (n0z: nzcomplex): real_pred(n0z * conjugate(n0z));


decl_type: tcc
theory: arithmetic
library: complex
signature: nil
location: 75 0 78 999
body:
  % Subtype TCC generated (at line 36, column 26) for  z * conjugate(z)
      % expected type  real
  sq_abs_nonneg_TCC1: OBLIGATION
    FORALL (z: complex): real_pred(z * conjugate(z));


decl_type: tcc
theory: arithmetic
library: complex
signature: nil
location: 80 0 83 999
body:
  % Subtype TCC generated (at line 51, column 39) for  (n0z * conjugate(n0z))
      % expected type  nznum
  Re_div_TCC1: OBLIGATION
    FORALL (n0z: nzcomplex): (n0z * conjugate(n0z)) /= 0;


decl_type: tcc
theory: arithmetic
library: complex
signature: nil
location: 85 0 87 999
body:
  % Subtype TCC generated (at line 61, column 47) for  conjugate(n0z)
      % expected type  nznum
  conjugate_inv_TCC1: OBLIGATION FORALL (n0z: nzcomplex): conjugate(n0z) /= 0;


decl_type: formula
theory: polar
library: complex
signature: nil
location: 83 2 84 73
body:
    arg_neg:  LEMMA arg(-n0x)    = IF 0 < arg(n0x) THEN arg(n0x) - pi
                                                   ELSE arg(n0x) + pi ENDIF


decl_type: formula
theory: polar
library: complex
signature: nil
location: 85 2 88 65
body:
    arg_mult: LEMMA arg(n0x*n0y) = LET r = arg(n0x)+arg(n0y) IN
                                   IF    r >   pi THEN r-2*pi
                                   ELSIF r <= -pi THEN r+2*pi
                                                  ELSE r      ENDIF


decl_type: formula
theory: polar
library: complex
signature: nil
location: 89 2 91 73
body:
    arg_inv:  LEMMA arg(1/n0z)   = IF    arg(n0z) = 0  THEN 0
                                   ELSIF arg(n0z) = pi THEN pi
                                                       ELSE -arg(n0z) ENDIF


decl_type: formula
theory: polar
library: complex
signature: nil
location: 92 2 95 65
body:
    arg_div:  LEMMA arg(n0x/n0y) = LET r = arg(n0x)-arg(n0y) IN
                                   IF    r >   pi THEN r-2*pi
                                   ELSIF r <= -pi THEN r+2*pi
                                                  ELSE r      ENDIF


decl_type: formula
theory: polar
library: complex
signature: nil
location: 102 2 103 34
body:
    arg_from_polar: LEMMA r>0 AND -pi < theta AND theta<=pi IMPLIES
      arg(from_polar(r,theta))=theta


decl_type: function
theory: polar
library: complex
signature: [complex -> argrng]
location: 61 2 63 70
body:
    arg(z):argrng = IF    z = 0     THEN 0
                    ELSIF Im(z) < 0 THEN atan2(Re(z),Im(z)) - 2*pi
                                    ELSE atan2(Re(z),Im(z))        ENDIF


decl_type: tcc
theory: polar
library: complex
signature: nil
location: 113 0 115 999
body:
  % Subtype TCC generated (at line 21, column 58) for  0
      % expected type  argrng
  argrng_TCC1: OBLIGATION -pi < 0 & 0 <= pi;


decl_type: tcc
theory: polar
library: complex
signature: nil
location: 117 0 121 999
body:
  % Subtype TCC generated (at line 33, column 23) for  z * conjugate(z)
      % expected type  nnx: nonneg_real
  abs_TCC1: OBLIGATION
    FORALL (z: complex):
      real_pred(z * conjugate(z)) AND z * conjugate(z) >= 0;


decl_type: tcc
theory: polar
library: complex
signature: nil
location: 123 0 125 999
body:
  % Subtype TCC generated (at line 45, column 40) for  abs(n0z)
      % expected type  nznum
  abs_inv_TCC1: OBLIGATION FORALL (n0z: nzcomplex): abs(n0z) /= 0;


decl_type: tcc
theory: polar
library: complex
signature: nil
location: 127 0 131 999
body:
  % Subtype TCC generated (at line 62, column 51) for  Im(z)
      % expected type  {z_1: real | Re(z) = 0 => z_1 /= 0}
  arg_TCC1: OBLIGATION
    FORALL (z: complex):
      Im(z) < 0 AND NOT z = 0 IMPLIES Re(z) = 0 => Im(z) /= 0;


decl_type: tcc
theory: polar
library: complex
signature: nil
location: 133 0 140 999
body:
  % Subtype TCC generated (at line 62, column 39) for
      % atan2(Re(z), Im(z)) - 2 * pi
      % expected type  argrng
  arg_TCC2: OBLIGATION
    FORALL (z: complex):
      Im(z) < 0 AND NOT z = 0 IMPLIES
       -pi < atan2(Re(z), Im(z)) - 2 * pi &
        atan2(Re(z), Im(z)) - 2 * pi <= pi;


decl_type: tcc
theory: polar
library: complex
signature: nil
location: 142 0 146 999
body:
  % Subtype TCC generated (at line 63, column 51) for  Im(z)
      % expected type  {z_1: real | Re(z) = 0 => z_1 /= 0}
  arg_TCC3: OBLIGATION
    FORALL (z: complex):
      NOT Im(z) < 0 AND NOT z = 0 IMPLIES Re(z) = 0 => Im(z) /= 0;


decl_type: tcc
theory: polar
library: complex
signature: nil
location: 148 0 153 999
body:
  % Subtype TCC generated (at line 63, column 39) for  atan2(Re(z), Im(z))
      % expected type  argrng
  arg_TCC4: OBLIGATION
    FORALL (z: complex):
      NOT Im(z) < 0 AND NOT z = 0 IMPLIES
       -pi < atan2(Re(z), Im(z)) & atan2(Re(z), Im(z)) <= pi;


decl_type: formula
theory: exp
library: complex
signature: nil
location: 44 2 45 51
body:
    ln_exp          : LEMMA (2*j-1)*pi < Im(z) AND Im(z) <= (2*j+1)*pi IMPLIES
                            ln(exp(z)) = z - 2*j*pi*i


decl_type: formula
theory: exp
library: complex
signature: nil
location: 47 2 51 53
body:
    ln_mult         : LEMMA ln(n0x*n0y)  = ln(n0x) + ln(n0y) -
                            LET r = arg(n0x)+arg(n0y) IN
                            IF    r >   pi THEN 2*pi*i
                            ELSIF r <= -pi THEN -2*pi*i
                                           ELSE 0 ENDIF


decl_type: formula
theory: exp
library: complex
signature: nil
location: 52 2 53 64
body:
    ln_inv          : LEMMA ln(1/n0x)   = IF arg(n0x) = pi THEN 2*pi
                                          ELSE 0 ENDIF*i - ln(n0x)


decl_type: formula
theory: exp
library: complex
signature: nil
location: 54 2 58 53
body:
    ln_div          : LEMMA ln(n0x/n0y)  = ln(n0x) - ln(n0y) -
                            LET r = arg(n0x)-arg(n0y) IN
                            IF    r >   pi THEN 2*pi*i
                            ELSIF r <= -pi THEN -2*pi*i
                                           ELSE 0 ENDIF


decl_type: tcc
theory: exp
library: complex
signature: nil
location: 65 0 69 999
body:
  % Subtype TCC generated (at line 24, column 22) for
      % exp(Re(z)) * (cos(Im(z)) + i * sin(Im(z)))
      % expected type  nzcomplex
  exp_TCC1: OBLIGATION
    FORALL (z: complex): exp(Re(z)) * (cos(Im(z)) + i * sin(Im(z))) /= 0;


decl_type: tcc
theory: exp
library: complex
signature: nil
location: 71 0 73 999
body:
  % Subtype TCC generated (at line 40, column 24) for  abs(n0z)
      % expected type  posreal
  ln_TCC1: OBLIGATION FORALL (n0z: nzcomplex): abs(n0z) > 0;


decl_type: function
theory: complex_sets
library: complex
signature: [nonempty_set[real] -> nonempty_set[real]]
location: 29 2 30 53
body:
    -: MACRO [nonempty_set[real]->nonempty_set[real]]
        = (LAMBDA (X:nonempty_set[real]): {x | X(-x)});


decl_type: function
theory: complex_sets
library: complex
signature:
  [[nonempty_set[real], nonempty_set[real]] ->
  nonempty_set[real]]

location: 31 2 32 84
body:
    +: MACRO [nonempty_set[real],nonempty_set[real]->nonempty_set[real]]
        = (LAMBDA (X,Y:nonempty_set[real]): {z:real | EXISTS (x:(X),y:(Y)): z = x+y});


decl_type: function
theory: complex_sets
library: complex
signature:
  [[nonempty_set[real], nonempty_set[real]] ->
  nonempty_set[real]]

location: 33 2 34 84
body:
    -: MACRO [nonempty_set[real],nonempty_set[real]->nonempty_set[real]]
        = (LAMBDA (X,Y:nonempty_set[real]): {z:real | EXISTS (x:(X),y:(Y)): z = x-y});


decl_type: tcc
theory: complex_sets
library: complex
signature: nil
location: 48 0 51 999
body:
  % Subtype TCC generated (at line 30, column 40) for  {x | X(-x)}
      % expected type  nonempty_set[real]
  difference_TCC1: OBLIGATION
    FORALL (X: nonempty_set[real]): nonempty?[real]({x | X(-x)});


decl_type: tcc
theory: complex_sets
library: complex
signature: nil
location: 53 0 58 999
body:
  % Subtype TCC generated (at line 32, column 42) for
      % {z: real | EXISTS (x: (X), y: (Y)): z = x + y}
      % expected type  nonempty_set[real]
  plus_TCC1: OBLIGATION
    FORALL (X, Y: nonempty_set[real]):
      nonempty?[real]({z: real | EXISTS (x: (X), y: (Y)): z = x + y});


