# Declarations

decl_type: tcc
theory: more_list_props
library: structures
signature: nil
location: 182 0 183 999
body:
  % Termination TCC generated (at line 73, column 21) for  ^(l1, n - 1)
  caret_TCC2: OBLIGATION FORALL (n: nat): NOT n = 0 IMPLIES n - 1 < n;


decl_type: tcc
theory: more_list_props
library: structures
signature: nil
location: 185 0 188 999
body:
  % Subtype TCC generated (at line 89, column 34) for  pair`2 - pair`1
      % expected type  naturalnumber
  caret_TCC3: OBLIGATION
    FORALL (pair: [nat, nat]): pair`2 > pair`1 IMPLIES pair`2 - pair`1 >= 0;


decl_type: tcc
theory: more_list_props
library: structures
signature: nil
location: 190 0 196 999
body:
  % Subtype TCC generated (at line 86, column 39) for  m
      % expected type  below[length[T](l1)]
  caret_TCC4: OBLIGATION
    FORALL (l1: list[T], pair: [nat, nat], m: nat, n: nat):
           m = n AND NOT m > n AND NOT m >= length(l1) AND NOT m < 0
       AND n = pair`2 AND m = pair`1
       IMPLIES m < length[T](l1);


decl_type: tcc
theory: more_list_props
library: structures
signature: nil
location: 198 0 204 999
body:
  % Subtype TCC generated (at line 87, column 27) for  m
      % expected type  below[length[T](l1)]
  caret_TCC5: OBLIGATION
    FORALL (l1: list[T], pair: [nat, nat], m: nat, n: nat):
           NOT m = n AND NOT m > n AND NOT m >= length(l1) AND NOT m < 0
       AND n = pair`2 AND m = pair`1
       IMPLIES m < length[T](l1);


decl_type: tcc
theory: more_list_props
library: structures
signature: nil
location: 206 0 213 999
body:
  % Termination TCC generated (at line 87, column 31) for  ^(l1, (m + 1, n))
  caret_TCC6: OBLIGATION
    FORALL (l1: list[T], pair: [nat, nat], m: nat, n: nat):
           NOT m = n AND NOT m > n AND NOT m >= length(l1) AND NOT m < 0
       AND n = pair`2 AND m = pair`1
       IMPLIES
       IF n > m + 1 THEN n - (m + 1) ELSE 0 ENDIF <
        IF pair`2 > pair`1 THEN pair`2 - pair`1 ELSE 0 ENDIF;


decl_type: tcc
theory: more_list_props
library: structures
signature: nil
location: 215 0 220 999
body:
  % Subtype TCC generated (at line 109, column 90) for  n
      % expected type  below[length[T](l2)]
  list_extensionality_TCC1: OBLIGATION
    FORALL (l1, l2: list[T]):
      length(l1) = length(l2) IMPLIES
       (FORALL (n: below(length[T](l1))): n < length[T](l2));


decl_type: tcc
theory: more_list_props
library: structures
signature: nil
location: 222 0 226 999
body:
  % Subtype TCC generated (at line 125, column 25) for  i
      % expected type  below[length[T](append(l1, l2))]
  nth_append_TCC1: OBLIGATION
    FORALL (l1, l2: list[T], i: nat):
      i < length(l1) + length(l2) IMPLIES i < length[T](append[T](l1, l2));


decl_type: tcc
theory: more_list_props
library: structures
signature: nil
location: 228 0 233 999
body:
  % Subtype TCC generated (at line 126, column 42) for  i - length(l1)
      % expected type  below[length[T](l2)]
  nth_append_TCC2: OBLIGATION
    FORALL (l1, l2: list[T], i: nat):
      NOT i < length(l1) AND i < length(l1) + length(l2) IMPLIES
       i - length[T](l1) >= 0 AND i - length[T](l1) < length[T](l2);


decl_type: tcc
theory: more_list_props
library: structures
signature: nil
location: 235 0 239 999
body:
  % Subtype TCC generated (at line 142, column 39) for  j
      % expected type  below[length[T](reverse(L))]
  reverse_def_TCC1: OBLIGATION
    FORALL (L: list[T], j: nat):
      j < length(L) IMPLIES j < length[T](reverse[T](L));


decl_type: tcc
theory: more_list_props
library: structures
signature: nil
location: 241 0 246 999
body:
  % Subtype TCC generated (at line 142, column 50) for  length(L) - 1 - j
      % expected type  below[length[T](L)]
  reverse_def_TCC2: OBLIGATION
    FORALL (L: list[T], j: nat):
      j < length(L) IMPLIES
       length[T](L) - 1 - j >= 0 AND length[T](L) - 1 - j < length[T](L);


decl_type: tcc
theory: more_list_props
library: structures
signature: nil
location: 248 0 251 999
body:
  % Subtype TCC generated (at line 148, column 29) for  L
      % expected type  (cons?[T])
  expand_list_TCC1: OBLIGATION
    FORALL (L: list[T]): NOT null?(L) IMPLIES cons?[T](L);


decl_type: formula
theory: listn
library: structures
signature: nil
location: 10 2 12 66
body:
    listn_ext : LEMMA
      FORALL(n:nat,l1:listn(n),l2:listn(n)):
        (FORALL (i:below(n)): nth(l1,i) = nth(l2,i)) IMPLIES l1 = l2


decl_type: function
theory: listn
library: structures
location: 17 2 28 17
signature:
  [d: [list[T], nat, [T -> T]] ->
          {sl: listn(length(d`1)) |
                   FORALL (i: below(length(d`1))):
                     IF i = d`2 THEN nth(sl, i) = d`3(nth(d`1, i))
                     ELSE nth(sl, i) = nth(d`1, i)
                     ENDIF}]

body:
    setnth(l:list,n:nat,f:[T->T]) : RECURSIVE 
      {sl : listn(length(l)) | 
            FORALL (i:below(length(l))) : IF i=n THEN nth(sl,i) = f(nth(l,i)) 
                                          ELSE nth(sl,i) = nth(l,i)
                                          ENDIF} =
      CASES l OF
        null : null,
        cons(a,r) : IF n=0 THEN cons(f(a),r)
                    ELSE cons(a,setnth(r,n-1,f))
                    ENDIF
      ENDCASES
    MEASURE l BY <<


decl_type: function
theory: listn
library: structures
signature: [f: finseq[T] -> {fsn: Finseqn(f`length) | fsn = f}]
location: 34 2 36 27
body:
    normalize_fseq(f:finseq[T]): {fsn: Finseqn(f`length)|fsn = f} =
      LET fslist = finseq2list(f)
      IN  list2finseq(fslist)


decl_type: tcc
theory: listn
library: structures
signature: nil
location: 47 0 51 999
body:
  % Subtype TCC generated (at line 12, column 35) for  i
      % expected type  below[length[T](l1)]
  listn_ext_TCC1: OBLIGATION
    FORALL (n: nat, l1: listn(n), l2: listn(n), i: below(n)):
      i < length[T](l1);


decl_type: tcc
theory: listn
library: structures
signature: nil
location: 53 0 57 999
body:
  % Subtype TCC generated (at line 12, column 47) for  i
      % expected type  below[length[T](l2)]
  listn_ext_TCC2: OBLIGATION
    FORALL (n: nat, l1: listn(n), l2: listn(n), i: below(n)):
      i < length[T](l2);


decl_type: tcc
theory: listn
library: structures
signature: nil
location: 59 0 61 999
body:
  % Judgement subtype TCC generated (at line 15, column 4) for  null
      % expected type  listn(0)
  listn_0: OBLIGATION length[T](null[T]) = 0;


decl_type: tcc
theory: listn
library: structures
signature: nil
location: 63 0 68 999
body:
  % Subtype TCC generated (at line 19, column 59) for  i
      % expected type  below[length[T](sl)]
  setnth_TCC1: OBLIGATION
    FORALL (l: list, n: nat, sl: listn(length[T](l)),
            i: below(length[T](l))):
      i = n IMPLIES i < length[T](sl);


decl_type: tcc
theory: listn
library: structures
signature: nil
location: 70 0 75 999
body:
  % Subtype TCC generated (at line 20, column 52) for  i
      % expected type  below[length[T](sl)]
  setnth_TCC2: OBLIGATION
    FORALL (l: list, n: nat, sl: listn(length[T](l)),
            i: below(length[T](l))):
      NOT i = n IMPLIES i < length[T](sl);


decl_type: tcc
theory: listn
library: structures
signature: nil
location: 77 0 90 999
body:
  % Subtype TCC generated (at line 23, column 13) for  null
      % expected type  {sl: listn(length(l)) |
                     %          FORALL (i: below(length(l))):
                     %            IF i = n THEN nth(sl, i) = f(nth(l, i))
                     %            ELSE nth(sl, i) = nth(l, i)
                     %            ENDIF}
  setnth_TCC3: OBLIGATION
    FORALL (l: list[T], n: nat, f: [T -> T]):
      l = null IMPLIES
       (FORALL (i: below(length[T](l))):
          IF i = n THEN nth[T](null[T], i) = f(nth[T](l, i))
          ELSE nth[T](null[T], i) = nth[T](l, i)
          ENDIF)
        AND length[T](null[T]) = length[T](l);


decl_type: tcc
theory: listn
library: structures
signature: nil
location: 92 0 105 999
body:
  % Subtype TCC generated (at line 24, column 30) for  cons(f(a), r)
      % expected type  {sl: listn(length(l)) |
                     %          FORALL (i: below(length(l))):
                     %            IF i = n THEN nth(sl, i) = f(nth(l, i))
                     %            ELSE nth(sl, i) = nth(l, i)
                     %            ENDIF}
  setnth_TCC4: OBLIGATION
    FORALL (l: list[T], n: nat, f: [T -> T], a: T, r: list[T]):
      n = 0 AND l = cons(a, r) IMPLIES
       length[T](cons[T](f(a), r)) = length[T](l) AND
        (FORALL (i: below(length[T](l))):
           IF i = n THEN nth[T](cons[T](f(a), r), i) = f(nth[T](l, i))
           ELSE nth[T](cons[T](f(a), r), i) = nth[T](l, i)
           ENDIF);


decl_type: tcc
theory: listn
library: structures
signature: nil
location: 107 0 111 999
body:
  % Subtype TCC generated (at line 25, column 39) for  n - 1
      % expected type  nat
  setnth_TCC5: OBLIGATION
    FORALL (l: list[T], n: nat, f: [T -> T], a: T, r: list[T]):
      NOT n = 0 AND l = cons(a, r) IMPLIES n - 1 >= 0;


decl_type: tcc
theory: listn
library: structures
signature: nil
location: 113 0 116 999
body:
  % Termination TCC generated (at line 25, column 30) for  setnth(r, n - 1, f)
  setnth_TCC6: OBLIGATION
    FORALL (l: list[T], n: nat, f: [T -> T], a: T, r: list[T]):
      NOT n = 0 AND l = cons(a, r) IMPLIES <<[T](r, l);


decl_type: tcc
theory: listn
library: structures
signature: nil
location: 118 0 141 999
body:
  % Subtype TCC generated (at line 25, column 23) for
      % cons(a, setnth(r, n - 1, f))
      % expected type  {sl: listn(length(l)) |
                     %          FORALL (i: below(length(l))):
                     %            IF i = n THEN nth(sl, i) = f(nth(l, i))
                     %            ELSE nth(sl, i) = nth(l, i)
                     %            ENDIF}
  setnth_TCC7: OBLIGATION
    FORALL (l: list[T],
            v:
              [d1: {z: [list[T], nat, [T -> T]] | z`1 << l} ->
                 {sl: listn(length(d1`1)) |
                          FORALL (i: below(length(d1`1))):
                            IF i = d1`2 THEN nth(sl, i) = d1`3(nth(d1`1, i))
                            ELSE nth(sl, i) = nth(d1`1, i)
                            ENDIF}],
            n: nat, f: [T -> T], a: T, r: list[T]):
      NOT n = 0 AND l = cons(a, r) IMPLIES
       length[T](cons[T](a, v(r, n - 1, f))) = length[T](l) AND
        (FORALL (i: below(length[T](l))):
           IF i = n
             THEN nth[T](cons[T](a, v(r, n - 1, f)), i) = f(nth[T](l, i))
           ELSE nth[T](cons[T](a, v(r, n - 1, f)), i) = nth[T](l, i)
           ENDIF);


decl_type: tcc
theory: listn
library: structures
signature: nil
location: 143 0 149 999
body:
  % Subtype TCC generated (at line 36, column 8) for  list2finseq(fslist)
      % expected type  {fsn: Finseqn(f`length) | fsn = f}
  normalize_fseq_TCC1: OBLIGATION
    FORALL (f: finseq[T], fslist: list[T]):
      fslist = finseq2list(f) IMPLIES
       list2finseq[T](fslist)`length = f`length AND
        list2finseq[T](fslist) = f;


decl_type: formula
theory: array2list
library: structures
signature: nil
location: 25 2 30 11
body:
    list2array_sound : LEMMA
      FORALL(l:list,t:T,i:nat) : 
        list2array(t)(l)(i) = 
          IF i < length(l) THEN nth(l,i)
          ELSE t
        ENDIF 


decl_type: formula
theory: array2list
library: structures
signature: nil
location: 37 2 39 47
body:
    array2list_inv : LEMMA
      FORALL (a:[nat->T],t:T,n:nat,i:below(n)) :      
        list2array(t)(array2list(n)(a))(i) = a(i)


decl_type: formula
theory: array2list
library: structures
signature: nil
location: 41 2 43 63
body:
    list2array_inv : LEMMA
      FORALL (l:list,t:T,i:below(length(l))) :      
        nth(array2list(length(l))(list2array(t)(l)),i) = nth(l,i)


decl_type: formula
theory: array2list
library: structures
signature: nil
location: 45 2 47 49
body:
    list2array_inv_ext : LEMMA
      FORALL (l:list,t:T) :
        array2list(length(l))(list2array(t)(l)) = l


decl_type: function
theory: array2list
library: structures
location: 7 2 12 15
signature:
  [d: [[nat -> T], n: nat, upto(n)] ->
          {l: listn(d`2 - d`3) |
                   FORALL (j: subrange(d`3, d`2 - 1)):
                     d`1(j) = nth(l, j - d`3)}]

body:
    array2list_it(a:[nat->T],n:nat,i:upto(n)) : RECURSIVE 
      {l:listn(n-i) | FORALL (j:subrange(i,n-1)) : a(j) = nth(l,j-i)} =
      IF i = n THEN null
      ELSE cons(a(i),array2list_it(a,n,i+1))
      ENDIF
      MEASURE n-i


decl_type: function
theory: array2list
library: structures
location: 14 2 16 24
signature:
  [n: nat ->
          [a: [nat -> T] ->
             {l: listn(n) | FORALL (i: below(n)): a(i) = nth(l, i)}]]

body:
    array2list(n:nat)(a:[nat->T]) : 
      {l:listn(n) | FORALL (i:below(n)) : a(i) = nth(l,i)} =
      array2list_it(a,n,0)


decl_type: function
theory: array2list
library: structures
signature: [T -> [list[T] -> [nat -> T]]]
location: 18 2 23 17
body:
    list2array(t:T)(l:list)(i:nat) : RECURSIVE T =
      IF null?(l) THEN t
      ELSIF i=0 THEN car(l)  
      ELSE list2array(t)(cdr(l))(i-1)
      ENDIF
    MEASURE l BY <<


decl_type: function
theory: array2list
library: structures
signature:
  [d: [T, nat] ->
  {l: listn(d`2) | FORALL (i: below(d`2)): nth(l, i) = d`1}]

location: 49 2 51 34
body:
    fill(t:T,n:nat) : 
      {l:listn(n) | FORALL (i:below(n)) : nth(l,i) = t} =
      array2list(n)(LAMBDA(n:nat):t)


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 59 0 63 999
body:
  % Subtype TCC generated (at line 8, column 51) for  j
      % expected type  nat
  array2list_it_TCC1: OBLIGATION
    FORALL (n: nat, i: upto(n), l: listn[T](n - i), j: subrange(i, n - 1)):
      j >= 0;


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 65 0 69 999
body:
  % Subtype TCC generated (at line 8, column 62) for  j - i
      % expected type  below[length[T](l)]
  array2list_it_TCC2: OBLIGATION
    FORALL (n: nat, i: upto(n), l: listn[T](n - i), j: subrange(i, n - 1)):
      j - i >= 0 AND j - i < length[T](l);


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 71 0 73 999
body:
  % Subtype TCC generated (at line 12, column 12) for  n - i
      % expected type  naturalnumber
  array2list_it_TCC3: OBLIGATION FORALL (n: nat, i: upto(n)): n - i >= 0;


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 75 0 83 999
body:
  % Subtype TCC generated (at line 9, column 18) for  null
      % expected type  {l: listn(n - i) |
                     %          FORALL (j: subrange(i, n - 1)):
                     %            a(j) = nth(l, j - i)}
  array2list_it_TCC4: OBLIGATION
    FORALL (a: [nat -> T], n: nat, i: upto(n)):
      i = n IMPLIES
       (FORALL (j: subrange(i, n - 1)): a(j) = nth[T](null[T], j - i)) AND
        length[T](null[T]) = n - i;


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 85 0 88 999
body:
  % Subtype TCC generated (at line 10, column 37) for  i + 1
      % expected type  upto(n)
  array2list_it_TCC5: OBLIGATION
    FORALL (n: nat, i: upto(n)): NOT i = n IMPLIES i + 1 <= n;


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 90 0 93 999
body:
  % Termination TCC generated (at line 10, column 19) for
      % array2list_it(a, n, i + 1)
  array2list_it_TCC6: OBLIGATION
    FORALL (n: nat, i: upto(n)): NOT i = n IMPLIES n - (i + 1) < n - i;


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 95 0 110 999
body:
  % Subtype TCC generated (at line 10, column 9) for
      % cons(a(i), array2list_it(a, n, i + 1))
      % expected type  {l: listn(n - i) |
                     %          FORALL (j: subrange(i, n - 1)):
                     %            a(j) = nth(l, j - i)}
  array2list_it_TCC7: OBLIGATION
    FORALL (a: [nat -> T], n: nat, i: upto(n),
            v:
              [d1: {z: [[nat -> T], n: nat, upto(n)] | z`2 - z`3 < n - i} ->
                 {l: listn(d1`2 - d1`3) |
                          FORALL (j: subrange(d1`3, d1`2 - 1)):
                            d1`1(j) = nth(l, j - d1`3)}]):
      NOT i = n IMPLIES
       length[T](cons[T](a(i), v(a, n, i + 1))) = n - i AND
        (FORALL (j: subrange(i, n - 1)):
           a(j) = nth[T](cons[T](a(i), v(a, n, i + 1)), j - i));


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 112 0 115 999
body:
  % Subtype TCC generated (at line 15, column 53) for  i
      % expected type  below[length[T](l)]
  array2list_TCC1: OBLIGATION
    FORALL (n: nat, l: listn[T](n), i: below(n)): i < length[T](l);


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 117 0 119 999
body:
  % Subtype TCC generated (at line 16, column 22) for  0
      % expected type  upto(n)
  array2list_TCC2: OBLIGATION FORALL (n: nat): 0 <= n;


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 121 0 125 999
body:
  % Subtype TCC generated (at line 16, column 4) for  array2list_it(a, n, 0)
      % expected type  {l: listn(n) | FORALL (i: below(n)): a(i) = nth(l, i)}
  array2list_TCC3: OBLIGATION
    FORALL (n: nat, a: [nat -> T]):
      FORALL (i: below(n)): a(i) = nth[T](array2list_it(a, n, 0), i);


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 127 0 130 999
body:
  % Subtype TCC generated (at line 20, column 23) for  l
      % expected type  (cons?[T])
  list2array_TCC1: OBLIGATION
    FORALL (l: list[T], i: nat): i = 0 AND NOT null?(l) IMPLIES cons?[T](l);


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 132 0 136 999
body:
  % Subtype TCC generated (at line 21, column 27) for  l
      % expected type  (cons?[T])
  list2array_TCC2: OBLIGATION
    FORALL (l: list[T], i: nat):
      NOT i = 0 AND NOT null?(l) IMPLIES cons?[T](l);


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 138 0 142 999
body:
  % Termination TCC generated (at line 21, column 9) for
      % list2array(t)(cdr(l))
  list2array_TCC3: OBLIGATION
    FORALL (l: list[T], i: nat):
      NOT i = 0 AND NOT null?(l) IMPLIES <<[T](cdr[T](l), l);


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 144 0 148 999
body:
  % Subtype TCC generated (at line 21, column 31) for  i - 1
      % expected type  nat
  list2array_TCC4: OBLIGATION
    FORALL (l: list[T], i: nat):
      NOT i = 0 AND NOT null?(l) IMPLIES i - 1 >= 0;


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 150 0 152 999
body:
  % Subtype TCC generated (at line 32, column 23) for  {t: T | TRUE}
      % expected type  p: (nonempty?[T])
  default_TCC1: OBLIGATION nonempty?[T]({t: T | TRUE});


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 154 0 160 999
body:
  % Subtype TCC generated (at line 43, column 50) for  i
      % expected type  below
                     %     [length[T]
                     %          (array2list(length(l))(list2array(t)(l)))]
  list2array_inv_TCC1: OBLIGATION
    FORALL (l: list[T], t: T, i: below(length[T](l))):
      i < length[T](array2list(length[T](l))(list2array(t)(l)));


decl_type: tcc
theory: array2list
library: structures
signature: nil
location: 162 0 167 999
body:
  % Subtype TCC generated (at line 51, column 4) for
      % array2list(n)(LAMBDA (n: nat): t)
      % expected type  {l: listn(n) | FORALL (i: below(n)): nth(l, i) = t}
  fill_TCC1: OBLIGATION
    FORALL (t: T, n: nat):
      FORALL (i: below(n)): nth[T](array2list(n)(LAMBDA (n: nat): t), i) = t;


decl_type: function
theory: permutation
library: structures
signature: [[below(N), below(N)] -> permutation]
location: 20 2 21 67
body:
    transpose(i,j): permutation = 
            LAMBDA k: IF k = j THEN i ELSIF k = i THEN j ELSE k ENDIF


decl_type: tcc
theory: permutation
library: structures
signature: nil
location: 30 0 32 999
body:
  % Existence TCC generated (at line 16, column 43) for
      % inverse[below(N), below(N)]
  inverse_id_TCC1: OBLIGATION N > 0 IMPLIES (EXISTS (x: below(N)): TRUE);


decl_type: tcc
theory: permutation
library: structures
signature: nil
location: 34 0 40 999
body:
  % Subtype TCC generated (at line 21, column 10) for
      % LAMBDA k: IF k = j THEN i ELSIF k = i THEN j ELSE k ENDIF
      % expected type  permutation
  transpose_TCC1: OBLIGATION
    FORALL (i: below(N), j: below(N)):
      bijective?[below(N), below(N)]
          (LAMBDA k: IF k = j THEN i ELSIF k = i THEN j ELSE k ENDIF);


decl_type: formula
theory: permutation_ops
library: structures
signature: nil
location: 15 2 17 39
body:
    sorted_iff_id_lem  : LEMMA (FORALL i: i >= m => pi(i) = i) &
                             (FORALL (i,j): i < j => pi(i) <= pi(j)) IMPLIES
                                pi(i) = i


decl_type: formula
theory: bags
library: structures
signature: nil
location: 65 2 66 77
body:
    delete_insert         : LEMMA n > 0 IMPLIES
                                    (delete(x,insert(x,b),n) = delete(x,b,n-1))


decl_type: formula
theory: bags
library: structures
signature: nil
location: 70 2 71 79
body:
    delete_insert_diff    : LEMMA x /= y IMPLIES
                              (delete(x,insert(y,b),n) = insert(y,delete(x,b,n)))


decl_type: formula
theory: bags
library: structures
signature: nil
location: 73 2 74 63
body:
    decomposition         : LEMMA NOT empty?(b) IMPLIES 
                                    (EXISTS a,x: b = insert(x,a))


decl_type: formula
theory: bags
library: structures
signature: nil
location: 95 2 96 76
body:
    bag_distributive      : LEMMA intersection(a,union(b,c)) = 
                                    union(intersection(a,b),intersection(a,c))


decl_type: formula
theory: bags
library: structures
signature: nil
location: 115 2 116 59
body:
    union_upper_bound       : LEMMA subbag?(a, c) and subbag?(b, c) IMPLIES 
                                      subbag?(union(a, b), c)


decl_type: function
theory: bags
library: structures
signature: [[T, bag, nat] -> bag]
location: 27 2 29 54
body:
    delete(x,b,n)    : bag = (LAMBDA t: IF x = t THEN
                                          IF b(t) >= n THEN b(t) - n ELSE 0 ENDIF 
                                        ELSE b(t) ENDIF)


decl_type: tcc
theory: bags
library: structures
signature: nil
location: 123 0 127 999
body:
  % Subtype TCC generated (at line 28, column 58) for  b(t) - n
      % expected type  nat
  delete_TCC1: OBLIGATION
    FORALL (x: T, b: bag, n: nat, t):
      b(t) >= n AND x = t IMPLIES b(t) - n >= 0;


decl_type: tcc
theory: bags
library: structures
signature: nil
location: 129 0 131 999
body:
  % Subtype TCC generated (at line 66, column 72) for  n - 1
      % expected type  nat
  delete_insert_TCC1: OBLIGATION FORALL (n: nat): n > 0 IMPLIES n - 1 >= 0;


decl_type: formula
theory: bags_to_sets
library: structures
signature: nil
location: 27 2 28 68
body:
    bag_union_lem        : LEMMA bag_to_set(union(A, B)) = 
                                   union(bag_to_set(A), bag_to_set(B))


decl_type: formula
theory: bags_to_sets
library: structures
signature: nil
location: 30 2 31 74
body:
    bag_intersection_lem : LEMMA bag_to_set(intersection(A,B)) = 
                                   intersection(bag_to_set(A),bag_to_set(B))


decl_type: formula
theory: bags_to_sets
library: structures
signature: nil
location: 33 2 34 69
body:
    subbag_lem           : LEMMA subbag?(A,B) IMPLIES 
                                   subset?(bag_to_set(A),bag_to_set(B))


decl_type: formula
theory: bags_to_sets
library: structures
signature: nil
location: 44 2 45 67
body:
    bag_plus_lem         : LEMMA bag_to_set(plus(A,B)) = 
                                   union(bag_to_set(A),bag_to_set(B))


decl_type: formula
theory: bags_to_sets
library: structures
signature: nil
location: 47 2 49 63
body:
    extract_empty_or_singlton_set: 
                         LEMMA singleton?(bag_to_set(extract(t,A))) OR
                                 empty?(bag_to_set(extract(t,A))) 


decl_type: formula
theory: bags_to_sets
library: structures
signature: nil
location: 51 2 52 70
body:
    extract_singleton  : LEMMA singleton?(bag_to_set(extract(t,A))) IMPLIES 
                                 singleton(t) = bag_to_set(extract(t,A))


decl_type: formula
theory: bags_aux
library: structures
signature: nil
location: 38 2 40 61
body:
    filter_insert:      LEMMA filter(insert(x,b),p) = 
                                 IF p(x) THEN insert(x,filter(b,p)) 
                                         ELSE filter(b,p) ENDIF


decl_type: formula
theory: bags_aux
library: structures
signature: nil
location: 44 2 45 60
body:
    filter_prop:        LEMMA (FORALL x: p(x) => q(x)) => 
                              subbag?(filter(b,p),filter(b,q))


decl_type: tcc
theory: bags_aux
library: structures
signature: nil
location: 54 0 57 999
body:
  % Subtype TCC generated (at line 22, column 40) for  bag_to_set(b)
      % expected type  p: (nonempty?[T])
  choose_TCC1: OBLIGATION
    FORALL (b: (nonempty_bag?[T])): nonempty?[T](bag_to_set[T](b));


decl_type: tcc
theory: bags_aux
library: structures
signature: nil
location: 59 0 62 999
body:
  % Subtype TCC generated (at line 24, column 55) for  b
      % expected type  (nonempty_bag?)
  rest_TCC1: OBLIGATION
    FORALL (b: bag[T]): NOT empty?(b) IMPLIES nonempty_bag?[T](b);


decl_type: formula
theory: finite_bags
library: structures
signature: nil
location: 103 3 104 63
body:
     card_disj_intersection : LEMMA disjoint?(A,B) IMPLIES
                                      card(intersection(A,B)) = 0


decl_type: formula
theory: finite_bags
library: structures
signature: nil
location: 106 3 108 80
body:
     sum_bag_disj_union     : LEMMA disjoint?(A,B) IMPLIES
                                      sum(bag_to_set(A),(LAMBDA (t:T): union(A,B)(t)))
                                        = sum(bag_to_set(A), (LAMBDA (t:T): A(t)))


decl_type: formula
theory: finite_bags
library: structures
signature: nil
location: 114 3 115 70
body:
     card_disjoint_add      : LEMMA disjoint?(A,B) IMPLIES 
                                    card(union(A,B)) = card(A) + card(B)


decl_type: formula
theory: finite_bags
library: structures
signature: nil
location: 119 3 120 86
body:
     card_union_extract_add : LEMMA x /= y IMPLIES 
                                    card(union(extract(x,A),extract(y,A))) = A(x) + A(y)


decl_type: formula
theory: finite_bags
library: structures
signature: nil
location: 122 3 123 83
body:
     card_union_extract     : LEMMA x /= y IMPLIES 
                                    card(union(extract(x,A),extract(y,A))) <= card(A)


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 135 0 137 999
body:
  % Judgement subtype TCC generated (at line 30, column 13) for  bag_to_set(B)
      % expected type  finite_set[T]
  bag_to_set_TCC1: OBLIGATION FORALL (B): is_finite[T](bag_to_set[T](B));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 139 0 142 999
body:
  % Judgement subtype TCC generated (at line 63, column 12) for  x
      % expected type  (nonempty_bag?[T])
  subtype_TCC1: OBLIGATION
    FORALL (x: nonempty_finite_bag): nonempty_bag?[T](x);


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 144 0 147 999
body:
  % Judgement subtype TCC generated (at line 65, column 12) for
      % singleton_bag(x)
      % expected type  finite_bag
  singleton_bag_TCC1: OBLIGATION FORALL (x): is_finite(singleton_bag[T](x));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 149 0 151 999
body:
  % Judgement subtype TCC generated (at line 67, column 12) for  union(A, B)
      % expected type  finite_bag
  union_TCC1: OBLIGATION FORALL (A, B): is_finite(union[T](A, B));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 153 0 157 999
body:
  % Judgement subtype TCC generated (at line 67, column 24) for
      % intersection(A, B)
      % expected type  finite_bag
  intersection_TCC1: OBLIGATION
    FORALL (A, B): is_finite(intersection[T](A, B));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 159 0 161 999
body:
  % Judgement subtype TCC generated (at line 67, column 43) for  plus(A, B)
      % expected type  finite_bag
  plus_TCC1: OBLIGATION FORALL (A, B): is_finite(plus[T](A, B));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 163 0 165 999
body:
  % Judgement subtype TCC generated (at line 71, column 12) for  union(A, NB)
      % expected type  nonempty_finite_bag
  union_TCC2: OBLIGATION FORALL (A, NB): NOT empty?[T](union[T](A, NB));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 167 0 169 999
body:
  % Judgement subtype TCC generated (at line 71, column 25) for  plus(A, NB)
      % expected type  nonempty_finite_bag
  plus_TCC2: OBLIGATION FORALL (A, NB): NOT empty?[T](plus[T](A, NB));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 171 0 173 999
body:
  % Judgement subtype TCC generated (at line 73, column 12) for  union(NA, B)
      % expected type  nonempty_finite_bag
  union_TCC3: OBLIGATION FORALL (B, NA): NOT empty?[T](union[T](NA, B));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 175 0 177 999
body:
  % Judgement subtype TCC generated (at line 73, column 25) for  plus(NA, B)
      % expected type  nonempty_finite_bag
  plus_TCC3: OBLIGATION FORALL (B, NA): NOT empty?[T](plus[T](NA, B));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 179 0 183 999
body:
  % Judgement subtype TCC generated (at line 75, column 12) for  insert(x, A)
      % expected type  nonempty_finite_bag
  insert_TCC1: OBLIGATION
    FORALL (A, x):
      is_finite(insert[T](x, A)) AND NOT empty?[T](insert[T](x, A));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 185 0 187 999
body:
  % Judgement subtype TCC generated (at line 77, column 12) for  purge(x, A)
      % expected type  finite_bag
  purge_TCC1: OBLIGATION FORALL (A, x): is_finite(purge[T](x, A));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 189 0 192 999
body:
  % Judgement subtype TCC generated (at line 79, column 12) for
      % delete(x, A, n)
      % expected type  finite_bag
  delete_TCC1: OBLIGATION FORALL (A, n, x): is_finite(delete[T](x, A, n));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 194 0 196 999
body:
  % Judgement subtype TCC generated (at line 81, column 12) for  emptybag
      % expected type  finite_bag
  emptybag_TCC1: OBLIGATION is_finite(emptybag[T]);


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 198 0 200 999
body:
  % Judgement subtype TCC generated (at line 83, column 12) for  extract(x, A)
      % expected type  finite_bag
  extract_TCC1: OBLIGATION FORALL (A, x): is_finite(extract[T](x, A));


decl_type: tcc
theory: finite_bags
library: structures
signature: nil
location: 202 0 205 999
body:
  % Subtype TCC generated (at line 95, column 37) for  B WITH [x := xn]
      % expected type  finite_bag
  card_bag_particular_TCC1: OBLIGATION
    FORALL (B: finite_bag, x: T, xn: nat): is_finite((B WITH [x := xn]));


decl_type: formula
theory: finite_bags_aux
library: structures
signature: nil
location: 22 2 23 32
body:
    card_bag_rest      : LEMMA nonempty_bag?(b) IMPLIES
                                   card(b) = card(rest(b)) + 1 


decl_type: formula
theory: finite_bags_aux
library: structures
signature: nil
location: 31 2 32 78
body:
    card_filter_insert: LEMMA card(filter(insert(x,b),p)) =
                                 card(filter(b,p)) + IF p(x) THEN 1 ELSE 0 ENDIF


decl_type: formula
theory: finite_bags_aux
library: structures
signature: nil
location: 34 2 36 64
body:
    card_filter_delete: LEMMA card(filter(delete(x,b,n),p)) =
                                 card(filter(b,p)) - IF p(x) THEN min(b(x),n) 
                                                      ELSE 0 ENDIF


decl_type: tcc
theory: finite_bags_aux
library: structures
signature: nil
location: 45 0 47 999
body:
  % Judgement subtype TCC generated (at line 20, column 12) for  rest(b)
      % expected type  finite_bag[T]
  rest_TCC1: OBLIGATION FORALL (b): is_finite[T](rest[T](b));


decl_type: tcc
theory: finite_bags_aux
library: structures
signature: nil
location: 49 0 51 999
body:
  % Judgement subtype TCC generated (at line 29, column 12) for  filter(b, p)
      % expected type  finite_bag[T]
  filter_TCC1: OBLIGATION FORALL (b, p): is_finite[T](filter[T](b, p));


decl_type: formula
theory: finite_bags_inductions
library: structures
signature: nil
location: 22 2 25 48
body:
    finite_bag_induction: THEOREM
            (FORALL pb: (pb(emptybag[T]) AND 
                        (FORALL x,b: pb(b) IMPLIES pb(insert(x,b))))
                        IMPLIES (FORALL b: pb(b)))


decl_type: tcc
theory: finite_bags_minmax
library: structures
signature: nil
location: 37 0 40 999
body:
  % Subtype TCC generated (at line 24, column 27) for  bag_to_set(D)
      % expected type  SS: non_empty_finite_set[T]
  max_TCC1: OBLIGATION
    FORALL (D: nonempty_finite_bag[T]): NOT empty?[T](bag_to_set[T](D));


decl_type: formula
theory: finite_bags_lems
library: structures
signature: nil
location: 19 3 20 70
body:
     card_bag_union      : THEOREM card(union(A,B)) = card(A) + card(B) -
                                                 card(intersection(A,B))


decl_type: formula
theory: finite_bags_lems
library: structures
signature: nil
location: 22 3 23 72
body:
     card_bag_disj_union : THEOREM disjoint?(A,B) IMPLIES 
                                      card(union(A,B)) = card(A) + card(B)


decl_type: formula
theory: finite_bags_lems
library: structures
signature: nil
location: 25 3 26 52
body:
     card_subbag_strict  : THEOREM subbag?(A,B) AND member(x, B) AND NOT member(x, A) IMPLIES
                                     card(A) < card(B)


decl_type: formula
theory: finite_bags_lems
library: structures
signature: nil
location: 28 3 29 52
body:
     card_subbag_strict2 : THEOREM subbag?(A,B) AND A(x) < B(x) IMPLIES
                                     card(A) < card(B)


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 70 2 71 75
body:
    l_filter_orders      : LEMMA leq(i, v) IMPLIES 
                                      subbag?(l_filter(X, i), l_filter(X, v))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 73 2 74 75
body:
    u_filter_orders      : LEMMA leq(v, i) IMPLIES 
                                      subbag?(u_filter(X, i), u_filter(X, v))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 76 2 78 69
body:
    l_filter_orders_2    : LEMMA (leq(i, v) AND i /= v ) IMPLIES 
                                      subbag?(l_filter(X, i), 
                                              purge(v, l_filter(X, v)))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 80 2 82 69
body:
    u_filter_orders_2    : LEMMA (leq(v, i) AND i /= v ) IMPLIES 
                                      subbag?(u_filter(X, i), 
                                              purge(v, u_filter(X, v)))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 84 2 85 61
body:
    l_filter_insert_assoc: LEMMA l_filter(insert(i, X), i) 
                                    = insert(i, l_filter(X, i))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 87 2 88 61
body:
    u_filter_insert_assoc: LEMMA u_filter(insert(i, X), i) = 
                                      insert(i, u_filter(X, i))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 94 2 95 71
body:
    l_filter_purge       : LEMMA (leq(i, v) AND i /= v) IMPLIES 
                                     subbag?(l_filter(X, i), purge(v, X))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 97 2 98 71
body:
    u_filter_purge       : LEMMA (leq(i, v) AND i /= v) IMPLIES 
                                     subbag?(u_filter(X, v), purge(i, X))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 100 2 101 76
body:
    l_u_diff_disj        : LEMMA (leq(v, i) AND i /= v) IMPLIES
                                     disjoint?(l_filter(X, v), u_filter(X, i))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 103 2 104 53
body:
    l_u_fullset          : LEMMA union(purge(i, l_filter(X, i)), 
                                    u_filter(X, i)) = X


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 106 2 107 53
body:
    l_u_fullset2         : LEMMA union(purge(i, u_filter(X, i)), 
                                    l_filter(X, i)) = X


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 109 2 110 50
body:
    l_u_diff             : LEMMA card(l_filter(A, i)) + card(u_filter(A, i)) 
                                    = card(A) + A(i)


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 112 2 114 65
body:
    subset_diff_elements : LEMMA (leq(v, i) AND i /= v) IMPLIES
                                     subbag?(union(l_filter(X, v), 
                                                u_filter(X, i)), X)


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 116 2 118 48
body:
    card_diff_elements   : LEMMA (leq(v, i) AND i /= v) IMPLIES 
                                     card(l_filter(A, v)) + card(u_filter(A, i)) 
                                        <= card(A)


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 120 2 121 78
body:
    card_plus            : LEMMA card(A) + card(B) = 
                                     card(union(A, B)) + card(intersection(A,B))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 123 2 124 72
body:
    pigeonhole           : LEMMA card(A) + card(B) > card(union(A,B)) IMPLIES
                                     EXISTS x: member(x,A) AND member(x,B)


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 126 2 130 74
body:
    maj_pigeonhole       : LEMMA 2 * card(A) > card(C) AND 
                                     subbag?(A,C) AND
                                     2 * card(B) >= card(C) AND 
                                     subbag?(B,C) IMPLIES
                                       EXISTS x: member(x,A) AND member(x,B)


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 132 2 133 62
body:
    l_filter_nonempty    : LEMMA 2 * card(l_filter(A, i)) > card(A) IMPLIES
                                      NOT empty?(l_filter(A, i)) 


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 135 2 136 62
body:
    u_filter_nonempty    : LEMMA 2 * card(u_filter(A, i)) > card(A) IMPLIES
                                      NOT empty?(u_filter(A, i)) 


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 138 2 140 70
body:
    l_filter_max         : LEMMA NOT empty?(l_filter(A, i)) IMPLIES 
                                      l_filter(A, i) = 
                                        l_filter(A, max(l_filter(A, i)))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 142 2 144 70
body:
    u_filter_min         : LEMMA NOT empty?(u_filter(A, i)) IMPLIES 
                                      u_filter(A, i) = 
                                        u_filter(A, min(u_filter(A, i)))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 146 2 148 64
body:
    l_filter_max_purge   : LEMMA NOT empty?(purge(i, l_filter(A, i))) IMPLIES
                                      l_filter(A, max(purge(i, l_filter(A, i))))
                                        = purge(i, l_filter(A, i))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 150 2 152 64
body:
    u_filter_min_purge   : LEMMA NOT empty?(purge(i, u_filter(A, i))) IMPLIES
                                      u_filter(A, min(purge(i, u_filter(A, i))))
                                        = purge(i, u_filter(A, i))


decl_type: formula
theory: bag_filters
library: structures
signature: nil
location: 154 2 156 44
body:
    filter_exists        :  LEMMA (EXISTS i: 2 * card(l_filter(A, i)) > card(A) 
                                        AND 2 * card(u_filter(A, i)) >= card(A))
                                  OR empty?(A)


decl_type: function
theory: bag_filters
library: structures
signature: [[bag[T], T] -> bag[T]]
location: 40 2 42 39
body:
    l_filter(X, v): bag =  LAMBDA i: 
                             IF leq(i, v) THEN X(i) 
                             ELSE 0 ENDIF


decl_type: function
theory: bag_filters
library: structures
signature: [[bag[T], T] -> bag[T]]
location: 44 2 46 39
body:
    u_filter(X, v): bag =  LAMBDA i: 
                             IF leq(v, i) THEN X(i)
                             ELSE 0 ENDIF


decl_type: tcc
theory: bag_filters
library: structures
signature: nil
location: 163 0 165 999
body:
  % Judgement subtype TCC generated (at line 54, column 12) for  l_filter(A, i)
      % expected type  finite_bag[T]
  l_filter_TCC1: OBLIGATION FORALL (A, i): is_finite[T](l_filter(A, i));


decl_type: tcc
theory: bag_filters
library: structures
signature: nil
location: 167 0 169 999
body:
  % Judgement subtype TCC generated (at line 56, column 12) for  u_filter(A, i)
      % expected type  finite_bag[T]
  u_filter_TCC1: OBLIGATION FORALL (A, i): is_finite[T](u_filter(A, i));


decl_type: function
theory: middle_value_select
library: structures
signature: [finite_bag[T] -> [T -> bool]]
location: 22 2 23 64
body:
    mid_val?(A)(v)    : bool = 2 * card(l_filter(A, v)) > card(A) AND
                               2 * card(u_filter(A, v)) >= card(A) 


decl_type: formula
theory: majority_vote
library: structures
signature: nil
location: 29 2 30 67
body:
    maj_size           : LEMMA 2 * A(v) > card(A) IMPLIES 
                                      2 * card(purge(v, A)) < card(A)


decl_type: formula
theory: majority_vote
library: structures
signature: nil
location: 38 2 39 71
body:
    maj_is_extraction  : LEMMA maj?(A)(v) IMPLIES  
                                      maj?(A) = bag_to_set(extract(v, A))


decl_type: function
theory: majority_vote
library: structures
signature: [finite_bag[T] -> T]
location: 24 2 26 47
body:
    maj(A)      : T = IF empty?(maj?(A)) 
                      THEN no_majority 
                      ELSE epsilon(maj?(A)) ENDIF 


decl_type: formula
theory: fault_masking_vote
library: structures
signature: nil
location: 25 2 26 47
body:
    mid_val_is_maj : LEMMA maj(A) /= no_majority IMPLIES
                              mid_val(A) = maj(A)


decl_type: formula
theory: seq_pigeon
library: structures
signature: nil
location: 9 3 11 34
body:
     seq_pigeon_lem: LEMMA 
            (FORALL (i,j: below(length(w))): i /= j IMPLIES w(i) /= w(j)) IMPLIES
                length(w) <= card(S)


decl_type: formula
theory: seq_pigeon
library: structures
signature: nil
location: 13 3 14 78
body:
     seq_pigeon_hole: THEOREM length(w) > card(S) IMPLIES 
                        (EXISTS (i,j: below(length(w))): i /= j AND w(i) = w(j))


decl_type: formula
theory: set2seq
library: structures
signature: nil
location: 30 3 31 67
body:
     set2seq_lem: LEMMA LET fs = set2seq(S) IN
                            FORALL (ii: below(length(fs))): S(fs(ii))


decl_type: formula
theory: set2seq
library: structures
signature: nil
location: 33 3 35 70
body:
     set2seq_exists: LEMMA LET fs = set2seq(S) IN
                          S(x) IMPLIES
                              EXISTS (ii: below(length(fs))): fs(ii) = x


decl_type: formula
theory: set2seq
library: structures
signature: nil
location: 39 3 41 64
body:
     set2seq_neq   : LEMMA LET fs = set2seq(S) IN
                       FORALL (ii,jj: below(length(fs))): 
                                 ii /= jj IMPLIES fs(ii) /= fs(jj)


decl_type: function
theory: set2seq
library: structures
signature: [T -> finite_sequence[T]]
location: 15 3 16 71
body:
     #(t:T): finite_sequence[T] =  (# length := 1,
                                      seq := (LAMBDA (x: below[1]): t) #)


decl_type: function
theory: set2seq
library: structures
signature: [finite_set[T] -> finite_sequence[T]]
location: 20 3 24 24
body:
     set2seq(S: finite_set[T]):  RECURSIVE finite_sequence[T] =
          IF empty?[T](S) THEN empty_seq
          ELSE #(choose[T](S)) o set2seq(rest[T](S)) 
          ENDIF 
        MEASURE card[T](S) 


decl_type: tcc
theory: set2seq
library: structures
signature: nil
location: 63 0 65 999
body:
  % Subtype TCC generated (at line 18, column 27) for  0
      % expected type  below[length( #(x))]
  gen_seq_lem_TCC1: OBLIGATION FORALL (x: T): 0 < length( #(x));


decl_type: tcc
theory: set2seq
library: structures
signature: nil
location: 67 0 70 999
body:
  % Subtype TCC generated (at line 22, column 25) for  S
      % expected type  p: (nonempty?)
  set2seq_TCC1: OBLIGATION
    FORALL (S: finite_set[T]): NOT empty?[T](S) IMPLIES nonempty?[T](S);


decl_type: tcc
theory: set2seq
library: structures
signature: nil
location: 72 0 75 999
body:
  % Termination TCC generated (at line 22, column 31) for  set2seq(rest[T](S))
  set2seq_TCC2: OBLIGATION
    FORALL (S: finite_set[T]):
      NOT empty?[T](S) IMPLIES card[T](rest[T](S)) < card[T](S);


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 123 2 124 76
body:
    length_delete: LEMMA seq`length /= 0 IMPLIES
                            length(delete(seq, length(seq) - 1)) < length(seq)


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 126 2 127 78
body:
    seq_empty: LEMMA seq1 o seq2 = empty_seq IMPLIES 
                                           length(seq1) = 0 AND length(seq2) = 0


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 129 2 130 63
body:
    seq_first_rest: LEMMA seq`length /= 0 IMPLIES 
                           seq = add_first(first(seq), rest(seq))


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 132 2 133 56
body:
    seq_first_rest_1: LEMMA seq`length /= 0 IMPLIES 
                           seq = #(first(seq)) o rest(seq)


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 138 2 139 43
body:
    length_rest_0: LEMMA seq`length /= 0 AND length(rest(seq)) = 0 
                         IFF  length(seq) = 1


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 145 2 149 27
body:
    nth_add_first: LEMMA FORALL (i: below[seq`length + 1]):
                        IF i = 0 
                        THEN add_first(x, seq)(i) = x 
                        ELSE add_first(x, seq)(i) = seq(i - 1)
                        ENDIF


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 151 2 152 64
body:
    first_add_last: LEMMA seq`length /= 0 IMPLIES
                              first(add_last(seq, x)) = first(seq)


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 154 2 155 74
body:
    rest_add_last: LEMMA seq`length /= 0 IMPLIES
                             rest(add_last(seq, x)) = add_last(rest(seq), x)


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 157 2 158 79
body:
    add_first_last_commute:LEMMA 
                  add_first(x, add_last(seq, y)) = add_last(add_first(x, seq), y)


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 160 2 161 73
body:
    add_first_last: LEMMA seq`length /= 0 IMPLIES
           add_first(first(seq), add_last(rest(seq), x)) = add_last(seq, x)


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 164 2 165 76
body:
    add_last_delete: LEMMA seq`length /= 0 IMPLIES
                        seq = add_last(delete(seq, seq`length - 1), last(seq))


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 167 2 169 74
body:
    add_last_delete_is_o: LEMMA seq`length /= 0 IMPLIES
       add_last(delete(seq, seq`length - 1), last(seq)) =
                          delete(seq, seq`length - 1)o#(seq(seq`length - 1))


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 172 2 176 27
body:
    nth_add_last: LEMMA FORALL (i: below[seq`length + 1]):
                        IF i =  seq`length
                        THEN add_last(seq, x)(i) = x 
                        ELSE add_last(seq, x)(i) = seq(i)
                        ENDIF


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 185 2 186 78
body:
    rest_compo: LEMMA seq1`length /= 0 IMPLIES 
                                           rest(seq1 o seq2) = rest(seq1) o seq2


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 188 2 189 75
body:
    rest_pos: LEMMA rest(seq)`length /= 0 IMPLIES 
                FORALL (i: below[length(seq) - 1]): seq(i + 1) = rest(seq)(i)


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 192 2 193 51
body:
    delete_is_empty: LEMMA seq`length = 1  IMPLIES
                           delete(seq, 0) = empty_seq


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 196 2 197 79
body:
    delete_pos: LEMMA seq`length /= 0  IMPLIES
     FORALL (i: below[length(seq) - 1]): seq(i) = delete(seq, length(seq) - 1)(i)


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 201 2 203 78
body:
    insert_delete: LEMMA seq`length /= 0 IMPLIES
                          FORALL (n: below[seq`length]): 
                                        insert?(seq(n), delete(seq, n), n) = seq


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 206 1 208 67
body:
   add_first_delete: LEMMA seq`length /= 0 IMPLIES
      FORALL (n: below[seq`length]): n /= 0 
          => add_first(seq(0), rest(delete(seq, n))) = delete(seq, n)


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 210 1 216 27
body:
   delete_rest: LEMMA FORALL (n: below[seq`length]): 
                        IF n = 0
                        THEN
                          delete(seq, 0) = rest(seq)
                        ELSE
                          delete(rest(seq), n - 1) = rest(delete(seq, n))
                        ENDIF


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 219 1 220 78
body:
   first_equal: LEMMA add_first(x, seq1) = add_first(y, seq2) IMPLIES 
                                                           x = y AND seq1 = seq2


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 229 1 230 78
body:
   replace_n2: LEMMA length(seq) /= 0 IMPLIES FORALL (n: below[length(seq)]): 
                          replace(x, replace(y, seq, n), n) = replace(x, seq, n)


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 232 1 237 60
body:
   delete_equivalent: LEMMA  
           FORALL (i: below[seq1`length]), (j: below[seq2`length]):
              equivalent(seq1, seq2) & 
              seq1(i) = seq2(j) 
                         =>
                  equivalent(delete(seq1, i), delete(seq2, j))


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 243 1 245 24
body:
   o_equals_o : LEMMA
      seq1 o seq2 = seq3 o seq4 AND length(seq1) = length(seq3)
       IMPLIES seq1 = seq3


decl_type: formula
theory: seq_extras
library: structures
signature: nil
location: 247 1 249 44
body:
   o_length_o : LEMMA
      seq1 o seq2 = seq3 o seq4 AND length(seq1) < length(seq3)
         IMPLIES EXISTS seq: seq3 = seq1 o seq


decl_type: function
theory: seq_extras
library: structures
signature: [finseq[T] -> finseq[T]]
location: 37 2 40 27
body:
    rest(seq): finseq = IF seq`length = 0 
                        THEN seq
                        ELSE ^(seq,(1, seq`length - 1))
                        ENDIF


decl_type: function
theory: seq_extras
library: structures
signature: [[seq: finseq[T], below[length(seq)]] -> finseq[T]]
location: 42 2 52 14
body:
    delete(seq, (n: below[length(seq)])): finseq =
      (IF seq`length = 0
       THEN 
         seq
       ELSE
         (# length := seq`length - 1,
               seq := (LAMBDA (i: below[seq`length - 1]):
                                 (IF i < n THEN seq(i)
                                  ELSE seq(i + 1) 
                                  ENDIF)) #)
          ENDIF)


decl_type: function
theory: seq_extras
library: structures
signature: [[T, seq: finseq[T], upto[length(seq)]] -> finseq[T]]
location: 56 2 61 55
body:
    insert?(x, seq, (n: upto[length(seq)])): finseq =
            (# length := seq`length + 1,
                  seq := (LAMBDA (i: below[seq`length + 1]):
                              (IF i < n THEN seq(i)
                               ELSIF i = n THEN x
                               ELSE seq(i - 1) ENDIF)) #)


decl_type: function
theory: seq_extras
library: structures
signature: [[T, seq: finseq[T], below[length(seq)]] -> finseq[T]]
location: 71 2 79 15
body:
    replace(x, seq, (n: below[length(seq)])): finseq = 
          (IF seq`length = 0 THEN seq
           ELSE
            (# length := seq`length,
                  seq := (LAMBDA (i: below[seq`length]):
                              (IF i < n THEN seq(i)
                               ELSIF i = n THEN x
                               ELSE seq(i) ENDIF)) #)
           ENDIF)


decl_type: function
theory: seq_extras
library: structures
signature: [[finseq[T], finseq[T]] -> finseq[T]]
location: 85 3 93 16
body:
     replace_seq(seq1, seq2): finseq = 
          (IF seq2`length = 0 THEN seq2
           ELSE
            (# length := seq2`length,
                  seq := (LAMBDA (i: below[seq2`length]):
                              (IF i < seq1`length
                               THEN seq1(i)
                               ELSE seq2(i) ENDIF)) #)
           ENDIF);


decl_type: function
theory: seq_extras
library: structures
signature: [finseq[T] -> bool]
location: 97 1 99 43
body:
   different_elements(seq): bool = 
             FORALL (i, j: below[seq`length]): 
                   i /= j => seq(i) /= seq(j)


decl_type: function
theory: seq_extras
library: structures
signature: [[finseq[T], finseq[T]] -> bool]
location: 101 1 106 76
body:
   equivalent(seq1, seq2): bool = 
                           seq1`length = seq2`length &
                           different_elements(seq1)   &
                           different_elements(seq2)   &
                           FORALL (i: below[seq1`length]):
                             EXISTS (j: below[seq2`length]): seq1(i) = seq2(j)


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 262 0 264 999
body:
  % Subtype TCC generated (at line 33, column 37) for  0
      % expected type  below[length(seq)]
  first_TCC1: OBLIGATION FORALL (seq: not_empty_seq): 0 < length(seq);


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 266 0 270 999
body:
  % Subtype TCC generated (at line 35, column 36) for  seq`length - 1
      % expected type  below[length(seq)]
  last_TCC1: OBLIGATION
    FORALL (seq: not_empty_seq):
      seq`length - 1 >= 0 AND seq`length - 1 < length(seq);


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 272 0 275 999
body:
  % Subtype TCC generated (at line 39, column 37) for  seq`length - 1
      % expected type  nat
  rest_TCC1: OBLIGATION
    FORALL (seq: finseq[T]): NOT seq`length = 0 IMPLIES seq`length - 1 >= 0;


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 277 0 282 999
body:
  % Subtype TCC generated (at line 49, column 50) for  i
      % expected type  below[length(seq)]
  delete_TCC1: OBLIGATION
    FORALL (seq: finseq[T], (n: below[length(seq)])):
      NOT seq`length = 0 IMPLIES
       (FORALL (i: below[seq`length - 1]): i < n IMPLIES i < length(seq));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 284 0 290 999
body:
  % Subtype TCC generated (at line 50, column 41) for  i + 1
      % expected type  below[length(seq)]
  delete_TCC2: OBLIGATION
    FORALL (seq: finseq[T], (n: below[length(seq)])):
      NOT seq`length = 0 IMPLIES
       (FORALL (i: below[seq`length - 1]):
          NOT i < n IMPLIES i + 1 < length(seq));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 292 0 297 999
body:
  % Subtype TCC generated (at line 59, column 47) for  i
      % expected type  below[length(seq)]
  insert?_TCC1: OBLIGATION
    FORALL (x: T, seq: finseq[T], (n: upto[length(seq)]),
            i: below[seq`length + 1]):
      i < n IMPLIES i < length(seq);


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 299 0 304 999
body:
  % Subtype TCC generated (at line 61, column 38) for  i - 1
      % expected type  below[length(seq)]
  insert?_TCC2: OBLIGATION
    FORALL (x: T, seq: finseq[T], (n: upto[length(seq)]),
            i: below[seq`length + 1]):
      NOT i = n AND NOT i < n IMPLIES i - 1 >= 0 AND i - 1 < length(seq);


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 306 0 308 999
body:
  % Subtype TCC generated (at line 64, column 46) for  0
      % expected type  upto[length(seq)]
  add_first_TCC1: OBLIGATION FORALL (x: T, seq: finseq[T]): 0 <= length(seq);


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 310 0 313 999
body:
  % Subtype TCC generated (at line 66, column 45) for  length(seq)
      % expected type  upto[length(seq)]
  add_last_TCC1: OBLIGATION
    FORALL (seq: finseq[T], x: T): length(seq) <= length(seq);


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 315 0 320 999
body:
  % Subtype TCC generated (at line 124, column 45) for  length(seq) - 1
      % expected type  below[length(seq)]
  length_delete_TCC1: OBLIGATION
    FORALL (seq: finseq[T]):
      seq`length /= 0 IMPLIES
       length(seq) - 1 >= 0 AND length(seq) - 1 < length(seq);


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 322 0 325 999
body:
  % Subtype TCC generated (at line 143, column 25) for  add_first(x, seq)
      % expected type  not_empty_seq
  first_add_TCC1: OBLIGATION
    FORALL (seq: finseq[T], x: T): length(add_first(x, seq)) /= 0;


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 327 0 331 999
body:
  % Subtype TCC generated (at line 147, column 45) for  i
      % expected type  below[length(add_first(x, seq))]
  nth_add_first_TCC1: OBLIGATION
    FORALL (seq: finseq[T], x: T, i: below[1 + seq`length]):
      i = 0 IMPLIES i < length(add_first(x, seq));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 333 0 337 999
body:
  % Subtype TCC generated (at line 148, column 45) for  i
      % expected type  below[length(add_first(x, seq))]
  nth_add_first_TCC2: OBLIGATION
    FORALL (seq: finseq[T], x: T, i: below[1 + seq`length]):
      NOT i = 0 IMPLIES i < length(add_first(x, seq));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 339 0 343 999
body:
  % Subtype TCC generated (at line 148, column 54) for  i - 1
      % expected type  below[length(seq)]
  nth_add_first_TCC3: OBLIGATION
    FORALL (seq: finseq[T], i: below[1 + seq`length]):
      NOT i = 0 IMPLIES i - 1 >= 0 AND i - 1 < length(seq);


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 345 0 349 999
body:
  % Subtype TCC generated (at line 152, column 34) for  add_last(seq, x)
      % expected type  not_empty_seq
  first_add_last_TCC1: OBLIGATION
    FORALL (seq: finseq[T], x: T):
      seq`length /= 0 IMPLIES length(add_last(seq, x)) /= 0;


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 351 0 355 999
body:
  % Subtype TCC generated (at line 174, column 44) for  i
      % expected type  below[length(add_last(seq, x))]
  nth_add_last_TCC1: OBLIGATION
    FORALL (seq: finseq[T], x: T, i: below[1 + seq`length]):
      i = seq`length IMPLIES i < length(add_last(seq, x));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 357 0 361 999
body:
  % Subtype TCC generated (at line 175, column 44) for  i
      % expected type  below[length(add_last(seq, x))]
  nth_add_last_TCC2: OBLIGATION
    FORALL (seq: finseq[T], x: T, i: below[1 + seq`length]):
      NOT i = seq`length IMPLIES i < length(add_last(seq, x));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 363 0 367 999
body:
  % Subtype TCC generated (at line 175, column 53) for  i
      % expected type  below[length(seq)]
  nth_add_last_TCC3: OBLIGATION
    FORALL (seq: finseq[T], i: below[1 + seq`length]):
      NOT i = seq`length IMPLIES i < length(seq);


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 369 0 373 999
body:
  % Subtype TCC generated (at line 182, column 52) for  seq1 o seq2
      % expected type  not_empty_seq
  first_compo_TCC1: OBLIGATION
    FORALL (seq1, seq2: finseq[T]):
      seq1`length /= 0 IMPLIES length(o[T](seq1, seq2)) /= 0;


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 375 0 379 999
body:
  % Subtype TCC generated (at line 189, column 31) for  length(seq) - 1
      % expected type  nat
  rest_pos_TCC1: OBLIGATION
    FORALL (seq: finseq[T]):
      rest(seq)`length /= 0 IMPLIES length(seq) - 1 >= 0;


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 381 0 386 999
body:
  % Subtype TCC generated (at line 189, column 54) for  i + 1
      % expected type  below[length(seq)]
  rest_pos_TCC2: OBLIGATION
    FORALL (seq: finseq[T]):
      rest(seq)`length /= 0 IMPLIES
       (FORALL (i: below[length(seq) - 1]): i + 1 < length(seq));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 388 0 393 999
body:
  % Subtype TCC generated (at line 189, column 73) for  i
      % expected type  below[length(rest(seq))]
  rest_pos_TCC3: OBLIGATION
    FORALL (seq: finseq[T]):
      rest(seq)`length /= 0 IMPLIES
       (FORALL (i: below[length(seq) - 1]): i < length(rest(seq)));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 395 0 398 999
body:
  % Subtype TCC generated (at line 193, column 37) for  0
      % expected type  below[length(seq)]
  delete_is_empty_TCC1: OBLIGATION
    FORALL (seq: finseq[T]): seq`length = 1 IMPLIES 0 < length(seq);


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 400 0 405 999
body:
  % Subtype TCC generated (at line 197, column 43) for  i
      % expected type  below[length(seq)]
  delete_pos_TCC1: OBLIGATION
    FORALL (seq: finseq[T]):
      seq`length /= 0 IMPLIES
       (FORALL (i: below[length(seq) - 1]): i < length(seq));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 407 0 413 999
body:
  % Subtype TCC generated (at line 197, column 77) for  i
      % expected type  below[length(delete(seq, length(seq) - 1))]
  delete_pos_TCC2: OBLIGATION
    FORALL (seq: finseq[T]):
      seq`length /= 0 IMPLIES
       (FORALL (i: below[length(seq) - 1]):
          i < length(delete(seq, length(seq) - 1)));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 415 0 420 999
body:
  % Subtype TCC generated (at line 203, column 70) for  n
      % expected type  upto[length(delete(seq, n))]
  insert_delete_TCC1: OBLIGATION
    FORALL (seq: finseq[T]):
      seq`length /= 0 IMPLIES
       (FORALL (n: below[seq`length]): n <= length(delete(seq, n)));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 422 0 427 999
body:
  % Subtype TCC generated (at line 208, column 25) for  0
      % expected type  below[length(seq)]
  add_first_delete_TCC1: OBLIGATION
    FORALL (seq: finseq[T]):
      seq`length /= 0 IMPLIES
       (FORALL (n: below[seq`length]): n /= 0 IMPLIES 0 < length(seq));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 429 0 433 999
body:
  % Subtype TCC generated (at line 213, column 36) for  0
      % expected type  below[length(seq)]
  delete_rest_TCC1: OBLIGATION
    FORALL (seq: finseq[T], n: below[seq`length]):
      n = 0 IMPLIES 0 < length(seq);


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 435 0 439 999
body:
  % Subtype TCC generated (at line 215, column 42) for  n - 1
      % expected type  below[length(rest(seq))]
  delete_rest_TCC2: OBLIGATION
    FORALL (seq: finseq[T], n: below[seq`length]):
      NOT n = 0 IMPLIES n - 1 >= 0 AND n - 1 < length(rest(seq));


decl_type: tcc
theory: seq_extras
library: structures
signature: nil
location: 441 0 445 999
body:
  % Subtype TCC generated (at line 224, column 60) for  n
      % expected type  below[length(replace(x, seq, n))]
  nth_x_TCC1: OBLIGATION
    FORALL (seq: finseq[T], x: T, n: below[length(seq)]):
      n < length(replace(x, seq, n));


decl_type: function
theory: seqs
library: structures
signature: [[T, finite_sequence[T]] -> bool]
location: 9 2 10 61
body:
    in?(x: T, s: finite_sequence[T]): bool = 
                (EXISTS (ii: below(length(s))): x = seq(s)(ii))


decl_type: function
theory: seqs
library: structures
signature: [[nat, T] -> finite_sequence[T]]
location: 12 2 13 84
body:
    const_seq(n: nat,c:T): finite_sequence[T] = (# length := n,
                                                   seq := (LAMBDA (i: below(n)): c) #)


decl_type: function
theory: seqs
library: structures
signature: [T -> ne_seqs]
location: 15 2 17 26
body:
    seq1(t:T): ne_seqs = (# length := 1,
                            seq := (LAMBDA (n: below(1)): t)
                          #)


decl_type: function
theory: seqs
library: structures
signature: [[T, T] -> ne_seqs]
location: 20 2 23 27
body:
    seq2(a,b:T): ne_seqs = (# length := 2,
                            seq := (LAMBDA (n: below(2)): IF n < 1 THEN a 
                                                          ELSE b ENDIF)
                           #)


decl_type: function
theory: seqs
library: structures
signature: [finite_sequence[T] -> finite_sequence[T]]
location: 31 2 33 26
body:
    rev(fs): finite_sequence[T] = (# length := l(fs),
                             seq := (LAMBDA (i: below(l(fs))): seq(fs)(l(fs)-1-i))
                          #)


decl_type: function
theory: seqs
library: structures
signature: [[finite_sequence[T], T] -> finite_sequence[T]]
location: 36 2 41 31
body:
    add1(fs,t): finite_sequence[T] = (# length := l(fs) + 1,
                                 seq := (LAMBDA (ii: below(l(fs)+1)):
                                      IF ii < l(fs) THEN seq(fs)(ii) 
                                      ELSE t 
                                      ENDIF)
                               #)


decl_type: tcc
theory: seqs
library: structures
signature: nil
location: 49 0 51 999
body:
  % Subtype TCC generated (at line 26, column 30) for  0
      % expected type  below[seq1(t)`length]
  seq1_def_TCC1: OBLIGATION FORALL (t: T): 0 < seq1(t)`length;


decl_type: tcc
theory: seqs
library: structures
signature: nil
location: 53 0 57 999
body:
  % Subtype TCC generated (at line 32, column 69) for  fs`length - 1 - i
      % expected type  below[fs`length]
  rev_TCC1: OBLIGATION
    FORALL (fs: finite_sequence[T], i: below(fs`length)):
      fs`length - 1 - i >= 0 AND fs`length - 1 - i < fs`length;


decl_type: tcc
theory: seq2set
library: structures
signature: nil
location: 45 0 52 999
body:
  % Subtype TCC generated (at line 16, column 5) for
      % {s: T | (EXISTS (kk: below(length(fs))): finseq_appl[T](fs)(kk) = s)}
      % expected type  finite_set[T]
  seq2set_TCC1: OBLIGATION
    FORALL (fs: finite_sequence[T]):
      is_finite[T]
          ({s: T |
              EXISTS (kk: below(length(fs))): finseq_appl[T](fs)(kk) = s});


decl_type: tcc
theory: seq2set
library: structures
signature: nil
location: 54 0 56 999
body:
  % Judgement subtype TCC generated (at line 24, column 13) for  seq2set(ss)
      % expected type  (nonempty?[T])
  seq2set_TCC2: OBLIGATION FORALL (ss): nonempty?[T](seq2set(ss));


decl_type: function
theory: max_seq
library: structures
location: 50 2 52 69
signature:
  [d: [s: ne_seqs[T], ii: dom(s), abv(ii, s)] ->
          {i: subrange(d`2, d`3) |
                   FORALL j:
                     d`2 <= j AND j <= d`3 IMPLIES
                      seq(d`1)(j) <= seq(d`1)(i)}]

body:
    Imax(s, (ii: dom(s)),(jj: abv(ii,s))): 
         {i: subrange(ii,jj) | (FORALL j: ii <= j AND j <= jj 
                                       IMPLIES seq(s)(j) <= seq(s)(i))}


decl_type: function
theory: max_seq
library: structures
location: 58 2 59 58
signature:
  [s: ne_seqs[T] ->
          {t: T |
                   (FORALL (ii: dom(s)): seq(s)(ii) <= t) AND
                    (EXISTS (jj: dom(s)): seq(s)(jj) = t)}]

body:
    max(s): { t: T | (FORALL (ii: dom(s)): seq(s)(ii) <= t) AND
                      (EXISTS (jj: dom(s)): seq(s)(jj) = t)} 


decl_type: tcc
theory: max_seq
library: structures
signature: nil
location: 89 0 93 999
body:
  % Subtype TCC generated (at line 52, column 52) for  j
      % expected type  below[s`length]
  Imax_TCC1: OBLIGATION
    FORALL (s, (ii: dom(s)), (jj: abv(ii, s)), i: subrange(ii, jj), j):
      ii <= j AND j <= jj IMPLIES j < s`length;


decl_type: tcc
theory: max_seq
library: structures
signature: nil
location: 95 0 99 999
body:
  % Subtype TCC generated (at line 52, column 65) for  i
      % expected type  below[s`length]
  Imax_TCC2: OBLIGATION
    FORALL (s, (ii: dom(s)), (jj: abv(ii, s)), i: subrange(ii, jj), j):
      ii <= j AND j <= jj IMPLIES i < s`length;


decl_type: tcc
theory: max_seq
library: structures
signature: nil
location: 101 0 113 999
body:
  % Existence TCC generated (at line 50, column 2) for
      % Imax(s, (ii: dom(s)), (jj: abv(ii, s))):
      %       {i: subrange(ii, jj) |
      %                (FORALL j:
      %                   ii <= j AND j <= jj IMPLIES seq(s)(j) <= seq(s)(i))}
  Imax_TCC3: OBLIGATION
    EXISTS (x:
              [d: [s: ne_seqs[T], ii: dom(s), abv(ii, s)] ->
                 {i: subrange(d`2, d`3) |
                          FORALL j:
                            d`2 <= j AND j <= d`3 IMPLIES
                             seq(d`1)(j) <= seq(d`1)(i)}]):
      TRUE;


decl_type: tcc
theory: max_seq
library: structures
signature: nil
location: 115 0 118 999
body:
  % Subtype TCC generated (at line 54, column 59) for  ii
      % expected type  abv(ii, s)
  Imax_1_TCC1: OBLIGATION
    FORALL (s: ne_seqs[T], ii: dom(s)): ii <= ii AND ii < length(s);


decl_type: tcc
theory: max_seq
library: structures
signature: nil
location: 120 0 127 999
body:
  % Existence TCC generated (at line 56, column 2) for
      % imax(s): {i: dom(s) | (FORALL (ii: dom(s)): seq(s)(ii) <= seq(s)(i))}
  imax_TCC1: OBLIGATION
    EXISTS (x:
              [s: ne_seqs[T] ->
                 {i: dom(s) |
                          FORALL (ii: dom(s)): seq(s)(ii) <= seq(s)(i)}]):
      TRUE;


decl_type: tcc
theory: max_seq
library: structures
signature: nil
location: 129 0 140 999
body:
  % Existence TCC generated (at line 58, column 2) for
      % max(s):
      %       {t: T |
      %                (FORALL (ii: dom(s)): seq(s)(ii) <= t) AND
      %                 (EXISTS (jj: dom(s)): seq(s)(jj) = t)}
  max_TCC1: OBLIGATION
    EXISTS (x:
              [s: ne_seqs[T] ->
                 {t: T |
                          (FORALL (ii: dom(s)): seq(s)(ii) <= t) AND
                           (EXISTS (jj: dom(s)): seq(s)(jj) = t)}]):
      TRUE;


decl_type: tcc
theory: max_seq
library: structures
signature: nil
location: 142 0 145 999
body:
  % Subtype TCC generated (at line 80, column 36) for  0
      % expected type  below[s`length]
  max_seq_2_TCC1: OBLIGATION
    FORALL (s: ne_seqs[T]): length(s) = 2 IMPLIES 0 < s`length;


decl_type: tcc
theory: max_seq
library: structures
signature: nil
location: 147 0 150 999
body:
  % Subtype TCC generated (at line 80, column 49) for  1
      % expected type  below[s`length]
  max_seq_2_TCC2: OBLIGATION
    FORALL (s: ne_seqs[T]): length(s) = 2 IMPLIES 1 < s`length;


decl_type: function
theory: min_seq
library: structures
location: 50 2 52 69
signature:
  [d: [s: ne_seqs[T], ii: dom(s), abv(ii, s)] ->
          {i: subrange(d`2, d`3) |
                   FORALL j:
                     d`2 <= j AND j <= d`3 IMPLIES
                      seq(d`1)(i) <= seq(d`1)(j)}]

body:
    Imin(s, (ii: dom(s)),(jj: abv(ii,s))): 
         {i: subrange(ii,jj) | (FORALL j: ii <= j AND j <= jj 
                                       IMPLIES seq(s)(i) <= seq(s)(j))}


decl_type: function
theory: min_seq
library: structures
location: 58 2 59 58
signature:
  [s: ne_seqs[T] ->
          {t: T |
                   (FORALL (ii: dom(s)): t <= seq(s)(ii)) AND
                    (EXISTS (jj: dom(s)): seq(s)(jj) = t)}]

body:
    min(s): { t: T | (FORALL (ii: dom(s)): t <= seq(s)(ii)) AND
                      (EXISTS (jj: dom(s)): seq(s)(jj) = t)} 


decl_type: tcc
theory: min_seq
library: structures
signature: nil
location: 90 0 94 999
body:
  % Subtype TCC generated (at line 52, column 52) for  i
      % expected type  below[s`length]
  Imin_TCC1: OBLIGATION
    FORALL (s, (ii: dom(s)), (jj: abv(ii, s)), i: subrange(ii, jj), j):
      ii <= j AND j <= jj IMPLIES i < s`length;


decl_type: tcc
theory: min_seq
library: structures
signature: nil
location: 96 0 100 999
body:
  % Subtype TCC generated (at line 52, column 65) for  j
      % expected type  below[s`length]
  Imin_TCC2: OBLIGATION
    FORALL (s, (ii: dom(s)), (jj: abv(ii, s)), i: subrange(ii, jj), j):
      ii <= j AND j <= jj IMPLIES j < s`length;


decl_type: tcc
theory: min_seq
library: structures
signature: nil
location: 102 0 114 999
body:
  % Existence TCC generated (at line 50, column 2) for
      % Imin(s, (ii: dom(s)), (jj: abv(ii, s))):
      %       {i: subrange(ii, jj) |
      %                (FORALL j:
      %                   ii <= j AND j <= jj IMPLIES seq(s)(i) <= seq(s)(j))}
  Imin_TCC3: OBLIGATION
    EXISTS (x:
              [d: [s: ne_seqs[T], ii: dom(s), abv(ii, s)] ->
                 {i: subrange(d`2, d`3) |
                          FORALL j:
                            d`2 <= j AND j <= d`3 IMPLIES
                             seq(d`1)(i) <= seq(d`1)(j)}]):
      TRUE;


decl_type: tcc
theory: min_seq
library: structures
signature: nil
location: 116 0 119 999
body:
  % Subtype TCC generated (at line 54, column 63) for  ii
      % expected type  abv(ii, s)
  Imin_seq_1_TCC1: OBLIGATION
    FORALL (s: ne_seqs[T], ii: dom(s)): ii <= ii AND ii < length(s);


decl_type: tcc
theory: min_seq
library: structures
signature: nil
location: 121 0 128 999
body:
  % Existence TCC generated (at line 56, column 2) for
      % imin(s): {i: dom(s) | (FORALL (ii: dom(s)): seq(s)(i) <= seq(s)(ii))}
  imin_TCC1: OBLIGATION
    EXISTS (x:
              [s: ne_seqs[T] ->
                 {i: dom(s) |
                          FORALL (ii: dom(s)): seq(s)(i) <= seq(s)(ii)}]):
      TRUE;


decl_type: tcc
theory: min_seq
library: structures
signature: nil
location: 130 0 141 999
body:
  % Existence TCC generated (at line 58, column 2) for
      % min(s):
      %       {t: T |
      %                (FORALL (ii: dom(s)): t <= seq(s)(ii)) AND
      %                 (EXISTS (jj: dom(s)): seq(s)(jj) = t)}
  min_TCC1: OBLIGATION
    EXISTS (x:
              [s: ne_seqs[T] ->
                 {t: T |
                          (FORALL (ii: dom(s)): t <= seq(s)(ii)) AND
                           (EXISTS (jj: dom(s)): seq(s)(jj) = t)}]):
      TRUE;


decl_type: tcc
theory: min_seq
library: structures
signature: nil
location: 143 0 146 999
body:
  % Subtype TCC generated (at line 81, column 30) for  0
      % expected type  below[s`length]
  min_seq_2_TCC1: OBLIGATION
    FORALL (s: ne_seqs[T]): length(s) = 2 IMPLIES 0 < s`length;


decl_type: tcc
theory: min_seq
library: structures
signature: nil
location: 148 0 151 999
body:
  % Subtype TCC generated (at line 81, column 43) for  1
      % expected type  below[s`length]
  min_seq_2_TCC2: OBLIGATION
    FORALL (s: ne_seqs[T]): length(s) = 2 IMPLIES 1 < s`length;


decl_type: formula
theory: permutations_seq
library: structures
signature: nil
location: 41 2 42 54
body:
    perm_in?      : LEMMA permutation?(A1,A2) IMPLIES 
                               (in?(A1)(x) = in?(A2)(x))


decl_type: formula
theory: sort_seq
library: structures
signature: nil
location: 62 2 63 60
body:
    sort_seq_in   : LEMMA FORALL (ii: below(length(s))): 
                                       in?(seq(sort(s))(ii),s)


decl_type: formula
theory: sort_seq
library: structures
signature: nil
location: 91 2 92 52
body:
    isort_map_bij: LEMMA FORALL (s: {ss: finite_sequence[T]  | length(ss) > 0}):
                              bijective?(isort_map(s))


decl_type: function
theory: sort_seq
library: structures
location: 71 2 73 79
signature:
  [s: seqs ->
          {map: [below(length(s)) -> below(length(s))] |
                   bijective?(map) AND
                    (FORALL (i: below(length(s))):
                       seq(s)(i) = seq(sort(s))(map(i)))}]

body:
    sort_map(s): { map: [below(length(s)) -> below(length(s))] | 
              bijective?(map) AND
                (FORALL (i: below(length(s))): seq(s)(i) = seq(sort(s))(map(i)))}


decl_type: function
theory: sort_seq
library: structures
location: 83 2 86 79
signature:
  [s: {ss: finite_sequence[T] | length(ss) > 0} ->
          {map: [below(length(s)) -> below(length(s))] |
                   bijective?(map) AND
                    (FORALL (i: below(length(s))):
                       seq(s)(map(i)) = seq(sort(s))(i))}]

body:
    isort_map(s: {ss: finite_sequence[T]  | length(ss) > 0}):
         { map: [below(length(s)) -> below(length(s))] | 
               bijective?(map) AND
                 (FORALL (i:below(length(s))): seq(s)(map(i)) = seq(sort(s))(i))}


decl_type: tcc
theory: sort_seq
library: structures
signature: nil
location: 103 0 107 999
body:
  % Subtype TCC generated (at line 50, column 43) for  i
      % expected type  below[s`length]
  increasing?_TCC1: OBLIGATION
    FORALL (s: seqs, i, j):
      0 <= i AND i < j AND j < length(s) IMPLIES i < s`length;


decl_type: tcc
theory: sort_seq
library: structures
signature: nil
location: 109 0 116 999
body:
  % Existence TCC generated (at line 52, column 2) for
      % sort(s): {ss: seqs | permutation?[T, <=](s, ss) AND increasing?(ss)}
  sort_TCC1: OBLIGATION
    EXISTS (x:
              [s: seqs ->
                 {ss: seqs |
                          permutation?[T, <=](s, ss) AND increasing?(ss)}]):
      TRUE;


decl_type: tcc
theory: sort_seq
library: structures
signature: nil
location: 118 0 121 999
body:
  % Subtype TCC generated (at line 63, column 54) for  ii
      % expected type  below[sort(s)`length]
  sort_seq_in_TCC1: OBLIGATION
    FORALL (s: seqs, ii: below(length(s))): ii < sort(s)`length;


decl_type: tcc
theory: sort_seq
library: structures
signature: nil
location: 123 0 128 999
body:
  % Subtype TCC generated (at line 73, column 70) for  map(i)
      % expected type  below[sort(s)`length]
  sort_map_TCC1: OBLIGATION
    FORALL (s, map: [below(length(s)) -> below(length(s))]):
      bijective?(map) IMPLIES
       (FORALL (i: below(length(s))): map(i) < sort(s)`length);


decl_type: tcc
theory: sort_seq
library: structures
signature: nil
location: 130 0 144 999
body:
  % Existence TCC generated (at line 71, column 2) for
      % sort_map(s):
      %       {map: [below(length(s)) -> below(length(s))] |
      %                bijective?(map) AND
      %                 (FORALL (i: below(length(s))):
      %                    seq(s)(i) = seq(sort(s))(map(i)))}
  sort_map_TCC2: OBLIGATION
    EXISTS (x:
              [s: seqs ->
                 {map: [below(length(s)) -> below(length(s))] |
                          bijective?[below(length(s)), below(length(s))](map)
                           AND
                           (FORALL (i: below(length(s))):
                              seq(s)(i) = seq(sort(s))(map(i)))}]):
      TRUE;


decl_type: tcc
theory: sort_seq
library: structures
signature: nil
location: 146 0 149 999
body:
  % Subtype TCC generated (at line 76, column 53) for  sort_map(s)(i)
      % expected type  below[sort(s)`length]
  sort_map_def_TCC1: OBLIGATION
    FORALL (s: seqs, i: below(length(s))): sort_map(s)(i) < sort(s)`length;


decl_type: tcc
theory: sort_seq
library: structures
signature: nil
location: 151 0 165 999
body:
  % Existence TCC generated (at line 83, column 2) for
      % isort_map(s: {ss: finite_sequence[T] | length(ss) > 0}):
      %       {map: [below(length(s)) -> below(length(s))] |
      %                bijective?(map) AND
      %                 (FORALL (i: below(length(s))):
      %                    seq(s)(map(i)) = seq(sort(s))(i))}
  isort_map_TCC1: OBLIGATION
    EXISTS (x:
              [s: {ss: finite_sequence[T] | length(ss) > 0} ->
                 {map: [below(length(s)) -> below(length(s))] |
                          bijective?[below(length(s)), below(length(s))](map)
                           AND
                           (FORALL (i: below(length(s))):
                              seq(s)(map(i)) = seq(sort(s))(i))}]):
      TRUE;


decl_type: tcc
theory: sort_seq
library: structures
signature: nil
location: 167 0 170 999
body:
  % Subtype TCC generated (at line 89, column 46) for  s
      % expected type  s: {ss: finite_sequence[T] | length(ss) > 0}
  isort_map_def_TCC1: OBLIGATION
    FORALL (s: seqs, i: below(length(s))): length(s) > 0;


decl_type: tcc
theory: sort_seq_lems
library: structures
signature: nil
location: 21 0 24 999
body:
  % Subtype TCC generated (at line 11, column 36) for  0
      % expected type  below[sort(s)`length]
  sort_seq_min_TCC1: OBLIGATION
    FORALL (s: ne_seqs[T]): 0 < sort[T, <=](s)`length;


decl_type: tcc
theory: sort_seq_lems
library: structures
signature: nil
location: 26 0 30 999
body:
  % Subtype TCC generated (at line 13, column 36) for  length(s) - 1
      % expected type  below[sort(s)`length]
  sort_seq_max_TCC1: OBLIGATION
    FORALL (s: ne_seqs[T]):
      length(s) - 1 >= 0 AND length(s) - 1 < sort[T, <=](s)`length;


decl_type: tcc
theory: minmax_seq2set
library: structures
signature: nil
location: -22 0 -19 999
body:
  % Subtype TCC generated (at line 37, column 35) for  seq2set(ne_fs)
      % expected type  SS: non_empty_finite_set[T]
  minmax_seq2set_TCC1: OBLIGATION
    FORALL (ne_fs: ne_seqs[T]): NOT empty?[T](seq2set[T](ne_fs));


decl_type: tcc
theory: minmax_set2seq
library: structures
signature: nil
location: -39 0 -36 999
body:
  % Subtype TCC generated (at line 55, column 31) for  set2seq(S)
      % expected type  s: ne_seqs[T]
  minmax_set2seq_TCC1: OBLIGATION
    FORALL (S: finite_set[T]): card(S) > 0 IMPLIES length(set2seq[T](S)) > 0;


decl_type: tcc
theory: minmax_set2seq
library: structures
signature: nil
location: -34 0 -31 999
body:
  % Subtype TCC generated (at line 55, column 56) for  S
      % expected type  SS: non_empty_finite_set[T]
  minmax_set2seq_TCC2: OBLIGATION
    FORALL (S: finite_set[T]): card(S) > 0 IMPLIES NOT empty?[T](S);


decl_type: formula
theory: sort_inversions
library: structures
signature: nil
location: 46 2 49 58
body:
    inversions_transpose: LEMMA
      j < N-1 & NOT A(j) <= A(j+1) =>
        inversions(A o transpose(j,j+1)) =
          ap(transpose(j,j+1),remove((j,j+1),inversions(A)))


decl_type: formula
theory: sort_inversions
library: structures
signature: nil
location: 57 2 59 70
body:
    card_inversions_transpose: THEOREM
      j < N-1 & NOT A(j) <= A(j+1) =>
        card(inversions(A)) = 1 + card(inversions(A o transpose(j,j+1)))


decl_type: formula
theory: sort_inversions
library: structures
signature: nil
location: 66 2 68 44
body:
    successive_inversion_lem: LEMMA
      (EXISTS i: i < i+d & i+d < N & NOT A(i) <= A(i+d)) =>
      (EXISTS j: j < N-1 & NOT A(j) <= A(j+1))


decl_type: tcc
theory: sort_inversions
library: structures
signature: nil
location: 78 0 83 999
body:
  % Subtype TCC generated (at line 31, column 4) for
      % {i, j | i < j & NOT A(i) <= A(j)}
      % expected type  finite_set[index_pair]
  inversions_TCC1: OBLIGATION
    FORALL (A: [below(N) -> T]):
      is_finite[index_pair]({i, j | i < j & NOT A(i) <= A(j)});


decl_type: tcc
theory: sort_inversions
library: structures
signature: nil
location: 85 0 90 999
body:
  % Subtype TCC generated (at line 40, column 39) for
      % LAMBDA (i, j): inv(pi(i), pi(j))
      % expected type  finite_set[index_pair]
  ap_TCC1: OBLIGATION
    FORALL (pi: permutation[N], inv: finite_set[index_pair]):
      is_finite[index_pair](LAMBDA (i, j): inv(pi(i), pi(j)));


decl_type: tcc
theory: sort_inversions
library: structures
signature: nil
location: 92 0 95 999
body:
  % Subtype TCC generated (at line 47, column 28) for  j + 1
      % expected type  below(N)
  inversions_transpose_TCC1: OBLIGATION
    FORALL (j: below(N)): j < N - 1 IMPLIES j + 1 < N;


decl_type: formula
theory: bubblesort
library: structures
signature: nil
location: 16 2 18 60
body:
    epsilon_lem  : LEMMA NOT sorted?(A) &
                         (j = epsilon! j: j < N - 1 & NOT A(j) <= A(j+1)) =>
                                j < N - 1 & NOT A(j) <= A(j+1)


decl_type: function
theory: bubblesort
library: structures
signature: [[below(N) -> T] -> [below(N) -> T]]
location: 20 2 26 46
body:
    bubblesort(A): RECURSIVE [below(N) -> T] =
                        IF sorted?(A) THEN A
                        ELSE
                          LET j = epsilon! j: j < N-1 & NOT A(j) <= A(j+1) IN
                          bubblesort(A o transpose(j,j+1))
                        ENDIF
                     MEASURE card(inversions(A))


decl_type: tcc
theory: bubblesort
library: structures
signature: nil
location: 35 0 39 999
body:
  % Subtype TCC generated (at line 17, column 66) for  j + 1
      % expected type  below(N)
  epsilon_lem_TCC1: OBLIGATION
    FORALL (A: [below(N) -> T]):
      NOT sorted?(A) IMPLIES (FORALL (j): j < N - 1 IMPLIES j + 1 < N);


decl_type: tcc
theory: bubblesort
library: structures
signature: nil
location: 41 0 44 999
body:
  % Existence TCC generated (at line 17, column 28) for  epsilon
  epsilon_lem_TCC2: OBLIGATION
    FORALL (A: [below(N) -> T]):
      NOT sorted?(A) IMPLIES (EXISTS (x: below(N)): TRUE);


decl_type: tcc
theory: bubblesort
library: structures
signature: nil
location: 46 0 54 999
body:
  % Subtype TCC generated (at line 24, column 51) for  j + 1
      % expected type  below(N)
  bubblesort_TCC1: OBLIGATION
    FORALL (A: [below(N) -> T]):
      NOT sorted?(A) IMPLIES
       (FORALL (j: below(N)):
          j =
           epsilon! (j_1: below(N)): j_1 < N - 1 & NOT A(j_1) <= A(j_1 + 1)
           IMPLIES j + 1 < N);


decl_type: tcc
theory: bubblesort
library: structures
signature: nil
location: 56 0 68 999
body:
  % Termination TCC generated (at line 24, column 24) for
      % bubblesort(A o transpose(j, j + 1))
  bubblesort_TCC2: OBLIGATION
    FORALL (A: [below(N) -> T]):
      NOT sorted?(A) IMPLIES
       (FORALL (j: below(N)):
          j =
           epsilon! (j_1: below(N)): j_1 < N - 1 & NOT A(j_1) <= A(j_1 + 1)
           IMPLIES
           card[index_pair[N, T, <=]]
               (inversions[N, T, <=]
                    (o[below(N), below(N), T](A, transpose[N](j, j + 1))))
            < card[index_pair[N, T, <=]](inversions[N, T, <=](A)));


decl_type: formula
theory: majority_seq
library: structures
signature: nil
location: 83 2 84 50
body:
    maj_const:         LEMMA maj_exists(const_seq(n,c)) AND
                             maj(const_seq(n,c)) = c


decl_type: tcc
theory: majority_seq
library: structures
signature: nil
location: 91 0 96 999
body:
  % Subtype TCC generated (at line 47, column 14) for
      % {i: below(length(fs)) | seq(fs)(i) = mv}
      % expected type  S: finite_set[below(length(fs))]
  is_majority_TCC1: OBLIGATION
    FORALL (mv: T, fs: finite_sequence[T]):
      is_finite[below(length(fs))]({i: below(length(fs)) | seq(fs)(i) = mv});


decl_type: tcc
theory: majority_seq
library: structures
signature: nil
location: 98 0 104 999
body:
  % Existence TCC generated (at line 51, column 2) for
      % maj(fs): {mv | maj_exists(fs) => is_majority(mv, fs)}
  maj_TCC1: OBLIGATION
    EXISTS (x:
              [fs: finite_sequence[T] ->
                 {mv | maj_exists(fs) => is_majority(mv, fs)}]):
      TRUE;


decl_type: formula
theory: majority_array
library: structures
signature: nil
location: 44 2 45 45
body:
    is_majority_unique: LEMMA is_majority(mv1,A) AND is_majority(mv2,A)
                              IMPLIES mv1 = mv2


decl_type: formula
theory: majority_array
library: structures
signature: nil
location: 47 2 48 57
body:
    maj_lem:            LEMMA is_majority(mv,A) IFF 
                              maj_exists(A) AND maj(A) = mv


decl_type: formula
theory: majority_array
library: structures
signature: nil
location: 50 2 53 53
body:
    maj_subset:         LEMMA   (EXISTS (IDS: finite_set[below(N)]):
                                     2*card(IDS) > N
                                 AND (FORALL ii: IDS(ii) IMPLIES A(ii) = mv))
                              IMPLIES is_majority(mv,A)


decl_type: formula
theory: majority_array
library: structures
signature: nil
location: 55 2 56 54
body:
    maj_in_array:       LEMMA is_majority(mv,A) IMPLIES 
                                 (EXISTS ii: A(ii) = mv)


decl_type: formula
theory: majority_array
library: structures
signature: nil
location: 64 2 65 53
body:
    maj_const:         LEMMA maj_exists(constant_array(c)) AND
                             maj(constant_array(c)) = c


decl_type: tcc
theory: majority_array
library: structures
signature: nil
location: 72 0 76 999
body:
  % Subtype TCC generated (at line 38, column 36) for  {ii | A(ii) = mv}
      % expected type  S: finite_set[below[N]]
  is_majority_TCC1: OBLIGATION
    FORALL (mv: T, A: [below[N] -> T]):
      is_finite[below[N]]({ii | A(ii) = mv});


decl_type: tcc
theory: majority_array
library: structures
signature: nil
location: 78 0 84 999
body:
  % Existence TCC generated (at line 42, column 2) for
      % maj(A): {mv | maj_exists(A) => is_majority(mv, A)}
  maj_TCC1: OBLIGATION
    EXISTS (x:
              [A: [below[N] -> T] ->
                 {mv | maj_exists(A) => is_majority(mv, A)}]):
      TRUE;


decl_type: function
theory: concat_arrays
library: structures
signature:
  [[below_array[n, T], below_array[m, T]] ->
  below_array[m + n, T]]

location: 16 2 18 55
body:
    o(a_n, a_m): below_array[n+m,T] = (LAMBDA nm: IF nm < n THEN a_n(nm)
                                                   ELSE a_m(nm - n)
                                                   ENDIF)


decl_type: tcc
theory: concat_arrays
library: structures
signature: nil
location: 36 0 40 999
body:
  % Subtype TCC generated (at line 17, column 58) for  nm - n
      % expected type  below(m)
  oh_TCC1: OBLIGATION
    FORALL (a_n: below_array[n, T], a_m: below_array[m, T], nm):
      NOT nm < n IMPLIES nm - n >= 0 AND nm - n < m;


decl_type: tcc
theory: concat_arrays
library: structures
signature: nil
location: 42 0 45 999
body:
  % Subtype TCC generated (at line 23, column 55) for  a_n
      % expected type  below_array[n + m, T]
  concat_array_bot0_TCC1: OBLIGATION
    m = 0 IMPLIES (FORALL (x: nat): x < n IFF x < m + n);


decl_type: tcc
theory: concat_arrays
library: structures
signature: nil
location: 47 0 50 999
body:
  % Subtype TCC generated (at line 25, column 55) for  a_m
      % expected type  below_array[n + m, T]
  concat_array_top0_TCC1: OBLIGATION
    n = 0 IMPLIES (FORALL (x: nat): x < m IFF x < m + n);


decl_type: tcc
theory: concat_arrays
library: structures
signature: nil
location: 52 0 54 999
body:
  % Subtype TCC generated (at line 27, column 41) for  i
      % expected type  below(n + m)
  concat_array_bot_TCC1: OBLIGATION FORALL (i: below(n)): i < m + n;


decl_type: tcc
theory: concat_arrays
library: structures
signature: nil
location: 56 0 59 999
body:
  % Subtype TCC generated (at line 29, column 41) for  j
      % expected type  below(n + m)
  concat_array_top_TCC1: OBLIGATION
    FORALL (j: {i: int | i >= n AND i < m + n}): j >= 0 AND j < m + n;


decl_type: tcc
theory: concat_arrays
library: structures
signature: nil
location: 61 0 64 999
body:
  % Subtype TCC generated (at line 29, column 50) for  j - n
      % expected type  below(m)
  concat_array_top_TCC2: OBLIGATION
    FORALL (j: {i: int | i >= n AND i < m + n}): j - n >= 0 AND j - n < m;


decl_type: tcc
theory: empty_array_def
library: structures
signature: nil
location: 14 0 16 999
body:
  % Existence TCC generated (at line 7, column 2) for
      % empty_array: below_array[0, T]
  empty_array_TCC1: OBLIGATION EXISTS (x: below_array[0, T]): TRUE;


decl_type: formula
theory: caret_arrays
library: structures
signature: nil
location: 28 2 29 63
body:
    caret_elim: LEMMA i <= j AND k < i - j + 1
                                IMPLIES  (A ^ (i, j))(k) = A(j+k)


decl_type: function
theory: caret_arrays
library: structures
location: 13 2 19 13
signature:
  [d: [below_array[N, T], [nat, below[N]]] ->
          below_array
              [IF d`2`1 > d`2`2 THEN 0 ELSE 1 - d`2`1 + d`2`2 ENDIF,
               T]]

body:
    ^(A, p): below_array[LET (m, n) = p IN
                            IF m > n THEN 0
                            ELSE n - m + 1 ENDIF,T] =
        LET (m, n) = p IN
          IF m <= n THEN (LAMBDA (x: below[n-m+1]): A(x + m))
          ELSE empty_array 
          ENDIF


decl_type: tcc
theory: caret_arrays
library: structures
signature: nil
location: 39 0 42 999
body:
  % Subtype TCC generated (at line 13, column 11) for
      % below_array[LET (m, n) = p IN IF m > n THEN 0 ELSE n - m + 1 ENDIF, T]
      % expected type  nat
  caret_TCC1: OBLIGATION FORALL (p): NOT p`1 > p`2 IMPLIES 1 - p`1 + p`2 >= 0;


decl_type: tcc
theory: caret_arrays
library: structures
signature: nil
location: 44 0 48 999
body:
  % Subtype TCC generated (at line 17, column 45) for  1 + n - m
      % expected type  nat
  caret_TCC2: OBLIGATION
    FORALL (A: below_array[N, T], p: [nat, below[N]], m: nat, n: below[N]):
      m <= n AND n = p`2 AND m = p`1 IMPLIES 1 + n - m >= 0;


decl_type: tcc
theory: caret_arrays
library: structures
signature: nil
location: 50 0 55 999
body:
  % Subtype TCC generated (at line 17, column 52) for  x + m
      % expected type  below(N)
  caret_TCC3: OBLIGATION
    FORALL (A: below_array[N, T], p: [nat, below[N]], m: nat, n: below[N]):
      m <= n AND n = p`2 AND m = p`1 IMPLIES
       (FORALL (x: below[n - m + 1]): n = p`2 AND m = p`1 IMPLIES x + m < N);


decl_type: tcc
theory: caret_arrays
library: structures
signature: nil
location: 57 0 67 999
body:
  % Subtype TCC generated (at line 17, column 24) for
      % (LAMBDA (x: below[n - m + 1]): A(x + m))
      % expected type  below_array
                     %     [LET (m, n) = p IN
                     %        IF m > n THEN 0 ELSE n - m + 1 ENDIF,
                     %      T]
  caret_TCC4: OBLIGATION
    FORALL (A: below_array[N, T], p: [nat, below[N]], m: nat, n: below[N]):
      m <= n AND n = p`2 AND m = p`1 IMPLIES
       (FORALL (x: nat):
          x < 1 + n - m IFF x < IF p`1 > p`2 THEN 0 ELSE 1 - p`1 + p`2 ENDIF);


decl_type: tcc
theory: caret_arrays
library: structures
signature: nil
location: 69 0 78 999
body:
  % Subtype TCC generated (at line 18, column 13) for  empty_array
      % expected type  below_array
                     %     [LET (m, n) = p IN
                     %        IF m > n THEN 0 ELSE n - m + 1 ENDIF,
                     %      T]
  caret_TCC5: OBLIGATION
    FORALL (A: below_array[N, T], p: [nat, below[N]], m: nat, n: below[N]):
      NOT m <= n AND n = p`2 AND m = p`1 IMPLIES
       (FORALL (x: nat):
          NOT x < IF p`1 > p`2 THEN 0 ELSE 1 - p`1 + p`2 ENDIF);


decl_type: tcc
theory: caret_arrays
library: structures
signature: nil
location: 80 0 82 999
body:
  % Subtype TCC generated (at line 24, column 39) for  N - 1
      % expected type  below[N]
  caret_all_TCC1: OBLIGATION N > 0 IMPLIES N - 1 >= 0 AND N - 1 < N;


decl_type: tcc
theory: caret_arrays
library: structures
signature: nil
location: 84 0 88 999
body:
  % Subtype TCC generated (at line 24, column 46) for  A
      % expected type  below_array[IF 0 > N - 1 THEN 0 ELSE N ENDIF, T]
  caret_all_TCC2: OBLIGATION
    N > 0 IMPLIES
     (FORALL (x: nat): x < N IFF x < IF 0 > N - 1 THEN 0 ELSE N ENDIF);


decl_type: tcc
theory: caret_arrays
library: structures
signature: nil
location: 90 0 95 999
body:
  % Subtype TCC generated (at line 29, column 52) for  k
      % expected type  below(IF i > j THEN 0 ELSE 1 + j - i ENDIF)
  caret_elim_TCC1: OBLIGATION
    FORALL (i, j, k: below(N)):
      k < i - j + 1 AND i <= j IMPLIES
       k < IF i > j THEN 0 ELSE 1 + j - i ENDIF;


decl_type: tcc
theory: caret_arrays
library: structures
signature: nil
location: 97 0 100 999
body:
  % Subtype TCC generated (at line 29, column 59) for  j + k
      % expected type  below(N)
  caret_elim_TCC2: OBLIGATION
    FORALL (i, j, k: below(N)): k < i - j + 1 AND i <= j IMPLIES j + k < N;


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 13 2 14 55
body:
    caret_fill0      : LEMMA FORALL (j: below(n)):
                                i <= j IMPLIES fill(n,t)^(i,j) = fill(j-i+1,t)


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 16 2 17 55
body:
    caret_fill1      : LEMMA FORALL (j: below(n)):
                                i <= j IMPLIES fill(n,t)^(i,j) = fill(j-i+1,t)


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 19 2 20 54
body:
    caret_concat_bot : LEMMA FORALL (j: below(n), A_n: barr(n), B_m: barr(m)):
                                  j < n IMPLIES (A_n o B_m)^(i,j) = A_n^(i,j)


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 22 2 24 48
body:
    caret_concat_top : LEMMA FORALL (A_n: barr(n), B_m: barr(m)):
                                  i >= n AND j >= n AND j < n + m
                                    IMPLIES (A_n o B_m)^(i,j) = B_m^(i-n, j-n)


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 26 2 28 49
body:
    caret_concat_all : LEMMA FORALL (j: below(n), A_n: barr(n), B_m: barr(m)):
                          i <= n AND n <= j IMPLIES 
                                  (A_n o B_m)^(i,j) = A_n^(0,i-n) o B_m^(j,n-1) 


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 30 2 31 72
body:
    array_decomp     : LEMMA FORALL (n: posnat, k: below(n-1), A_n:barr(n)): 
                                       (A_n^(0,k)) o (A_n^(k+1,n-1)) = A_n


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 34 2 35 63
body:
    caret_bot_all    : LEMMA FORALL (n: posnat, A_n: barr(n), B_m: barr(m)):
                                        (A_n o B_m)^(0,n-1) = A_n


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 37 2 38 74
body:
    caret_top_all    : LEMMA FORALL (A_n: barr(n), B_m: barr(m)):
                                 n+m > 0 IMPLIES (A_n o B_m)^(n,n+m-1) = B_m


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 44 2 47 67
body:
    concat_array_bot  : THEOREM (FORALL (i: below(m),
                                           a_m:below_array[m,T],
                                           a_n:below_array[n,T]):
                                             (a_m o a_n)(i) = a_m(i))


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 49 2 52 69
body:
    concat_array_top  : THEOREM (FORALL (j: {i: int | i >= m AND i < n+m},
                                          a_m:below_array[m,T],
                                          a_n:below_array[n,T]):
                                             (a_m o a_n)(j) = a_n(j-m))


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 54 2 55 70
body:
    concat_array_r    : THEOREM (FORALL (a_n:below_array[n,T]): 
                                             a_n o empty_array[T] = a_n)


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 57 2 58 70
body:
    concat_array_l    : THEOREM (FORALL (a_n:below_array[n,T]):
                                             empty_array[T] o a_n = a_n)


decl_type: formula
theory: array_ops
library: structures
signature: nil
location: 61 2 64 81
body:
    concat_array_assoc: THEOREM (FORALL (a_m:below_array[m,T]),
                                         (a_n:below_array[n,T]),
                                         (a_j:below_array[j,T]):
                                             a_m o (a_n o a_j) = (a_m o a_n) o a_j)


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 73 0 76 999
body:
  % Subtype TCC generated (at line 14, column 47) for  j - i + 1
      % expected type  nat
  caret_fill0_TCC1: OBLIGATION
    FORALL (i, n: nat, j: below(n)): i <= j IMPLIES j - i + 1 >= 0;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 78 0 84 999
body:
  % Subtype TCC generated (at line 14, column 42) for  fill(j - i + 1, t)
      % expected type  below_array[IF i > j THEN 0 ELSE 1 + j - i ENDIF, T]
  caret_fill0_TCC2: OBLIGATION
    FORALL (i, n: nat, j: below(n)):
      i <= j IMPLIES
       (FORALL (x: nat):
          x < 1 + j - i IFF x < IF i > j THEN 0 ELSE 1 + j - i ENDIF);


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 86 0 90 999
body:
  % Subtype TCC generated (at line 20, column 40) for  j
      % expected type  below[m + n]
  caret_concat_bot_TCC1: OBLIGATION
    FORALL (m, n: nat, j: below(n), A_n: barr(n), B_m: barr(m)):
      j < n IMPLIES j < m + n;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 92 0 96 999
body:
  % Subtype TCC generated (at line 24, column 29) for  j
      % expected type  below[m + n]
  caret_concat_top_TCC1: OBLIGATION
    FORALL (i, j, m, n: nat, A_n: barr(n), B_m: barr(m)):
      i >= n AND j >= n AND j < n + m IMPLIES j < m + n;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 98 0 102 999
body:
  % Subtype TCC generated (at line 24, column 39) for  i - n
      % expected type  nat
  caret_concat_top_TCC2: OBLIGATION
    FORALL (i, j, m, n: nat, A_n: barr(n), B_m: barr(m)):
      i >= n AND j >= n AND j < n + m IMPLIES i - n >= 0;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 104 0 108 999
body:
  % Subtype TCC generated (at line 24, column 44) for  j - n
      % expected type  below[m]
  caret_concat_top_TCC3: OBLIGATION
    FORALL (i, j, m, n: nat, A_n: barr(n), B_m: barr(m)):
      i >= n AND j >= n AND j < n + m IMPLIES j - n >= 0 AND j - n < m;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 110 0 117 999
body:
  % Subtype TCC generated (at line 24, column 34) for  B_m ^ (i - n, j - n)
      % expected type  below_array[IF i > j THEN 0 ELSE 1 + j - i ENDIF, T]
  caret_concat_top_TCC4: OBLIGATION
    FORALL (i, j, m, n: nat, A_n: barr(n), B_m: barr(m)):
      i >= n AND j >= n AND j < n + m IMPLIES
       (FORALL (x: nat):
          x < IF i - n > j - n THEN 0 ELSE 1 + j - i ENDIF IFF
           x < IF i > j THEN 0 ELSE 1 + j - i ENDIF);


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 119 0 123 999
body:
  % Subtype TCC generated (at line 28, column 19) for  j
      % expected type  below[m + n]
  caret_concat_all_TCC1: OBLIGATION
    FORALL (i, m, n: nat, j: below(n), A_n: barr(n), B_m: barr(m)):
      i <= n AND n <= j IMPLIES j < m + n;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 125 0 129 999
body:
  % Subtype TCC generated (at line 28, column 31) for  i - n
      % expected type  below[n]
  caret_concat_all_TCC2: OBLIGATION
    FORALL (i, m, n: nat, j: below(n), A_n: barr(n), B_m: barr(m)):
      i <= n AND n <= j IMPLIES i - n >= 0 AND i - n < n;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 131 0 135 999
body:
  % Subtype TCC generated (at line 28, column 45) for  n - 1
      % expected type  below[m]
  caret_concat_all_TCC3: OBLIGATION
    FORALL (i, m, n: nat, j: below(n), A_n: barr(n), B_m: barr(m)):
      i <= n AND n <= j IMPLIES n - 1 >= 0 AND n - 1 < m;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 137 0 141 999
body:
  % Subtype TCC generated (at line 89, column 18) for  1 + i - n
      % expected type  nat
  caret_concat_all_TCC4: OBLIGATION
    FORALL (i, m, n: nat, j: below(n), A_n: barr(n), B_m: barr(m)):
      NOT 0 > i - n AND i <= n AND n <= j IMPLIES 1 + i - n >= 0;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 143 0 147 999
body:
  % Subtype TCC generated (at line 28, column 45) for  n - j
      % expected type  nat
  caret_concat_all_TCC5: OBLIGATION
    FORALL (i, m, n: nat, j: below(n), A_n: barr(n), B_m: barr(m)):
      NOT j > n - 1 AND i <= n AND n <= j IMPLIES n - j >= 0;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 149 0 159 999
body:
  % Subtype TCC generated (at line 28, column 24) for
      % A_n ^ (0, i - n) o B_m ^ (j, n - 1)
      % expected type  below_array[IF i > j THEN 0 ELSE 1 + j - i ENDIF, T]
  caret_concat_all_TCC6: OBLIGATION
    FORALL (i, m, n: nat, j: below(n), A_n: barr(n), B_m: barr(m)):
      i <= n AND n <= j IMPLIES
       (FORALL (x: nat):
          x <
           IF j > n - 1 THEN 0 ELSE n - j ENDIF +
            IF 0 > i - n THEN 0 ELSE 1 + i - n ENDIF
           IFF x < IF i > j THEN 0 ELSE 1 + j - i ENDIF);


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 161 0 164 999
body:
  % Subtype TCC generated (at line 31, column 45) for  k
      % expected type  below[n]
  array_decomp_TCC1: OBLIGATION
    FORALL (n: posnat, k: below(n - 1), A_n: barr(n)): k < n;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 166 0 170 999
body:
  % Subtype TCC generated (at line 31, column 61) for  n - 1
      % expected type  below[n]
  array_decomp_TCC2: OBLIGATION
    FORALL (n: posnat, k: below(n - 1), A_n: barr(n)):
      n - 1 >= 0 AND n - 1 < n;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 172 0 176 999
body:
  % Subtype TCC generated (at line 31, column 61) for  n - 1 - k
      % expected type  nat
  array_decomp_TCC3: OBLIGATION
    FORALL (n: posnat, k: below(n - 1), A_n: barr(n)):
      NOT 1 + k > n - 1 IMPLIES n - 1 - k >= 0;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 178 0 189 999
body:
  % Subtype TCC generated (at line 31, column 69) for  A_n
      % expected type  below_array
                     %     [IF 1 + k > n - 1 THEN 0 ELSE n - 1 - k ENDIF +
                     %       IF 0 > k THEN 0 ELSE 1 + k ENDIF,
                     %      T]
  array_decomp_TCC4: OBLIGATION
    FORALL (n: posnat, k: below(n - 1), A_n: barr(n)):
      FORALL (x: nat):
        x < n IFF
         x <
          IF 1 + k > n - 1 THEN 0 ELSE n - 1 - k ENDIF +
           IF 0 > k THEN 0 ELSE 1 + k ENDIF;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 191 0 195 999
body:
  % Subtype TCC generated (at line 35, column 53) for  n - 1
      % expected type  below[n + m]
  caret_bot_all_TCC1: OBLIGATION
    FORALL (m: nat, n: posnat, A_n: barr(n), B_m: barr(m)):
      n - 1 >= 0 AND n - 1 < n + m;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 197 0 201 999
body:
  % Subtype TCC generated (at line 35, column 60) for  A_n
      % expected type  below_array[IF 0 > n - 1 THEN 0 ELSE n ENDIF, T]
  caret_bot_all_TCC2: OBLIGATION
    FORALL (m: nat, n: posnat, A_n: barr(n), B_m: barr(m)):
      FORALL (x: nat): x < n IFF x < IF 0 > n - 1 THEN 0 ELSE n ENDIF;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 203 0 207 999
body:
  % Subtype TCC generated (at line 38, column 62) for  n + m - 1
      % expected type  below[m + n]
  caret_top_all_TCC1: OBLIGATION
    FORALL (m, n: nat, A_n: barr(n), B_m: barr(m)):
      n + m > 0 IMPLIES n + m - 1 >= 0 AND n + m - 1 < m + n;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 209 0 214 999
body:
  % Subtype TCC generated (at line 38, column 71) for  B_m
      % expected type  below_array[IF n > m + n - 1 THEN 0 ELSE m ENDIF, T]
  caret_top_all_TCC2: OBLIGATION
    FORALL (m, n: nat, A_n: barr(n), B_m: barr(m)):
      n + m > 0 IMPLIES
       (FORALL (x: nat): x < m IFF x < IF n > m + n - 1 THEN 0 ELSE m ENDIF);


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 216 0 221 999
body:
  % Subtype TCC generated (at line 47, column 55) for  i
      % expected type  below(m + n)
  concat_array_bot_TCC1: OBLIGATION
    FORALL (m, n: nat, i: below(m), a_m: below_array[m, T],
            a_n: below_array[n, T]):
      i < m + n;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 223 0 228 999
body:
  % Subtype TCC generated (at line 52, column 55) for  j
      % expected type  below(m + n)
  concat_array_top_TCC1: OBLIGATION
    FORALL (m, n: nat, j: {i: int | i >= m AND i < m + n},
            a_m: below_array[m, T], a_n: below_array[n, T]):
      j >= 0 AND j < m + n;


decl_type: tcc
theory: array_ops
library: structures
signature: nil
location: 230 0 235 999
body:
  % Subtype TCC generated (at line 52, column 64) for  j - m
      % expected type  below(n)
  concat_array_top_TCC2: OBLIGATION
    FORALL (m, n: nat, j: {i: int | i >= m AND i < m + n},
            a_m: below_array[m, T], a_n: below_array[n, T]):
      j - m >= 0 AND j - m < n;


decl_type: formula
theory: max_array
library: structures
signature: nil
location: 64 2 65 58
body:
    max_2     : LEMMA N = 2 IMPLIES max(A) = IF A(0) <= A(1) THEN A(1)
                                             ELSE A(0) ENDIF


decl_type: tcc
theory: max_array
library: structures
signature: nil
location: 72 0 78 999
body:
  % Existence TCC generated (at line 44, column 2) for
      % imax(A): {i: below(N) | (FORALL ii: A(ii) <= A(i))}
  imax_TCC1: OBLIGATION
    EXISTS (x:
              [A: [below(N) -> T] ->
                 {i: below(N) | FORALL ii: A(ii) <= A(i)}]):
      TRUE;


decl_type: tcc
theory: max_array
library: structures
signature: nil
location: 80 0 88 999
body:
  % Existence TCC generated (at line 46, column 2) for
      % max(A): {t: T | (FORALL ii: A(ii) <= t) AND (EXISTS jj: A(jj) = t)}
  max_TCC1: OBLIGATION
    EXISTS (x:
              [A: [below(N) -> T] ->
                 {t: T |
                          (FORALL ii: A(ii) <= t) AND
                           (EXISTS jj: A(jj) = t)}]):
      TRUE;


decl_type: tcc
theory: max_array
library: structures
signature: nil
location: 90 0 92 999
body:
  % Subtype TCC generated (at line 64, column 48) for  0
      % expected type  below(N)
  max_2_TCC1: OBLIGATION N = 2 IMPLIES 0 < N;


decl_type: tcc
theory: max_array
library: structures
signature: nil
location: 94 0 96 999
body:
  % Subtype TCC generated (at line 64, column 56) for  1
      % expected type  below(N)
  max_2_TCC2: OBLIGATION N = 2 IMPLIES 1 < N;


decl_type: formula
theory: min_array
library: structures
signature: nil
location: 62 2 63 58
body:
    min_2     : LEMMA N = 2 IMPLIES min(A) = IF A(0) <= A(1) THEN A(0)
                                             ELSE A(1) ENDIF


decl_type: tcc
theory: min_array
library: structures
signature: nil
location: 70 0 76 999
body:
  % Existence TCC generated (at line 42, column 2) for
      % imin(A): {i: below(N) | (FORALL ii: A(i) <= A(ii))}
  imin_TCC1: OBLIGATION
    EXISTS (x:
              [A: [below(N) -> T] ->
                 {i: below(N) | FORALL ii: A(i) <= A(ii)}]):
      TRUE;


decl_type: tcc
theory: min_array
library: structures
signature: nil
location: 78 0 86 999
body:
  % Existence TCC generated (at line 44, column 2) for
      % min(A): {t: T | (FORALL ii: t <= A(ii)) AND (EXISTS jj: A(jj) = t)}
  min_TCC1: OBLIGATION
    EXISTS (x:
              [A: [below(N) -> T] ->
                 {t: T |
                          (FORALL ii: t <= A(ii)) AND
                           (EXISTS jj: A(jj) = t)}]):
      TRUE;


decl_type: tcc
theory: min_array
library: structures
signature: nil
location: 88 0 90 999
body:
  % Subtype TCC generated (at line 62, column 48) for  0
      % expected type  below(N)
  min_2_TCC1: OBLIGATION N = 2 IMPLIES 0 < N;


decl_type: tcc
theory: min_array
library: structures
signature: nil
location: 92 0 94 999
body:
  % Subtype TCC generated (at line 62, column 56) for  1
      % expected type  below(N)
  min_2_TCC2: OBLIGATION N = 2 IMPLIES 1 < N;


decl_type: tcc
theory: sort_array_lems
library: structures
signature: nil
location: 22 0 24 999
body:
  % Subtype TCC generated (at line 12, column 27) for  0
      % expected type  below(N)
  sort_min_TCC1: OBLIGATION 0 < N;


decl_type: tcc
theory: sort_array_lems
library: structures
signature: nil
location: 26 0 28 999
body:
  % Subtype TCC generated (at line 14, column 27) for  N - 1
      % expected type  below(N)
  sort_max_TCC1: OBLIGATION N - 1 >= 0 AND N - 1 < N;


decl_type: formula
theory: function_props_aux
library: structures
signature: nil
location: 14 2 15 70
body:
    inverse_image_composition: LEMMA
      inverse_image(f1, inverse_image(f2,Y)) = inverse_image(f2 o f1, Y)


decl_type: formula
theory: function_props_aux
library: structures
signature: nil
location: 18 2 21 77
body:
    composition_inverse_alt: LEMMA FORALL (f1:(bijective?[T1,T2]),
                                           f2:(bijective?[T2,T3])):
                                   inverse_alt(f2 o f1)
                                            = inverse_alt(f1) o inverse_alt(f2)


decl_type: tcc
theory: function_props_aux
library: structures
signature: nil
location: 28 0 33 999
body:
  % Assuming TCC generated (at line 1370, column 3) for
      % function_inverse_alt[T1, T3]
      % generated from assumption function_inverse_alt.inverse_types
  composition_inverse_alt_TCC1: OBLIGATION
    FORALL (f1: (bijective?[T1, T2]), f2: (bijective?[T2, T3])):
      (EXISTS (d: T1): TRUE) OR (FORALL (r: T3): FALSE);


decl_type: tcc
theory: function_props_aux
library: structures
signature: nil
location: 35 0 40 999
body:
  % Assuming TCC generated (at line 1370, column 3) for
      % function_inverse_alt[T1, T2]
      % generated from assumption function_inverse_alt.inverse_types
  composition_inverse_alt_TCC2: OBLIGATION
    FORALL (f1: (bijective?[T1, T2]), f2: (bijective?[T2, T3])):
      (EXISTS (d: T1): TRUE) OR (FORALL (r: T2): FALSE);


decl_type: tcc
theory: function_props_aux
library: structures
signature: nil
location: 42 0 47 999
body:
  % Assuming TCC generated (at line 1370, column 3) for
      % function_inverse_alt[T2, T3]
      % generated from assumption function_inverse_alt.inverse_types
  composition_inverse_alt_TCC3: OBLIGATION
    FORALL (f1: (bijective?[T1, T2]), f2: (bijective?[T2, T3])):
      (EXISTS (d: T2): TRUE) OR (FORALL (r: T3): FALSE);


decl_type: formula
theory: function_inverse_alt_aux
library: structures
signature: nil
location: 15 2 16 79
body:
    inverse_inverse_alt: LEMMA bijective?[D,R](f) =>
                                                  inverse_alt(inverse_alt(f)) = f


decl_type: tcc
theory: function_inverse_alt_aux
library: structures
signature: nil
location: 23 0 29 999
body:
  % Assuming TCC generated (at line 1370, column 3) for
      % function_inverse_alt[D, R]
      % generated from assumption function_inverse_alt.inverse_types
  inverse_inverse_alt_TCC1: OBLIGATION
    FORALL (f: [D -> R]):
      bijective?[D, R](f) IMPLIES
       (EXISTS (d: D): TRUE) OR (FORALL (r: R): FALSE);


decl_type: tcc
theory: function_inverse_alt_aux
library: structures
signature: nil
location: 31 0 37 999
body:
  % Assuming TCC generated (at line 1370, column 3) for
      % function_inverse_alt[R, D]
      % generated from assumption function_inverse_alt.inverse_types
  inverse_inverse_alt_TCC2: OBLIGATION
    FORALL (f: [D -> R]):
      bijective?[D, R](f) IMPLIES
       (EXISTS (d: R): TRUE) OR (FORALL (r: D): FALSE);


decl_type: formula
theory: function_image_bis
library: structures
signature: nil
location: 31 2 33 64
body:
    bijective_image_inverse_alt: LEMMA FORALL (bij:(bijective?[D,R])):
       inverse_image(bij,Y) = IF empty?(Y) THEN emptyset[D]
                              ELSE image(inverse_alt(bij),Y) ENDIF


decl_type: tcc
theory: function_image_bis
library: structures
signature: nil
location: 40 0 45 999
body:
  % Assuming TCC generated (at line 1370, column 3) for
      % function_inverse_alt[D, R]
      % generated from assumption function_inverse_alt.inverse_types
  bijective_image_inverse_alt_TCC1: OBLIGATION
    FORALL (Y: set[R], bij: (bijective?[D, R])):
      NOT empty?(Y) IMPLIES (EXISTS (d: D): TRUE) OR (FORALL (r: R): FALSE);


decl_type: formula
theory: const_fun_def
library: structures
signature: nil
location: 25 2 27 63
body:
    image_const: LEMMA
       image(const_fun(a),X)
          = IF empty?(X) THEN emptyset[T] ELSE singleton(a) ENDIF


decl_type: formula
theory: const_fun_def
library: structures
signature: nil
location: 29 2 31 56
body:
    inverse_image_const: LEMMA
       inverse_image(const_fun(a),Y)
          = IF Y(a) THEN fullset[S] ELSE emptyset[S] ENDIF


decl_type: formula
theory: Unit_adt
library: structures
signature: nil
location: 20 2 22 61
body:
    Unit_induction: AXIOM
      FORALL (p: [Unit -> boolean]):
        p(unit) IMPLIES (FORALL (Unit_var: Unit): p(Unit_var));


decl_type: function
theory: Unit_adt_reduce
library: structures
signature: [range -> [Unit -> range]]
location: 6 2 9 56
body:
    reduce(unit?_fun: range):  [Unit -> range] =
        LAMBDA (Unit_adtvar: Unit):
          LET red: [Unit -> range] = reduce(unit?_fun) IN
            CASES Unit_adtvar OF unit: unit?_fun ENDCASES;


decl_type: function
theory: Unit_adt_reduce
library: structures
signature: [[Unit -> range] -> [Unit -> range]]
location: 11 2 14 69
body:
    REDUCE(unit?_fun: [Unit -> range]):  [Unit -> range] =
        LAMBDA (Unit_adtvar: Unit):
          LET red: [Unit -> range] = REDUCE(unit?_fun) IN
            CASES Unit_adtvar OF unit: unit?_fun(Unit_adtvar) ENDCASES;


decl_type: formula
theory: RealInt
library: reals
signature: nil
location: 86 0 89 999
body:
  RealInf_ord_defaxiom: AXIOM
    RealInf_ord(oo) = 0 AND
     (FORALL (get_inf: Inf): RealInf_ord(ninf(get_inf)) = 1) AND
      (FORALL (get_real: real): RealInf_ord(open(get_real)) = 2);


decl_type: formula
theory: RealInt
library: reals
signature: nil
location: 91 0 92 999
body:
  RealInf_oo_extensionality: AXIOM
    FORALL (inf?_var: (inf?), inf?_var2: (inf?)): inf?_var = inf?_var2;


decl_type: formula
theory: RealInt
library: reals
signature: nil
location: 94 0 96 999
body:
  RealInf_ninf_extensionality: AXIOM
    FORALL (ninf?_var: (ninf?), ninf?_var2: (ninf?)):
      get_inf(ninf?_var) = get_inf(ninf?_var2) IMPLIES ninf?_var = ninf?_var2;


decl_type: formula
theory: RealInt
library: reals
signature: nil
location: 101 0 104 999
body:
  RealInf_open_extensionality: AXIOM
    FORALL (open?_var: (open?), open?_var2: (open?)):
      get_real(open?_var) = get_real(open?_var2) IMPLIES
       open?_var = open?_var2;


decl_type: formula
theory: RealInt
library: reals
signature: nil
location: 115 0 117 999
body:
  RealInf_inclusive: AXIOM
    FORALL (RealInf_var: RealInf):
      inf?(RealInf_var) OR ninf?(RealInf_var) OR open?(RealInf_var);


decl_type: formula
theory: RealInt
library: reals
signature: nil
location: 119 0 124 999
body:
  RealInf_induction: AXIOM
    FORALL (p: [RealInf -> boolean]):
      (p(oo) AND
        (FORALL (ninf1_var: Inf): p(ninf1_var) IMPLIES p(ninf(ninf1_var)))
         AND (FORALL (open1_var: real): p(open(open1_var))))
       IMPLIES (FORALL (RealInf_var: RealInf): p(RealInf_var));


decl_type: type
theory: RealInt
library: reals
signature: nil
location: 5 2 10 28
body:
    RealInt : TYPE = [# lb: real,
                       ub: real,
                       bounded_below: bool,
                       bounded_above: bool,
                       closed_below: bool,
                       closed_above: bool #]


decl_type: function
theory: RealInt
library: reals
signature: [RealInt -> [real -> bool]]
location: 15 2 19 57
body:
    contains?(I)(x): bool =
      (I`bounded_below IMPLIES
        (IF I`closed_below THEN I`lb<=x ELSE I`lb<x ENDIF)) AND
      (I`bounded_above IMPLIES
        (IF I`closed_above THEN x<=I`ub ELSE x<I`ub ENDIF))


decl_type: function
theory: RealInt
library: reals
signature: [[real, real, bool, bool, bool, bool] -> RealInt]
location: 22 2 25 3
body:
    mk_realint(x,y:real,bb,ba,cb,ca:bool) : MACRO RealInt =
      (# lb:=x,ub:=y,bounded_below:=bb,bounded_above:=ba,closed_below:=cb,closed_above:=ca #)

    ;##(x,I) : bool = contains?(I)(x)


decl_type: function
theory: RealInt
library: reals
signature: [RealInf -> upto(2)]
location: 158 0 159 999
body:
  ord(x: RealInf): [RealInf -> upto(2)] =
      CASES x OF oo: 0, ninf(ninf1_var): 1, open(open1_var): 2 ENDCASES


decl_type: function
theory: RealInt
library: reals
signature: [[RealInf, RealInf] -> boolean]
location: 161 0 167 999
body:
  subterm(x: RealInf, y: RealInf):  boolean =
      x = y OR
       CASES y
         OF oo: FALSE,
            ninf(ninf1_var): subterm(x, ninf1_var),
            open(open1_var): FALSE
         ENDCASES;


decl_type: function
theory: RealInt
library: reals
signature: [[nat, [nat -> nat], [real -> nat]] -> [RealInf -> nat]]
location: 169 0 180 999
body:
  reduce_nat(inf?_fun: nat, ninf?_fun: [nat -> nat],
             open?_fun: [real -> nat]):
        [RealInf -> nat] =
      LAMBDA (RealInf_adtvar: RealInf):
        LET red: [RealInf -> nat] =
              reduce_nat(inf?_fun, ninf?_fun, open?_fun)
          IN
          CASES RealInf_adtvar
            OF oo: inf?_fun,
               ninf(ninf1_var): ninf?_fun(red(ninf1_var)),
               open(open1_var): open?_fun(open1_var)
            ENDCASES;


decl_type: function
theory: RealInt
library: reals
location: 182 0 193 999
signature:
  [[[RealInf -> nat], [[nat, RealInf] -> nat],
         [[real, RealInf] -> nat]] ->
          [RealInf -> nat]]

body:
  REDUCE_nat(inf?_fun: [RealInf -> nat], ninf?_fun: [[nat, RealInf] -> nat],
             open?_fun: [[real, RealInf] -> nat]):
        [RealInf -> nat] =
      LAMBDA (RealInf_adtvar: RealInf):
        LET red: [RealInf -> nat] =
              REDUCE_nat(inf?_fun, ninf?_fun, open?_fun)
          IN
          CASES RealInf_adtvar
            OF oo: inf?_fun(RealInf_adtvar),
               ninf(ninf1_var): ninf?_fun(red(ninf1_var), RealInf_adtvar),
               open(open1_var): open?_fun(open1_var, RealInf_adtvar)
            ENDCASES;


decl_type: function
theory: RealInt
library: reals
signature:
  [[ordinal, [ordinal -> ordinal], [real -> ordinal]] ->
  [RealInf -> ordinal]]

location: 195 0 206 999
body:
  reduce_ordinal(inf?_fun: ordinal, ninf?_fun: [ordinal -> ordinal],
                 open?_fun: [real -> ordinal]):
        [RealInf -> ordinal] =
      LAMBDA (RealInf_adtvar: RealInf):
        LET red: [RealInf -> ordinal] =
              reduce_ordinal(inf?_fun, ninf?_fun, open?_fun)
          IN
          CASES RealInf_adtvar
            OF oo: inf?_fun,
               ninf(ninf1_var): ninf?_fun(red(ninf1_var)),
               open(open1_var): open?_fun(open1_var)
            ENDCASES;


decl_type: function
theory: RealInt
library: reals
location: 208 0 220 999
signature:
  [[[RealInf -> ordinal], [[ordinal, RealInf] -> ordinal],
         [[real, RealInf] -> ordinal]] ->
          [RealInf -> ordinal]]

body:
  REDUCE_ordinal(inf?_fun: [RealInf -> ordinal],
                 ninf?_fun: [[ordinal, RealInf] -> ordinal],
                 open?_fun: [[real, RealInf] -> ordinal]):
        [RealInf -> ordinal] =
      LAMBDA (RealInf_adtvar: RealInf):
        LET red: [RealInf -> ordinal] =
              REDUCE_ordinal(inf?_fun, ninf?_fun, open?_fun)
          IN
          CASES RealInf_adtvar
            OF oo: inf?_fun(RealInf_adtvar),
               ninf(ninf1_var): ninf?_fun(red(ninf1_var), RealInf_adtvar),
               open(open1_var): open?_fun(open1_var, RealInf_adtvar)
            ENDCASES;


decl_type: function
theory: RealInt
library: reals
signature: [[real, RealInf] -> RealInt]
location: 38 3 42 3
body:
    ;[||](x,ry) : RealInt = 
      LET y = IF open?(ry) THEN get_real(ry) ELSIF ninf?(ry) THEN x-1 ELSE x+1 ENDIF IN
      mk_realint(x,y,TRUE,open?(ry),TRUE,FALSE)

    ;[||](rx,y) : RealInt = 


decl_type: function
theory: RealInt
library: reals
signature: [[RealInf, real] -> RealInt]
location: 42 3 46 3
body:
    ;[||](rx,y) : RealInt = 
      LET x = IF open?(rx) THEN get_real(rx) ELSIF inf?(rx) THEN y+1 ELSE y-1 ENDIF IN
      mk_realint(x,y,open?(rx),TRUE,FALSE,TRUE)

    ;[||](rx,ry) : RealInt = 


decl_type: function
theory: RealInt
library: reals
signature: [[RealInf, RealInf] -> RealInt]
location: 46 3 59 51
body:
    ;[||](rx,ry) : RealInt = 
      LET x = IF open?(rx) THEN get_real(rx) 
              ELSIF open?(ry) THEN 
                IF inf?(rx) THEN get_real(ry)+1
                ELSE get_real(ry)-1 
                ENDIF
              ELSE -1 ENDIF,
          y = IF open?(ry) THEN get_real(ry) 
              ELSIF open?(rx) THEN 
                IF ninf?(ry) THEN get_real(rx)-1
                ELSE get_real(rx)+1 
                ENDIF
              ELSE 1 ENDIF IN
      mk_realint(x,y,open?(rx),open?(ry),FALSE,FALSE)


decl_type: constant
theory: RealInt
library: reals
signature: (strict_well_founded?[RealInf])
location: 224 0 230 999
body:
  <<:  (strict_well_founded?[RealInf]) =
      LAMBDA (x, y: RealInf):
        CASES y
          OF oo: FALSE,
             ninf(ninf1_var): x = ninf1_var OR x << ninf1_var,
             open(open1_var): FALSE
          ENDCASES;


decl_type: datatype
theory: RealInt
library: reals
signature: nil
location: 27 12 32 13
body:
    RealInf : DATATYPE WITH SUBTYPES Inf,nInf,RealN 
    BEGIN
      oo  : inf? : Inf
      ninf(get_inf:Inf) : ninf? : nInf
      open(get_real:real) : open? : RealN 
    END RealInf


decl_type: type
theory: connected_set
library: reals
signature: nil
location: 11 3 12 78
body:
     Connected : TYPE = 
       {s:set[real] | FORALL (a,b:(s)),(c:real): a <= c AND c <= b IMPLIES s(c)}


decl_type: tcc
theory: connected_set
library: reals
signature: nil
location: 59 0 65 999
body:
  % Subtype TCC generated (at line 31, column 33) for  {z: real | z > x}
      % expected type  ConnectedGt(x)
  OpenInf_TCC1: OBLIGATION
    FORALL (x: real):
      (FORALL (a, b: ({z: real | z > x})), (c: real):
         a <= c AND c <= b IMPLIES c > x)
       AND (FORALL (z_1: ({z: real | z > x})): z_1 > x);


decl_type: tcc
theory: connected_set
library: reals
signature: nil
location: 67 0 73 999
body:
  % Subtype TCC generated (at line 34, column 34) for  {z: real | z >= x}
      % expected type  ConnectedGe(x)
  CloseInf_TCC1: OBLIGATION
    FORALL (x: real):
      (FORALL (a, b: ({z: real | z >= x})), (c: real):
         a <= c AND c <= b IMPLIES c >= x)
       AND (FORALL (z_1: ({z: real | z >= x})): z_1 >= x);


decl_type: tcc
theory: connected_set
library: reals
signature: nil
location: 75 0 81 999
body:
  % Subtype TCC generated (at line 37, column 33) for  {z: real | z < x}
      % expected type  ConnectedLt(x)
  InfOpen_TCC1: OBLIGATION
    FORALL (x: real):
      (FORALL (a, b: ({z: real | z < x})), (c: real):
         a <= c AND c <= b IMPLIES c < x)
       AND (FORALL (z_1: ({z: real | z < x})): z_1 < x);


decl_type: tcc
theory: connected_set
library: reals
signature: nil
location: 83 0 89 999
body:
  % Subtype TCC generated (at line 40, column 34) for  {z: real | z <= x}
      % expected type  ConnectedLe(x)
  InfClose_TCC1: OBLIGATION
    FORALL (x: real):
      (FORALL (a, b: ({z: real | z <= x})), (c: real):
         a <= c AND c <= b IMPLIES c <= x)
       AND (FORALL (z_1: ({z: real | z <= x})): z_1 <= x);


decl_type: tcc
theory: connected_set
library: reals
signature: nil
location: 91 0 98 999
body:
  % Subtype TCC generated (at line 43, column 40) for
      % {z: real | x < z AND z < y}
      % expected type  ConnectedGtLt(x, y)
  OpenOpen_TCC1: OBLIGATION
    FORALL (x: real, y: real):
      (FORALL (a, b: ({z: real | x < z AND z < y})), (c: real):
         a <= c AND c <= b IMPLIES x < c AND c < y)
       AND (FORALL (z_1: ({z: real | x < z AND z < y})): x < z_1 AND z_1 < y);


decl_type: tcc
theory: connected_set
library: reals
signature: nil
location: 100 0 108 999
body:
  % Subtype TCC generated (at line 46, column 41) for
      % {z: real | x < z AND z <= y}
      % expected type  ConnectedGtLe(x, y)
  OpenClose_TCC1: OBLIGATION
    FORALL (x: real, y: real):
      (FORALL (a, b: ({z: real | x < z AND z <= y})), (c: real):
         a <= c AND c <= b IMPLIES x < c AND c <= y)
       AND
       (FORALL (z_1: ({z: real | x < z AND z <= y})): x < z_1 AND z_1 <= y);


decl_type: tcc
theory: connected_set
library: reals
signature: nil
location: 110 0 118 999
body:
  % Subtype TCC generated (at line 49, column 41) for
      % {z: real | x <= z AND z < y}
      % expected type  ConnectedGeLt(x, y)
  CloseOpen_TCC1: OBLIGATION
    FORALL (x: real, y: real):
      (FORALL (a, b: ({z: real | x <= z AND z < y})), (c: real):
         a <= c AND c <= b IMPLIES x <= c AND c < y)
       AND
       (FORALL (z_1: ({z: real | x <= z AND z < y})): x <= z_1 AND z_1 < y);


decl_type: tcc
theory: connected_set
library: reals
signature: nil
location: 120 0 128 999
body:
  % Subtype TCC generated (at line 52, column 42) for
      % {z: real | x <= z AND z <= y}
      % expected type  ConnectedGeLe(x, y)
  CloseClose_TCC1: OBLIGATION
    FORALL (x: real, y: real):
      (FORALL (a, b: ({z: real | x <= z AND z <= y})), (c: real):
         a <= c AND c <= b IMPLIES x <= c AND c <= y)
       AND
       (FORALL (z_1: ({z: real | x <= z AND z <= y})): x <= z_1 AND z_1 <= y);


decl_type: formula
theory: product
library: reals
signature: nil
location: 109 2 110 76
body:
    product_eq_0    : THEOREM product(low,high,F) = 0 IMPLIES  
                                    (EXISTS (n: subrange(low,high)): F(n) = 0)


decl_type: formula
theory: product
library: reals
signature: nil
location: 113 2 114 76
body:
    product_eq_zero    : THEOREM product(low,high,F) = 0 IFF  
                                    (EXISTS (n: subrange(low,high)): F(n) = 0)


decl_type: formula
theory: product
library: reals
signature: nil
location: 122 2 123 69
body:
    product_nz      : THEOREM (FORALL (n: subrange(low,high)): F(n) /= 0)
                                       IMPLIES product(low,high,F) /= 0 


decl_type: formula
theory: product
library: reals
signature: nil
location: 141 2 143 74
body:
    product_prod2     : THEOREM low=low2 AND high=high2 IMPLIES
                                 product(low, high, F) * product(low2, high2, G)
                               = product(low, high, (LAMBDA i: F(i) * G(i)))


decl_type: formula
theory: product
library: reals
signature: nil
location: 145 2 147 99
body:
    product_cross   : THEOREM (FORALL (i:T): G(i) /= 0) IMPLIES
                                product(low, high, F) 
                                = product(low, high, G) * product(low, high, (LAMBDA i: F(i) / G(i)))


decl_type: formula
theory: product
library: reals
signature: nil
location: 170 2 171 63
body:
    product_1          : THEOREM (FORALL (n: subrange(low,high)): F(n) = 1)
                                  IMPLIES product(low,high,F) = 1


decl_type: function
theory: product
library: reals
signature: [[T_low, T_high, [T -> real]] -> real]
location: 57 3 61 49
body:
     product(low, high, F): RECURSIVE real
        = IF low > high THEN 1
          ELSE  F(high)*product(low, high-1, F)
          ENDIF                            
     MEASURE (LAMBDA low, high, F: abs(high+1-low))


decl_type: function
theory: product
library: reals
signature: [[[T -> real], T_low, T_high] -> [T -> real]]
location: 153 2 154 63
body:
    restrict(F, low, high): function[T -> real] = 
       (LAMBDA i: IF i < low OR i > high THEN 0 ELSE F(i) ENDIF )


decl_type: tcc
theory: product
library: reals
signature: nil
location: 231 0 234 999
body:
  % Subtype TCC generated (at line 59, column 16) for  high
      % expected type  T
  product_TCC1: OBLIGATION
    FORALL (low: T_low, high: T_high): NOT low > high IMPLIES T_pred(high);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 236 0 241 999
body:
  % Subtype TCC generated (at line 59, column 35) for  high - 1
      % expected type  T_high
  product_TCC2: OBLIGATION
    FORALL (low: T_low, high: T_high):
      NOT low > high IMPLIES
       T_pred(high - 1) OR (EXISTS (j: T): high - 1 <= j);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 243 0 247 999
body:
  % Termination TCC generated (at line 59, column 22) for
      % product(low, high - 1, F)
  product_TCC3: OBLIGATION
    FORALL (low: T_low, high: T_high):
      NOT low > high IMPLIES abs(high - 1 + 1 - low) < abs(high + 1 - low);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 249 0 254 999
body:
  % Subtype TCC generated (at line 65, column 40) for  low + nn + rng
      % expected type  T_high
  product_spl_TCC1: OBLIGATION
    FORALL (low: T_low, nn, rng: nat):
      T_pred(low + nn + rng) IMPLIES
       T_pred(low + nn + rng) OR (EXISTS (j: T): low + nn + rng <= j);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 256 0 261 999
body:
  % Subtype TCC generated (at line 66, column 42) for  low + nn
      % expected type  T_high
  product_spl_TCC2: OBLIGATION
    FORALL (low: T_low, nn, rng: nat):
      T_pred(low + nn + rng) IMPLIES
       T_pred(low + nn) OR (EXISTS (j: T): low + nn <= j);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 263 0 268 999
body:
  % Subtype TCC generated (at line 66, column 62) for  low + nn + 1
      % expected type  T_low
  product_spl_TCC3: OBLIGATION
    FORALL (low: T_low, nn, rng: nat):
      T_pred(low + nn + rng) IMPLIES
       T_pred(low + nn + 1) OR (EXISTS (j: T): j <= low + nn + 1);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 270 0 274 999
body:
  % Subtype TCC generated (at line 70, column 50) for  z
      % expected type  T_high
  product_split_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low, z: int):
      z <= high AND low - 1 <= z IMPLIES T_pred(z) OR (EXISTS (j: T): z <= j);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 276 0 281 999
body:
  % Subtype TCC generated (at line 70, column 66) for  z + 1
      % expected type  T_low
  product_split_TCC2: OBLIGATION
    FORALL (high: T_high, low: T_low, z: int):
      z <= high AND low - 1 <= z IMPLIES
       T_pred(z + 1) OR (EXISTS (j: T): j <= z + 1);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 283 0 286 999
body:
  % Subtype TCC generated (at line 85, column 53) for  low
      % expected type  T
  product_first_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low): high >= low IMPLIES T_pred(low);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 288 0 292 999
body:
  % Subtype TCC generated (at line 85, column 68) for  low + 1
      % expected type  T_low
  product_first_TCC2: OBLIGATION
    FORALL (high: T_high, low: T_low):
      high >= low IMPLIES T_pred(low + 1) OR (EXISTS (j: T): j <= low + 1);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 294 0 298 999
body:
  % Subtype TCC generated (at line 88, column 63) for  high - 1
      % expected type  T_high
  product_last_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low):
      high >= low IMPLIES T_pred(high - 1) OR (EXISTS (j: T): high - 1 <= j);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 300 0 303 999
body:
  % Subtype TCC generated (at line 88, column 78) for  high
      % expected type  T
  product_last_TCC2: OBLIGATION
    FORALL (high: T_high, low: T_low): high >= low IMPLIES T_pred(high);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 305 0 310 999
body:
  % Subtype TCC generated (at line 91, column 63) for  i - 1
      % expected type  T_high
  product_middle_TCC1: OBLIGATION
    FORALL (high: T_high, i: T, low: T_low):
      i >= low AND high >= i IMPLIES
       T_pred(i - 1) OR (EXISTS (j: T): i - 1 <= j);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 312 0 317 999
body:
  % Subtype TCC generated (at line 92, column 56) for  i + 1
      % expected type  T_low
  product_middle_TCC2: OBLIGATION
    FORALL (high: T_high, i: T, low: T_low):
      i >= low AND high >= i IMPLIES
       T_pred(i + 1) OR (EXISTS (j: T): j <= i + 1);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 319 0 323 999
body:
  % Subtype TCC generated (at line 95, column 52) for  (high - low + 1)
      % expected type  {i: int | nzr /= 0 OR i >= 0}
  product_const_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low, nzr: nzreal):
      high >= low IMPLIES nzr /= 0 OR (high - low + 1) >= 0;


decl_type: tcc
theory: product
library: reals
signature: nil
location: 325 0 329 999
body:
  % Subtype TCC generated (at line 101, column 34) for  (high - low + 1)
      % expected type  {i: int | a /= 0 OR i >= 0}
  product_scal_TCC1: OBLIGATION
    FORALL (a: real, high: T_high, low: T_low):
      a /= 0 AND low <= high IMPLIES a /= 0 OR (high - low + 1) >= 0;


decl_type: tcc
theory: product
library: reals
signature: nil
location: 331 0 336 999
body:
  % Subtype TCC generated (at line 110, column 69) for  n
      % expected type  T
  product_eq_0_TCC1: OBLIGATION
    FORALL (F: [T -> real], high: T_high, low: T_low):
      product(low, high, F) = 0 IMPLIES
       (FORALL (n: subrange(low, high)): T_pred(n));


decl_type: tcc
theory: product
library: reals
signature: nil
location: 338 0 341 999
body:
  % Subtype TCC generated (at line 114, column 69) for  n
      % expected type  T
  product_eq_zero_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low, n: subrange(low, high)): T_pred(n);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 343 0 348 999
body:
  % Subtype TCC generated (at line 127, column 20) for  low + z
      % expected type  T_low
  product_shift_T_TCC1: OBLIGATION
    FORALL (low: T_low, z: int):
      (FORALL (i: T): T_pred(i + z)) IMPLIES
       T_pred(low + z) OR (EXISTS (j: T): j <= low + z);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 350 0 355 999
body:
  % Subtype TCC generated (at line 127, column 26) for  high + z
      % expected type  T_high
  product_shift_T_TCC2: OBLIGATION
    FORALL (high: T_high, z: int):
      (FORALL (i: T): T_pred(i + z)) IMPLIES
       T_pred(high + z) OR (EXISTS (j: T): high + z <= j);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 357 0 361 999
body:
  % Subtype TCC generated (at line 128, column 71) for  i + z
      % expected type  T
  product_shift_T_TCC3: OBLIGATION
    FORALL (z: int):
      (FORALL (i: T): T_pred(i + z)) IMPLIES (FORALL (i1: T): T_pred(i1 + z));


decl_type: tcc
theory: product
library: reals
signature: nil
location: 363 0 368 999
body:
  % Subtype TCC generated (at line 131, column 21) for  low + z
      % expected type  T_low
  product_shift_T2_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low, z: int):
      T_pred(high + z) AND T_pred(low + z) IMPLIES
       T_pred(low + z) OR (EXISTS (j: T): j <= low + z);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 370 0 375 999
body:
  % Subtype TCC generated (at line 131, column 27) for  high + z
      % expected type  T_high
  product_shift_T2_TCC2: OBLIGATION
    FORALL (high: T_high, low: T_low, z: int):
      T_pred(high + z) AND T_pred(low + z) IMPLIES
       T_pred(high + z) OR (EXISTS (j: T): high + z <= j);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 377 0 381 999
body:
  % Subtype TCC generated (at line 147, column 93) for  G(i)
      % expected type  nznum
  product_cross_TCC1: OBLIGATION
    FORALL (G: [T -> real]):
      (FORALL (i: T): G(i) /= 0) IMPLIES (FORALL (i1): G(i1) /= 0);


decl_type: tcc
theory: product
library: reals
signature: nil
location: 383 0 387 999
body:
  % Judgement subtype TCC generated (at line 196, column 22) for
      % product(low, high, Fnnr)
      % expected type  nnreal
  prod_nnr: OBLIGATION
    FORALL (Fnnr, high, low): product(low, high, Fnnr) >= 0;


decl_type: tcc
theory: product
library: reals
signature: nil
location: 389 0 392 999
body:
  % Judgement subtype TCC generated (at line 198, column 21) for
      % product(low, high, Fpr)
      % expected type  posreal
  prod_pr: OBLIGATION FORALL (Fpr, high, low): product(low, high, Fpr) > 0;


decl_type: tcc
theory: product
library: reals
signature: nil
location: 394 0 401 999
body:
  % Judgement subtype TCC generated (at line 200, column 22) for
      % product(low, high, Fnat)
      % expected type  nat
  prod_nat: OBLIGATION
    FORALL (Fnat, high, low):
      rational_pred(product(low, high, Fnat)) AND
       integer_pred(product(low, high, Fnat)) AND
        product(low, high, Fnat) >= 0;


decl_type: tcc
theory: product
library: reals
signature: nil
location: 403 0 407 999
body:
  % Judgement subtype TCC generated (at line 202, column 25) for
      % product(low, high, Fposnat)
      % expected type  posnat
  prod_posnat: OBLIGATION
    FORALL (Fposnat, high, low): product(low, high, Fposnat) > 0;


decl_type: formula
theory: product_nat
library: reals
signature: nil
location: 63 2 66 51
body:
    product_reverse  : THEOREM low<=high IMPLIES
                     product(low, high, F) = 
                     product(low, high, LAMBDA (j:nat): IF high+low-j<0 THEN 0
                                                        ELSE F(high+low-j) ENDIF)


decl_type: tcc
theory: product_nat
library: reals
signature: nil
location: 139 0 143 999
body:
  % Subtype TCC generated (at line 61, column 50) for  i
      % expected type  T_high[nat]
  product_split_ge_TCC1: OBLIGATION
    FORALL (high, i: int, low: nat):
      i <= high AND low - 1 <= i IMPLIES i >= 0 OR (EXISTS (j: nat): i <= j);


decl_type: tcc
theory: product_nat
library: reals
signature: nil
location: 145 0 150 999
body:
  % Subtype TCC generated (at line 61, column 66) for  i + 1
      % expected type  T_low[nat]
  product_split_ge_TCC2: OBLIGATION
    FORALL (high, i: int, low: nat):
      i <= high AND low - 1 <= i IMPLIES
       i + 1 >= 0 OR (EXISTS (j: nat): j <= i + 1);


decl_type: tcc
theory: product_nat
library: reals
signature: nil
location: 152 0 157 999
body:
  % Subtype TCC generated (at line 66, column 33) for  high + low - j
      % expected type  nat
  product_reverse_TCC1: OBLIGATION
    FORALL (high: int, low: nat):
      low <= high IMPLIES
       (FORALL (j: nat): NOT high + low - j < 0 IMPLIES high + low - j >= 0);


decl_type: tcc
theory: product_nat
library: reals
signature: nil
location: 159 0 162 999
body:
  % Subtype TCC generated (at line 73, column 33) for  ing
      % expected type  T_high[nat]
  product_0_neg_TCC1: OBLIGATION
    FORALL (ing: negint): ing >= 0 OR (EXISTS (j: nat): ing <= j);


decl_type: formula
theory: product_fseq_posnat
library: reals
signature: nil
location: 33 3 36 53
body:
     product_fseq_shift: LEMMA  product(l1, l1 + l2 - 1,
                                   LAMBDA (n: nat): IF n < l1 THEN unk`seq(n)
                                                    ELSE fs`seq(n - l1)  ENDIF)
                           = product(0, l2 - 1, fs`seq)


decl_type: formula
theory: product_fseq_posnat
library: reals
signature: nil
location: 44 3 46 66
body:
     product_fseq_split: LEMMA length(fs) > 1 IMPLIES
                              product(fs) = product(fs ^ (0, length(fs) - 2)) * 
                                             seq(fs)(length(fs) - 1) 


decl_type: function
theory: product_fseq_posnat
library: reals
signature: [fseq[posnat] -> posnat]
location: 25 3 27 30
body:
     product(fs): posnat = IF length(fs) = 0 THEN 1
                           ELSE product(0,length(fs)-1,fs`seq)
                           ENDIF


decl_type: tcc
theory: product_fseq_posnat
library: reals
signature: nil
location: 62 0 65 999
body:
  % Subtype TCC generated (at line 23, column 40) for  n
      % expected type  T_high[nat]
  product_nat_nat_TCC1: OBLIGATION
    FORALL (n): n >= 0 OR (EXISTS (j: nat): n <= j);


decl_type: tcc
theory: product_fseq_posnat
library: reals
signature: nil
location: 67 0 72 999
body:
  % Subtype TCC generated (at line 26, column 40) for  length(fs) - 1
      % expected type  T_high[nat]
  product_TCC1: OBLIGATION
    FORALL (fs: fseq[posnat]):
      NOT length(fs) = 0 IMPLIES
       length(fs) - 1 >= 0 OR (EXISTS (j: nat): length(fs) - 1 <= j);


decl_type: tcc
theory: product_fseq_posnat
library: reals
signature: nil
location: 74 0 78 999
body:
  % Subtype TCC generated (at line 33, column 42) for  l1 + l2 - 1
      % expected type  T_high[nat]
  product_fseq_shift_TCC1: OBLIGATION
    FORALL (l1, l2: nat):
      l1 + l2 - 1 >= 0 OR (EXISTS (j: nat): l1 + l2 - 1 <= j);


decl_type: tcc
theory: product_fseq_posnat
library: reals
signature: nil
location: 80 0 83 999
body:
  % Subtype TCC generated (at line 35, column 62) for  n - l1
      % expected type  nat
  product_fseq_shift_TCC2: OBLIGATION
    FORALL (l1, n: nat): NOT n < l1 IMPLIES n - l1 >= 0;


decl_type: tcc
theory: product_fseq_posnat
library: reals
signature: nil
location: 85 0 88 999
body:
  % Subtype TCC generated (at line 36, column 38) for  l2 - 1
      % expected type  T_high[nat]
  product_fseq_shift_TCC3: OBLIGATION
    FORALL (l2: nat): l2 - 1 >= 0 OR (EXISTS (j: nat): l2 - 1 <= j);


decl_type: tcc
theory: product_fseq_posnat
library: reals
signature: nil
location: 90 0 93 999
body:
  % Subtype TCC generated (at line 45, column 59) for  length(fs) - 2
      % expected type  nat
  product_fseq_split_TCC1: OBLIGATION
    FORALL (fs: fseq[posnat]): length(fs) > 1 IMPLIES length(fs) - 2 >= 0;


decl_type: tcc
theory: product_fseq_posnat
library: reals
signature: nil
location: 95 0 98 999
body:
  % Subtype TCC generated (at line 46, column 51) for  length(fs) - 1
      % expected type  nat
  product_fseq_split_TCC2: OBLIGATION
    FORALL (fs: fseq[posnat]): length(fs) > 1 IMPLIES length(fs) - 1 >= 0;


decl_type: function
theory: product_fseq
library: reals
signature: [fseq[T] -> real]
location: 18 3 20 28
body:
     product(fs): real = IF length(fs) = 0 THEN 1
                         ELSE product(0,length(fs)-1,fs`seq)
                         ENDIF


decl_type: tcc
theory: product_fseq
library: reals
signature: nil
location: 52 0 57 999
body:
  % Subtype TCC generated (at line 19, column 38) for  length(fs) - 1
      % expected type  T_high[nat]
  product_TCC1: OBLIGATION
    FORALL (fs: fseq[T]):
      NOT length(fs) = 0 IMPLIES
       length(fs) - 1 >= 0 OR (EXISTS (j: nat): length(fs) - 1 <= j);


decl_type: tcc
theory: product_fseq
library: reals
signature: nil
location: 59 0 63 999
body:
  % Subtype TCC generated (at line 28, column 42) for  l1 + l2 - 1
      % expected type  T_high[nat]
  product_fseq_shift_TCC1: OBLIGATION
    FORALL (l1, l2: nat):
      l1 + l2 - 1 >= 0 OR (EXISTS (j: nat): l1 + l2 - 1 <= j);


decl_type: tcc
theory: product_fseq
library: reals
signature: nil
location: 65 0 68 999
body:
  % Subtype TCC generated (at line 30, column 62) for  n - l1
      % expected type  nat
  product_fseq_shift_TCC2: OBLIGATION
    FORALL (l1, n: nat): NOT n < l1 IMPLIES n - l1 >= 0;


decl_type: tcc
theory: product_fseq
library: reals
signature: nil
location: 70 0 73 999
body:
  % Subtype TCC generated (at line 31, column 38) for  l2 - 1
      % expected type  T_high[nat]
  product_fseq_shift_TCC3: OBLIGATION
    FORALL (l2: nat): l2 - 1 >= 0 OR (EXISTS (j: nat): l2 - 1 <= j);


decl_type: tcc
theory: product_fseq
library: reals
signature: nil
location: 75 0 78 999
body:
  % Subtype TCC generated (at line 40, column 59) for  length(fs) - 2
      % expected type  nat
  product_fseq_split_TCC1: OBLIGATION
    FORALL (fs: fseq[T]): length(fs) > 1 IMPLIES length(fs) - 2 >= 0;


decl_type: tcc
theory: product_fseq
library: reals
signature: nil
location: 80 0 83 999
body:
  % Subtype TCC generated (at line 41, column 51) for  length(fs) - 1
      % expected type  nat
  product_fseq_split_TCC2: OBLIGATION
    FORALL (fs: fseq[T]): length(fs) > 1 IMPLIES length(fs) - 1 >= 0;


decl_type: formula
theory: product_seq_scaf
library: reals
signature: nil
location: 17 3 26 31
body:
     product_rec_mult: LEMMA n < length(fs1 o fs2) IMPLIES
                     product_rec(fs1 o fs2,n) = 
                            IF n < length(fs1) THEN
                               product_rec(fs1,n)
                            ELSIF length(fs1) = 0 THEN
                               product_rec(fs2,n)
                            ELSE
                               product_rec(fs1,length(fs1)-1) 
                               * product_rec(fs2,n-length(fs1))
                            ENDIF


decl_type: formula
theory: product_seq_scaf
library: reals
signature: nil
location: 28 3 30 58
body:
     product_rec_caret: LEMMA n < length(fs) AND m < length(fs) 
                                 AND n <= m IMPLIES product_rec(fs, n) =
                                 product_rec(fs ^ (0, m), n)


decl_type: function
theory: product_seq_scaf
library: reals
signature: [[fs: finite_sequence, below(length(fs))] -> posnat]
location: 9 3 12 32
body:
     product_rec(fs: finite_sequence, i: below(length(fs)) ): RECURSIVE posnat = 
                   IF i = 0 THEN seq(fs)(0)
                   ELSE seq(fs)(i) * product_rec(fs,i-1)
                   ENDIF MEASURE i


decl_type: tcc
theory: product_seq_scaf
library: reals
signature: nil
location: 38 0 42 999
body:
  % Subtype TCC generated (at line 10, column 39) for  0
      % expected type  below[fs`length]
  product_rec_TCC1: OBLIGATION
    FORALL (fs: finite_sequence[posnat], i: below(length(fs))):
      i = 0 IMPLIES 0 < fs`length;


decl_type: tcc
theory: product_seq_scaf
library: reals
signature: nil
location: 44 0 48 999
body:
  % Subtype TCC generated (at line 11, column 50) for  i - 1
      % expected type  below(length(fs))
  product_rec_TCC2: OBLIGATION
    FORALL (fs: finite_sequence[posnat], i: below(length(fs))):
      NOT i = 0 IMPLIES i - 1 >= 0 AND i - 1 < length(fs);


decl_type: tcc
theory: product_seq_scaf
library: reals
signature: nil
location: 50 0 54 999
body:
  % Termination TCC generated (at line 11, column 35) for
      % product_rec(fs, i - 1)
  product_rec_TCC3: OBLIGATION
    FORALL (fs: finite_sequence[posnat], i: below(length(fs))):
      NOT i = 0 IMPLIES i - 1 < i;


decl_type: tcc
theory: product_seq_scaf
library: reals
signature: nil
location: 56 0 61 999
body:
  % Subtype TCC generated (at line 22, column 45) for  n
      % expected type  below(length(fs2))
  product_rec_mult_TCC1: OBLIGATION
    FORALL (fs1, fs2: finite_sequence[posnat], n: nat):
      n < length(fs1 o fs2) AND NOT n < length(fs1) AND length(fs1) = 0
       IMPLIES n < length(fs2);


decl_type: tcc
theory: product_seq_scaf
library: reals
signature: nil
location: 63 0 68 999
body:
  % Subtype TCC generated (at line 24, column 45) for  length(fs1) - 1
      % expected type  below(length(fs1))
  product_rec_mult_TCC2: OBLIGATION
    FORALL (fs1, fs2: finite_sequence[posnat], n: nat):
      n < length(fs1 o fs2) AND NOT n < length(fs1) AND NOT length(fs1) = 0
       IMPLIES length(fs1) - 1 >= 0 AND length(fs1) - 1 < length(fs1);


decl_type: tcc
theory: product_seq_scaf
library: reals
signature: nil
location: 70 0 75 999
body:
  % Subtype TCC generated (at line 25, column 47) for  n - length(fs1)
      % expected type  below(length(fs2))
  product_rec_mult_TCC3: OBLIGATION
    FORALL (fs1, fs2: finite_sequence[posnat], n: nat):
      n < length(fs1 o fs2) AND NOT n < length(fs1) AND NOT length(fs1) = 0
       IMPLIES n - length(fs1) >= 0 AND n - length(fs1) < length(fs2);


decl_type: tcc
theory: product_seq_scaf
library: reals
signature: nil
location: 77 0 82 999
body:
  % Subtype TCC generated (at line 30, column 56) for  n
      % expected type  below(length(fs ^ (0, m)))
  product_rec_caret_TCC1: OBLIGATION
    FORALL (fs: finite_sequence[posnat], m, n: nat):
      n <= m AND m < length(fs) AND n < length(fs) IMPLIES
       n < length(^[posnat](fs, (0, m)));


decl_type: formula
theory: product_seq
library: reals
signature: nil
location: 32 3 34 66
body:
     product_split: LEMMA length(fs) > 1 IMPLIES
                              product(fs) = product(fs ^ (0, length(fs) - 2)) * 
                                             seq(fs)(length(fs) - 1) 


decl_type: function
theory: product_seq
library: reals
signature: [finite_sequence[posnat] -> posnat]
location: 18 3 20 30
body:
     product(fs): posnat = IF length(fs) = 0 THEN 1
                           ELSE product_rec(fs,length(fs)-1)
                           ENDIF


decl_type: function
theory: product_seq
library: reals
signature: [posnat -> finite_sequence[posnat]]
location: 38 3 40 70
body:
     gen_seq1(n: posnat): finite_sequence[posnat] =
                                 (# length := 1,
                                    seq := (LAMBDA (ii: below(1)): n) #)


decl_type: tcc
theory: product_seq
library: reals
signature: nil
location: 56 0 61 999
body:
  % Subtype TCC generated (at line 19, column 45) for  length(fs) - 1
      % expected type  below(length(fs))
  product_TCC1: OBLIGATION
    FORALL (fs: finite_sequence[posnat]):
      NOT length(fs) = 0 IMPLIES
       length(fs) - 1 >= 0 AND length(fs) - 1 < length(fs);


decl_type: tcc
theory: product_seq
library: reals
signature: nil
location: 63 0 67 999
body:
  % Subtype TCC generated (at line 33, column 59) for  length(fs) - 2
      % expected type  nat
  product_split_TCC1: OBLIGATION
    FORALL (fs: finite_sequence[posnat]):
      length(fs) > 1 IMPLIES length(fs) - 2 >= 0;


decl_type: tcc
theory: product_seq
library: reals
signature: nil
location: 69 0 74 999
body:
  % Subtype TCC generated (at line 34, column 51) for  length(fs) - 1
      % expected type  below[fs`length]
  product_split_TCC2: OBLIGATION
    FORALL (fs: finite_sequence[posnat]):
      length(fs) > 1 IMPLIES
       length(fs) - 1 >= 0 AND length(fs) - 1 < fs`length;


decl_type: type
theory: intervals_real
library: reals
signature: nil
location: 17 3 18 77
body:
     Open_interval(a,b:T): TYPE = {x: T | (a <= b IMPLIES (a < x AND x < b)) 
                                        AND (b < a  IMPLIES (b < x AND x < a))}


decl_type: type
theory: intervals_real
library: reals
signature: nil
location: 20 3 21 79
body:
     Closed_interval(a,b:T): TYPE = {x: T | (a <= b IMPLIES (a <= x AND x <= b)) 
                                        AND (b < a  IMPLIES (b <= x AND x <= a))}


decl_type: formula
theory: sq
library: reals
signature: nil
location: 88 2 90 52
body:
    triangle_rectangle: LEMMA sq(a)+sq(b) <= sq(nnc) IMPLIES
                                -nnc <= a AND a <= nnc AND 
                                -nnc <= b AND b <= nnc   


decl_type: formula
theory: sq
library: reals
signature: nil
location: 92 2 94 49
body:
    triangle_ineq_lt  : LEMMA sq(a) + sq(b) < sq(d) IMPLIES  
                                    abs(a) < abs(d) AND
                                    abs(b) < abs(d)   


decl_type: formula
theory: sq
library: reals
signature: nil
location: 97 2 99 50
body:
    triangle_ineq_le  : LEMMA sq(a) + sq(b) <= sq(d) IMPLIES 
                                    abs(a) <= abs(d) AND
                                    abs(b) <= abs(d)   


decl_type: tcc
theory: sq
library: reals
signature: nil
location: 117 0 119 999
body:
  % Subtype TCC generated (at line 9, column 23) for  a * a
      % expected type  nonneg_real
  sq_TCC1: OBLIGATION FORALL (a: real): a * a >= 0;


decl_type: tcc
theory: sq
library: reals
signature: nil
location: 121 0 123 999
body:
  % Judgement subtype TCC generated (at line 11, column 32) for  sq(nz)
      % expected type  posreal
  sq_nz_pos: OBLIGATION FORALL (nz): sq(nz) > 0;


decl_type: tcc
theory: sq
library: reals
signature: nil
location: 125 0 127 999
body:
  % Subtype TCC generated (at line 15, column 38) for  2
      % expected type  {i: int | a /= 0 OR i >= 0}
  sq_expt2_TCC1: OBLIGATION FORALL (a: real): a /= 0 OR 2 >= 0;


decl_type: tcc
theory: sq
library: reals
signature: nil
location: 129 0 131 999
body:
  % Subtype TCC generated (at line 43, column 54) for  sq(d)
      % expected type  nznum
  sq_div_TCC1: OBLIGATION FORALL (d: real): d /= 0 IMPLIES sq(d) /= 0;


decl_type: formula
theory: sqrt_exists
library: reals
signature: nil
location: 24 2 25 81
body:
    sqrt_exists  : LEMMA
                     EXISTS (x1: [nnx: nonneg_real -> {nny | nny*nny = nnx}]): TRUE


decl_type: tcc
theory: sqrt_exists
library: reals
signature: nil
location: 34 0 37 999
body:
  % Subtype TCC generated (at line 22, column 38) for  i
      % expected type  {i: int | nnx /= 0 OR i >= 0}
  lt1_expt_le_TCC1: OBLIGATION
    FORALL (i: posnat, nnx: nonneg_real): nnx < 1 IMPLIES nnx /= 0 OR i >= 0;


decl_type: function
theory: sign
library: reals
location: 94 2 97 16
signature:
  [x: real ->
          {sig: real |
                   (sig = -1 OR sig = 1 OR sig = 0) AND
                    sig * x = abs(x)}]

body:
    sign_ext(x): {sig:real|(sig=-1 OR sig=1 OR sig=0) AND sig*x=abs(x)} =
      IF x<0 THEN -1
      ELSIF x>0 THEN 1
      ELSE 0 ENDIF


decl_type: tcc
theory: sign
library: reals
signature: nil
location: 106 0 109 999
body:
  % Judgement subtype TCC generated (at line 21, column 28) for  eps1 * eps2
      % expected type  Sign
  sign_mult_clos: OBLIGATION
    FORALL (eps1, eps2): eps1 * eps2 = 1 OR eps1 * eps2 = -1;


decl_type: tcc
theory: sign
library: reals
signature: nil
location: 111 0 116 999
body:
  % Judgement subtype TCC generated (at line 23, column 29) for  eps1 / eps2
      % expected type  Sign
  sign_div_clos: OBLIGATION
    FORALL (eps1, eps2):
      integer_pred(eps1 / eps2) AND
       eps1 / eps2 /= 0 AND (eps1 / eps2 = 1 OR eps1 / eps2 = -1);


decl_type: tcc
theory: sign
library: reals
signature: nil
location: 118 0 120 999
body:
  % Judgement subtype TCC generated (at line 25, column 29) for  -eps1
      % expected type  Sign
  sign_neg_clos: OBLIGATION FORALL (eps1): -eps1 = 1 OR -eps1 = -1;


decl_type: tcc
theory: sign
library: reals
signature: nil
location: 122 0 128 999
body:
  % Judgement subtype TCC generated (at line 27, column 30) for  sq(eps1)
      % expected type  Sign
  sign_sq_clos: OBLIGATION
    FORALL (eps1):
      rational_pred(sq(eps1)) AND
       integer_pred(sq(eps1)) AND
        sq(eps1) /= 0 AND (sq(eps1) = 1 OR sq(eps1) = -1);


decl_type: tcc
theory: sign
library: reals
signature: nil
location: 130 0 132 999
body:
  % Subtype TCC generated (at line 71, column 45) for  y
      % expected type  nznum
  sign_div_pos2_TCC1: OBLIGATION FORALL (y: real): y > 0 IMPLIES y /= 0;


decl_type: tcc
theory: sign
library: reals
signature: nil
location: 134 0 136 999
body:
  % Subtype TCC generated (at line 77, column 45) for  y
      % expected type  nznum
  sign_div_neg2_TCC1: OBLIGATION FORALL (y: real): y < 0 IMPLIES y /= 0;


decl_type: tcc
theory: sign
library: reals
signature: nil
location: 138 0 142 999
body:
  % Subtype TCC generated (at line 95, column 16) for  -1
      % expected type  {sig: real |
                     %          (sig = -1 OR sig = 1 OR sig = 0) AND
                     %           sig * x = abs(x)}
  sign_ext_TCC1: OBLIGATION FORALL (x: real): x < 0 IMPLIES -1 * x = abs(x);


decl_type: tcc
theory: sign
library: reals
signature: nil
location: 144 0 149 999
body:
  % Subtype TCC generated (at line 96, column 19) for  1
      % expected type  {sig: real |
                     %          (sig = -1 OR sig = 1 OR sig = 0) AND
                     %           sig * x = abs(x)}
  sign_ext_TCC2: OBLIGATION
    FORALL (x: real): x > 0 AND NOT x < 0 IMPLIES 1 * x = abs(x);


decl_type: tcc
theory: sign
library: reals
signature: nil
location: 151 0 156 999
body:
  % Subtype TCC generated (at line 97, column 9) for  0
      % expected type  {sig: real |
                     %          (sig = -1 OR sig = 1 OR sig = 0) AND
                     %           sig * x = abs(x)}
  sign_ext_TCC3: OBLIGATION
    FORALL (x: real): NOT x > 0 AND NOT x < 0 IMPLIES 0 * x = abs(x);


decl_type: formula
theory: sqrt
library: reals
signature: nil
location: 50 2 51 74
body:
    sqrt_div            : LEMMA  nnz /= 0 IMPLIES 
                                     sqrt(nny / nnz) = sqrt(nny) / sqrt(nnz)


decl_type: formula
theory: sqrt
library: reals
signature: nil
location: 97 2 98 78
body:
    sqrt_cauchy         : LEMMA FORALL (a,b,c,d: real):
                             a*c + b*d <= sqrt(sq(a)+sq(b)) *  sqrt(sq(c)+sq(d))


decl_type: tcc
theory: sqrt
library: reals
signature: nil
location: 126 0 129 999
body:
  % Existence TCC generated (at line 19, column 2) for
      % sqrt(nnx): {nnz: nnreal | nnz * nnz = nnx}
  sqrt_TCC1: OBLIGATION
    EXISTS (x: [nnx: nonneg_real -> {nnz: nnreal | nnz * nnz = nnx}]): TRUE;


decl_type: tcc
theory: sqrt
library: reals
signature: nil
location: 131 0 133 999
body:
  % Judgement subtype TCC generated (at line 21, column 34) for  sqrt(px)
      % expected type  posreal
  sqrt_pos: OBLIGATION FORALL (px: posreal): sqrt(px) > 0;


decl_type: tcc
theory: sqrt
library: reals
signature: nil
location: 135 0 138 999
body:
  % Subtype TCC generated (at line 51, column 40) for  nny / nnz
      % expected type  nnx: nonneg_real
  sqrt_div_TCC1: OBLIGATION
    FORALL (nny, nnz: nonneg_real): nnz /= 0 IMPLIES nny / nnz >= 0;


decl_type: tcc
theory: sqrt
library: reals
signature: nil
location: 140 0 143 999
body:
  % Subtype TCC generated (at line 51, column 65) for  sqrt(nnz)
      % expected type  nznum
  sqrt_div_TCC2: OBLIGATION
    FORALL (nnz: nonneg_real): nnz /= 0 IMPLIES sqrt(nnz) /= 0;


decl_type: formula
theory: prelude_aux
library: reals
signature: nil
location: 17 3 18 50
body:
     floor_lt_floor_int: LEMMA i > 1 AND  x >= i IMPLIES
                             floor(x / i) < floor(x)


decl_type: formula
theory: prelude_aux
library: reals
signature: nil
location: 21 3 22 70
body:
     floor_small: LEMMA  abs(x) < abs(y) IMPLIES
                           floor(x/y) = IF x/y >= 0 THEN 0 ELSE -1 ENDIF


decl_type: tcc
theory: prelude_aux
library: reals
signature: nil
location: 34 0 36 999
body:
  % Subtype TCC generated (at line 11, column 47) for  y
      % expected type  nznum
  floor_div_le_TCC1: OBLIGATION FORALL (y: real): y >= 1 IMPLIES y /= 0;


decl_type: tcc
theory: prelude_aux
library: reals
signature: nil
location: 38 0 40 999
body:
  % Subtype TCC generated (at line 13, column 47) for  y
      % expected type  nznum
  floor_div_lt_TCC1: OBLIGATION FORALL (y: real): y > 1 IMPLIES y /= 0;


decl_type: tcc
theory: prelude_aux
library: reals
signature: nil
location: 42 0 45 999
body:
  % Subtype TCC generated (at line 18, column 37) for  i
      % expected type  nznum
  floor_lt_floor_int_TCC1: OBLIGATION
    FORALL (i: nat, x: real): x >= i AND i > 1 IMPLIES i /= 0;


decl_type: tcc
theory: prelude_aux
library: reals
signature: nil
location: 47 0 50 999
body:
  % Subtype TCC generated (at line 22, column 33) for  y
      % expected type  nznum
  floor_small_TCC1: OBLIGATION
    FORALL (x, y: real): abs(x) < abs(y) IMPLIES y /= 0;


decl_type: function
theory: log_nat
library: reals
signature:
  [d: [{x: real | x >= 1}, above(1)] ->
  [n: nat, {y | y < d`2 AND d`1 = d`2 ^ n * y}]]

location: 19 2 23 20
body:
    log_nat(x,p): RECURSIVE [n:nat,{y | y<p AND x=p^n*y}] =
      if   x < p then (0,x)
      else let (n,y) = log_nat(x/p,p) in (n+1,y)
      endif
      MEASURE floor(x)


decl_type: function
theory: log_nat
library: reals
location: 33 2 37 21
signature:
  [d:
          [x: {x: real | x >= 1}, p: above(1), na: nat,
           {ya | x = p ^ na * ya}] ->
          [n: nat, {y | y < d`2 AND d`1 = d`2 ^ n * y}]]

body:
    log_nat_itaux(x,p,na,(ya | x=p^na*ya)): RECURSIVE [n:nat,{y | y<p AND x=p^n*y}] = 
      if   ya < p then (na,ya)
      else log_nat_itaux(x,p,na+1,ya/p)
      endif
      MEASURE floor(ya)


decl_type: function
theory: log_nat
library: reals
location: 45 2 52 49
signature:
  [xp: posreal ->
          {k: int |
                   xp <= 2 ^ k AND
                    (FORALL (i: int): i < k IMPLIES 2 ^ i < xp)}]

body:
    least_pow_2_ge(xp:posreal): {k:int |
      xp<=2^k AND FORALL (i:int): i<k IMPLIES 2^i<xp} =
      IF xp>=1 THEN
        LET (n,y) = log_nat_it(xp,2) IN
          IF y=1 THEN n
          ELSE n+1 ENDIF
      ELSIF xp>1/2 THEN 0
      ELSE LET n = log_nat_it(1/xp,2)`1 IN -n ENDIF


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 59 0 62 999
body:
  % Subtype TCC generated (at line 19, column 50) for  n
      % expected type  {i: int | p /= 0 OR i >= 0}
  log_nat_TCC1: OBLIGATION
    FORALL (n: nat, p, y: {x: real | x >= 1}): y < p IMPLIES p /= 0 OR n >= 0;


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 64 0 66 999
body:
  % Subtype TCC generated (at line 23, column 12) for  floor(x)
      % expected type  naturalnumber
  log_nat_TCC2: OBLIGATION FORALL (x: {x: real | x >= 1}): floor(x) >= 0;


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 68 0 72 999
body:
  % Subtype TCC generated (at line 20, column 23) for  x
      % expected type  {y | y < p AND x = p ^ 0 * y}
  log_nat_TCC3: OBLIGATION
    FORALL (x: {x: real | x >= 1}, p: above(1)):
      x < p IMPLIES x < p AND x = p ^ 0 * x;


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 74 0 87 999
body:
  % Subtype TCC generated (at line 21, column 44) for  y
      % expected type  {y | y < p AND x = (p ^ (1 + n)) * y}
  log_nat_TCC4: OBLIGATION
    FORALL (x: {x: real | x >= 1},
            v:
              [d1:
                 {z: [{x: real | x >= 1}, above(1)] |
                          floor(z`1) < floor(x)} ->
                 [n: nat, {y | y < d1`2 AND d1`1 = d1`2 ^ n * y}]],
            p: above(1)):
      NOT x < p IMPLIES
       (FORALL (n: nat, y: {y | y < p AND x / p = p ^ n * y}):
          y = v(x / p, p)`2 AND n = v(x / p, p)`1 IMPLIES
           y < p AND x = (p ^ (1 + n)) * y);


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 89 0 92 999
body:
  % Subtype TCC generated (at line 21, column 29) for  x / p
      % expected type  {x: real | x >= 1}
  log_nat_TCC5: OBLIGATION
    FORALL (x: {x: real | x >= 1}, p: above(1)): NOT x < p IMPLIES x / p >= 1;


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 94 0 97 999
body:
  % Termination TCC generated (at line 21, column 21) for  log_nat(x / p, p)
  log_nat_TCC6: OBLIGATION
    FORALL (x: {x: real | x >= 1}, p: above(1)):
      NOT x < p IMPLIES floor(x / p) < floor(x);


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 99 0 104 999
body:
  % Subtype TCC generated (at line 27, column 6) for  n
      % expected type  {i: int | p /= 0 OR i >= 0}
  log_nat_bounds_TCC1: OBLIGATION
    FORALL (p: above(1), x: {x: real | x >= 1}, n: nat,
            y: {y | y < p AND x = p ^ n * y}):
      y = log_nat(x, p)`2 AND n = log_nat(x, p)`1 IMPLIES p /= 0 OR n >= 0;


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 106 0 112 999
body:
  % Subtype TCC generated (at line 27, column 24) for  (n + 1)
      % expected type  {i: int | p /= 0 OR i >= 0}
  log_nat_bounds_TCC2: OBLIGATION
    FORALL (p: above(1), x: {x: real | x >= 1}, n: nat,
            y: {y | y < p AND x = p ^ n * y}):
      p ^ n <= x AND y = log_nat(x, p)`2 AND n = log_nat(x, p)`1 IMPLIES
       p /= 0 OR (n + 1) >= 0;


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 114 0 117 999
body:
  % Subtype TCC generated (at line 33, column 33) for  na
      % expected type  {i: int | p /= 0 OR i >= 0}
  log_nat_itaux_TCC1: OBLIGATION
    FORALL (na, p, ya: {x: real | x >= 1}): p /= 0 OR na >= 0;


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 119 0 124 999
body:
  % Subtype TCC generated (at line 37, column 12) for  floor(ya)
      % expected type  naturalnumber
  log_nat_itaux_TCC2: OBLIGATION
    FORALL (x: {x: real | x >= 1}, p: above(1), na: nat,
            (ya: {x: real | x >= 1} | x = p ^ na * ya)):
      floor(ya) >= 0;


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 126 0 131 999
body:
  % Subtype TCC generated (at line 34, column 25) for  ya
      % expected type  {y | y < p AND x = p ^ na * y}
  log_nat_itaux_TCC3: OBLIGATION
    FORALL (x: {x: real | x >= 1}, p: above(1), na: nat,
            (ya: {x: real | x >= 1} | x = p ^ na * ya)):
      ya < p IMPLIES ya < p AND x = p ^ na * ya;


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 133 0 138 999
body:
  % Subtype TCC generated (at line 35, column 32) for  ya / p
      % expected type  {ya | x = (p ^ (1 + na)) * ya}
  log_nat_itaux_TCC4: OBLIGATION
    FORALL (x: {x: real | x >= 1}, p: above(1), na: nat,
            (ya: {x: real | x >= 1} | x = p ^ na * ya)):
      NOT ya < p IMPLIES ya / p >= 1 AND x = (p ^ (1 + na)) * (ya / p);


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 140 0 145 999
body:
  % Termination TCC generated (at line 35, column 9) for
      % log_nat_itaux(x, p, na + 1, ya / p)
  log_nat_itaux_TCC5: OBLIGATION
    FORALL (x: {x: real | x >= 1}, p: above(1), na: nat,
            (ya: {x: real | x >= 1} | x = p ^ na * ya)):
      NOT ya < p IMPLIES floor(ya / p) < floor(ya);


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 147 0 150 999
body:
  % Subtype TCC generated (at line 40, column 24) for  x
      % expected type  {ya | x = p ^ 0 * ya}
  log_nat_it_TCC1: OBLIGATION
    FORALL (x: {x: real | x >= 1}, p: above(1)): x = p ^ 0 * x;


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 152 0 162 999
body:
  % Subtype TCC generated (at line 49, column 20) for  n
      % expected type  {k: int |
                     %          xp <= 2 ^ k AND
                     %           (FORALL (i: int): i < k IMPLIES 2 ^ i < xp)}
  least_pow_2_ge_TCC1: OBLIGATION
    FORALL (xp: posreal):
      xp >= 1 IMPLIES
       (FORALL (n: nat, y: {y | y < 2 AND xp = 2 ^ n * y}):
          y = 1 AND y = log_nat_it(xp, 2)`2 AND n = log_nat_it(xp, 2)`1
           IMPLIES
           xp <= 2 ^ n AND (FORALL (i: int): i < n IMPLIES 2 ^ i < xp));


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 164 0 175 999
body:
  % Subtype TCC generated (at line 50, column 6) for  n + 1
      % expected type  {k: int |
                     %          xp <= 2 ^ k AND
                     %           (FORALL (i: int): i < k IMPLIES 2 ^ i < xp)}
  least_pow_2_ge_TCC2: OBLIGATION
    FORALL (xp: posreal):
      xp >= 1 IMPLIES
       (FORALL (n: nat, y: {y | y < 2 AND xp = 2 ^ n * y}):
          NOT y = 1 AND y = log_nat_it(xp, 2)`2 AND n = log_nat_it(xp, 2)`1
           IMPLIES
           xp <= 2 ^ (n + 1) AND
            (FORALL (i: int): i < n + 1 IMPLIES 2 ^ i < xp));


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 177 0 184 999
body:
  % Subtype TCC generated (at line 51, column 22) for  0
      % expected type  {k: int |
                     %          xp <= 2 ^ k AND
                     %           (FORALL (i: int): i < k IMPLIES 2 ^ i < xp)}
  least_pow_2_ge_TCC3: OBLIGATION
    FORALL (xp: posreal):
      xp > 1 / 2 AND NOT xp >= 1 IMPLIES
       xp <= 2 ^ 0 AND (FORALL (i: int): i < 0 IMPLIES 2 ^ i < xp);


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 186 0 189 999
body:
  % Subtype TCC generated (at line 52, column 28) for  1 / xp
      % expected type  {x: real | x >= 1}
  least_pow_2_ge_TCC4: OBLIGATION
    FORALL (xp: posreal): NOT xp > 1 / 2 AND NOT xp >= 1 IMPLIES 1 / xp >= 1;


decl_type: tcc
theory: log_nat
library: reals
signature: nil
location: 191 0 200 999
body:
  % Subtype TCC generated (at line 52, column 41) for  -n
      % expected type  {k: int |
                     %          xp <= 2 ^ k AND
                     %           (FORALL (i: int): i < k IMPLIES 2 ^ i < xp)}
  least_pow_2_ge_TCC5: OBLIGATION
    FORALL (xp: posreal):
      NOT xp > 1 / 2 AND NOT xp >= 1 IMPLIES
       (FORALL (n: nat):
          n = log_nat_it(1 / xp, 2)`1 IMPLIES
           xp <= 2 ^ -n AND (FORALL (i: int): i < -n IMPLIES 2 ^ i < xp));


decl_type: formula
theory: sqrt_approx
library: reals
signature: nil
location: 34 2 37 64
body:
    sqrt_newton_aux_NOT_increasing: LEMMA 
      EXISTS (x1,x2:nnreal,(y1:nnreal|x1<sq(y1)),(y2:nnreal|x2<sq(y2)),eps): 
        x1<x2 AND y1<y2 IMPLIES
          sqrt_newton_aux(x1,y1,eps) >= sqrt_newton_aux(x2,y2,eps)


decl_type: formula
theory: sqrt_approx
library: reals
signature: nil
location: 66 2 68 34
body:
    sqrt_old_bounds      : LEMMA
          sqrt_lb_old(x,n) <= sqrt(x) AND
          sqrt(x) < sqrt_ub_old(x,n)


decl_type: formula
theory: sqrt_approx
library: reals
signature: nil
location: 79 2 80 63
body:
    sqrt_approx_fast_increasing: LEMMA 
        x<=y IMPLIES sqrt_approx_fast(x,n)<=sqrt_approx_fast(y,n)


decl_type: function
theory: sqrt_approx
library: reals
signature:
  [d: [x: nnreal, {y | x < sq(y)}, posreal] ->
  {z | d`1 < sq(z) AND sq(z) - d`1 < d`3}]

location: 27 2 32 75
body:
    sqrt_newton_aux(x,(y | x < sq(y)),eps) :  
      recursive {z | x < sq(z) AND sq(z)-x < eps} =
      if sq(y)-x < eps then y  
      else sqrt_newton_aux(x,((y+x/y)/2),eps) 
      endif
      measure if sq(y)-x < eps then 0 else 1+log_nat((sq(y)-x)/eps,4)`1 endif


decl_type: function
theory: sqrt_approx
library: reals
signature: [d: [nnreal, nat] -> {z | abs(sq(z) - d`1) < 10 ^ (-d`2) / 2}]
location: 53 2 58 32
body:
    sqrt_approx(x,n) : {z | abs(sq(z)-x) < 10^(-n)/2} =
      LET eps = 10^(-n),
          N = 2*10^n,
          k = floor(x*N),
          xx = k/N
      IN sqrt_newton(xx,10^(-n)/2)


decl_type: function
theory: sqrt_approx
library: reals
signature: [d: [nnreal, nat] -> {z | abs(sq(z) - d`1) < 10 ^ (-d`2) / 2}]
location: 70 2 77 9
body:
    sqrt_approx_fast(x,n) : {z | abs(sq(z)-x) < 10^(-n)/2} =
      IF x<=64 THEN LET sa = sqrt_approx(x,n) IN min(sa,8) ELSE
        LET twoexp = log_nat(x,4)`1,
            newx = x/(4^twoexp),
            exp2err = floor(twoexp/3)+1,
            newn = n + 2*exp2err
        IN LET sa = (2^twoexp)*min(sqrt_approx(newx,newn),2) IN max(sa,8)
      ENDIF


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 96 0 100 999
body:
  % Subtype TCC generated (at line 32, column 51) for  (sq(y) - x) / eps
      % expected type  {x: real | x >= 1}
  sqrt_newton_aux_TCC1: OBLIGATION
    FORALL (x: nnreal, (y: nnreal | x < sq(y)), eps: posreal):
      NOT sq(y) - x < eps IMPLIES (sq(y) - x) / eps >= 1;


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 102 0 107 999
body:
  % Subtype TCC generated (at line 32, column 51) for
      % (sq(z1`2) - z1`1) / z1`3
      % expected type  {x: real | x >= 1}
  sqrt_newton_aux_TCC2: OBLIGATION
    FORALL (z1: [x: nnreal, {y | x < sq(y)}, posreal]):
      NOT sq(z1`2) - z1`1 < z1`3 IMPLIES (sq(z1`2) - z1`1) / z1`3 >= 1;


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 109 0 113 999
body:
  % Subtype TCC generated (at line 29, column 26) for  y
      % expected type  {z | x < sq(z) AND sq(z) - x < eps}
  sqrt_newton_aux_TCC3: OBLIGATION
    FORALL (x: nnreal, (y: nnreal | x < sq(y)), eps: posreal):
      sq(y) - x < eps IMPLIES y > 0 AND x < sq(y) AND sq(y) - x < eps;


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 115 0 119 999
body:
  % Subtype TCC generated (at line 30, column 33) for  y
      % expected type  nznum
  sqrt_newton_aux_TCC4: OBLIGATION
    FORALL (x: nnreal, (y: nnreal | x < sq(y)), eps: posreal):
      NOT sq(y) - x < eps IMPLIES y /= 0;


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 121 0 126 999
body:
  % Subtype TCC generated (at line 30, column 28) for  ((y + x / y) / 2)
      % expected type  {y | x < sq(y)}
  sqrt_newton_aux_TCC5: OBLIGATION
    FORALL (x: nnreal, (y: nnreal | x < sq(y)), eps: posreal):
      NOT sq(y) - x < eps IMPLIES
       ((y + x / y) / 2) >= 0 AND x < sq(((y + x / y) / 2));


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 128 0 139 999
body:
  % Termination TCC generated (at line 30, column 9) for
      % sqrt_newton_aux(x, ((y + x / y) / 2), eps)
  sqrt_newton_aux_TCC6: OBLIGATION
    FORALL (x: nnreal, (y: nnreal | x < sq(y)), eps: posreal):
      NOT sq(y) - x < eps IMPLIES
       IF sq(((y + x / y) / 2)) - x < eps THEN 0
       ELSE 1 + log_nat((sq(((y + x / y) / 2)) - x) / eps, 4)`1
       ENDIF
        <
        IF sq(y) - x < eps THEN 0
        ELSE 1 + log_nat((sq(y) - x) / eps, 4)`1
        ENDIF;


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 141 0 143 999
body:
  % Subtype TCC generated (at line 40, column 22) for  x + 1
      % expected type  {y | x < sq(y)}
  sqrt_newton_TCC1: OBLIGATION FORALL (x: nnreal): x < sq(x + 1);


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 145 0 154 999
body:
  % Subtype TCC generated (at line 58, column 19) for  xx
      % expected type  nnreal
  sqrt_approx_TCC1: OBLIGATION
    FORALL (x: nnreal, n: nat, eps: posrat):
      eps = 10 ^ (-n) IMPLIES
       (FORALL (N: posint):
          N = 2 * 10 ^ n IMPLIES
           (FORALL (k: {i | i <= x * N & x * N < 1 + i}):
              k = floor(x * N) IMPLIES
               (FORALL (xx: rat): xx = k / N IMPLIES xx >= 0)));


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 156 0 169 999
body:
  % Subtype TCC generated (at line 58, column 7) for
      % sqrt_newton(xx, 10 ^ (-n) / 2)
      % expected type  {z | abs(sq(z) - x) < 10 ^ (-n) / 2}
  sqrt_approx_TCC2: OBLIGATION
    FORALL (x: nnreal, n: nat, eps: posrat):
      eps = 10 ^ (-n) IMPLIES
       (FORALL (N: posint):
          N = 2 * 10 ^ n IMPLIES
           (FORALL (k: {i | i <= x * N & x * N < 1 + i}):
              k = floor(x * N) IMPLIES
               (FORALL (xx: rat):
                  xx = k / N IMPLIES
                   abs(sq(sqrt_newton(xx, 10 ^ (-n) / 2)) - x) <
                    10 ^ (-n) / 2)));


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 171 0 178 999
body:
  % Subtype TCC generated (at line 71, column 47) for  min(sa, 8)
      % expected type  {z | abs(sq(z) - x) < 10 ^ (-n) / 2}
  sqrt_approx_fast_TCC1: OBLIGATION
    FORALL (x: nnreal, n: nat):
      x <= 64 IMPLIES
       (FORALL (sa: {z | abs(sq(z) - x) < 10 ^ (-n) / 2}):
          sa = sqrt_approx(x, n) IMPLIES
           abs(sq(min(sa, 8)) - x) < 10 ^ (-n) / 2);


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 180 0 183 999
body:
  % Subtype TCC generated (at line 72, column 27) for  x
      % expected type  {x: real | x >= 1}
  sqrt_approx_fast_TCC2: OBLIGATION
    FORALL (x: nnreal): NOT x <= 64 IMPLIES x >= 1;


decl_type: tcc
theory: sqrt_approx
library: reals
signature: nil
location: 185 0 201 999
body:
  % Subtype TCC generated (at line 76, column 62) for  max(sa, 8)
      % expected type  {z | abs(sq(z) - x) < 10 ^ (-n) / 2}
  sqrt_approx_fast_TCC3: OBLIGATION
    FORALL (x: nnreal, n: nat):
      NOT x <= 64 IMPLIES
       (FORALL (twoexp: nat):
          twoexp = log_nat(x, 4)`1 IMPLIES
           (FORALL (newx: nnreal):
              newx = x / (4 ^ twoexp) IMPLIES
               (FORALL (exp2err: posint):
                  exp2err = floor(twoexp / 3) + 1 IMPLIES
                   (FORALL (newn: posint):
                      newn = n + 2 * exp2err IMPLIES
                       (FORALL (sa: posreal):
                          sa = (2 ^ twoexp) * min(sqrt_approx(newx, newn), 2)
                           IMPLIES
                           abs(sq(max(sa, 8)) - x) < 10 ^ (-n) / 2)))));


decl_type: function
theory: sign3
library: reals
signature: [real -> Sign3]
location: 12 2 14 38
body:
    sign3(x:real): Sign3 = IF x = 0 THEN 0
                           ELSIF x > 0 THEN 1
                           ELSE -1 ENDIF


decl_type: tcc
theory: sign3
library: reals
signature: nil
location: 92 0 96 999
body:
  % Judgement subtype TCC generated (at line 20, column 29) for  eps1 * eps2
      % expected type  Sign3
  sign3_mult_clos: OBLIGATION
    FORALL (eps1, eps2):
      eps1 * eps2 = 1 OR eps1 * eps2 = -1 OR eps1 * eps2 = 0;


decl_type: tcc
theory: sign3
library: reals
signature: nil
location: 98 0 103 999
body:
  % Judgement subtype TCC generated (at line 22, column 30) for  eps / epsnz
      % expected type  Sign3
  sign3_div_clos: OBLIGATION
    FORALL (eps, epsnz):
      integer_pred(eps / epsnz) AND
       (eps / epsnz = 1 OR eps / epsnz = -1 OR eps / epsnz = 0);


decl_type: tcc
theory: sign3
library: reals
signature: nil
location: 105 0 108 999
body:
  % Judgement subtype TCC generated (at line 24, column 30) for  -eps1
      % expected type  Sign3
  sign3_neg_clos: OBLIGATION
    FORALL (eps1): -eps1 = 1 OR -eps1 = -1 OR -eps1 = 0;


decl_type: tcc
theory: sign3
library: reals
signature: nil
location: 110 0 116 999
body:
  % Judgement subtype TCC generated (at line 26, column 31) for  sq(eps1)
      % expected type  Sign3
  sign3_sq_clos: OBLIGATION
    FORALL (eps1):
      rational_pred(sq(eps1)) AND
       integer_pred(sq(eps1)) AND
        (sq(eps1) = 1 OR sq(eps1) = -1 OR sq(eps1) = 0);


decl_type: tcc
theory: sign3
library: reals
signature: nil
location: 118 0 120 999
body:
  % Subtype TCC generated (at line 66, column 47) for  y
      % expected type  nznum
  sign3_div_pos2_TCC1: OBLIGATION FORALL (y: real): y > 0 IMPLIES y /= 0;


decl_type: tcc
theory: sign3
library: reals
signature: nil
location: 122 0 124 999
body:
  % Subtype TCC generated (at line 72, column 47) for  y
      % expected type  nznum
  sign3_div_neg2_TCC1: OBLIGATION FORALL (y: real): y < 0 IMPLIES y /= 0;


decl_type: tcc
theory: sign3
library: reals
signature: nil
location: 126 0 129 999
body:
  % Subtype TCC generated (at line 75, column 28) for  sign3(y)
      % expected type  nznum
  sign3_div_mult_TCC1: OBLIGATION
    FORALL (y: real): y /= 0 IMPLIES sign3(y) /= 0;


decl_type: formula
theory: real_facts
library: reals
signature: nil
location: 11 2 12 73
body:
    bounded?_lem  : LEMMA bounded?(S) IFF
                            EXISTS (B: real): FORALL (x: (S)):  abs(x) <= B


decl_type: formula
theory: real_facts
library: reals
signature: nil
location: 22 2 24 50
body:
    archimedean3 : THEOREM
          FORALL (x : nonneg_real) :
             (FORALL (a : posnat) : x <= 1/a) implies x = 0


decl_type: tcc
theory: real_facts
library: reals
signature: nil
location: 78 0 84 999
body:
  % Subtype TCC generated (at line 52, column 43) for  {x | a <= x AND x <= b}
      % expected type  SA: (bounded_above?)
  lub_closed_intv_TCC1: OBLIGATION
    FORALL (a, b: real):
      a < b IMPLIES
       nonempty?[real]({x | a <= x AND x <= b}) AND
        bounded_above?({x | a <= x AND x <= b});


decl_type: tcc
theory: real_facts
library: reals
signature: nil
location: 86 0 92 999
body:
  % Subtype TCC generated (at line 63, column 43) for  {x | a <= x AND x <= b}
      % expected type  SB: (bounded_below?)
  glb_closed_intv_TCC1: OBLIGATION
    FORALL (a, b: real):
      a < b IMPLIES
       nonempty?[real]({x | a <= x AND x <= b}) AND
        bounded_below?({x | a <= x AND x <= b});


decl_type: function
theory: bound_defs
library: reals
signature: [pred[[T, T]] -> [[T, pred[S]] -> bool]]
location: 30 2 32 64
body:
    least_upper_bound(<)(x, pe): bool =
      upper_bound(<)(x, pe) AND
        (FORALL y: upper_bound(<)(y, pe) IMPLIES (x < y OR x = y))


decl_type: function
theory: bound_defs
library: reals
signature: [pred[[T, T]] -> [[T, pred[S]] -> bool]]
location: 34 2 36 65
body:
    greatest_lower_bound(<)(x, pe): bool =
      lower_bound(<)(x, pe) AND
         (FORALL y: lower_bound(<)(y, pe) IMPLIES (y < x OR x = y))


decl_type: formula
theory: reals_complete_more
library: reals
signature: nil
location: 6 2 9 56
body:
    real_complete2: LEMMA   % this could replace real_complete in prelude
      (FORALL (S: (nonempty?[T])):
        (EXISTS (y: real): upper_bound(<=)(y, S)) IMPLIES
          (EXISTS (x: real): least_upper_bound(<=)(x, S)))


decl_type: formula
theory: reals_complete_more
library: reals
signature: nil
location: 11 2 14 59
body:
    real_lower_complete2: LEMMA % this could replace real_complete in prelude
      (FORALL (S: (nonempty?[T])):
        (EXISTS (y : real): lower_bound(<=)(y, S)) IMPLIES 
          (EXISTS (x: real): greatest_lower_bound(<=)(x, S)))


decl_type: tcc
theory: bounded_reals
library: reals
signature: nil
location: 93 0 98 999
body:
  % Existence TCC generated (at line 47, column 2) for
      % sup(Su): {x | least_upper_bound(<=)(x, Su)}
  sup_TCC1: OBLIGATION
    EXISTS (x1:
              [Su: sup_set -> {x | least_upper_bound[real, T](<=)(x, Su)}]):
      TRUE;


decl_type: tcc
theory: bounded_reals
library: reals
signature: nil
location: 100 0 102 999
body:
  % Subtype TCC generated (at line 56, column 14) for  sup(W)
      % expected type  T
  max_TCC1: OBLIGATION FORALL (W: max_set): T_pred(sup(W));


decl_type: tcc
theory: bounded_reals
library: reals
signature: nil
location: 104 0 110 999
body:
  % Existence TCC generated (at line 71, column 2) for
      % inf(Sl): {x | greatest_lower_bound(<=)(x, Sl)}
  inf_TCC1: OBLIGATION
    EXISTS (x1:
              [Sl: inf_set ->
                 {x | greatest_lower_bound[real, T](<=)(x, Sl)}]):
      TRUE;


decl_type: tcc
theory: bounded_reals
library: reals
signature: nil
location: 112 0 114 999
body:
  % Subtype TCC generated (at line 80, column 14) for  inf(X)
      % expected type  T
  min_TCC1: OBLIGATION FORALL (X: min_set): T_pred(inf(X));


decl_type: formula
theory: real_sets
library: reals
signature: nil
location: 28 2 29 56
body:
    upper_bound_subset   : LEMMA subset?(S1, S2) AND upper_bound(<=)(a, S2) 
                                   IMPLIES upper_bound(<=)(a, S1)


decl_type: formula
theory: real_sets
library: reals
signature: nil
location: 34 2 35 78
body:
    adherence_sup        : THEOREM (FORALL (epsilon: posreal):
                                       (EXISTS (y: (U)) : sup(U) - epsilon < y))


decl_type: formula
theory: real_sets
library: reals
signature: nil
location: 44 2 45 57
body:
    lower_bound_subset   : LEMMA subset?(S1, S2) and lower_bound(<=)(a, S2) 
                                    IMPLIES lower_bound(<=)(a, S1)


decl_type: formula
theory: real_sets
library: reals
signature: nil
location: 50 2 51 78
body:
    adherence_inf        : THEOREM (FORALL (epsilon: posreal):
                                       (EXISTS (y: (V)) : y < inf(V) + epsilon))


decl_type: formula
theory: real_fun_preds
library: reals
signature: nil
location: 33 2 34 75
body:
    bounded?_lem          : LEMMA bounded?(f) IFF
                                 EXISTS (B: nnreal): FORALL x: abs(f(x)) <= B


decl_type: tcc
theory: real_fun_ops
library: reals
signature: nil
location: 43 0 46 999
body:
  % Subtype TCC generated (at line 26, column 49) for  n
      % expected type  {i: int | f(t) /= 0 OR i >= 0}
  caret_TCC1: OBLIGATION
    FORALL (f: [T -> real], n: nat, t: T): f(t) /= 0 OR n >= 0;


decl_type: function
theory: real_fun_ops_aux
library: reals
signature: [[sequence[[T -> real]], nat] -> [T -> real]]
location: 29 2 30 70
body:
    maximum(F,n): RECURSIVE [T->real]
      = IF n = 0 THEN F(0) ELSE max(F(n),maximum(F,n-1)) ENDIF MEASURE n


decl_type: function
theory: real_fun_ops_aux
library: reals
signature: [[sequence[[T -> real]], nat] -> [T -> real]]
location: 31 2 32 70
body:
    minimum(F,n): RECURSIVE [T->real]
      = IF n = 0 THEN F(0) ELSE min(F(n),minimum(F,n-1)) ENDIF MEASURE n


decl_type: tcc
theory: real_fun_ops_aux
library: reals
signature: nil
location: 59 0 61 999
body:
  % Subtype TCC generated (at line 26, column 37) for  -min(f(x), 0)
      % expected type  nnreal
  minus_TCC1: OBLIGATION FORALL (f: [T -> real], x): -min(f(x), 0) >= 0;


decl_type: tcc
theory: real_fun_ops_aux
library: reals
signature: nil
location: 63 0 65 999
body:
  % Subtype TCC generated (at line 27, column 37) for  max(f(x), 0)
      % expected type  nnreal
  plus_TCC1: OBLIGATION FORALL (f: [T -> real], x): max(f(x), 0) >= 0;


decl_type: tcc
theory: real_fun_ops_aux
library: reals
signature: nil
location: 67 0 69 999
body:
  % Subtype TCC generated (at line 30, column 49) for  n - 1
      % expected type  nat
  maximum_TCC1: OBLIGATION FORALL (n: nat): NOT n = 0 IMPLIES n - 1 >= 0;


decl_type: tcc
theory: real_fun_ops_aux
library: reals
signature: nil
location: 71 0 72 999
body:
  % Termination TCC generated (at line 30, column 39) for  maximum(F, n - 1)
  maximum_TCC2: OBLIGATION FORALL (n: nat): NOT n = 0 IMPLIES n - 1 < n;


decl_type: tcc
theory: real_order_ep
library: reals
signature: nil
location: 23 0 27 999
body:
  % Judgement subtype TCC generated (at line 12, column 4) for
      % real_ord_ep(epsil)
      % expected type  (well_founded?[real])
  real_ord_ep_well_founded: OBLIGATION
    FORALL (epsil): well_founded?[real](real_ord_ep(epsil));


decl_type: tcc
theory: real_orders
library: reals
signature: nil
location: 74 0 76 999
body:
  % Judgement subtype TCC generated (at line 10, column 30) for  <=
      % expected type  RealOrder
  le_realorder: OBLIGATION realorder?(<=);


decl_type: tcc
theory: real_orders
library: reals
signature: nil
location: 78 0 80 999
body:
  % Judgement subtype TCC generated (at line 11, column 30) for  <
      % expected type  RealOrder
  lt_realorder: OBLIGATION realorder?(<);


decl_type: tcc
theory: real_orders
library: reals
signature: nil
location: 82 0 84 999
body:
  % Judgement subtype TCC generated (at line 12, column 30) for  >=
      % expected type  RealOrder
  ge_realorder: OBLIGATION realorder?(>=);


decl_type: tcc
theory: real_orders
library: reals
signature: nil
location: 86 0 88 999
body:
  % Judgement subtype TCC generated (at line 13, column 30) for  >
      % expected type  RealOrder
  gt_realorder: OBLIGATION realorder?(>);


decl_type: tcc
theory: real_orders
library: reals
signature: nil
location: 90 0 93 999
body:
  % Judgement subtype TCC generated (at line 31, column 4) for
      % neg_rel(relreal)
      % expected type  RealOrder
  neg_rel_order: OBLIGATION FORALL (relreal): realorder?(neg_rel(relreal));


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 67 2 69 53
body:
    root_scalar : LEMMA
      discr(a,b,c) >= 0 IMPLIES
        root(k*a,k*b,k*c,eps) = root(a,b,c,sign(k)*eps)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 98 2 101 27
body:
    root_eq_0 : LEMMA
      discr(a,b,c) >= 0 IMPLIES
        (c = 0 AND (b = 0 OR eps = sign(b)) IFF
         root(a,b,c,eps) = 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 114 2 118 51
body:
    roots_eq_0 : LEMMA
      discr(a,b,c) >= 0 IMPLIES
        (b = 0 AND a*c >= 0 
        IFF
        root(a,b,c,-eps) = 0 AND root(a,b,c,eps) = 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 120 2 123 40
body:
    root_inv : LEMMA
      discr(a,b,c) >= 0 AND
      c /= 0 IMPLIES
      root(a,b,c,eps) = 1/root(c,b,a,-eps)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 133 2 139 25
body:
    roots_le_ge_0 : LEMMA
     discr(a,b,c) >= 0 IMPLIES
     (a*c <= 0 AND
      (c=0 AND b=0 OR eps=sign(a))
      IFF
      root(a,b,c,-eps) <= 0 AND
      root(a,b,c,eps) >= 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 141 2 146 24
body:
    roots_lt_gt_0 : LEMMA
     discr(a,b,c) >= 0 IMPLIES
     (a*c < 0 AND eps=sign(a)
      IFF
      root(a,b,c,-eps) < 0 AND
      root(a,b,c,eps) > 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 148 2 152 35
body:
    sign_ab_roots_ge_0 : LEMMA
      discr(a,b,c) >= 0 AND
      a*c >= 0 
      IMPLIES
      -sign(a*b)*root(a,b,c,eps) >= 0


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 154 2 160 28
body:
    roots_ge_0 : LEMMA
      discr(a,b,c) >= 0 
      IMPLIES
        (a*c >= 0 AND a*b <= 0 
         IFF
         root(a,b,c,-eps) >= 0 AND
         root(a,b,c,eps) >= 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 162 2 167 26
body:
    roots_le_0 : LEMMA
      discr(a,b,c) >= 0 IMPLIES
      (a*c >= 0 AND a*b >= 0 
       IFF
       root(a,b,c,-eps) <= 0 AND
       root(a,b,c,eps) <= 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 169 2 173 34
body:
    sign_ab_roots_gt_0 : LEMMA
      discr(a,b,c) >= 0 AND
      a*c > 0 
      IMPLIES
      -sign(a*b)*root(a,b,c,eps) > 0


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 175 2 180 25
body:
    roots_gt_0 : LEMMA
      discr(a,b,c) >= 0 IMPLIES
      (a*c > 0 AND a*b <= 0 
       IFF
       root(a,b,c,-eps) > 0 AND
       root(a,b,c,eps) > 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 182 2 187 25
body:
    roots_lt_0 : LEMMA
      discr(a,b,c) >= 0 IMPLIES
      (a*c > 0 AND a*b >= 0 
       IFF
       root(a,b,c,-eps) < 0 AND
       root(a,b,c,eps) < 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 189 2 194 25
body:
    root_gt_0 : LEMMA
      discr(a,b,c) >= 0 IMPLIES
      ((a*c > 0 AND a*b <= 0) OR
       (a*c <= 0 AND eps=sign(a) AND (c /= 0 OR a*b < 0))
       IFF
       root(a,b,c,eps) > 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 196 2 201 26
body:
    root_ge_0 : LEMMA
      discr(a,b,c) >= 0 IMPLIES
      ((a*c >= 0 AND a*b <= 0) OR
       (a*c <= 0 AND eps = sign(a))
       IFF
       root(a,b,c,eps) >= 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 203 2 208 25
body:
    root_lt_0 : LEMMA
      discr(a,b,c) >= 0 IMPLIES
      ((a*c > 0 AND a*b >= 0) OR
       (a*c <= 0 AND eps=-sign(a) AND (c /= 0 OR a*b > 0))
       IFF
       root(a,b,c,eps) < 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 210 2 215 26
body:
    root_le_0 : LEMMA
      discr(a,b,c) >= 0 IMPLIES
      ((a*c >= 0 AND a*b >= 0) OR
       (a*c <= 0 AND eps = -sign(a))
       IFF
       root(a,b,c,eps) <= 0)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 221 2 225 22
body:
    quadratic_eq_0 : LEMMA
      (a*sq(x) + b*x + c = 0 IFF
        discr(a,b,c) >= 0 AND
        (x = x1(a,b,c) OR
         x = x2(a,b,c)))


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 231 2 234 43
body:
    not_solvable_quadratic : LEMMA     
      NOT discr(a,b,c) >= 0 =>
      ((FORALL(x) : a * sq(x) + b*x + c > 0) OR
       (FORALL(x) : a * sq(x) + b*x + c < 0))


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 236 2 241 35
body:
    quadratic_le_0 : LEMMA
      a*sq(x) + b*x + c <= 0 IFF
      ((discr(a,b,c) >= 0 AND 
        ((a > 0 AND x2(a,b,c) <= x AND x <= x1(a,b,c)) OR
         (a < 0 AND (x <= x1(a,b,c) OR x2(a,b,c) <= x)))) OR
       (discr(a,b,c) < 0 AND c <= 0))


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 243 2 249 34
body:
    quadratic_lt_0 : LEMMA
      a*sq(x) + b*x + c < 0 IFF
      ((discr(a,b,c) >= 0 AND   
        ((a > 0 AND  x2(a,b,c) < x AND x < x1(a,b,c)) OR
         (a < 0 AND ((x < x1(a,b,c) AND x < x2(a,b,c)) OR
                     (x1(a,b,c) < x AND x2(a,b,c) < x))))) OR
       (discr(a,b,c) < 0 AND c < 0))


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 251 2 256 35
body:
    quadratic_ge_0 : LEMMA
      a*sq(x) + b*x + c >= 0 IFF
      ((discr(a,b,c) >= 0 AND 
        ((a < 0 AND x1(a,b,c) <= x AND x <= x2(a,b,c)) OR
         (a > 0 AND (x <= x2(a,b,c) OR x1(a,b,c) <= x)))) OR
       (discr(a,b,c) < 0 AND c >= 0))


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 258 2 263 34
body:
    quadratic_gt_0 : LEMMA
      a*sq(x) + b*x + c > 0 IFF
      ((discr(a,b,c) >= 0 AND 
        ((a < 0 AND x1(a,b,c) < x AND x < x2(a,b,c)) OR
         (a > 0 AND (x < x2(a,b,c) OR x1(a,b,c) < x)))) OR
       (discr(a,b,c) < 0 AND c > 0))


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 274 2 277 79
body:
    quadratic_eq_0_full: THEOREM
      aa*sq(x) + b*x + c = 0 IFF
        aa = 0 AND b = 0 AND c = 0 OR
        solvable?(aa,b,c) AND (x = solution(aa,b,c,-1) OR x = solution(aa,b,c,1))


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 285 2 287 61
body:
    quad_eq_0 : THEOREM
      quadratic(a,b,c)(x) = 0 IFF
        discr(a,b,c) >= 0 AND EXISTS (eps): x = root(a,b,c,eps)


decl_type: formula
theory: quadratic
library: reals
signature: nil
location: 289 2 292 66
body:
    quad_eq_0_full: THEOREM
      quadratic(aa,b,c)(x) = 0 IFF
        aa = 0 AND b = 0 AND c = 0 OR
        solvable?(aa,b,c) AND EXISTS (eps): x = solution(aa,b,c,eps) 


decl_type: function
theory: quadratic
library: reals
signature:
  [[a: nonzero_real, b: real, {c: real | discr(a, b, c) >= 0},
  Sign] ->
  real]

location: 60 2 61 39
body:
    root(a:nonzero_real,b:real,c:real|discr(a,b,c)>=0,eps:Sign):real =
      (-b + eps*sqrt(discr(a,b,c)))/(2*a)


decl_type: function
theory: quadratic
library: reals
signature: [[aa: real, b: real, {c | solvable?(aa, b, c)}, Sign] -> real]
location: 271 2 272 51
body:
    solution(aa,b,(c | solvable?(aa,b,c)), eps: Sign): real =
      IF aa = 0 THEN -c/b ELSE root(aa,b,c,eps) ENDIF


decl_type: tcc
theory: quadratic
library: reals
signature: nil
location: 299 0 304 999
body:
  % Subtype TCC generated (at line 61, column 19) for  discr(a, b, c)
      % expected type  nnx: nonneg_real
  root_TCC1: OBLIGATION
    FORALL (a: nonzero_real, b: real, c: real | discr(a, b, c) >= 0,
            eps: Sign):
      discr(a, b, c) >= 0;


decl_type: tcc
theory: quadratic
library: reals
signature: nil
location: 306 0 310 999
body:
  % Subtype TCC generated (at line 65, column 35) for  -c
      % expected type  {c: real | discr(-a, -b, c) >= 0}
  root_symm_TCC1: OBLIGATION
    FORALL (a: nonzero_real, b, c: real):
      discr(a, b, c) >= 0 IMPLIES discr(-a, -b, -c) >= 0;


decl_type: tcc
theory: quadratic
library: reals
signature: nil
location: 312 0 316 999
body:
  % Subtype TCC generated (at line 69, column 19) for  k * c
      % expected type  {c: real | discr(k * a, k * b, c) >= 0}
  root_scalar_TCC1: OBLIGATION
    FORALL (a: nonzero_real, b, c: real, k: nzreal):
      discr(a, b, c) >= 0 IMPLIES discr(k * a, k * b, k * c) >= 0;


decl_type: tcc
theory: quadratic
library: reals
signature: nil
location: 318 0 322 999
body:
  % Subtype TCC generated (at line 123, column 33) for  a
      % expected type  {c_1: real | discr(c, b, c_1) >= 0}
  root_inv_TCC1: OBLIGATION
    FORALL (a: nonzero_real, b, c: real):
      c /= 0 AND discr(a, b, c) >= 0 IMPLIES discr(c, b, a) >= 0;


decl_type: tcc
theory: quadratic
library: reals
signature: nil
location: 324 0 328 999
body:
  % Subtype TCC generated (at line 123, column 24) for  root(c, b, a, -eps)
      % expected type  nznum
  root_inv_TCC2: OBLIGATION
    FORALL (a: nonzero_real, b, c: real, eps: Sign):
      c /= 0 AND discr(a, b, c) >= 0 IMPLIES root(c, b, a, -eps) /= 0;


decl_type: tcc
theory: quadratic
library: reals
signature: nil
location: 330 0 334 999
body:
  % Subtype TCC generated (at line 131, column 13) for  c
      % expected type  {c: real | discr(a, b, c) >= 0}
  root_lt_TCC1: OBLIGATION
    FORALL (a: nonzero_real, b, c: real):
      discr(a, b, c) > 0 IMPLIES discr(a, b, c) >= 0;


decl_type: tcc
theory: quadratic
library: reals
signature: nil
location: 336 0 340 999
body:
  % Subtype TCC generated (at line 272, column 22) for  b
      % expected type  nznum
  solution_TCC1: OBLIGATION
    FORALL (aa: real, b: real, (c: real | solvable?(aa, b, c)), eps: Sign):
      aa = 0 IMPLIES b /= 0;


decl_type: tcc
theory: quadratic
library: reals
signature: nil
location: 342 0 346 999
body:
  % Subtype TCC generated (at line 272, column 34) for  aa
      % expected type  nonzero_real
  solution_TCC2: OBLIGATION
    FORALL (aa: real, b: real, (c: real | solvable?(aa, b, c)), eps: Sign):
      NOT aa = 0 IMPLIES aa /= 0;


decl_type: tcc
theory: quadratic
library: reals
signature: nil
location: 348 0 352 999
body:
  % Subtype TCC generated (at line 272, column 39) for  c
      % expected type  {c: real | discr(aa, b, c) >= 0}
  solution_TCC3: OBLIGATION
    FORALL (aa: real, b: real, (c: real | solvable?(aa, b, c)), eps: Sign):
      NOT aa = 0 IMPLIES discr(aa, b, c) >= 0;


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 30 3 31 62
body:
     composition_of_convex: LEMMA (FORALL (x,y): x<=y IMPLIES g(x)<=g(y))
                              AND convex?(f) AND convex?(g) IMPLIES convex?(g o f)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 33 3 34 44
body:
     max_of_convex: LEMMA convex?(f) AND convex?(g) IMPLIES 
                    convex?((LAMBDA (z): max(f(z),g(z))))


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 40 3 41 60
body:
     convex_function_right_lt: LEMMA convex?(f) AND A<C AND C<B
       IMPLIES f(B) >= ((B-A)/(C-A))*f(C) - ((B-C)/(C-A))*f(A)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 43 3 44 60
body:
     convex_function_left_lt: LEMMA convex?(f) AND A<C AND C<B
       IMPLIES f(A) >= ((B-A)/(B-C))*f(C) - ((C-A)/(B-C))*f(B)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 50 3 52 34
body:
     between_point_is_wtd_av: LEMMA FORALL (x,y,z: real): x<=z AND z<=y
                              IMPLIES (EXISTS (t: real): 0<=t AND t<=1
                                      AND z = t*x + (1-t)*y)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 56 3 58 34
body:
     between_point_is_wtd_av2: LEMMA FORALL (x,y,z: real): x<=z AND z<=y
                              IMPLIES (EXISTS (t: real): 0<=t AND t<=1
                                      AND z = (1-t)*x + t*y)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 62 3 65 28
body:
     convex_const_on_connected_min: LEMMA convex?(f) AND x < y AND
                  (FORALL (z): x<=z AND z<=y IMPLIES f(x) = f(z))
                  IMPLIES
                  (FORALL (w): f(x) <= f(w))


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 67 3 70 54
body:
     convex_min_is_connected: LEMMA convex?(f) AND x < y AND f(x) = f(y)
                              AND (FORALL (z): f(x) <= f(z))
                              IMPLIES
                              (FORALL (w): x<=w AND w<=y IMPLIES f(w) = f(x))


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 74 3 77 49
body:
     loc_convex_min_is_connected: LEMMA convex?(f) AND A<=x AND x<y AND y<=B AND
                  f(x) = f(y) AND
                  (FORALL (w): x<=w AND w<=y IMPLIES f(x) <= f(w)) IMPLIES
                  (FORALL (w): x<=w AND w<=y IMPLIES f(w) = f(x))


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 81 3 82 38
body:
     convex_btw_pt_left_lt: LEMMA convex?(f) AND A<x AND x<=B AND f(A)<=c
                               AND f(B)<c IMPLIES f(x) < c


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 84 3 85 39
body:
     convex_btw_pt_right_lt: LEMMA convex?(f) AND A<=x AND x<B AND f(A)<c
                               AND f(B)<=c IMPLIES f(x) < c


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 87 3 89 38
body:
     convex_wtd_av_lt: LEMMA convex?(f) AND f(x)<c AND f(y) < c
                       IMPLIES (FORALL (t): 0 <= t AND t <= 1 IMPLIES 
                       f(t*x + (1-t)*y) < c)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 94 3 96 18
body:
     convex_increasing: LEMMA convex?(f) AND (FORALL (y): f(y)>=f(x))
                        AND v>=x AND w>=v IMPLIES
                        f(w)>=f(v)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 98 3 100 18
body:
     convex_decreasing: LEMMA convex?(f) AND (FORALL (y): f(y)>=f(x))
                        AND w<=v AND v<=x IMPLIES
                        f(w)>=f(v)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 112 3 114 15
body:
     strictly_convex_unique_min: LEMMA strictly_convex?(f) AND (FORALL (z):
                                 f(x) <= f(z) AND f(y) <= f(z)) IMPLIES
                                 x = y


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 116 3 122 9
body:
     strictly_conv_uniq_intv_min: LEMMA strictly_convex?(f) AND 
                                  (A <= x AND x <= B) AND
                                  (A <= y AND y <= B) AND
                                  (FORALL (z): (A <= z and z <= B) IMPLIES
                                   f(x) <= f(z) AND f(y) <= f(z))
                                  IMPLIES
                                  x = y


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 127 3 129 38
body:
     composition_of_strictly_convex: LEMMA (FORALL (x,y): x<=y IMPLIES g(x)<g(y))
                              AND convex?(f) AND strictly_convex?(g) 
                              IMPLIES strictly_convex?(g o f)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 131 3 133 50
body:
     max_of_strictly_convex: LEMMA strictly_convex?(f) AND
                                  strictly_convex?(g) IMPLIES
                                  strictly_convex?((LAMBDA (z): max(f(z),g(z))))


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 135 3 136 38
body:
     sum_of_strictly_convex: LEMMA strictly_convex?(f) AND strictly_convex?(g) 
                             IMPLIES strictly_convex?(f+g)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 142 3 143 39
body:
     strictly_convex_btw_pt_lt: LEMMA strictly_convex?(f) AND A<x AND x<B AND f(A)<=c
                               AND f(B)<=c IMPLIES f(x) < c


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 154 3 156 28
body:
     quad_linear_max_convex: LEMMA LET maxfun = (LAMBDA (t): max(quadratic(a,b,c)(t),
                                                               abs(x + t*y)-H))
                                 IN convex?(maxfun)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 158 3 163 11
body:
     quad_linear_max_glob_min: LEMMA LET maxfun = (LAMBDA (t): max(quadratic(a,b,c)(t),
                                                               abs(x + t*y)-H))
                                 IN y /= 0 AND maxfun(w) = 0 AND maxfun(v) = 0 AND
                                    (FORALL (z): 0 <= maxfun(z)) 
                                    IMPLIES
                                    v = w


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 165 3 172 11
body:
     quad_linear_max_loc_min: LEMMA LET maxfun = (LAMBDA (t): max(quadratic(a,b,c)(t),
                                                               abs(x + t*y)-H))
                                 IN y /= 0 AND 
                                    (A <= w AND w <= B) AND (A <= v AND v <= B) AND
                                    maxfun(w) = 0 AND maxfun(v) = 0 AND
                                    (FORALL (z): (A <= z AND z <= B) IMPLIES 0 <= maxfun(z)) 
                                    IMPLIES
                                    v = w


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 177 3 178 40
body:
     power_of_convex: LEMMA convex?(f) AND (FORALL (x): f(x)>=0)
                  IMPLIES convex?(LAMBDA (x): f(x)^k)


decl_type: formula
theory: convex_functions
library: reals
signature: nil
location: 180 3 181 53
body:
     power_of_strictly_convex: LEMMA strictly_convex?(f) AND (FORALL (x): f(x)>=0)
                  IMPLIES strictly_convex?(LAMBDA (x): f(x)^(k+1))


decl_type: function
theory: convex_functions
library: reals
signature: [[real -> real] -> bool]
location: 25 3 26 55
body:
     convex?(f): bool = FORALL (x,y,t): 0 <= t and t <= 1 IMPLIES 
                      f(t*x + (1-t)*y) <= t*f(x) + (1-t)*f(y)


decl_type: function
theory: convex_functions
library: reals
signature: [[real -> real] -> bool]
location: 107 3 108 55
body:
     strictly_convex?(f): bool = FORALL (x,y,t): 0 < t and t < 1 and x /= y IMPLIES 
                          f(t*x + (1-t)*y) < t*f(x) + (1-t)*f(y)


decl_type: tcc
theory: convex_functions
library: reals
signature: nil
location: 191 0 195 999
body:
  % Subtype TCC generated (at line 41, column 29) for  (C - A)
      % expected type  nznum
  convex_function_right_lt_TCC1: OBLIGATION
    FORALL (A, B, C: real, f: [real -> real]):
      C < B AND A < C AND convex?(f) IMPLIES (C - A) /= 0;


decl_type: tcc
theory: convex_functions
library: reals
signature: nil
location: 197 0 201 999
body:
  % Subtype TCC generated (at line 44, column 29) for  (B - C)
      % expected type  nznum
  convex_function_left_lt_TCC1: OBLIGATION
    FORALL (A, B, C: real, f: [real -> real]):
      C < B AND A < C AND convex?(f) IMPLIES (B - C) /= 0;


decl_type: tcc
theory: convex_functions
library: reals
signature: nil
location: 203 0 208 999
body:
  % Subtype TCC generated (at line 178, column 38) for  k
      % expected type  {i: int | f(x) /= 0 OR i >= 0}
  power_of_convex_TCC1: OBLIGATION
    FORALL (f: [real -> real], k: nat):
      (FORALL (x): f(x) >= 0) AND convex?(f) IMPLIES
       (FORALL (x1: real): f(x1) /= 0 OR k >= 0);


decl_type: tcc
theory: convex_functions
library: reals
signature: nil
location: 210 0 215 999
body:
  % Subtype TCC generated (at line 181, column 48) for  (k + 1)
      % expected type  {i: int | f(x) /= 0 OR i >= 0}
  power_of_strictly_convex_TCC1: OBLIGATION
    FORALL (f: [real -> real], k: nat):
      (FORALL (x): f(x) >= 0) AND strictly_convex?(f) IMPLIES
       (FORALL (x1: real): f(x1) /= 0 OR (k + 1) >= 0);


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 27 2 28 50
body:
    quad_minmaxpt_delta: LEMMA LET f = quadratic(a,b,c), m = -b/(2*a) IN
                                 f(m + t) = f(m - t)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 30 2 31 61
body:
    quad_minmaxpt_midpt: LEMMA LET f = quadratic(a,b,c), m = -b/(2*a) IN
                                 x /= y AND f(x) = f(y) IMPLIES m = (x + y)/2


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 41 2 44 49
body:
    quad_min : LEMMA  LET f = quadratic(a,b,c),
                              minpt = -b/(2*a) IN
                            a > 0 IMPLIES
                               is_minimum?(minpt,f)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 46 2 49 65
body:
    quad_min_val : LEMMA LET f = quadratic(a,b,c),
                             minpt = -b/(2*a) IN
                              a > 0  
                                IMPLIES f(x) >= (4*a*c-sq(b))/(4*a)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 51 2 56 40
body:
    quad_min_mono_inc : LEMMA LET f = quadratic(a,b,c),
                                  minpt = -b/(2*a) IN
                               a > 0 IMPLIES 
                               x > y AND y >= minpt
                               IMPLIES 
                               f(x) > f(y)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 58 2 63 44
body:
    quad_min_mono_dec : LEMMA  LET f = quadratic(a,b,c),
                                   minpt = -b/(2*a) IN
                                a > 0 AND 
                                x < y AND y <= minpt 
                                IMPLIES 
                                   f(x) > f(y)  


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 65 2 69 76
body:
    quad_min_eq_intv: LEMMA a > 0 AND 
                             quadratic(a,b,c)(xl) = quadratic(a,b,c)(xu) AND
                             xl < t AND t < xu
                                 IMPLIES 
                                    quadratic(a,b,c)(t) < quadratic(a,b,c)(xu)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 71 2 76 52
body:
    quad_min_eq_is_in: LEMMA a > 0 AND 
                             quadratic(a,b,c)(xl) = quadratic(a,b,c)(xu) AND
                             quadratic(a,b,c)(t) < quadratic(a,b,c)(xu) AND 
                             xl < xu
                                 IMPLIES 
                                   (xl < t AND t < xu)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 78 2 82 18
body:
    quad_loc_min_is_glob_min: LEMMA a > 0 AND (FORALL (y): (x-epsil < y AND
                                    y < x+epsil) IMPLIES 
                                    quadratic(a,b,c)(y) >= quadratic(a,b,c)(x))
                                    IMPLIES
                                    x = -b/(2*a)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 93 2 96 55
body:
    quad_max : LEMMA LET f = quadratic(a,b,c),
                         maxpt = -b/(2*a) IN 
                           a < 0                          
                             IMPLIES is_maximum?(maxpt,f)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 98 2 101 67
body:
    quad_max_val : LEMMA LET f = quadratic(a,b,c),
                             maxpt = -b/(2*a) IN 
                                a < 0 
                                  IMPLIES f(x) <= (4*a*c-sq(b))/(4*a)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 104 2 109 44
body:
    quad_max_mono_inc : LEMMA LET f = quadratic(a,b,c),
                                  maxpt = -b/(2*a) IN
                               a < 0 AND
                               x < y AND y <= maxpt 
                               IMPLIES 
                                   f(x) < f(y)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 111 2 116 49
body:
    quad_max_mono_dec : LEMMA LET f = quadratic(a,b,c),
                                  maxpt = -b/(2*a) IN
                                    a < 0 AND 
                                    x > y AND y >= maxpt
                                    IMPLIES 
                                        f(x) < f(y)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 118 2 122 76
body:
    quad_max_eq_intv: LEMMA a < 0 AND 
                             quadratic(a,b,c)(xl) = quadratic(a,b,c)(xu) AND
                             xl < t AND t < xu
                                 IMPLIES 
                                    quadratic(a,b,c)(t) > quadratic(a,b,c)(xu)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 124 2 129 52
body:
    quad_max_eq_is_in: LEMMA a < 0 AND 
                             quadratic(a,b,c)(xl) = quadratic(a,b,c)(xu) AND
                             quadratic(a,b,c)(t) > quadratic(a,b,c)(xu) AND 
                             xl < xu
                                 IMPLIES 
                                   (xl < t AND t < xu)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 131 2 135 16
body:
    quad_loc_max_is_glob_max: LEMMA a < 0 AND (FORALL (y): (x-epsil < y AND
                                  y < x+epsil) IMPLIES 
                                  quadratic(a,b,c)(y) <= quadratic(a,b,c)(x))
                                  IMPLIES
                                  x = -b/(2*a)


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 137 2 140 83
body:
    quad_intv_max_at_endpoint: LEMMA a>0 AND xl<=xu IMPLIES
      (FORALL (t): xl<=t AND t<=xu IMPLIES quadratic(a,b,c)(t)<=quadratic(a,b,c)(xl))
      OR
      (FORALL (t): xl<=t AND t<=xu IMPLIES quadratic(a,b,c)(t)<=quadratic(a,b,c)(xu))


decl_type: formula
theory: quad_minmax
library: reals
signature: nil
location: 142 2 143 54
body:
    quad_intv_increasing_from_min: LEMMA a > 0 AND abs(x-(-b/(2*a))) <= abs(y-(-b/(2*a)))
      IMPLIES quadratic(a,b,c)(x) <= quadratic(a,b,c)(y)


decl_type: formula
theory: quadratic_2b
library: reals
signature: nil
location: 48 2 51 41
body:
    quad2b_eq_0 : THEOREM
      quadratic(a,2*b,c)(x) = 0 IFF
        discr2b(a,b,c) >= 0 AND
        EXISTS (eps): x = root2b(a,b,c,eps)


decl_type: function
theory: quadratic_2b
library: reals
signature:
  [[a: nzreal, b: real, {c: real | discr2b(a, b, c) >= 0}, Sign] ->
  real]

location: 37 2 38 37
body:
    root2b(a:nzreal,b:real,c:real|discr2b(a,b,c)>=0,eps:Sign):real =
      (-b + eps*sqrt(discr2b(a,b,c)))/a


decl_type: tcc
theory: quadratic_2b
library: reals
signature: nil
location: 58 0 62 999
body:
  % Subtype TCC generated (at line 38, column 19) for  discr2b(a, b, c)
      % expected type  nnx: nonneg_real
  root2b_TCC1: OBLIGATION
    FORALL (a: nzreal, b: real, c: real | discr2b(a, b, c) >= 0, eps: Sign):
      discr2b(a, b, c) >= 0;


decl_type: tcc
theory: quadratic_2b
library: reals
signature: nil
location: 64 0 68 999
body:
  % Subtype TCC generated (at line 42, column 37) for  c
      % expected type  {c: real | discr(a, 2 * b, c) >= 0}
  root2b_root_TCC1: OBLIGATION
    FORALL (a: nzreal, b, c: real):
      discr2b(a, b, c) >= 0 IMPLIES discr(a, 2 * b, c) >= 0;


decl_type: tcc
theory: quadratic_2b
library: reals
signature: nil
location: 70 0 74 999
body:
  % Subtype TCC generated (at line 46, column 37) for  c
      % expected type  {c: real | discr2b(a, b / 2, c) >= 0}
  root_root2b_TCC1: OBLIGATION
    FORALL (a: nzreal, b, c: real):
      discr(a, b, c) >= 0 IMPLIES discr2b(a, b / 2, c) >= 0;


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 96 2 99 47
body:
    sigma_rew : LEMMA sigma(low, high, F) = IF low > high THEN 0
                                            ELSIF high = low THEN F(low) 
                                            ELSE  F(high) + sigma(low, high-1, F)
                                            ENDIF


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 104 2 106 80
body:
    sigma_spl     : THEOREM T_pred(low + nn + rng) IMPLIES 
                             sigma(low, low+nn+rng, F) = 
                                sigma(low,low+nn,F) + sigma(low+nn+1,low+nn+rng,F)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 108 2 110 75
body:
    sigma_split   : THEOREM low - 1 <= z AND z <= high IMPLIES 
                              sigma(low, high, F) = 
                                       sigma(low, z, F) + sigma(z+1, high, F)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 126 2 127 80
body:
    sigma_diff    : THEOREM low - 1 <= z AND z <= high IMPLIES
                      sigma(low, high, F) - sigma(low, z, F) = sigma(z+1, high, F)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 129 2 130 80
body:
    sigma_diff_neg: THEOREM low - 1 <= z AND z <= high IMPLIES
                    sigma(low, z, F) - sigma(low, high, F) = - sigma(z+1, high, F)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 134 2 135 79
body:
    sigma_first   : THEOREM high >= low IMPLIES 
                             sigma(low, high, F) = F(low) + sigma(low+1, high, F)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 137 2 138 79
body:
    sigma_last    : THEOREM high >= low IMPLIES 
                            sigma(low, high, F) = sigma(low, high-1, F) + F(high)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 140 2 142 67
body:
    sigma_middle : THEOREM high >= i AND i >= low IMPLIES
                            sigma(low, high, F) = sigma(low, i-1, F) + F(i) +
                                                  sigma(i+1, high, F) 


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 144 2 145 76
body:
    sigma_const   : THEOREM sigma(low, high, (LAMBDA i: x)) = 
                             IF high >= low THEN (high-low+1) * x ELSE 0 ENDIF


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 150 2 151 54
body:
    sigma_scal    : THEOREM sigma(low, high, (LAMBDA i: a * F(i)))
                               = a * sigma(low, high, F)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 155 2 156 52
body:
    sigma_scal_right    : THEOREM sigma(low, high, (LAMBDA i: F(i)*a))
                               = sigma(low, high, F)*a


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 158 2 160 73
body:
    sigma_bound   : THEOREM low - 1 <= high AND
                           (FORALL i: i >= low AND i <= high IMPLIES F(i) <= B)
                              IMPLIES sigma(low, high, F) <= B*(high-low+1) %was abs(high-low+1)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 162 2 163 72
body:
    sigma_abs     : THEOREM abs(sigma(low, high, F)) <= 
                                sigma(low, high, LAMBDA (n: T): abs(F(n)))


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 165 2 166 62
body:
    sigma_ge_0    : THEOREM (FORALL (n: subrange(low,high)): F(n) >= 0)
                                  IMPLIES sigma(low,high,F) >= 0


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 168 2 170 61
body:
    sigma_gt_0    : THEOREM low <= high AND 
                            (FORALL (n: subrange(low,high)): F(n) > 0)
                                  IMPLIES sigma(low,high,F) > 0


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 173 2 175 75
body:
    sigma_shift_T : THEOREM (FORALL (i:T): T_pred(i+z)) IMPLIES 
                                   sigma(low+z,high+z,F) = 
                                      sigma(low,high, (LAMBDA (i:T): F(i+z)))


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 177 2 180 62
body:
    sigma_shift_T2 : THEOREM T_pred(low+z) AND T_pred(high+z) IMPLIES 
                                   sigma(low+z,high+z,F) = 
                   sigma(low,high, (LAMBDA (i:T): IF T_pred(i+z) THEN F(i+z)
                                                  ELSE 0 ENDIF))


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 185 2 186 72
body:
    sigma_sum     : THEOREM sigma(low, high, F) + sigma(low, high, G)
                               = sigma(low, high, (LAMBDA i: F(i) + G(i)))


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 188 2 189 72
body:
    sigma_minus   : THEOREM sigma(low, high, F) - sigma(low, high, G)
                               = sigma(low, high, (LAMBDA i: F(i) - G(i)))


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 191 2 193 59
body:
    sigma_abs_bnd  : THEOREM (FORALL (i: subrange(low,high)): abs(F(i)) <= G(i))
                         IMPLIES sigma(low, high, LAMBDA (n: T): abs(F(n))) <=
                                          sigma(low, high, G)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 198 2 199 79
body:
    sigma_restrict   : THEOREM l <= low AND h >= high IMPLIES     
                              sigma(low,high,F) = sigma(low,high,restrict(F,l,h))


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 201 2 202 68
body:
    sigma_restrict_to: THEOREM sigma(low,high,F) = 
                                  sigma(low,high,restrict(F,low,high))


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 204 2 205 77
body:
    sigma_restrict_eq: THEOREM restrict(F,low,high) = restrict(G,low,high) 
                                  IMPLIES sigma(low,high,F) = sigma(low,high,G)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 207 2 210 50
body:
    sigma_shift_fun_eq: THEOREM high1-low1 = high2-low2 AND
                                (FORALL (i:subrange(0,high1-low1)): F(low1+i) = G(low2+i))
                                IMPLIES
                                sigma(low1,high1,F) = sigma(low2,high2,G)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 212 2 213 81
body:
    sigma_const_restrict_eq: LEMMA restrict(F,low,high) = restrict(G,low,high) 
                                  IMPLIES x*sigma(low,high,F) = x*sigma(low,high,G)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 215 2 216 48
body:
    sigma_restrict_eq_0: THEOREM (FORALL (i: subrange(low,high)): F(i) = 0)
                                 IMPLIES sigma(low,high,F) = 0


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 220 2 223 32
body:
    sigma_eq_one_arg : THEOREM low<=z AND z<=high AND
                               (FORALL (i:subrange(low,z-1)):F(i)=0) AND
                               (FORALL (i:subrange(z+1,high)):F(i)=0) IMPLIES
                               sigma(low,high,F) = F(z)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 225 2 227 32
body:
    sigma_eq_one_arg2 : THEOREM low<=z AND z<=high AND
                               (FORALL (i:subrange(low,high)):i/=z IMPLIES F(i)=0) IMPLIES
                               sigma(low,high,F) = F(z)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 229 2 232 47
body:
    sigma_eq_two_args: THEOREM low<=z1 AND z1<=high AND
                               low<=z2 AND z2<=high AND z1/=z2 AND
                               (FORALL (i:subrange(low,high)): i/=z1 AND i/=z2 IMPLIES F(i)=0)
                               IMPLIES sigma(low,high,F) = F(z1)+F(z2)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 234 2 235 50
body:
    sigma_const_restrict_eq_0: THEOREM (FORALL (i: subrange(low,high)): F(i) = 0)
                                 IMPLIES x*sigma(low,high,F) = 0


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 238 2 239 77
body:
    sigma_eq         : THEOREM (FORALL (n: subrange(low,high)): F(n) = G(n))
                                  IMPLIES sigma(low,high,F) = sigma(low,high,G) 


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 242 2 243 78
body:
    sigma_le         : THEOREM (FORALL (n: subrange(low,high)): F(n) <= G(n))
                                  IMPLIES sigma(low,high,F) <= sigma(low,high,G) 


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 245 2 247 77
body:
    sigma_lt         : THEOREM low <= high AND
                               (FORALL (n: subrange(low,high)): F(n) < G(n))
                                  IMPLIES sigma(low,high,F) < sigma(low,high,G)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 249 2 250 78
body:
    sigma_ge         : THEOREM (FORALL (n: subrange(low,high)): F(n) >= G(n))
                                  IMPLIES sigma(low,high,F) >= sigma(low,high,G) 


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 252 2 254 77
body:
    sigma_gt         : THEOREM low <= high AND
                               (FORALL (n: subrange(low,high)): F(n) > G(n))
                                  IMPLIES sigma(low,high,F) > sigma(low,high,G)


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 256 2 258 75
body:
    sigma_with       : THEOREM low <= i AND i <= high AND
                               F = G WITH [i := a] IMPLIES
                            sigma(low, high,F) = sigma(low,high,G) - G(i) + a


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 260 2 263 28
body:
    sigma_le_scal    : THEOREM low<=high AND
                        (FORALL (i): low<=i AND i<=high IMPLIES F(i)<=B/(high-low+1))
                        IMPLIES
                        sigma(low,high,F)<=B


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 271 2 272 65
body:
    sigma_nonneg     : THEOREM (FORALL i: F(i) >= 0) 
                                   IMPLIES sigma(low, high, F) >= 0


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 274 2 275 65
body:
    sigma_nonpos     : THEOREM (FORALL i: F(i) <= 0) 
                                   IMPLIES sigma(low, high, F) <= 0


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 301 2 302 76
body:
    sigma_nonneg_eq_0 : THEOREM sigma(low,high,Fnnr) = 0 
                                AND low <= i AND i <= high IMPLIES Fnnr(i) = 0


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 304 2 305 65
body:
    sigma_nn_ge_comps : THEOREM low <= i AND i <= high IMPLIES 
                                    sigma(low,high,Fnnr) >= Fnnr(i) 


decl_type: formula
theory: sigma
library: reals
signature: nil
location: 318 3 320 62
body:
     sum_it_prop : LEMMA
       low - 1 <= i AND i <= high =>
       sum_it_def(i+1,high,F,sigma(low,i,F)) = sigma(low,high,F)


decl_type: function
theory: sigma
library: reals
signature: [[T_low, T_high, [T -> real]] -> real]
location: 81 2 85 49
body:
    sigma(low, high, F): RECURSIVE real
        = IF low > high THEN 0
          ELSE  F(high) + sigma(low, high-1, F)
          ENDIF                            
     MEASURE (LAMBDA low, high, F: abs(high+1-low))


decl_type: function
theory: sigma
library: reals
signature: [[T_low, T_high, [T -> real]] -> real]
location: 88 2 93 49
body:
    sigma2(low, high, F): RECURSIVE real
        = IF low > high THEN 0
          ELSIF high = low THEN F(low) 
          ELSE  F(high) + sigma2(low, high-1, F)
          ENDIF
     MEASURE (LAMBDA low, high, F: abs(high+1-low))


decl_type: function
theory: sigma
library: reals
signature: [[T_low, T_high, [T -> real], real] -> real]
location: 310 3 314 52
body:
     sum_it_def(low, high, F,a): RECURSIVE real
        = IF low > high THEN a
          ELSE  sum_it_def(low+1,high,F,a+F(low))
          ENDIF
     MEASURE (LAMBDA low, high, F, a: abs(high+1-low))


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 343 0 349 999
body:
  % Subtype TCC generated (at line 72, column 47) for  n
      % expected type  T_high
  high_low_rewrite_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low):
      NOT high < low IMPLIES
       (FORALL (n: subrange(low, high)):
          T_pred(n) OR (EXISTS (j: T): n <= j));


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 351 0 354 999
body:
  % Subtype TCC generated (at line 83, column 16) for  high
      % expected type  T
  sigma_TCC1: OBLIGATION
    FORALL (low: T_low, high: T_high): NOT low > high IMPLIES T_pred(high);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 356 0 361 999
body:
  % Subtype TCC generated (at line 83, column 35) for  high - 1
      % expected type  T_high
  sigma_TCC2: OBLIGATION
    FORALL (low: T_low, high: T_high):
      NOT low > high IMPLIES
       T_pred(high - 1) OR (EXISTS (j: T): high - 1 <= j);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 363 0 367 999
body:
  % Termination TCC generated (at line 83, column 24) for
      % sigma(low, high - 1, F)
  sigma_TCC3: OBLIGATION
    FORALL (low: T_low, high: T_high):
      NOT low > high IMPLIES abs(high - 1 + 1 - low) < abs(high + 1 - low);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 369 0 373 999
body:
  % Subtype TCC generated (at line 90, column 32) for  low
      % expected type  T
  sigma2_TCC1: OBLIGATION
    FORALL (low: T_low, high: T_high):
      high = low AND NOT low > high IMPLIES T_pred(low);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 375 0 380 999
body:
  % Subtype TCC generated (at line 105, column 38) for  low + nn + rng
      % expected type  T_high
  sigma_spl_TCC1: OBLIGATION
    FORALL (low: T_low, nn, rng: nat):
      T_pred(low + nn + rng) IMPLIES
       T_pred(low + nn + rng) OR (EXISTS (j: T): low + nn + rng <= j);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 382 0 387 999
body:
  % Subtype TCC generated (at line 106, column 40) for  low + nn
      % expected type  T_high
  sigma_spl_TCC2: OBLIGATION
    FORALL (low: T_low, nn, rng: nat):
      T_pred(low + nn + rng) IMPLIES
       T_pred(low + nn) OR (EXISTS (j: T): low + nn <= j);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 389 0 394 999
body:
  % Subtype TCC generated (at line 106, column 58) for  low + nn + 1
      % expected type  T_low
  sigma_spl_TCC3: OBLIGATION
    FORALL (low: T_low, nn, rng: nat):
      T_pred(low + nn + rng) IMPLIES
       T_pred(low + nn + 1) OR (EXISTS (j: T): j <= low + nn + 1);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 396 0 400 999
body:
  % Subtype TCC generated (at line 110, column 48) for  z
      % expected type  T_high
  sigma_split_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low, z: int):
      z <= high AND low - 1 <= z IMPLIES T_pred(z) OR (EXISTS (j: T): z <= j);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 402 0 407 999
body:
  % Subtype TCC generated (at line 110, column 62) for  z + 1
      % expected type  T_low
  sigma_split_TCC2: OBLIGATION
    FORALL (high: T_high, low: T_low, z: int):
      z <= high AND low - 1 <= z IMPLIES
       T_pred(z + 1) OR (EXISTS (j: T): j <= z + 1);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 409 0 412 999
body:
  % Subtype TCC generated (at line 135, column 51) for  low
      % expected type  T
  sigma_first_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low): high >= low IMPLIES T_pred(low);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 414 0 418 999
body:
  % Subtype TCC generated (at line 135, column 64) for  low + 1
      % expected type  T_low
  sigma_first_TCC2: OBLIGATION
    FORALL (high: T_high, low: T_low):
      high >= low IMPLIES T_pred(low + 1) OR (EXISTS (j: T): j <= low + 1);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 420 0 424 999
body:
  % Subtype TCC generated (at line 138, column 59) for  high - 1
      % expected type  T_high
  sigma_last_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low):
      high >= low IMPLIES T_pred(high - 1) OR (EXISTS (j: T): high - 1 <= j);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 426 0 429 999
body:
  % Subtype TCC generated (at line 138, column 74) for  high
      % expected type  T
  sigma_last_TCC2: OBLIGATION
    FORALL (high: T_high, low: T_low): high >= low IMPLIES T_pred(high);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 431 0 436 999
body:
  % Subtype TCC generated (at line 141, column 59) for  i - 1
      % expected type  T_high
  sigma_middle_TCC1: OBLIGATION
    FORALL (high: T_high, i: T, low: T_low):
      i >= low AND high >= i IMPLIES
       T_pred(i - 1) OR (EXISTS (j: T): i - 1 <= j);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 438 0 443 999
body:
  % Subtype TCC generated (at line 142, column 54) for  i + 1
      % expected type  T_low
  sigma_middle_TCC2: OBLIGATION
    FORALL (high: T_high, i: T, low: T_low):
      i >= low AND high >= i IMPLIES
       T_pred(i + 1) OR (EXISTS (j: T): j <= i + 1);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 445 0 448 999
body:
  % Subtype TCC generated (at line 165, column 61) for  n
      % expected type  T
  sigma_ge_0_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low, n: subrange(low, high)): T_pred(n);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 450 0 455 999
body:
  % Subtype TCC generated (at line 174, column 18) for  low + z
      % expected type  T_low
  sigma_shift_T_TCC1: OBLIGATION
    FORALL (low: T_low, z: int):
      (FORALL (i: T): T_pred(i + z)) IMPLIES
       T_pred(low + z) OR (EXISTS (j: T): j <= low + z);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 457 0 462 999
body:
  % Subtype TCC generated (at line 174, column 24) for  high + z
      % expected type  T_high
  sigma_shift_T_TCC2: OBLIGATION
    FORALL (high: T_high, z: int):
      (FORALL (i: T): T_pred(i + z)) IMPLIES
       T_pred(high + z) OR (EXISTS (j: T): high + z <= j);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 464 0 468 999
body:
  % Subtype TCC generated (at line 175, column 69) for  i + z
      % expected type  T
  sigma_shift_T_TCC3: OBLIGATION
    FORALL (z: int):
      (FORALL (i: T): T_pred(i + z)) IMPLIES (FORALL (i1: T): T_pred(i1 + z));


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 470 0 475 999
body:
  % Subtype TCC generated (at line 178, column 18) for  low + z
      % expected type  T_low
  sigma_shift_T2_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low, z: int):
      T_pred(high + z) AND T_pred(low + z) IMPLIES
       T_pred(low + z) OR (EXISTS (j: T): j <= low + z);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 477 0 482 999
body:
  % Subtype TCC generated (at line 178, column 24) for  high + z
      % expected type  T_high
  sigma_shift_T2_TCC2: OBLIGATION
    FORALL (high: T_high, low: T_low, z: int):
      T_pred(high + z) AND T_pred(low + z) IMPLIES
       T_pred(high + z) OR (EXISTS (j: T): high + z <= j);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 484 0 489 999
body:
  % Subtype TCC generated (at line 208, column 55) for  low1 + i
      % expected type  T
  sigma_shift_fun_eq_TCC1: OBLIGATION
    FORALL (high1, high2: T_high, low1, low2: T_low):
      high1 - low1 = high2 - low2 IMPLIES
       (FORALL (i: subrange(0, high1 - low1)): T_pred(low1 + i));


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 491 0 496 999
body:
  % Subtype TCC generated (at line 208, column 67) for  low2 + i
      % expected type  T
  sigma_shift_fun_eq_TCC2: OBLIGATION
    FORALL (high1, high2: T_high, low1, low2: T_low):
      high1 - low1 = high2 - low2 IMPLIES
       (FORALL (i: subrange(0, high1 - low1)): T_pred(low2 + i));


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 498 0 503 999
body:
  % Subtype TCC generated (at line 221, column 47) for  i
      % expected type  T
  sigma_eq_one_arg_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low, z: int):
      low <= z AND z <= high IMPLIES
       (FORALL (i: subrange(low, z - 1)): T_pred(i));


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 505 0 511 999
body:
  % Subtype TCC generated (at line 222, column 41) for  i
      % expected type  T
  sigma_eq_one_arg_TCC2: OBLIGATION
    FORALL (F: [T -> real], high: T_high, low: T_low, z: int):
      (low <= z AND
        z <= high AND (FORALL (i: subrange(low, z - 1)): F(i) = 0))
       IMPLIES (FORALL (i1: subrange(1 + z, high)): T_pred(i1));


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 513 0 520 999
body:
  % Subtype TCC generated (at line 223, column 30) for  z
      % expected type  T
  sigma_eq_one_arg_TCC3: OBLIGATION
    FORALL (F: [T -> real], high: T_high, low: T_low, z: int):
      (FORALL (i: subrange(1 + z, high)): F(i) = 0) AND
       (FORALL (i: subrange(low, z - 1)): F(i) = 0) AND
        z <= high AND low <= z
       IMPLIES T_pred(z);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 522 0 528 999
body:
  % Subtype TCC generated (at line 227, column 30) for  z
      % expected type  T
  sigma_eq_one_arg2_TCC1: OBLIGATION
    FORALL (F: [T -> real], high: T_high, low: T_low, z: int):
      (FORALL (i: subrange(low, high)): i /= z IMPLIES F(i) = 0) AND
       z <= high AND low <= z
       IMPLIES T_pred(z);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 530 0 537 999
body:
  % Subtype TCC generated (at line 232, column 38) for  z1
      % expected type  T
  sigma_eq_two_args_TCC1: OBLIGATION
    FORALL (F: [T -> real], high: T_high, low: T_low, z1, z2: int):
           FORALL (i: subrange(low, high)):
             i /= z1 AND i /= z2 IMPLIES F(i) = 0
       AND z1 /= z2 AND z2 <= high AND low <= z2 AND z1 <= high AND low <= z1
       IMPLIES T_pred(z1);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 539 0 546 999
body:
  % Subtype TCC generated (at line 232, column 44) for  z2
      % expected type  T
  sigma_eq_two_args_TCC2: OBLIGATION
    FORALL (F: [T -> real], high: T_high, low: T_low, z1, z2: int):
           FORALL (i: subrange(low, high)):
             i /= z1 AND i /= z2 IMPLIES F(i) = 0
       AND z1 /= z2 AND z2 <= high AND low <= z2 AND z1 <= high AND low <= z1
       IMPLIES T_pred(z2);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 548 0 553 999
body:
  % Subtype TCC generated (at line 261, column 71) for  (high - low + 1)
      % expected type  nznum
  sigma_le_scal_TCC1: OBLIGATION
    FORALL (high: T_high, low: T_low):
      low <= high IMPLIES
       (FORALL (i: T): low <= i AND i <= high IMPLIES (high - low + 1) /= 0);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 555 0 559 999
body:
  % Judgement subtype TCC generated (at line 289, column 32) for
      % sigma(low, high, Fnnr)
      % expected type  nnreal
  sigma_nnreal: OBLIGATION
    FORALL (Fnnr, high, low): sigma(low, high, Fnnr) >= 0;


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 561 0 565 999
body:
  % Judgement subtype TCC generated (at line 291, column 32) for
      % sigma(low, high, Fnpr)
      % expected type  nonpos_real
  sigma_nonpos_real: OBLIGATION
    FORALL (Fnpr, high, low): sigma(low, high, Fnpr) <= 0;


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 567 0 573 999
body:
  % Judgement subtype TCC generated (at line 293, column 32) for
      % sigma(low, high, Fnat)
      % expected type  nat
  sigma_nat: OBLIGATION
    FORALL (Fnat, high, low):
      rational_pred(sigma(low, high, Fnat)) AND
       integer_pred(sigma(low, high, Fnat)) AND sigma(low, high, Fnat) >= 0;


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 575 0 581 999
body:
  % Judgement subtype TCC generated (at line 295, column 32) for
      % sigma(low, high, Fnpi)
      % expected type  nonpos_int
  sigma_nonpos_int: OBLIGATION
    FORALL (Fnpi, high, low):
      rational_pred(sigma(low, high, Fnpi)) AND
       integer_pred(sigma(low, high, Fnpi)) AND sigma(low, high, Fnpi) <= 0;


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 583 0 587 999
body:
  % Subtype TCC generated (at line 312, column 25) for  low + 1
      % expected type  T_low
  sum_it_def_TCC1: OBLIGATION
    FORALL (low: T_low, high: T_high):
      NOT low > high IMPLIES T_pred(low + 1) OR (EXISTS (j: T): j <= low + 1);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 589 0 592 999
body:
  % Subtype TCC generated (at line 312, column 42) for  low
      % expected type  T
  sum_it_def_TCC2: OBLIGATION
    FORALL (low: T_low, high: T_high): NOT low > high IMPLIES T_pred(low);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 594 0 598 999
body:
  % Termination TCC generated (at line 312, column 14) for
      % sum_it_def(low + 1, high, F, a + F(low))
  sum_it_def_TCC3: OBLIGATION
    FORALL (low: T_low, high: T_high):
      NOT low > high IMPLIES abs(high + 1 - (low + 1)) < abs(high + 1 - low);


decl_type: tcc
theory: sigma
library: reals
signature: nil
location: 600 0 605 999
body:
  % Subtype TCC generated (at line 320, column 16) for  i + 1
      % expected type  T_low
  sum_it_prop_TCC1: OBLIGATION
    FORALL (high: T_high, i: T, low: T_low):
      i <= high AND low - 1 <= i IMPLIES
       T_pred(i + 1) OR (EXISTS (j: T): j <= i + 1);


decl_type: formula
theory: sigma_upto
library: reals
signature: nil
location: 33 2 34 79
body:
    sigma_first_ge : THEOREM high >= low IMPLIES
                             sigma(low, high, F) = F(low) + sigma(low+1, high, F)


decl_type: formula
theory: sigma_upto
library: reals
signature: nil
location: 36 2 37 79
body:
    sigma_last_ge  : THEOREM high >= low IMPLIES 
                            sigma(low, high, F) = sigma(low, high-1, F) + F(high)


decl_type: formula
theory: sigma_upto
library: reals
signature: nil
location: 39 2 41 75
body:
    sigma_split_ge : THEOREM low-1 <= m AND m <= high IMPLIES 
                              sigma(low, high, F) = 
                                       sigma(low, m, F) + sigma(m+1, high, F)


decl_type: tcc
theory: sigma_upto
library: reals
signature: nil
location: 58 0 62 999
body:
  % Assuming TCC generated (at line 20, column 12) for  sigma[upto[N]]
      % generated from assumption sigma.connected_domain
  IMP_sigma_TCC1: OBLIGATION
    (FORALL (x, y: upto[N]), (z: integer):
       x <= z AND z <= y IMPLIES z >= 0 AND z <= N);


decl_type: tcc
theory: sigma_upto
library: reals
signature: nil
location: 64 0 67 999
body:
  % Judgement subtype TCC generated (at line 23, column 29) for  x
      % expected type  T_high[upto[N]]
  int_upto_T_high: OBLIGATION
    FORALL (x: int_upto): x >= 0 AND x <= N OR (EXISTS (j: upto[N]): x <= j);


decl_type: tcc
theory: sigma_upto
library: reals
signature: nil
location: 69 0 72 999
body:
  % Judgement subtype TCC generated (at line 24, column 26) for  x
      % expected type  T_low[upto[N]]
  nat_is_T_low: OBLIGATION
    FORALL (x: nat): x >= 0 AND x <= N OR (EXISTS (j: upto[N]): j <= x);


decl_type: tcc
theory: sigma_upto
library: reals
signature: nil
location: 74 0 79 999
body:
  % Subtype TCC generated (at line 34, column 38) for  high
      % expected type  T_high[upto[N]]
  sigma_first_ge_TCC1: OBLIGATION
    FORALL (high, low: upto[N]):
      high >= low IMPLIES
       high >= 0 AND high <= N OR (EXISTS (j: upto[N]): high <= j);


decl_type: tcc
theory: sigma_upto
library: reals
signature: nil
location: 81 0 87 999
body:
  % Subtype TCC generated (at line 37, column 59) for  high - 1
      % expected type  T_high[upto[N]]
  sigma_last_ge_TCC1: OBLIGATION
    FORALL (high, low: upto[N]):
      high >= low IMPLIES
       high - 1 >= 0 AND high - 1 <= N OR
        (EXISTS (j: upto[N]): high - 1 <= j);


decl_type: tcc
theory: sigma_upto
library: reals
signature: nil
location: 89 0 94 999
body:
  % Subtype TCC generated (at line 40, column 39) for  high
      % expected type  T_high[upto[N]]
  sigma_split_ge_TCC1: OBLIGATION
    FORALL (high, low, m: upto[N]):
      m <= high AND low - 1 <= m IMPLIES
       high >= 0 AND high <= N OR (EXISTS (j: upto[N]): high <= j);


decl_type: tcc
theory: sigma_upto
library: reals
signature: nil
location: 96 0 101 999
body:
  % Subtype TCC generated (at line 41, column 48) for  m
      % expected type  T_high[upto[N]]
  sigma_split_ge_TCC2: OBLIGATION
    FORALL (high, low, m: upto[N]):
      m <= high AND low - 1 <= m IMPLIES
       m >= 0 AND m <= N OR (EXISTS (j: upto[N]): m <= j);


decl_type: tcc
theory: sigma_upto
library: reals
signature: nil
location: 103 0 107 999
body:
  % Subtype TCC generated (at line 49, column 29) for  nn
      % expected type  T_high[upto[N]]
  sigma_0_neg_TCC1: OBLIGATION
    FORALL (nn: negint):
      nn >= 0 AND nn <= N OR (EXISTS (j: upto[N]): nn <= j);


decl_type: tcc
theory: factorial
library: reals
signature: nil
location: 29 0 31 999
body:
  % Subtype TCC generated (at line 17, column 28) for  1
      % expected type  T_low[nat]
  factorial_product_TCC1: OBLIGATION 1 >= 0 OR (EXISTS (j: nat): j <= 1);


decl_type: tcc
theory: factorial
library: reals
signature: nil
location: 33 0 36 999
body:
  % Subtype TCC generated (at line 17, column 30) for  n
      % expected type  T_high[nat]
  factorial_product_TCC2: OBLIGATION
    FORALL (n: nat): n >= 0 OR (EXISTS (j: nat): n <= j);


decl_type: tcc
theory: factorial
library: reals
signature: nil
location: 38 0 41 999
body:
  % Assuming TCC generated (at line 11, column 28) for  product[nat]
      % generated from assumption product.connected_domain
  factorial_product_TCC3: OBLIGATION
    (FORALL (x, y: nat), (z: integer): x <= z AND z <= y IMPLIES z >= 0);


decl_type: tcc
theory: factorial
library: reals
signature: nil
location: 43 0 46 999
body:
  % Subtype TCC generated (at line 20, column 13) for  1
      % expected type  T_low[posnat]
  product_factorial_TCC1: OBLIGATION
    1 >= 0 AND 1 > 0 OR (EXISTS (j: posnat): j <= 1);


decl_type: tcc
theory: factorial
library: reals
signature: nil
location: 48 0 51 999
body:
  % Subtype TCC generated (at line 20, column 15) for  p
      % expected type  T_high[posnat]
  product_factorial_TCC2: OBLIGATION
    FORALL (p: posnat): p >= 0 AND p > 0 OR (EXISTS (j: posnat): p <= j);


decl_type: tcc
theory: factorial
library: reals
signature: nil
location: 53 0 57 999
body:
  % Assuming TCC generated (at line 11, column 28) for  product[posnat]
      % generated from assumption product.connected_domain
  product_factorial_TCC3: OBLIGATION
    (FORALL (x, y: posnat), (z: integer):
       x <= z AND z <= y IMPLIES z >= 0 AND z > 0);


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 52 0 56 999
body:
  % Assuming TCC generated (at line 12, column 35) for  product[posnat]
      % generated from assumption product.connected_domain
  IMP_product_TCC1: OBLIGATION
    (FORALL (x, y: posnat), (z: integer):
       x <= z AND z <= y IMPLIES z >= 0 AND z > 0);


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 58 0 60 999
body:
  % Subtype TCC generated (at line 18, column 73) for  n - k
      % expected type  nat
  C_TCC1: OBLIGATION FORALL (n: nat, k: {i: nat | i <= n}): n - k >= 0;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 62 0 69 999
body:
  % Subtype TCC generated (at line 18, column 36) for
      % factorial(n) / (factorial(k) * factorial(n - k))
      % expected type  posnat
  C_TCC2: OBLIGATION
    FORALL (n: nat, k: {i: nat | i <= n}):
      integer_pred(factorial(n) / (factorial(k) * factorial(n - k))) AND
       factorial(n) / (factorial(k) * factorial(n - k)) >= 0 AND
        factorial(n) / (factorial(k) * factorial(n - k)) > 0;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 71 0 73 999
body:
  % Subtype TCC generated (at line 20, column 21) for  0
      % expected type  {i: nat | i <= n}
  C_0_TCC1: OBLIGATION FORALL (n: nat): 0 <= n;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 75 0 77 999
body:
  % Subtype TCC generated (at line 21, column 21) for  n
      % expected type  {i: nat | i <= n}
  C_n_TCC1: OBLIGATION FORALL (n: nat): n <= n;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 79 0 81 999
body:
  % Subtype TCC generated (at line 22, column 22) for  1
      % expected type  {i: nat | i <= pn}
  C_1_TCC1: OBLIGATION FORALL (pn: posnat): 1 <= pn;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 83 0 85 999
body:
  % Subtype TCC generated (at line 23, column 22) for  pn - 1
      % expected type  {i: nat | i <= pn}
  C_n_1_TCC1: OBLIGATION FORALL (pn: posnat): pn - 1 >= 0 AND pn - 1 <= pn;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 87 0 90 999
body:
  % Subtype TCC generated (at line 25, column 60) for  n - k
      % expected type  {i: nat | i <= n}
  C_symmetry_TCC1: OBLIGATION
    FORALL (n: nat, k: {i: nat | i <= n}): n - k >= 0 AND n - k <= n;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 92 0 95 999
body:
  % Subtype TCC generated (at line 27, column 56) for  k
      % expected type  {i: nat | i <= 1 + n}
  C_n_plus_1_TCC1: OBLIGATION
    FORALL (n: nat, k: {i: posnat | i <= n}): k <= 1 + n;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 97 0 100 999
body:
  % Subtype TCC generated (at line 27, column 72) for  k - 1
      % expected type  {i: nat | i <= n}
  C_n_plus_1_TCC2: OBLIGATION
    FORALL (n: nat, k: {i: posnat | i <= n}): k - 1 >= 0 AND k - 1 <= n;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 102 0 104 999
body:
  % Subtype TCC generated (at line 28, column 50) for  k
      % expected type  {i: nat | i <= n}
  C_k_plus_1_TCC1: OBLIGATION FORALL (n: nat, k: {i: nat | i < n}): k <= n;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 106 0 109 999
body:
  % Subtype TCC generated (at line 28, column 65) for  k + 1
      % expected type  {i: nat | i <= n}
  C_k_plus_1_TCC2: OBLIGATION
    FORALL (n: nat, k: {i: nat | i < n}): k + 1 <= n;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 111 0 113 999
body:
  % Subtype TCC generated (at line 31, column 28) for  2
      % expected type  {i: nat | i <= nge2}
  C_2_TCC1: OBLIGATION FORALL (nge2: {k: posnat | k >= 2}): 2 <= nge2;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 115 0 118 999
body:
  % Subtype TCC generated (at line 32, column 28) for  nge2 - 2
      % expected type  {i: nat | i <= nge2}
  C_n_2_TCC1: OBLIGATION
    FORALL (nge2: {k: posnat | k >= 2}): nge2 - 2 >= 0 AND nge2 - 2 <= nge2;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 120 0 124 999
body:
  % Subtype TCC generated (at line 34, column 27) for  0
      % expected type  T_low[{i: nat | i <= n}]
  sigma_C_TCC1: OBLIGATION
    FORALL (n: nat):
      0 >= 0 AND 0 <= n OR (EXISTS (j: {i: nat | i <= n}): j <= 0);


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 126 0 130 999
body:
  % Subtype TCC generated (at line 34, column 29) for  n
      % expected type  T_high[{i: nat | i <= n}]
  sigma_C_TCC2: OBLIGATION
    FORALL (n: nat):
      n >= 0 AND n <= n OR (EXISTS (j: {i: nat | i <= n}): n <= j);


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 132 0 137 999
body:
  % Assuming TCC generated (at line 20, column 12) for
      % sigma[{i: nat | i <= n}]
      % generated from assumption sigma.connected_domain
  sigma_C_TCC3: OBLIGATION
    FORALL (n: nat, x, y: {i: nat | i <= n}, z: integer):
      x <= z AND z <= y IMPLIES z >= 0 AND z <= n;


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 139 0 143 999
body:
  % Subtype TCC generated (at line 39, column 15) for  1
      % expected type  T_low[posnat]
  C_it_TCC1: OBLIGATION
    FORALL (n: nat, k: {i: nat | i <= n}):
      1 >= 0 AND 1 > 0 OR (EXISTS (j: posnat): j <= 1);


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 145 0 149 999
body:
  % Subtype TCC generated (at line 39, column 17) for  k
      % expected type  T_high[posnat]
  C_it_TCC2: OBLIGATION
    FORALL (n: nat, k: {i: nat | i <= n}):
      k >= 0 AND k > 0 OR (EXISTS (j: posnat): k <= j);


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 151 0 157 999
body:
  % Subtype TCC generated (at line 39, column 4) for
      % product_it(1, k, LAMBDA (i: posnat): (n - (k - i)) / i)
      % expected type  rat
  C_it_TCC3: OBLIGATION
    FORALL (n: nat, k: {i: nat | i <= n}):
      rational_pred(product_it[posnat]
                        (1, k, LAMBDA (i: posnat): (n - (k - i)) / i));


decl_type: tcc
theory: binomial
library: reals
signature: nil
location: 159 0 163 999
body:
  % Judgement subtype TCC generated (at line 45, column 4) for  C_it(n, k)
      % expected type  posnat
  C_it_posnat: OBLIGATION
    FORALL (n: nat, k: {i: nat | i <= n}):
      integer_pred(C_it(n, k)) AND C_it(n, k) >= 0 AND C_it(n, k) > 0;


decl_type: formula
theory: sigma_swap
library: reals
signature: nil
location: 32 2 34 76
body:
    sigma_swap: LEMMA
      sigma(low1,high1,LAMBDA (i:T): sigma(low2,high2,LAMBDA (j:T): F(i,j)))
      = sigma(low2,high2,LAMBDA (j:T): sigma(low1,high1,LAMBDA (i:T): F(i,j)))


decl_type: formula
theory: sigma_swap
library: reals
signature: nil
location: 36 2 39 72
body:
    sigma_swap_triangle: LEMMA
      high1 >= high2 IMPLIES
      sigma(low1,high1,LAMBDA (i:T): sigma(i,high2,LAMBDA (j:T): F(i,j)))
      = sigma(low1,high2,LAMBDA (j:T): sigma(low1,j,LAMBDA (i:T): F(i,j)))


decl_type: tcc
theory: sigma_swap
library: reals
signature: nil
location: 46 0 49 999
body:
  % Assuming TCC generated (at line 18, column 12) for  sigma[T]
      % generated from assumption sigma.connected_domain
  IMP_sigma_TCC1: OBLIGATION
    (FORALL (x, y: T), (z: integer): x <= z AND z <= y IMPLIES T_pred(z));


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 38 2 39 72
body:
    sigma_shift:  THEOREM sigma(low+m,high+m,F) = 
                                sigma(low,high, (LAMBDA (n: nat): F(n+m)))


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 41 2 45 63
body:
    sigma_shift_neg:  THEOREM low - m >= 0 IMPLIES 
                           sigma(low-m,high-m,F) = 
                               sigma(low,high, (LAMBDA n: IF n-m < 0 THEN 0 
                                                          ELSE F(n-m) 
                                                          ENDIF))


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 47 2 49 64
body:
    sigma_shift_ng2:  THEOREM low - m >= 0 IMPLIES 
                           sigma(low-m,high-m,F) = 
                               sigma(low,high, (LAMBDA n: F(n~m)))


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 52 2 55 85
body:
    sigma_shift_i:  THEOREM 0 <= low + i IMPLIES
                                sigma(low+i,high+i,F) = 
                                sigma(low,high, (LAMBDA (n: nat): IF n < low THEN 0
                                                                    ELSE F(n+i) ENDIF))


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 62 2 63 79
body:
    sigma_first_ge : THEOREM high >= low IMPLIES  % slightly more general
                             sigma(low, high, F) = F(low) + sigma(low+1, high, F)


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 66 2 68 75
body:
    sigma_split_ge : THEOREM low-1 <= i AND i <= high IMPLIES 
                              sigma(low, high, F) = 
                                       sigma(low, i, F) + sigma(i+1, high, F)


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 72 2 73 90
body:
    sigma_reverse : THEOREM sigma(low,high,F) = 
           sigma(low,high,(LAMBDA (n:nat): IF n > high+low THEN 0 ELSE F(high+low-n) ENDIF))


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 76 2 80 45
body:
    sigma_product    : THEOREM sigma(low1,high1,F)*sigma(low2,high2,G) =
                               sigma(low1+low2,high1+high2,LAMBDA (k:nat):
                                   sigma(low1,high1, 
                                     LAMBDA (i:nat): IF (i<k-high2 OR i>k-low2) THEN 0
                                                   ELSE F(i)*G(k-i) ENDIF))


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 85 2 90 47
body:
    sigma_bij: LEMMA FORALL (sig:[nat->nat]):
      (FORALL (i:subrange(low,high)): low<=sig(i) AND sig(i)<=high) AND
      (FORALL (i:subrange(low,high)): EXISTS (j:subrange(low,high)): sig(j)=i) AND
      (FORALL (i,j:subrange(low,high)): i/=j IMPLIES sig(i)/=sig(j))
      IMPLIES
      sigma(low,high,F) = sigma(low,high,F o sig)


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 92 2 99 45
body:
    sigma_inj: LEMMA FORALL (sig:[nat->nat]):
      (FORALL (i:subrange(low1,high1)): low2<=sig(i) AND sig(i)<=high2) AND
      (FORALL (i,j:subrange(low1,high1)): i/=j IMPLIES sig(i)/=sig(j)) AND
      (FORALL (i:subrange(low2,high2)): (EXISTS (j:subrange(low1,high1)): sig(j)=i) OR
        G(i)=0) AND
      (FORALL (i:subrange(low1,high1)): F(i) = G(sig(i)))
      IMPLIES
      sigma(low1,high1,F) = sigma(low2,high2,G)


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 111 2 113 77
body:
    sigma_product2   : THEOREM FORALL(M: posnat, N: posnat): 
                               sigma(0,M-1,F)*sigma(0,N-1,G) = 
                               sigma(0, M*N-1, LAMBDA(k:nat): F( (k-mod(k,N))/N)*G(mod(k,N)))               


decl_type: formula
theory: sigma_nat
library: reals
signature: nil
location: 116 2 118 56
body:
    sigma_geometric: LEMMA FORALL (r:real):
      r/=1 AND n<=m IMPLIES
      sigma(n,m,LAMBDA (k:nat): r^k) = (r^n-r^(m+1))/(1-r)


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 126 0 129 999
body:
  % Assuming TCC generated (at line 25, column 12) for  sigma[nat]
      % generated from assumption sigma.connected_domain
  IMP_sigma_TCC1: OBLIGATION
    (FORALL (x, y: nat), (z: integer): x <= z AND z <= y IMPLIES z >= 0);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 131 0 134 999
body:
  % Judgement subtype TCC generated (at line 27, column 27) for  x
      % expected type  T_high[nat]
  int_is_T_high: OBLIGATION
    FORALL (x: int): x >= 0 OR (EXISTS (j: nat): x <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 136 0 139 999
body:
  % Judgement subtype TCC generated (at line 28, column 27) for  x
      % expected type  T_low[nat]
  nat_is_T_low: OBLIGATION
    FORALL (x: nat): x >= 0 OR (EXISTS (j: nat): j <= x);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 141 0 145 999
body:
  % Subtype TCC generated (at line 38, column 36) for  high + m
      % expected type  T_high[nat]
  sigma_shift_TCC1: OBLIGATION
    FORALL (high: int, m: nat):
      high + m >= 0 OR (EXISTS (j: nat): high + m <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 147 0 151 999
body:
  % Subtype TCC generated (at line 42, column 31) for  low - m
      % expected type  T_low[nat]
  sigma_shift_neg_TCC1: OBLIGATION
    FORALL (low, m: nat):
      low - m >= 0 IMPLIES low - m >= 0 OR (EXISTS (j: nat): j <= low - m);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 153 0 157 999
body:
  % Subtype TCC generated (at line 42, column 37) for  high - m
      % expected type  T_high[nat]
  sigma_shift_neg_TCC2: OBLIGATION
    FORALL (high: int, low, m: nat):
      low - m >= 0 IMPLIES high - m >= 0 OR (EXISTS (j: nat): high - m <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 159 0 163 999
body:
  % Subtype TCC generated (at line 44, column 63) for  n - m
      % expected type  nat
  sigma_shift_neg_TCC3: OBLIGATION
    FORALL (low, m: nat):
      low - m >= 0 IMPLIES (FORALL (n): NOT n - m < 0 IMPLIES n - m >= 0);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 165 0 169 999
body:
  % Subtype TCC generated (at line 53, column 36) for  low + i
      % expected type  T_low[nat]
  sigma_shift_i_TCC1: OBLIGATION
    FORALL (i: int, low: nat):
      0 <= low + i IMPLIES low + i >= 0 OR (EXISTS (j: nat): j <= low + i);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 171 0 175 999
body:
  % Subtype TCC generated (at line 53, column 42) for  high + i
      % expected type  T_high[nat]
  sigma_shift_i_TCC2: OBLIGATION
    FORALL (high, i: int, low: nat):
      0 <= low + i IMPLIES high + i >= 0 OR (EXISTS (j: nat): high + i <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 177 0 181 999
body:
  % Subtype TCC generated (at line 55, column 73) for  n + i
      % expected type  nat
  sigma_shift_i_TCC3: OBLIGATION
    FORALL (i: int, low: nat):
      0 <= low + i IMPLIES (FORALL (n: nat): NOT n < low IMPLIES n + i >= 0);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 183 0 186 999
body:
  % Subtype TCC generated (at line 58, column 12) for  m
      % expected type  T_high[nat]
  sigma_shift_to_zero_TCC1: OBLIGATION
    FORALL (m, n: nat): n <= m IMPLIES m >= 0 OR (EXISTS (j: nat): m <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 188 0 192 999
body:
  % Subtype TCC generated (at line 58, column 27) for  m - n
      % expected type  T_high[nat]
  sigma_shift_to_zero_TCC2: OBLIGATION
    FORALL (m, n: nat):
      n <= m IMPLIES m - n >= 0 OR (EXISTS (j: nat): m - n <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 194 0 198 999
body:
  % Subtype TCC generated (at line 68, column 48) for  i
      % expected type  T_high[nat]
  sigma_split_ge_TCC1: OBLIGATION
    FORALL (high, i: int, low: nat):
      i <= high AND low - 1 <= i IMPLIES i >= 0 OR (EXISTS (j: nat): i <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 200 0 205 999
body:
  % Subtype TCC generated (at line 68, column 62) for  i + 1
      % expected type  T_low[nat]
  sigma_split_ge_TCC2: OBLIGATION
    FORALL (high, i: int, low: nat):
      i <= high AND low - 1 <= i IMPLIES
       i + 1 >= 0 OR (EXISTS (j: nat): j <= i + 1);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 207 0 211 999
body:
  % Subtype TCC generated (at line 73, column 71) for  high + low - n
      % expected type  nat
  sigma_reverse_TCC1: OBLIGATION
    FORALL (high: int, low, n: nat):
      NOT n > high + low IMPLIES high + low - n >= 0;


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 213 0 217 999
body:
  % Subtype TCC generated (at line 77, column 33) for  high1 + high2
      % expected type  T_high[nat]
  sigma_product_TCC1: OBLIGATION
    FORALL (high1, high2: int):
      high1 + high2 >= 0 OR (EXISTS (j: nat): high1 + high2 <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 219 0 223 999
body:
  % Subtype TCC generated (at line 80, column 33) for  k - i
      % expected type  nat
  sigma_product_TCC2: OBLIGATION
    FORALL (high2: int, low2, k: nat, i: nat):
      NOT i < k - high2 AND NOT i > k - low2 IMPLIES k - i >= 0;


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 225 0 228 999
body:
  % Subtype TCC generated (at line 86, column 45) for  i
      % expected type  nat
  sigma_bij_TCC1: OBLIGATION
    FORALL (high: int, low: nat, i: subrange(low, high)): i >= 0;


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 230 0 236 999
body:
  % Subtype TCC generated (at line 87, column 71) for  j
      % expected type  nat
  sigma_bij_TCC2: OBLIGATION
    FORALL (high: int, low: nat, sig: [nat -> nat]):
      (FORALL (i: subrange(low, high)): low <= sig(i) AND sig(i) <= high)
       IMPLIES
       (FORALL (i1: subrange(low, high), j: subrange(low, high)): j >= 0);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 238 0 244 999
body:
  % Subtype TCC generated (at line 94, column 65) for  j
      % expected type  nat
  sigma_inj_TCC1: OBLIGATION
    FORALL (high1, high2: int, low1, low2: nat, sig: [nat -> nat]):
      (FORALL (i: subrange(low1, high1)): low2 <= sig(i) AND sig(i) <= high2)
       IMPLIES
       (FORALL (i1, j: subrange(low1, high1)): i1 /= j IMPLIES j >= 0);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 246 0 258 999
body:
  % Subtype TCC generated (at line 96, column 8) for  i
      % expected type  nat
  sigma_inj_TCC2: OBLIGATION
    FORALL (high1, high2: int, low1, low2: nat, sig: [nat -> nat]):
      ((FORALL (i, j: subrange(low1, high1)):
          i /= j IMPLIES sig(i) /= sig(j))
        AND
        (FORALL (i: subrange(low1, high1)):
           low2 <= sig(i) AND sig(i) <= high2))
       IMPLIES
       (FORALL (i1: subrange(low2, high2)):
          NOT (EXISTS (j: subrange(low1, high1)): sig(j) = i1) IMPLIES
           i1 >= 0);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 260 0 274 999
body:
  % Subtype TCC generated (at line 99, column 37) for  high2
      % expected type  T_high[nat]
  sigma_inj_TCC3: OBLIGATION
    FORALL (F, G: [nat -> real], high1, high2: int, low1, low2: nat,
            sig: [nat -> nat]):
      ((FORALL (i: subrange(low1, high1)):
          low2 <= sig(i) AND sig(i) <= high2)
        AND
        (FORALL (i, j: subrange(low1, high1)):
           i /= j IMPLIES sig(i) /= sig(j))
         AND
         (FORALL (i: subrange(low2, high2)):
            (EXISTS (j: subrange(low1, high1)): sig(j) = i) OR G(i) = 0)
          AND (FORALL (i: subrange(low1, high1)): F(i) = G(sig(i))))
       IMPLIES high2 >= 0 OR (EXISTS (j: nat): high2 <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 276 0 279 999
body:
  % Subtype TCC generated (at line 107, column 29) for  nn
      % expected type  T_high[nat]
  sigma_0_neg_TCC1: OBLIGATION
    FORALL (nn: negint): nn >= 0 OR (EXISTS (j: nat): nn <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 281 0 284 999
body:
  % Subtype TCC generated (at line 112, column 23) for  M - 1
      % expected type  T_high[nat]
  sigma_product2_TCC1: OBLIGATION
    FORALL (M: posnat): M - 1 >= 0 OR (EXISTS (j: nat): M - 1 <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 286 0 290 999
body:
  % Subtype TCC generated (at line 113, column 24) for  M * N - 1
      % expected type  T_high[nat]
  sigma_product2_TCC2: OBLIGATION
    FORALL (M: posnat, N: posnat):
      M * N - 1 >= 0 OR (EXISTS (j: nat): M * N - 1 <= j);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 292 0 296 999
body:
  % Subtype TCC generated (at line 113, column 49) for  (k - mod(k, N)) / N
      % expected type  nat
  sigma_product2_TCC3: OBLIGATION
    FORALL (N: posnat, k: nat):
      integer_pred((k - mod(k, N)) / N) AND (k - mod(k, N)) / N >= 0;


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 298 0 302 999
body:
  % Subtype TCC generated (at line 118, column 32) for  k
      % expected type  {i: int | r /= 0 OR i >= 0}
  sigma_geometric_TCC1: OBLIGATION
    FORALL (m, n: nat, r: real):
      r /= 1 AND n <= m IMPLIES (FORALL (k: nat): r /= 0 OR k >= 0);


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 304 0 307 999
body:
  % Subtype TCC generated (at line 118, column 40) for  n
      % expected type  {i: int | r /= 0 OR i >= 0}
  sigma_geometric_TCC2: OBLIGATION
    FORALL (m, n: nat, r: real): r /= 1 AND n <= m IMPLIES r /= 0 OR n >= 0;


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 309 0 313 999
body:
  % Subtype TCC generated (at line 118, column 45) for  (m + 1)
      % expected type  {i: int | r /= 0 OR i >= 0}
  sigma_geometric_TCC3: OBLIGATION
    FORALL (m, n: nat, r: real):
      r /= 1 AND n <= m IMPLIES r /= 0 OR (m + 1) >= 0;


decl_type: tcc
theory: sigma_nat
library: reals
signature: nil
location: 315 0 318 999
body:
  % Subtype TCC generated (at line 118, column 52) for  (1 - r)
      % expected type  nznum
  sigma_geometric_TCC4: OBLIGATION
    FORALL (m, n: nat, r: real): r /= 1 AND n <= m IMPLIES (1 - r) /= 0;


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 33 2 33 114
body:
    polynomial_eq_a0_plus: LEMMA n>0 IMPLIES polynomial(a,n)(x) = a(0) + x*polynomial(LAMBDA (i:nat): a(i+1),n-1)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 53 2 54 70
body:
    extend_polynomial  : LEMMA (FORALL (i:posnat): a(n+i) = 0) IMPLIES
                                     polynomial(a,n) = polynomial(a,n+m)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 56 2 58 77
body:
    sum_polynomial     : LEMMA (FORALL (i:posnat): a(n+i) = 0) AND
                               (FORALL (i:posnat): b(m+i) = 0)
           IMPLIES polynomial(a,n) + polynomial(b,m) = polynomial(a+b,max(n,m))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 63 2 64 66
body:
    sum_polynomial_eq_degree_eval: LEMMA
      polynomial(a,n)(x) + polynomial(b,n)(x) = polynomial(a+b,n)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 68 2 70 76
body:
    diff_polynomial    : LEMMA (FORALL (i:posnat): a(n+i) = 0) AND
                        (FORALL (i:posnat): b(m+i) = 0)
          IMPLIES polynomial(a,n) - polynomial(b,m) = polynomial(a-b,max(n,m))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 74 2 75 77
body:
    mul_x_to_n_polynomial: LEMMA   polynomial(a,n) * (LAMBDA (x:real): x^pn)
         = polynomial(LAMBDA (i:nat): IF i < pn THEN 0 ELSE a(i-pn) ENDIF,n+pn)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 77 2 78 76
body:
    first_polynomial   : LEMMA polynomial(a,pn)(x) = 
                           a(0) + x*polynomial(LAMBDA (i:nat): a(i+1),pn-1)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 80 2 81 61
body:
    scal_polynomial    : LEMMA const_fun(y) * polynomial(a,n) 
                                 = polynomial(const_fun(y)*a,n)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 87 2 88 73
body:
    even_polynomial    : LEMMA even_fs?(a) IMPLIES
           polynomial(a,2*n)(x) = polynomial(LAMBDA (i:nat): a(2*i),n)(x^2)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 92 2 93 74
body:
    odd_polynomial: LEMMA odd_fs?(a) IMPLIES
      polynomial(a,2*n+1)(x) = x*polynomial(LAMBDA (i:nat): a(2*i+1),n)(x^2)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 101 2 102 78
body:
    abs_polynomial_le: LEMMA
      abs(polynomial(a,n)(x)) <= polynomial(LAMBDA (i:nat): abs(a(i)),n)(abs(x))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 104 2 106 71
body:
    nn_le_polynomial : LEMMA
      (FORALL (i:nat): a(i) >= 0) AND (FORALL (i:nat): b(i) >= a(i)) AND
       x >= 0 AND n <= m IMPLIES polynomial(a,n)(x) <= polynomial(b,m)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 111 2 112 55
body:
    power_polynomial : LEMMA (LAMBDA (x:real): (1+x)^pn) 
                            = polynomial(power_fs(pn),pn)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 120 2 121 88
body:
    binomial_theorem: LEMMA
      (x+y)^n = sigma(0,n,(LAMBDA (i:nat): IF i > n THEN 0 ELSE C(n,i)*x^i*y^(n-i) ENDIF))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 126 2 127 52
body:
    power_linear_polynomial: LEMMA FORALL (k:nat): k>=n IMPLIES
      (c+r*x)^n = polynomial(power_linear(c,r,n),k)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 131 2 132 87
body:
    polynomial_prod_def: LEMMA
      polynomial(a,n)(x)*polynomial(b,m)(x) = polynomial(polynomial_prod(a,n,b,m),n+m)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 152 2 155 43
body:
    poly_eq_le_degree: LEMMA
      (FORALL (ii:nat): ii<=n IMPLIES a(ii) = b(ii))
      IMPLIES
      polynomial(a,n)(x) = polynomial(b,n)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 157 2 161 43
body:
    poly_reduce_degree: LEMMA
      m<=n AND
      (FORALL (ii:nat): ii>m AND ii<=n IMPLIES a(ii)=0)
      IMPLIES
      polynomial(a,n)(x) = polynomial(a,m)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 163 2 168 43
body:
    poly_eq: LEMMA
      (FORALL (ii:nat): ii>min(n,m) IMPLIES 
        (ii<=n IMPLIES a(ii)=0) AND (ii<=m IMPLIES b(ii)=0)) AND
      (FORALL (ii:nat): ii<=min(n,m) IMPLIES a(ii)=b(ii))
      IMPLIES
      polynomial(a,n)(x) = polynomial(b,m)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 172 2 181 43
body:
    prop_extends_monomial: LEMMA
      LET eventzero = (LAMBDA (ab:sequence[real]): EXISTS (kk:nat): FORALL (mm:nat):
                            mm>kk IMPLIES ab(mm) = 0)
      IN
      FORALL (P:[sequence[real]->bool]):
      (FORALL (j:nat,ar:real): P(LAMBDA (i:nat): IF i = j THEN ar ELSE 0 ENDIF))
      AND
      (FORALL (a,b): P(a) AND P(b) IMPLIES P(a+b))
      IMPLIES
      (FORALL (a): eventzero(a) IMPLIES P(a))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 189 2 189 129
body:
    poly_translate_id: LEMMA FORALL (A:real,(B:real|A/=B)):polynomial(a,n)(x) = polynomial(poly_translate(a,n)(A,B),n)((x-A)/(B-A))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 191 2 194 72
body:
    polynomial_zero_factor: LEMMA
      polynomial(a,pn)(y) = 0 IMPLIES
      EXISTS (g:sequence[real]):
      (FORALL (x:real): polynomial(a,pn)(x) = (x-y)*polynomial(g,pn-1)(x))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 196 2 199 76
body:
    polynomial_zero_factor2: LEMMA
      polynomial(a,pn)(y)=0 IMPLIES
        LET g = poly_shift(LAMBDA (i): poly_shift(a,pn)(y)(i+1),pn-1)(-y) IN
          (FORALL (x:real): polynomial(a,pn)(x) = (x-y)*polynomial(g,pn-1)(x))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 201 2 202 117
body:
    polynomial_linear_divisor: LEMMA
      EXISTS (g:sequence[real]): FORALL (x:real): polynomial(a,pn)(x) = (x-y)*polynomial(g,pn-1)(x)+polynomial(a,pn)(y)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 204 2 207 41
body:
    polynomial_eq_coeff: LEMMA
      polynomial(a,n) = polynomial(b,n)
      IFF
      (FORALL (jj: upto(n)): a(jj) = b(jj))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 209 2 212 43
body:
    poly_eq_0_le_degree: LEMMA
      (FORALL (ii:nat): ii<=n IMPLIES a(ii)=0)
      IFF
      (FORALL (x:real): polynomial(a,n)(x)=0)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 214 2 217 44
body:
    poly_image_size: LEMMA n>0 AND
      (EXISTS (fp:[below(n+1)->real]): FORALL (i,j:below(n+1)):
        (i/=j IMPLIES fp(i)/=fp(j)) AND polynomial(a,n)(fp(i))=polynomial(a,n)(fp(j)))
      IMPLIES FORALL (k:subrange(1,n)): a(k)=0


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 219 2 221 44
body:
    poly_constant_on_interval: LEMMA
      x<y AND (FORALL (r1,r2:real): x<r1 AND r1<=r2 AND r2<y IMPLIES polynomial(a,n)(r1)=polynomial(a,n)(r2))
      IMPLIES FORALL (k:subrange(1,n)): a(k)=0


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 224 2 226 37
body:
    polynomial_div_id: LEMMA LET idf = (LAMBDA (x:real): x) IN
      idf*polynomial(a,n) = idf*polynomial(b,n) IMPLIES
      polynomial(a,n) = polynomial(b,n)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 235 2 236 98
body:
    poly_translate_rat_def: LEMMA FORALL (A,B,C,D,x:real): C*x+D/=0 IMPLIES
      (C*x+D)^n*polynomial(a,n)((A*x+B)/(C*x+D)) = polynomial(poly_translate_rat(A,B,C,D)(a,n),n)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 238 2 240 65
body:
    poly_translate_rat_bounded_left: LEMMA
      x/=A IMPLIES (x-A)^n*polynomial(a,n)(((B+1)*x-B*(A+1))/(x-A)) =
        polynomial(poly_translate_rat(B+1,-B*(A+1),1,-A)(a,n),n)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 242 2 244 64
body:
    poly_translate_rat_bounded_right: LEMMA
      x/=B IMPLIES (B-x)^n*polynomial(a,n)(((1-A)*x + A*(B-1))/(B-x)) =
        polynomial(poly_translate_rat(1-A,A*(B-1),-1,B)(a,n),n)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 254 2 256 60
body:
    poly_translate_rat2_def: LEMMA FORALL (A,B,C,D,E,F,x:real): (C*x+D)/=0 AND (E*x+F)/=0 IMPLIES
      (C*x+D)^n*(E*x+F)^n*polynomial(a,n)((A*x+B)/((C*x+D)*(E*x+F))) =
      polynomial(poly_translate_rat2(A,B,C,D,E,F)(a,n),2*n)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 266 2 266 133
body:
    poly_translate_inf_pos_def: LEMMA x/=0 IMPLIES x^n*polynomial(a,n)((1+x*(A-1))/x) = polynomial(poly_translate_inf_pos(a,n)(A),n)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 268 2 268 141
body:
    poly_translate_inf_pos_def_rev: LEMMA x/=A-1 IMPLIES polynomial(a,n)(x) = (x-A+1)^n*polynomial(poly_translate_inf_pos(a,n)(A),n)(1/(x-A+1))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 270 2 270 135
body:
    poly_translate_inf_neg_def: LEMMA x/=0 IMPLIES x^n*polynomial(a,n)((-1-x*(-A-1))/x) = polynomial(poly_translate_inf_neg(a,n)(A),n)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 274 2 274 141
body:
    poly_translate_inf_neg_def_rev: LEMMA x/=A+1 IMPLIES polynomial(a,n)(x) = (A+1-x)^n*polynomial(poly_translate_inf_neg(a,n)(A),n)(1/(A+1-x))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 278 2 282 105
body:
    poly_translate_inf_pos_rel: LEMMA ((rel = (<=)) OR (rel = (<)) OR (rel = (>=)) OR (rel = (>)))
                                IMPLIES
                                ((FORALL (x:real): x>=A IMPLIES rel(polynomial(a,n)(x),0))
                                 IFF
                                 (FORALL (x:real): 0<x AND x<=1 IMPLIES rel(polynomial(poly_translate_inf_pos(a,n)(A),n)(x),0)))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 284 2 288 105
body:
    poly_translate_inf_neg_rel: LEMMA ((rel = (<=)) OR (rel = (<)) OR (rel = (>=)) OR (rel = (>)))
                                IMPLIES
                                ((FORALL (x:real): x<=A IMPLIES rel(polynomial(a,n)(x),0))
                                 IFF
                                 (FORALL (x:real): 0<x AND x<=1 IMPLIES rel(polynomial(poly_translate_inf_neg(a,n)(A),n)(x),0)))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 306 2 307 93
body:
    poly_deriv_plus_eval: LEMMA
      polynomial(poly_deriv(a+b),n) = polynomial(poly_deriv(a),n) + polynomial(poly_deriv(b),n)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 309 2 312 179
body:
    poly_eq_deriv_plus: LEMMA
      n > 0 IMPLIES
      EXISTS (nseq:[nat->nat],pseq:[nat->sequence[real]]):
          FORALL (h:real,x): polynomial(a,n)(x+h) = polynomial(a,n)(x)+ h*polynomial(poly_deriv(a),n-1)(x) + h^2*polynomial(LAMBDA (ii:nat): polynomial(pseq(ii),nseq(ii))(h),n-1)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 319 2 322 55
body:
    poly_product_rule: LEMMA n>0 AND m>0 IMPLIES
      polynomial(poly_deriv(polynomial_prod(a,n,b,m)),n+m-1)(x) =
      polynomial(a,n)(x)*polynomial(poly_deriv(b),m-1)(x) +
      polynomial(poly_deriv(a),n-1)(x)*polynomial(b,m)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 324 2 326 36
body:
    deriv_power_linear: LEMMA
      poly_deriv(power_linear(c,r,n)) =
      r*n*power_linear(c,r,max(n-1,0))


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 332 2 335 67
body:
    poly_n_deriv_def: LEMMA
      poly_n_deriv(a,0) = a AND
      poly_n_deriv(a,1) = poly_deriv(a) AND
      FORALL (n): poly_deriv(poly_n_deriv(a,n)) = poly_n_deriv(a,n+1)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 343 2 344 95
body:
    poly_continuous: LEMMA FORALL (x:real,epsil:posreal): EXISTS (delta:posreal):
      FORALL (y:real): abs(x-y)<=delta IMPLIES abs(polynomial(a,n)(x)-polynomial(a,n)(y)) < epsil


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 348 2 350 85
body:
    poly_attains_maximum: LEMMA
      x<=y IMPLIES EXISTS (c:real): x<=c AND c<=y AND
      FORALL (cc:real): x<=cc AND cc<=y IMPLIES polynomial(a,n)(cc)<=polynomial(a,n)(c)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 352 2 354 85
body:
    poly_attains_minimum: LEMMA
      x<=y IMPLIES EXISTS (c:real): x<=c AND c<=y AND
      FORALL (cc:real): x<=cc AND cc<=y IMPLIES polynomial(a,n)(cc)>=polynomial(a,n)(c)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 358 2 362 43
body:
    poly_strictly_increasing: LEMMA
      n > 0 AND x < y AND
      (FORALL (c): x <= c AND c <= y IMPLIES polynomial(poly_deriv(a),n-1)(c) > 0)
      IMPLIES
      polynomial(a,n)(x) < polynomial(a,n)(y)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 364 2 368 44
body:
    poly_increasing: LEMMA
      x <= y AND n > 0 AND
      (FORALL (c): x <= c AND c <= y IMPLIES polynomial(poly_deriv(a),n-1)(c) >= 0)
      IMPLIES
      polynomial(a,n)(x) <= polynomial(a,n)(y)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 370 2 374 43
body:
    poly_strictly_decreasing: LEMMA
      n > 0 AND x < y AND
      (FORALL (c): x <= c AND c <= y IMPLIES polynomial(poly_deriv(a),n-1)(c) < 0)
      IMPLIES
      polynomial(a,n)(x) > polynomial(a,n)(y)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 376 2 380 44
body:
    poly_decreasing: LEMMA
      x <= y AND n > 0 AND
      (FORALL (c): x <= c AND c <= y IMPLIES polynomial(poly_deriv(a),n-1)(c) <= 0)
      IMPLIES
      polynomial(a,n)(x) >= polynomial(a,n)(y)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 382 2 384 65
body:
    poly_intermediate_value_increasing_0: LEMMA
      x<=y AND polynomial(a,n)(x) <= 0 AND polynomial(a,n)(y)>=0 IMPLIES
      EXISTS (cc:real): x<=cc AND cc<=y AND polynomial(a,n)(cc) = 0


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 386 2 388 65
body:
    poly_intermediate_value_inc: LEMMA
      x<=y AND polynomial(a,n)(x) <= c AND polynomial(a,n)(y)>=c IMPLIES
      EXISTS (cc:real): x<=cc AND cc<=y AND polynomial(a,n)(cc) = c


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 390 2 392 65
body:
    poly_intermediate_value_dec: LEMMA
      x<=y AND polynomial(a,n)(x) >=c AND polynomial(a,n)(y)<=c IMPLIES
      EXISTS (cc:real): x<=cc AND cc<=y AND polynomial(a,n)(cc) = c


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 396 2 398 71
body:
    poly_Rolle: LEMMA
      x<y AND n>0 AND polynomial(a,n)(x) = polynomial(a,n)(y) IMPLIES
      EXISTS (c:real): x<c AND c<y AND polynomial(poly_deriv(a),n-1)(c)=0


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 400 2 402 87
body:
    poly_mean_value: LEMMA x < y AND n > 0 IMPLIES
      EXISTS (cc:real): x<=cc AND cc<=y AND
        polynomial(poly_deriv(a),n-1)(cc) = (polynomial(a,n)(y)-polynomial(a,n)(x))/(y-x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 411 2 411 105
body:
    polynomial_int_sum: LEMMA polynomial_int(a,n,x,y) + polynomial_int(b,n,x,y) = polynomial_int(a+b,n,x,y)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 413 2 414 48
body:
    polynomial_ftc: THEOREM n>0 IMPLIES polynomial_int(poly_deriv(a),n-1,x,y) =
                            polynomial(a,n)(y) - polynomial(a,n)(x)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 416 2 418 23
body:
    antideriv_power_linear: LEMMA r/=0 IMPLIES
      poly_deriv(1/r*1/(n+1)*power_linear(c,r,n+1)) =
      power_linear(c,r,n)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 420 2 423 46
body:
    poly_local_max_deriv: LEMMA FORALL (epsil:posreal):
      n>0 AND (FORALL (y): abs(x-y)<epsil IMPLIES
        polynomial(a,n)(y)<=polynomial(a,n)(x))
      IMPLIES polynomial(poly_deriv(a),n-1)(x)=0


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 425 2 428 46
body:
    poly_local_min_deriv: LEMMA FORALL (epsil:posreal):
      n>0 AND (FORALL (y): abs(x-y)<epsil IMPLIES
        polynomial(a,n)(y)>=polynomial(a,n)(x))
      IMPLIES polynomial(poly_deriv(a),n-1)(x)=0


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 432 2 435 150
body:
    polynomial_integration_by_parts: LEMMA % int u*dv = u*v - int du*v
      n>0 AND m>0 IMPLIES
      polynomial_int(polynomial_prod(a,n,poly_deriv(b),m-1),n+m-1,x,y) =
      (polynomial(a,n)(y)*polynomial(b,m)(y) - polynomial(a,n)(x)*polynomial(b,m)(x)) - polynomial_int(polynomial_prod(poly_deriv(a),n-1,b,m),n+m-1,x,y)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 440 2 446 83
body:
    poly_maclaurin: LEMMA FORALL (k:nat,br:real): k>=n AND n>0 AND br>0 AND
      (FORALL (ii:nat): ii>k IMPLIES a(ii) = 0)
      IMPLIES
      EXISTS (c:real): 0<=c AND c<=br AND
      LET fk = polynomial(a,k),
          fn1 = polynomial(a,n-1) IN
        fk(br) = fn1(br) + (1/factorial(n))*polynomial(poly_n_deriv(a,n),k-n)(c)*br^n


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 458 2 461 76
body:
    taylor_poly_def: LEMMA FORALL (k:nat,rr:real): polynomial(taylor_poly(a,k,0,rr),k)(x) = polynomial(a,k)(rr) AND
                       FORALL (n): n<k IMPLIES polynomial(taylor_poly(a,k,n+1,rr),k)(x) = 
                                   polynomial(taylor_poly(a,k,n,rr),k)(x)+
                                   (polynomial(poly_n_deriv(a,n+1),k-n-1)(rr)/factorial(n+1))*(x-rr)^(n+1)


decl_type: formula
theory: polynomials
library: reals
signature: nil
location: 463 2 467 84
body:
    poly_taylor: LEMMA FORALL (k:nat): k>=n AND n>0 IMPLIES
      EXISTS (c:real): ((y<=c AND c<=x) OR (x<=c AND c<=y)) AND
      LET fk = polynomial(a,k),
          fn1 = polynomial(taylor_poly(a,k,n-1,y),n-1) IN
        fk(x) = fn1(x) + (1/factorial(n))*polynomial(poly_n_deriv(a,n),k-n)(c)*(x-y)^n


decl_type: function
theory: polynomials
library: reals
signature: [[sequence[real], nat] -> [real -> real]]
location: 26 2 27 78
body:
    polynomial(a,n): [real->real] = LAMBDA (x:real): 
               sigma(0,n, LAMBDA (i:nat): a(i)*(IF i = 0 THEN 1 ELSE x^i ENDIF))


decl_type: function
theory: polynomials
library: reals
signature: [[sequence[real], nat] -> bool]
location: 95 2 96 63
body:
    alternating_fs?(a:sequence[real],n:nat):bool
       = FORALL (i:nat): 0 <= i AND i < n IMPLIES a(i)*a(i+1) < 0


decl_type: function
theory: polynomials
library: reals
signature: [nat -> [nat -> int]]
location: 114 2 115 64
body:
    neg_power_fs(n:nat):[nat->int] = 
      (LAMBDA (i:nat): IF i > n THEN 0 ELSE (-1)^i * C(n,i) ENDIF)


decl_type: function
theory: polynomials
library: reals
signature: [[sequence[real], nat, sequence[real], nat] -> [nat -> real]]
location: 129 2 129 115
body:
    polynomial_prod(a,n,b,m)(i:nat): real = sigma(max(i-m,0),n,LAMBDA (k:nat): IF k<=i THEN a(k)*b(i-k) ELSE 0 ENDIF)


decl_type: function
theory: polynomials
library: reals
signature: [[sequence[real], nat] -> [real -> sequence[real]]]
location: 136 2 137 104
body:
    poly_shift(a,n)(c): sequence[real] =
      (LAMBDA (j:nat): sigma(j,n,(LAMBDA (i:nat): If (i<j OR i>n) THEN 0 ELSE a(i)*C(i,j)*c^(i-j) ENDIF)))


decl_type: function
theory: polynomials
library: reals
signature: [[sequence[real], nat] -> [[real, real] -> sequence[real]]]
location: 186 2 187 112
body:
    poly_translate(a,n)(A:real,B:real): sequence[real] =
      (LAMBDA (j:nat): (B-A)^j*sigma(j,n,(LAMBDA (i:nat): If (i<j OR i>n) THEN 0 ELSE a(i)*C(i,j)*A^(i-j) ENDIF)))


decl_type: function
theory: polynomials
library: reals
signature:
  [[real, real, real, real] ->
  [[sequence[real], nat] -> [nat -> real]]]

location: 231 2 233 135
body:
    poly_translate_rat(A,B,C,D:real)(a,n)(d:nat): real =
      sigma(0,n,LAMBDA (i:nat): a(i)*sigma(0, n - i, LAMBDA (k: nat): IF (k < d - i OR k > d OR k > n - i) THEN 0
                              ELSE (C(n - i, k) * D ^ (-1 * k - i + n)) * C ^ k * ((C(i, d - k) * B ^ (k - d + i)) * A ^ (d - k)) ENDIF))


decl_type: function
theory: polynomials
library: reals
signature:
  [[real, real, real, real, real, real] ->
  [[sequence[real], nat] -> [nat -> real]]]

location: 246 2 252 23
body:
    poly_translate_rat2(A,B,C,D,E,F:real)(a,n)(q:nat): real=
      sigma(0,n,LAMBDA (k:nat): a(k)*sigma(0, n, LAMBDA (i: nat): sigma(0,k,LAMBDA (j: nat):
                 IF (q > 2 * n-k OR i < n - q OR i > -1 * q - k + 2 * n 
                     OR j < i - n + k OR j > i OR j > k OR k>n) THEN 0
                 ELSE C(k,j)*B^j*A^(k-j)*C(n-k,i-j)*D^(i-j)*C^(j-i-k+n)*
                      C(n-k,-1*i-q-k+2*n)*F^(-1*i-q-k+2*n)*E^(i+q-n)
                 ENDIF)))


decl_type: function
theory: polynomials
library: reals
signature: [[sequence[real], nat] -> [real -> sequence[real]]]
location: 258 2 260 73
body:
    poly_translate_inf_pos(a,n)(A:real) : sequence[real] = 
      (LAMBDA (j:nat): IF j>n THEN 0 ELSE sigma(n-j,n,LAMBDA (i:nat): IF (i<n-j OR i>n) THEN 0 ELSE
                                                             a(i)*C(i,i-n+j)*(A-1)^(i-n+j) ENDIF) ENDIF)


decl_type: function
theory: polynomials
library: reals
signature: [[sequence[real], nat] -> [real -> sequence[real]]]
location: 262 2 264 81
body:
    poly_translate_inf_neg(a,n)(A:real) : sequence[real] = 
      (LAMBDA (j:nat): IF j>n THEN 0 ELSE sigma(n-j,n,LAMBDA (i:nat): IF (i<n-j OR i>n) THEN 0 ELSE
                                                             (-1)^i*a(i)*C(i,i-n+j)*(-A-1)^(i-n+j) ENDIF) ENDIF)


decl_type: function
theory: polynomials
library: reals
signature: [[sequence[real], nat, real, real] -> real]
location: 408 2 409 48
body:
    polynomial_int(a,n,x,y): real = polynomial(poly_integral(a,0),n+1)(y)-
                                    polynomial(poly_integral(a,0),n+1)(x)


decl_type: function
theory: polynomials
library: reals
signature: [[sequence[real], nat, nat, real] -> [nat -> real]]
location: 452 2 456 15
body:
    taylor_poly(a,(k:nat),n,(rr:real))(i:nat): real = 
          sigma(i,n,LAMBDA (d:nat): 
                  IF i<=d AND d<=k THEN 
                    (polynomial(poly_n_deriv(a,d),k-d)(rr)/factorial(d))*C(d,i)*(-rr)^(d-i) 
                  ELSE 0 ENDIF)


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 477 0 480 999
body:
  % Assuming TCC generated (at line 14, column 5) for  sigma_swap[nat]
      % generated from assumption sigma_swap.connected_domain
  IMP_sigma_swap_TCC1: OBLIGATION
    (FORALL (x, y: nat), (z: integer): x <= z AND z <= y IMPLIES z >= 0);


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 482 0 485 999
body:
  % Subtype TCC generated (at line 24, column 23) for  (i + j)
      % expected type  {i: int | x /= 0 OR i >= 0}
  expt_plus2_TCC1: OBLIGATION
    FORALL (i, j: nat, x: real): x /= 0 OR (i + j) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 487 0 489 999
body:
  % Subtype TCC generated (at line 24, column 32) for  i
      % expected type  {i: int | x /= 0 OR i >= 0}
  expt_plus2_TCC2: OBLIGATION FORALL (i: nat, x: real): x /= 0 OR i >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 491 0 494 999
body:
  % Subtype TCC generated (at line 27, column 21) for  n
      % expected type  T_high[nat]
  polynomial_TCC1: OBLIGATION
    FORALL (n: nat): n >= 0 OR (EXISTS (j: nat): n <= j);


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 496 0 499 999
body:
  % Subtype TCC generated (at line 33, column 107) for  n - 1
      % expected type  nat
  polynomial_eq_a0_plus_TCC1: OBLIGATION
    FORALL (n: nat): n > 0 IMPLIES n - 1 >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 501 0 504 999
body:
  % Subtype TCC generated (at line 74, column 71) for  pn
      % expected type  {i: int | x /= 0 OR i >= 0}
  mul_x_to_n_polynomial_TCC1: OBLIGATION
    FORALL (pn: posnat, x: real): x /= 0 OR pn >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 506 0 509 999
body:
  % Subtype TCC generated (at line 75, column 60) for  i - pn
      % expected type  nat
  mul_x_to_n_polynomial_TCC2: OBLIGATION
    FORALL (pn: posnat, i: nat): NOT i < pn IMPLIES i - pn >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 511 0 513 999
body:
  % Subtype TCC generated (at line 78, column 68) for  pn - 1
      % expected type  nat
  first_polynomial_TCC1: OBLIGATION FORALL (pn: posnat): pn - 1 >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 515 0 518 999
body:
  % Subtype TCC generated (at line 88, column 71) for  2
      % expected type  {i: int | x /= 0 OR i >= 0}
  even_polynomial_TCC1: OBLIGATION
    FORALL (a: sequence[real], x: real): even_fs?(a) IMPLIES x /= 0 OR 2 >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 520 0 523 999
body:
  % Subtype TCC generated (at line 93, column 72) for  2
      % expected type  {i: int | x /= 0 OR i >= 0}
  odd_polynomial_TCC1: OBLIGATION
    FORALL (a: sequence[real], x: real): odd_fs?(a) IMPLIES x /= 0 OR 2 >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 525 0 527 999
body:
  % Subtype TCC generated (at line 109, column 46) for  i
      % expected type  {i: nat | i <= n}
  power_fs_TCC1: OBLIGATION FORALL (n, i: nat): NOT i > n IMPLIES i <= n;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 529 0 532 999
body:
  % Subtype TCC generated (at line 111, column 51) for  pn
      % expected type  {i: int | (1 + x) /= 0 OR i >= 0}
  power_polynomial_TCC1: OBLIGATION
    FORALL (pn: posnat, x: real): (1 + x) /= 0 OR pn >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 534 0 537 999
body:
  % Subtype TCC generated (at line 118, column 28) for  pn
      % expected type  {i: int | (1 - x) /= 0 OR i >= 0}
  neg_power_polynomial_TCC1: OBLIGATION
    FORALL (pn: posnat, x: real): (1 - x) /= 0 OR pn >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 539 0 542 999
body:
  % Subtype TCC generated (at line 121, column 10) for  n
      % expected type  {i: int | (x + y) /= 0 OR i >= 0}
  binomial_theorem_TCC1: OBLIGATION
    FORALL (n: nat, x, y: real): (x + y) /= 0 OR n >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 544 0 548 999
body:
  % Subtype TCC generated (at line 121, column 76) for  (n - i)
      % expected type  {i: int | y /= 0 OR i >= 0}
  binomial_theorem_TCC2: OBLIGATION
    FORALL (n: nat, y: real, i: nat):
      NOT i > n IMPLIES y /= 0 OR (n - i) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 550 0 554 999
body:
  % Subtype TCC generated (at line 127, column 12) for  n
      % expected type  {i: int | (c + r * x) /= 0 OR i >= 0}
  power_linear_polynomial_TCC1: OBLIGATION
    FORALL (c: real, n: nat, r, x: real, k: nat):
      k >= n IMPLIES (c + r * x) /= 0 OR n >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 556 0 560 999
body:
  % Subtype TCC generated (at line 129, column 48) for  max(i - m, 0)
      % expected type  T_low[nat]
  polynomial_prod_TCC1: OBLIGATION
    FORALL (m: nat, i: nat):
      max(i - m, 0) >= 0 OR (EXISTS (j: nat): j <= max(i - m, 0));


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 562 0 565 999
body:
  % Subtype TCC generated (at line 129, column 97) for  i - k
      % expected type  nat
  polynomial_prod_TCC2: OBLIGATION
    FORALL (i: nat, k: nat): k <= i IMPLIES i - k >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 567 0 570 999
body:
  % Subtype TCC generated (at line 137, column 85) for  j
      % expected type  {i_1: nat | i_1 <= i}
  poly_shift_TCC1: OBLIGATION
    FORALL (n: nat, j: nat, i: nat): NOT i < j AND NOT i > n IMPLIES j <= i;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 572 0 576 999
body:
  % Subtype TCC generated (at line 137, column 91) for  (i - j)
      % expected type  {i: int | c /= 0 OR i >= 0}
  poly_shift_TCC2: OBLIGATION
    FORALL (n: nat, c: real, j: nat, i: nat):
      NOT i < j AND NOT i > n IMPLIES c /= 0 OR (i - j) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 578 0 581 999
body:
  % Subtype TCC generated (at line 187, column 27) for  j
      % expected type  {i: int | (B - A) /= 0 OR i >= 0}
  poly_translate_TCC1: OBLIGATION
    FORALL (A, B: real, j: nat): (B - A) /= 0 OR j >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 583 0 586 999
body:
  % Subtype TCC generated (at line 189, column 124) for  (B - A)
      % expected type  nznum
  poly_translate_id_TCC1: OBLIGATION
    FORALL (A: real, (B: real | A /= B)): (B - A) /= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 588 0 591 999
body:
  % Subtype TCC generated (at line 232, column 44) for  n - i
      % expected type  T_high[nat]
  poly_translate_rat_TCC1: OBLIGATION
    FORALL (n: nat, i: nat): n - i >= 0 OR (EXISTS (j: nat): n - i <= j);


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 593 0 597 999
body:
  % Subtype TCC generated (at line 233, column 36) for  n - i
      % expected type  nat
  poly_translate_rat_TCC2: OBLIGATION
    FORALL (n: nat, d: nat, i: nat, k: nat):
      NOT k < d - i AND NOT k > d AND NOT k > n - i IMPLIES n - i >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 599 0 603 999
body:
  % Subtype TCC generated (at line 233, column 43) for  k
      % expected type  {i_1: nat | i_1 <= n - i}
  poly_translate_rat_TCC3: OBLIGATION
    FORALL (n: nat, d: nat, i: nat, k: nat):
      NOT k < d - i AND NOT k > d AND NOT k > n - i IMPLIES k <= n - i;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 605 0 610 999
body:
  % Subtype TCC generated (at line 233, column 53) for  (-1 * k - i + n)
      % expected type  {i: int | D /= 0 OR i >= 0}
  poly_translate_rat_TCC4: OBLIGATION
    FORALL (D: real, n: nat, d: nat, i: nat, k: nat):
      NOT k < d - i AND NOT k > d AND NOT k > n - i IMPLIES
       D /= 0 OR (-1 * k - i + n) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 612 0 616 999
body:
  % Subtype TCC generated (at line 233, column 76) for  k
      % expected type  {i: int | C /= 0 OR i >= 0}
  poly_translate_rat_TCC5: OBLIGATION
    FORALL (C: real, n: nat, d: nat, i: nat, k: nat):
      NOT k < d - i AND NOT k > d AND NOT k > n - i IMPLIES C /= 0 OR k >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 618 0 623 999
body:
  % Subtype TCC generated (at line 233, column 87) for  d - k
      % expected type  {i_1: nat | i_1 <= i}
  poly_translate_rat_TCC6: OBLIGATION
    FORALL (n: nat, d: nat, i: nat, k: nat):
      NOT k < d - i AND NOT k > d AND NOT k > n - i IMPLIES
       d - k >= 0 AND d - k <= i;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 625 0 630 999
body:
  % Subtype TCC generated (at line 233, column 101) for  (k - d + i)
      % expected type  {i: int | B /= 0 OR i >= 0}
  poly_translate_rat_TCC7: OBLIGATION
    FORALL (B: real, n: nat, d: nat, i: nat, k: nat):
      NOT k < d - i AND NOT k > d AND NOT k > n - i IMPLIES
       B /= 0 OR (k - d + i) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 632 0 637 999
body:
  % Subtype TCC generated (at line 233, column 120) for  (d - k)
      % expected type  {i: int | A /= 0 OR i >= 0}
  poly_translate_rat_TCC8: OBLIGATION
    FORALL (A: real, n: nat, d: nat, i: nat, k: nat):
      NOT k < d - i AND NOT k > d AND NOT k > n - i IMPLIES
       A /= 0 OR (d - k) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 639 0 643 999
body:
  % Subtype TCC generated (at line 236, column 12) for  n
      % expected type  {i: int | NOT D + C * x = 0 OR i >= 0}
  poly_translate_rat_def_TCC1: OBLIGATION
    FORALL (n: nat, C, D, x: real):
      C * x + D /= 0 IMPLIES NOT D + C * x = 0 OR n >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 645 0 648 999
body:
  % Subtype TCC generated (at line 239, column 60) for  (x - A)
      % expected type  nznum
  poly_translate_rat_bounded_left_TCC1: OBLIGATION
    FORALL (A, x: real): x /= A IMPLIES (x - A) /= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 650 0 653 999
body:
  % Subtype TCC generated (at line 243, column 23) for  n
      % expected type  {i: int | (B - x) /= 0 OR i >= 0}
  poly_translate_rat_bounded_right_TCC1: OBLIGATION
    FORALL (B: real, n: nat, x: real): x /= B IMPLIES (B - x) /= 0 OR n >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 655 0 658 999
body:
  % Subtype TCC generated (at line 243, column 62) for  (B - x)
      % expected type  nznum
  poly_translate_rat_bounded_right_TCC2: OBLIGATION
    FORALL (B, x: real): x /= B IMPLIES (B - x) /= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 660 0 666 999
body:
  % Subtype TCC generated (at line 250, column 19) for  j
      % expected type  {i: nat | i <= k}
  poly_translate_rat2_TCC1: OBLIGATION
    FORALL (n: nat, q: nat, k: nat, i: nat, j: nat):
           NOT q > 2 * n - k AND NOT i < n - q AND NOT i > -1 * q - k + 2 * n
       AND NOT j < i - n + k AND NOT j > i AND NOT j > k AND NOT k > n
       IMPLIES j <= k;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 668 0 674 999
body:
  % Subtype TCC generated (at line 250, column 24) for  j
      % expected type  {i: int | B /= 0 OR i >= 0}
  poly_translate_rat2_TCC2: OBLIGATION
    FORALL (B: real, n: nat, q: nat, k: nat, i: nat, j: nat):
           NOT q > 2 * n - k AND NOT i < n - q AND NOT i > -1 * q - k + 2 * n
       AND NOT j < i - n + k AND NOT j > i AND NOT j > k AND NOT k > n
       IMPLIES B /= 0 OR j >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 676 0 682 999
body:
  % Subtype TCC generated (at line 250, column 29) for  (k - j)
      % expected type  {i: int | A /= 0 OR i >= 0}
  poly_translate_rat2_TCC3: OBLIGATION
    FORALL (A: real, n: nat, q: nat, k: nat, i: nat, j: nat):
           NOT q > 2 * n - k AND NOT i < n - q AND NOT i > -1 * q - k + 2 * n
       AND NOT j < i - n + k AND NOT j > i AND NOT j > k AND NOT k > n
       IMPLIES A /= 0 OR (k - j) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 684 0 690 999
body:
  % Subtype TCC generated (at line 250, column 36) for  n - k
      % expected type  nat
  poly_translate_rat2_TCC4: OBLIGATION
    FORALL (n: nat, q: nat, k: nat, i: nat, j: nat):
           NOT q > 2 * n - k AND NOT i < n - q AND NOT i > -1 * q - k + 2 * n
       AND NOT j < i - n + k AND NOT j > i AND NOT j > k AND NOT k > n
       IMPLIES n - k >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 692 0 698 999
body:
  % Subtype TCC generated (at line 250, column 40) for  i - j
      % expected type  {i: nat | i <= n - k}
  poly_translate_rat2_TCC5: OBLIGATION
    FORALL (n: nat, q: nat, k: nat, i: nat, j: nat):
           NOT q > 2 * n - k AND NOT i < n - q AND NOT i > -1 * q - k + 2 * n
       AND NOT j < i - n + k AND NOT j > i AND NOT j > k AND NOT k > n
       IMPLIES i - j >= 0 AND i - j <= n - k;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 700 0 706 999
body:
  % Subtype TCC generated (at line 250, column 48) for  (i - j)
      % expected type  {i: int | D /= 0 OR i >= 0}
  poly_translate_rat2_TCC6: OBLIGATION
    FORALL (D: real, n: nat, q: nat, k: nat, i: nat, j: nat):
           NOT q > 2 * n - k AND NOT i < n - q AND NOT i > -1 * q - k + 2 * n
       AND NOT j < i - n + k AND NOT j > i AND NOT j > k AND NOT k > n
       IMPLIES D /= 0 OR (i - j) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 708 0 714 999
body:
  % Subtype TCC generated (at line 250, column 56) for  (j - i - k + n)
      % expected type  {i: int | C /= 0 OR i >= 0}
  poly_translate_rat2_TCC7: OBLIGATION
    FORALL (C: real, n: nat, q: nat, k: nat, i: nat, j: nat):
           NOT q > 2 * n - k AND NOT i < n - q AND NOT i > -1 * q - k + 2 * n
       AND NOT j < i - n + k AND NOT j > i AND NOT j > k AND NOT k > n
       IMPLIES C /= 0 OR (j - i - k + n) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 716 0 723 999
body:
  % Subtype TCC generated (at line 251, column 14) for  -1 * i - q - k + 2 * n
      % expected type  {i: nat | i <= n - k}
  poly_translate_rat2_TCC8: OBLIGATION
    FORALL (n: nat, q: nat, k: nat, i: nat, j: nat):
           NOT q > 2 * n - k AND NOT i < n - q AND NOT i > -1 * q - k + 2 * n
       AND NOT j < i - n + k AND NOT j > i AND NOT j > k AND NOT k > n
       IMPLIES
       -1 * i - q - k + 2 * n >= 0 AND -1 * i - q - k + 2 * n <= n - k;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 725 0 732 999
body:
  % Subtype TCC generated (at line 251, column 31) for
      % (-1 * i - q - k + 2 * n)
      % expected type  {i: int | F /= 0 OR i >= 0}
  poly_translate_rat2_TCC9: OBLIGATION
    FORALL (F: real, n: nat, q: nat, k: nat, i: nat, j: nat):
           NOT q > 2 * n - k AND NOT i < n - q AND NOT i > -1 * q - k + 2 * n
       AND NOT j < i - n + k AND NOT j > i AND NOT j > k AND NOT k > n
       IMPLIES F /= 0 OR (-1 * i - q - k + 2 * n) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 734 0 740 999
body:
  % Subtype TCC generated (at line 251, column 48) for  (i + q - n)
      % expected type  {i: int | E /= 0 OR i >= 0}
  poly_translate_rat2_TCC10: OBLIGATION
    FORALL (E: real, n: nat, q: nat, k: nat, i: nat, j: nat):
           NOT q > 2 * n - k AND NOT i < n - q AND NOT i > -1 * q - k + 2 * n
       AND NOT j < i - n + k AND NOT j > i AND NOT j > k AND NOT k > n
       IMPLIES E /= 0 OR (i + q - n) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 742 0 747 999
body:
  % Subtype TCC generated (at line 255, column 22) for  n
      % expected type  {i: int | NOT F + E * x = 0 OR i >= 0}
  poly_translate_rat2_def_TCC1: OBLIGATION
    FORALL (n: nat, C, D, E, F, x: real):
      (C * x + D) /= 0 AND (E * x + F) /= 0 IMPLIES
       NOT F + E * x = 0 OR n >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 749 0 755 999
body:
  % Subtype TCC generated (at line 255, column 49) for
      % ((C * x + D) * (E * x + F))
      % expected type  nznum
  poly_translate_rat2_def_TCC2: OBLIGATION
    FORALL (C, D, E, F, x: real):
      (C * x + D) /= 0 AND (E * x + F) /= 0 IMPLIES
       ((C * x + D) * (E * x + F)) /= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 757 0 761 999
body:
  % Subtype TCC generated (at line 259, column 46) for  n - j
      % expected type  T_low[nat]
  poly_translate_inf_pos_TCC1: OBLIGATION
    FORALL (n: nat, j: nat):
      NOT j > n IMPLIES n - j >= 0 OR (EXISTS (j_1: nat): j_1 <= n - j);


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 763 0 770 999
body:
  % Subtype TCC generated (at line 260, column 39) for  i - n + j
      % expected type  {i_1: nat | i_1 <= i}
  poly_translate_inf_pos_TCC2: OBLIGATION
    FORALL (n: nat, j: nat):
      NOT j > n IMPLIES
       (FORALL (i: nat):
          NOT i < n - j AND NOT i > n IMPLIES
           i - n + j >= 0 AND i - n + j <= i);


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 772 0 779 999
body:
  % Subtype TCC generated (at line 260, column 53) for  (i - n + j)
      % expected type  {i: int | (A - 1) /= 0 OR i >= 0}
  poly_translate_inf_pos_TCC3: OBLIGATION
    FORALL (n: nat, A: real, j: nat):
      NOT j > n IMPLIES
       (FORALL (i: nat):
          NOT i < n - j AND NOT i > n IMPLIES
           (A - 1) /= 0 OR (i - n + j) >= 0);


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 781 0 788 999
body:
  % Subtype TCC generated (at line 264, column 61) for  (i - n + j)
      % expected type  {i: int | (-A - 1) /= 0 OR i >= 0}
  poly_translate_inf_neg_TCC1: OBLIGATION
    FORALL (n: nat, A: real, j: nat):
      NOT j > n IMPLIES
       (FORALL (i: nat):
          NOT i < n - j AND NOT i > n IMPLIES
           (-A - 1) /= 0 OR (i - n + j) >= 0);


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 790 0 794 999
body:
  % Subtype TCC generated (at line 268, column 84) for  n
      % expected type  {i: int | NOT 1 + x - A = 0 OR i >= 0}
  poly_translate_inf_pos_def_rev_TCC1: OBLIGATION
    FORALL (A: real, n: nat, x: real):
      x /= A - 1 IMPLIES NOT 1 + x - A = 0 OR n >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 796 0 799 999
body:
  % Subtype TCC generated (at line 268, column 134) for  (x - A + 1)
      % expected type  nznum
  poly_translate_inf_pos_def_rev_TCC2: OBLIGATION
    FORALL (A, x: real): x /= A - 1 IMPLIES (x - A + 1) /= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 801 0 805 999
body:
  % Subtype TCC generated (at line 274, column 84) for  n
      % expected type  {i: int | NOT (1 + A - x) = 0 OR i >= 0}
  poly_translate_inf_neg_def_rev_TCC1: OBLIGATION
    FORALL (A: real, n: nat, x: real):
      x /= A + 1 IMPLIES NOT (1 + A - x) = 0 OR n >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 807 0 810 999
body:
  % Subtype TCC generated (at line 274, column 134) for  (A + 1 - x)
      % expected type  nznum
  poly_translate_inf_neg_def_rev_TCC2: OBLIGATION
    FORALL (A, x: real): x /= A + 1 IMPLIES (A + 1 - x) /= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 812 0 815 999
body:
  % Subtype TCC generated (at line 312, column 109) for  2
      % expected type  {i: int | h /= 0 OR i >= 0}
  poly_eq_deriv_plus_TCC1: OBLIGATION
    FORALL (n: nat): n > 0 IMPLIES (FORALL (h: real): h /= 0 OR 2 >= 0);


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 817 0 820 999
body:
  % Subtype TCC generated (at line 320, column 52) for  n + m - 1
      % expected type  nat
  poly_product_rule_TCC1: OBLIGATION
    FORALL (m, n: nat): m > 0 AND n > 0 IMPLIES n + m - 1 >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 822 0 825 999
body:
  % Subtype TCC generated (at line 321, column 48) for  m - 1
      % expected type  nat
  poly_product_rule_TCC2: OBLIGATION
    FORALL (m, n: nat): m > 0 AND n > 0 IMPLIES m - 1 >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 827 0 829 999
body:
  % Subtype TCC generated (at line 326, column 25) for  max(n - 1, 0)
      % expected type  nat
  deriv_power_linear_TCC1: OBLIGATION FORALL (n: nat): max(n - 1, 0) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 831 0 833 999
body:
  % Subtype TCC generated (at line 330, column 37) for  n
      % expected type  {i_1: nat | i_1 <= i + n}
  poly_n_deriv_TCC1: OBLIGATION FORALL (n: nat, i: nat): n <= i + n;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 835 0 840 999
body:
  % Subtype TCC generated (at line 402, column 83) for  (y - x)
      % expected type  nznum
  poly_mean_value_TCC1: OBLIGATION
    FORALL (n: nat, x, y: real):
      n > 0 AND x < y IMPLIES
       (FORALL (cc: real): cc <= y AND x <= cc IMPLIES (y - x) /= 0);


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 842 0 845 999
body:
  % Subtype TCC generated (at line 406, column 55) for  n - 1
      % expected type  nat
  poly_integral_TCC1: OBLIGATION
    FORALL (n: nat): NOT n = 0 IMPLIES n - 1 >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 847 0 849 999
body:
  % Subtype TCC generated (at line 406, column 60) for  n
      % expected type  nznum
  poly_integral_TCC2: OBLIGATION FORALL (n: nat): NOT n = 0 IMPLIES n /= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 851 0 863 999
body:
  % Subtype TCC generated (at line 446, column 71) for  k - n
      % expected type  nat
  poly_maclaurin_TCC1: OBLIGATION
    FORALL (a: sequence[real], n, k: nat, br: real):
      (k >= n AND
        n > 0 AND br > 0 AND (FORALL (ii: nat): ii > k IMPLIES a(ii) = 0))
       IMPLIES
       (FORALL (c: real):
          c <= br AND 0 <= c IMPLIES
           (FORALL (fk: [real -> real]):
              fk = polynomial(a, k) IMPLIES
               (FORALL (fn1: [real -> real]):
                  fn1 = polynomial(a, n - 1) IMPLIES k - n >= 0)));


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 865 0 868 999
body:
  % Subtype TCC generated (at line 455, column 34) for  k - d
      % expected type  nat
  taylor_poly_TCC1: OBLIGATION
    FORALL ((k, i: nat), d: nat): i <= d AND d <= k IMPLIES k - d >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 870 0 874 999
body:
  % Subtype TCC generated (at line 455, column 71) for  (d - i)
      % expected type  {i: int | (-rr) /= 0 OR i >= 0}
  taylor_poly_TCC2: OBLIGATION
    FORALL ((k: nat), (rr: real), i: nat, d: nat):
      i <= d AND d <= k IMPLIES (-rr) /= 0 OR (d - i) >= 0;


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 876 0 881 999
body:
  % Subtype TCC generated (at line 461, column 37) for  k - n - 1
      % expected type  nat
  taylor_poly_def_TCC1: OBLIGATION
    FORALL (a: sequence[real], x: real, k: nat, rr: real):
      polynomial(taylor_poly(a, k, 0, rr), k)(x) = polynomial(a, k)(rr)
       IMPLIES (FORALL (n: nat): n < k IMPLIES k - n - 1 >= 0);


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 883 0 888 999
body:
  % Subtype TCC generated (at line 461, column 72) for  (n + 1)
      % expected type  {i: int | (x - rr) /= 0 OR i >= 0}
  taylor_poly_def_TCC2: OBLIGATION
    FORALL (a: sequence[real], x: real, k: nat, rr: real):
      polynomial(taylor_poly(a, k, 0, rr), k)(x) = polynomial(a, k)(rr)
       IMPLIES (FORALL (n: nat): n < k IMPLIES (x - rr) /= 0 OR (n + 1) >= 0);


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 890 0 901 999
body:
  % Subtype TCC generated (at line 467, column 69) for  k - n
      % expected type  nat
  poly_taylor_TCC1: OBLIGATION
    FORALL (a: sequence[real], n: nat, x, y: real, k: nat):
      k >= n AND n > 0 IMPLIES
       (FORALL (c: real):
          ((y <= c AND c <= x) OR (x <= c AND c <= y)) IMPLIES
           (FORALL (fk: [real -> real]):
              fk = polynomial(a, k) IMPLIES
               (FORALL (fn1: [real -> real]):
                  fn1 = polynomial(taylor_poly(a, k, n - 1, y), n - 1)
                   IMPLIES k - n >= 0)));


decl_type: tcc
theory: polynomials
library: reals
signature: nil
location: 903 0 914 999
body:
  % Subtype TCC generated (at line 467, column 83) for  n
      % expected type  {i: int | (x - y) /= 0 OR i >= 0}
  poly_taylor_TCC2: OBLIGATION
    FORALL (a: sequence[real], n: nat, x, y: real, k: nat):
      k >= n AND n > 0 IMPLIES
       (FORALL (c: real):
          ((y <= c AND c <= x) OR (x <= c AND c <= y)) IMPLIES
           (FORALL (fk: [real -> real]):
              fk = polynomial(a, k) IMPLIES
               (FORALL (fn1: [real -> real]):
                  fn1 = polynomial(taylor_poly(a, k, n - 1, y), n - 1)
                   IMPLIES (x - y) /= 0 OR n >= 0)));


decl_type: formula
theory: binomial_identities
library: reals
signature: nil
location: 27 2 28 82
body:
    binom_upper_summation: LEMMA n>=m IMPLIES 
      sigma(m,n,LAMBDA (k:nat): IF k<m OR k>n THEN 0 ELSE C(k,m) ENDIF) = C(n+1,m+1)


decl_type: formula
theory: binomial_identities
library: reals
signature: nil
location: 30 2 31 77
body:
    binom_parallel_summation: LEMMA 
      sigma(0,n,LAMBDA (k:nat): IF k>n THEN 0 ELSE C(r+k,k) ENDIF) = C(r+n+1,n)


decl_type: formula
theory: binomial_identities
library: reals
signature: nil
location: 33 2 34 101
body:
    binom_vandermonde_convolution: LEMMA n>=m AND n>=p IMPLIES 
      sigma(0,m,LAMBDA (k:nat): IF k>p OR k>m or m+p-n> k THEN 0 ELSE C(n-p,m-k)*C(p,k) ENDIF) = C(n,m)


decl_type: formula
theory: binomial_identities
library: reals
signature: nil
location: 36 2 37 98
body:
    binom_vandermonde_convolution_2: LEMMA n+p>=m IMPLIES 
      sigma(0,m,LAMBDA (k:nat): IF k>p OR k>m OR m-n>k THEN 0 ELSE C(n,m-k)*C(p,k) ENDIF) = C(n+p,m)


decl_type: formula
theory: binomial_identities
library: reals
signature: nil
location: 39 2 40 98
body:
    binom_vandermonde_convolution_3: LEMMA n+p>=m IMPLIES 
      sigma(0,m,LAMBDA (k:nat): IF k>m OR m-k>p OR k>n THEN 0 ELSE C(n,k)*C(p,m-k) ENDIF) = C(n+p,m)


decl_type: formula
theory: binomial_identities
library: reals
signature: nil
location: 44 2 45 112
body:
    binom_cross_sum: LEMMA k>=i IMPLIES 
      sigma(i,k,LAMBDA (j:nat):IF j<i OR j>k THEN 0 ELSE C(k,j)*C(j,i)*x^j*y^(k-j) ENDIF) = x^i*C(k,i)*(x+y)^(k-i)


decl_type: formula
theory: binomial_identities
library: reals
signature: nil
location: 47 2 49 29
body:
    binom_sum_cross_sum_half: LEMMA k>=i IMPLIES 
      sigma(i,k,LAMBDA (j:nat):IF j<i OR j>k THEN 0 ELSE C(k,j)*C(j,i)*(-1)^(k-j)*(1/2^j) ENDIF) =
      (1/2^k)*C(k,i)*(-1)^(k-i)


decl_type: formula
theory: binomial_identities
library: reals
signature: nil
location: 51 2 53 110
body:
    binom_pr1: LEMMA m>=N AND m>=i AND m<=8 IMPLIES
      sigma(max(N,i),m,LAMBDA (k:nat): IF k<max(N,i) OR k>m THEN 0 ELSE C(m-N,k-N)*C(k,i)*(-1)^(k-i)*1/2^k ENDIF) =
      sigma(0,min(N,i),LAMBDA (j:nat): IF j > min(N,i) THEN 0 ELSE C(m-j,i-j)*C(N,j)*(-1)^(N-j)*1/2^(m-j) ENDIF)


decl_type: formula
theory: binomial_identities
library: reals
signature: nil
location: 55 2 57 117
body:
    binomial_triple_cancel: LEMMA m>=N AND m>=i AND m<=8  IMPLIES
      sigma(max(N,i),m,LAMBDA (k:nat): IF k<max(N,i) OR k>m THEN 0 ELSE C(k,N)*C(m,k)*C(k,i)*(-1)^(k-i)*1/2^k ENDIF) =
      sigma(0,min(N,i),LAMBDA (j:nat): IF j > min(N,i) THEN 0 ELSE C(m-j,i-j)*C(N,j)*C(m,N)*(-1)^(N-j)*1/2^(m-j) ENDIF)


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 64 0 67 999
body:
  % Subtype TCC generated (at line 22, column 8) for  m
      % expected type  {i: nat | i <= r}
  binom_trinomial_revision_TCC1: OBLIGATION
    FORALL (k, m, r: nat): m >= k AND r >= m IMPLIES m <= r;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 69 0 72 999
body:
  % Subtype TCC generated (at line 22, column 15) for  k
      % expected type  {i: nat | i <= m}
  binom_trinomial_revision_TCC2: OBLIGATION
    FORALL (k, m, r: nat): m >= k AND r >= m IMPLIES k <= m;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 74 0 77 999
body:
  % Subtype TCC generated (at line 22, column 24) for  k
      % expected type  {i: nat | i <= r}
  binom_trinomial_revision_TCC3: OBLIGATION
    FORALL (k, m, r: nat): m >= k AND r >= m IMPLIES k <= r;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 79 0 82 999
body:
  % Subtype TCC generated (at line 22, column 29) for  r - k
      % expected type  nat
  binom_trinomial_revision_TCC4: OBLIGATION
    FORALL (k, m, r: nat): m >= k AND r >= m IMPLIES r - k >= 0;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 84 0 88 999
body:
  % Subtype TCC generated (at line 22, column 33) for  m - k
      % expected type  {i: nat | i <= r - k}
  binom_trinomial_revision_TCC5: OBLIGATION
    FORALL (k, m, r: nat):
      m >= k AND r >= m IMPLIES m - k >= 0 AND m - k <= r - k;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 90 0 93 999
body:
  % Subtype TCC generated (at line 25, column 8) for  k
      % expected type  {i: nat | i <= r}
  binom_absorption_TCC1: OBLIGATION
    FORALL (k, r: nat): k >= 1 AND r >= k IMPLIES k <= r;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 95 0 98 999
body:
  % Subtype TCC generated (at line 25, column 16) for  k
      % expected type  nznum
  binom_absorption_TCC2: OBLIGATION
    FORALL (k, r: nat): k >= 1 AND r >= k IMPLIES k /= 0;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 100 0 103 999
body:
  % Subtype TCC generated (at line 25, column 21) for  r - 1
      % expected type  nat
  binom_absorption_TCC3: OBLIGATION
    FORALL (k, r: nat): k >= 1 AND r >= k IMPLIES r - 1 >= 0;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 105 0 109 999
body:
  % Subtype TCC generated (at line 25, column 25) for  k - 1
      % expected type  {i: nat | i <= r - 1}
  binom_absorption_TCC4: OBLIGATION
    FORALL (k, r: nat):
      k >= 1 AND r >= k IMPLIES k - 1 >= 0 AND k - 1 <= r - 1;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 111 0 114 999
body:
  % Subtype TCC generated (at line 28, column 12) for  n
      % expected type  T_high[nat]
  binom_upper_summation_TCC1: OBLIGATION
    FORALL (m, n: nat): n >= m IMPLIES n >= 0 OR (EXISTS (j: nat): n <= j);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 116 0 121 999
body:
  % Subtype TCC generated (at line 28, column 60) for  m
      % expected type  {i: nat | i <= k}
  binom_upper_summation_TCC2: OBLIGATION
    FORALL (m, n: nat):
      n >= m IMPLIES
       (FORALL (k: nat): NOT k < m AND NOT k > n IMPLIES m <= k);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 123 0 126 999
body:
  % Subtype TCC generated (at line 28, column 78) for  m + 1
      % expected type  {i: nat | i <= 1 + n}
  binom_upper_summation_TCC3: OBLIGATION
    FORALL (m, n: nat): n >= m IMPLIES m + 1 <= 1 + n;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 128 0 131 999
body:
  % Subtype TCC generated (at line 31, column 12) for  n
      % expected type  T_high[nat]
  binom_parallel_summation_TCC1: OBLIGATION
    FORALL (n: nat): n >= 0 OR (EXISTS (j: nat): n <= j);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 133 0 136 999
body:
  % Subtype TCC generated (at line 31, column 55) for  k
      % expected type  {i: nat | i <= k + r}
  binom_parallel_summation_TCC2: OBLIGATION
    FORALL (n, r, k: nat): NOT k > n IMPLIES k <= k + r;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 138 0 141 999
body:
  % Subtype TCC generated (at line 31, column 75) for  n
      % expected type  {i: nat | i <= 1 + n + r}
  binom_parallel_summation_TCC3: OBLIGATION
    FORALL (n, r: nat): n <= 1 + n + r;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 143 0 147 999
body:
  % Subtype TCC generated (at line 34, column 12) for  m
      % expected type  T_high[nat]
  binom_vandermonde_convolution_TCC1: OBLIGATION
    FORALL (m, n, p: nat):
      n >= p AND n >= m IMPLIES m >= 0 OR (EXISTS (j: nat): m <= j);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 149 0 155 999
body:
  % Subtype TCC generated (at line 34, column 70) for  n - p
      % expected type  nat
  binom_vandermonde_convolution_TCC2: OBLIGATION
    FORALL (m, n, p: nat):
      n >= p AND n >= m IMPLIES
       (FORALL (k: nat):
          NOT k > p AND NOT k > m AND NOT m + p - n > k IMPLIES n - p >= 0);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 157 0 164 999
body:
  % Subtype TCC generated (at line 34, column 74) for  m - k
      % expected type  {i: nat | i <= n - p}
  binom_vandermonde_convolution_TCC3: OBLIGATION
    FORALL (m, n, p: nat):
      n >= p AND n >= m IMPLIES
       (FORALL (k: nat):
          NOT k > p AND NOT k > m AND NOT m + p - n > k IMPLIES
           m - k >= 0 AND m - k <= n - p);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 166 0 172 999
body:
  % Subtype TCC generated (at line 34, column 83) for  k
      % expected type  {i: nat | i <= p}
  binom_vandermonde_convolution_TCC4: OBLIGATION
    FORALL (m, n, p: nat):
      n >= p AND n >= m IMPLIES
       (FORALL (k: nat):
          NOT k > p AND NOT k > m AND NOT m + p - n > k IMPLIES k <= p);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 174 0 177 999
body:
  % Subtype TCC generated (at line 34, column 99) for  m
      % expected type  {i: nat | i <= n}
  binom_vandermonde_convolution_TCC5: OBLIGATION
    FORALL (m, n, p: nat): n >= p AND n >= m IMPLIES m <= n;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 179 0 183 999
body:
  % Subtype TCC generated (at line 37, column 12) for  m
      % expected type  T_high[nat]
  binom_vandermonde_convolution_2_TCC1: OBLIGATION
    FORALL (m, n, p: nat):
      n + p >= m IMPLIES m >= 0 OR (EXISTS (j: nat): m <= j);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 185 0 192 999
body:
  % Subtype TCC generated (at line 37, column 69) for  m - k
      % expected type  {i: nat | i <= n}
  binom_vandermonde_convolution_2_TCC2: OBLIGATION
    FORALL (m, n, p: nat):
      n + p >= m IMPLIES
       (FORALL (k: nat):
          NOT k > p AND NOT k > m AND NOT m - n > k IMPLIES
           m - k >= 0 AND m - k <= n);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 194 0 200 999
body:
  % Subtype TCC generated (at line 37, column 78) for  k
      % expected type  {i: nat | i <= p}
  binom_vandermonde_convolution_2_TCC3: OBLIGATION
    FORALL (m, n, p: nat):
      n + p >= m IMPLIES
       (FORALL (k: nat):
          NOT k > p AND NOT k > m AND NOT m - n > k IMPLIES k <= p);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 202 0 205 999
body:
  % Subtype TCC generated (at line 37, column 96) for  m
      % expected type  {i: nat | i <= n + p}
  binom_vandermonde_convolution_2_TCC4: OBLIGATION
    FORALL (m, n, p: nat): n + p >= m IMPLIES m <= n + p;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 207 0 213 999
body:
  % Subtype TCC generated (at line 40, column 69) for  k
      % expected type  {i: nat | i <= n}
  binom_vandermonde_convolution_3_TCC1: OBLIGATION
    FORALL (m, n, p: nat):
      n + p >= m IMPLIES
       (FORALL (k: nat):
          NOT k > m AND NOT m - k > p AND NOT k > n IMPLIES k <= n);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 215 0 222 999
body:
  % Subtype TCC generated (at line 40, column 76) for  m - k
      % expected type  {i: nat | i <= p}
  binom_vandermonde_convolution_3_TCC2: OBLIGATION
    FORALL (m, n, p: nat):
      n + p >= m IMPLIES
       (FORALL (k: nat):
          NOT k > m AND NOT m - k > p AND NOT k > n IMPLIES
           m - k >= 0 AND m - k <= p);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 224 0 229 999
body:
  % Subtype TCC generated (at line 45, column 59) for  j
      % expected type  {i: nat | i <= k}
  binom_cross_sum_TCC1: OBLIGATION
    FORALL (i, k: nat):
      k >= i IMPLIES
       (FORALL (j: nat): NOT j < i AND NOT j > k IMPLIES j <= k);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 231 0 236 999
body:
  % Subtype TCC generated (at line 45, column 71) for  j
      % expected type  {i: int | x /= 0 OR i >= 0}
  binom_cross_sum_TCC2: OBLIGATION
    FORALL (i, k: nat, x: real):
      k >= i IMPLIES
       (FORALL (j: nat): NOT j < i AND NOT j > k IMPLIES x /= 0 OR j >= 0);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 238 0 244 999
body:
  % Subtype TCC generated (at line 45, column 76) for  (k - j)
      % expected type  {i: int | y /= 0 OR i >= 0}
  binom_cross_sum_TCC3: OBLIGATION
    FORALL (i, k: nat, y: real):
      k >= i IMPLIES
       (FORALL (j: nat):
          NOT j < i AND NOT j > k IMPLIES y /= 0 OR (k - j) >= 0);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 246 0 249 999
body:
  % Subtype TCC generated (at line 45, column 92) for  i
      % expected type  {i: int | x /= 0 OR i >= 0}
  binom_cross_sum_TCC4: OBLIGATION
    FORALL (i, k: nat, x: real): k >= i IMPLIES x /= 0 OR i >= 0;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 251 0 253 999
body:
  % Subtype TCC generated (at line 45, column 98) for  i
      % expected type  {i: nat | i <= k}
  binom_cross_sum_TCC5: OBLIGATION FORALL (i, k: nat): k >= i IMPLIES i <= k;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 255 0 259 999
body:
  % Subtype TCC generated (at line 45, column 108) for  (k - i)
      % expected type  {i: int | (x + y) /= 0 OR i >= 0}
  binom_cross_sum_TCC6: OBLIGATION
    FORALL (i, k: nat, x, y: real):
      k >= i IMPLIES (x + y) /= 0 OR (k - i) >= 0;


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 261 0 266 999
body:
  % Subtype TCC generated (at line 52, column 19) for  m
      % expected type  T_high[nat]
  binom_pr1_TCC1: OBLIGATION
    FORALL (N, i, m: nat):
      m <= 8 AND m >= i AND m >= N IMPLIES
       m >= 0 OR (EXISTS (j: nat): m <= j);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 268 0 273 999
body:
  % Subtype TCC generated (at line 52, column 72) for  m - N
      % expected type  nat
  binom_pr1_TCC2: OBLIGATION
    FORALL (N, i, m: nat):
      m <= 8 AND m >= i AND m >= N IMPLIES
       (FORALL (k: nat): NOT k < max(N, i) AND NOT k > m IMPLIES m - N >= 0);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 275 0 282 999
body:
  % Subtype TCC generated (at line 52, column 76) for  k - N
      % expected type  {i: nat | i <= m - N}
  binom_pr1_TCC3: OBLIGATION
    FORALL (N, i, m: nat):
      m <= 8 AND m >= i AND m >= N IMPLIES
       (FORALL (k: nat):
          NOT k < max(N, i) AND NOT k > m IMPLIES
           k - N >= 0 AND k - N <= m - N);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 284 0 289 999
body:
  % Subtype TCC generated (at line 52, column 85) for  i
      % expected type  {i: nat | i <= k}
  binom_pr1_TCC4: OBLIGATION
    FORALL (N, i, m: nat):
      m <= 8 AND m >= i AND m >= N IMPLIES
       (FORALL (k: nat): NOT k < max(N, i) AND NOT k > m IMPLIES i <= k);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 291 0 296 999
body:
  % Subtype TCC generated (at line 53, column 12) for  min(N, i)
      % expected type  T_high[nat]
  binom_pr1_TCC5: OBLIGATION
    FORALL (N, i, m: nat):
      m <= 8 AND m >= i AND m >= N IMPLIES
       min(N, i) >= 0 OR (EXISTS (j: nat): min(N, i) <= j);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 298 0 303 999
body:
  % Subtype TCC generated (at line 53, column 67) for  m - j
      % expected type  nat
  binom_pr1_TCC6: OBLIGATION
    FORALL (N, i, m: nat):
      m <= 8 AND m >= i AND m >= N IMPLIES
       (FORALL (j: nat): NOT j > min(N, i) IMPLIES m - j >= 0);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 305 0 311 999
body:
  % Subtype TCC generated (at line 53, column 71) for  i - j
      % expected type  {i: nat | i <= m - j}
  binom_pr1_TCC7: OBLIGATION
    FORALL (N, i, m: nat):
      m <= 8 AND m >= i AND m >= N IMPLIES
       (FORALL (j: nat):
          NOT j > min(N, i) IMPLIES i - j >= 0 AND i - j <= m - j);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 313 0 318 999
body:
  % Subtype TCC generated (at line 53, column 80) for  j
      % expected type  {i: nat | i <= N}
  binom_pr1_TCC8: OBLIGATION
    FORALL (N, i, m: nat):
      m <= 8 AND m >= i AND m >= N IMPLIES
       (FORALL (j: nat): NOT j > min(N, i) IMPLIES j <= N);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 320 0 325 999
body:
  % Subtype TCC generated (at line 56, column 74) for  N
      % expected type  {i: nat | i <= k}
  binomial_triple_cancel_TCC1: OBLIGATION
    FORALL (N, i, m: nat):
      m <= 8 AND m >= i AND m >= N IMPLIES
       (FORALL (k: nat): NOT k < max(N, i) AND NOT k > m IMPLIES N <= k);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 327 0 332 999
body:
  % Subtype TCC generated (at line 56, column 81) for  k
      % expected type  {i: nat | i <= m}
  binomial_triple_cancel_TCC2: OBLIGATION
    FORALL (N, i, m: nat):
      m <= 8 AND m >= i AND m >= N IMPLIES
       (FORALL (k: nat): NOT k < max(N, i) AND NOT k > m IMPLIES k <= m);


decl_type: tcc
theory: binomial_identities
library: reals
signature: nil
location: 334 0 339 999
body:
  % Subtype TCC generated (at line 57, column 87) for  N
      % expected type  {i: nat | i <= m}
  binomial_triple_cancel_TCC3: OBLIGATION
    FORALL (N, i, m: nat):
      m <= 8 AND m >= i AND m >= N IMPLIES
       (FORALL (j: nat): NOT j > min(N, i) IMPLIES N <= m);


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 37 2 40 99
body:
    Bern_Polynomial: LEMMA 
               FORALL (i:nat, nn:above(i-1)):
               Bern(i,nn) = 
                 polynomial((LAMBDA (j:nat): IF j<i OR j>nn THEN 0 ELSE (-1)^(j-i)*C(nn,j)*C(j,i) ENDIF),nn)


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 44 2 45 79
body:
    Bern_nonnegative: LEMMA 
                      0<=x AND x<=1 IMPLIES FORALL (i:nat, nn:above(i-1)): Bern(i,nn)(x) >= 0


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 47 2 48 75
body:
    Bern_positive: LEMMA
                   0<x AND x<1 IMPLIES FORALL (i:nat, nn:above(i-1)): Bern(i,nn)(x) > 0


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 52 2 53 82
body:
    Bernstein_degree_raise: LEMMA
      k>p IMPLIES Bern(p,k-1)(x) = ((k-p)/k)*Bern(p,k)(x) + ((p+1)/k)*Bern(p+1,k)(x)


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 78 2 79 74
body:
    Bernstein_partition_of_unity: LEMMA
      sigma(0,p,(LAMBDA (i:nat): IF i>p THEN 0 ELSE Bern(i,p)(x) ENDIF)) = 1


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 83 2 85 99
body:
    Bernstein_conversion: LEMMA 
      k>=p IMPLIES
      x^p = sigma(p,k,(LAMBDA (i:nat): IF i<p OR i>k THEN 0 ELSE (C(i,p)/C(k,p))*Bern(i,k)(x) ENDIF))


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 87 2 89 99
body:
    Bernstein_conversion_2: LEMMA
      k>=p IMPLIES
      x^p = sigma(0,k,(LAMBDA (i:nat): IF i<p OR i>k THEN 0 ELSE (C(i,p)/C(k,p))*Bern(i,k)(x) ENDIF))


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 118 2 125 43
body:
    Bern_structural_decomp: LEMMA
      ((FORALL (b1,b2: Bernstein_Polynomial): b1`index = b2`index AND P(b1) AND P(b2) 
        IMPLIES P((# index:= b1`index,bern_seq := (LAMBDA (i:upto(b1`index)): b1`bern_seq(i) + b2`bern_seq(i)) #)))
      AND
      (FORALL (i,m:nat,x:real): i<=m IMPLIES 
       P((# index := m, bern_seq := (LAMBDA (j:upto(m)): IF j = i THEN x ELSE 0 ENDIF) #))))
      IMPLIES
      (FORALL (b:Bernstein_Polynomial): P(b))


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 135 2 136 73
body:
    Bernstein_equivalence: LEMMA
      m>=p IMPLIES polynomial(a,p) = Bern_poly(Bernstein_polynomial(a,p,m))


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 153 2 153 103
body:
    Bern_subdiv_left_id: LEMMA Bern_poly(Bern_subdiv_left(b)) = Bern_poly(b) o (LAMBDA (x:real): (1/2)*x)


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 155 2 156 49
body:
    Bern_subdiv_left_reverse: LEMMA Bern_poly(Bern_poly_reverse(Bern_subdiv_left(Bern_poly_reverse(b)))) = 
      Bern_poly(b) o (LAMBDA (x:real): (1/2)*(x+1)) 


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 158 2 158 109
body:
    Bern_subdiv_right_id: LEMMA Bern_poly(Bern_subdiv_right(b)) = Bern_poly(b) o (LAMBDA (x:real): (1/2)*(x+1))


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 160 2 165 49
body:
    Bern_subdiv_ge: LEMMA 
                    (FORALL (y:real): 0<=y AND y<=1 IMPLIES Bern_poly(Bern_subdiv_right(b))(y) >= Ma) 
                    AND 
                    (FORALL (y:real): 0<=y AND y<=1 IMPLIES Bern_poly(Bern_subdiv_left(b))(y) >= Ma)
                    IMPLIES 
                    (0<=x AND x<=1 IMPLIES Bern_poly(b)(x) >= Ma)


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 184 2 194 10
body:
    Bern_sweep_expand: LEMMA
      p<=b`index IMPLIES
      Bern_sweep(b)(p) =
        (# index := b`index,
        bern_seq :=
        (LAMBDA (i:upto(b`index)):
          IF i<=p THEN
            (1/(2^i))*sigma(0,i,(LAMBDA (j:nat): IF j > i THEN 0 ELSE b`bern_seq(j)*C(i,j) ENDIF))
          ELSE
            (1/(2^p))*sigma(0,p,(LAMBDA (j:nat): IF j > p THEN 0 ELSE b`bern_seq(j+(i-p))*C(p,j) ENDIF))
          ENDIF) #)


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 204 2 204 101
body:
    Bern_subdiv_r_id: LEMMA Bern_poly(Bern_subdiv_r(b)) = Bern_poly(b) o (LAMBDA (x:real): (1/2)*(x+1))


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 217 2 218 112
body:
    Bernstein_le: LEMMA 
      (FORALL (s:upto(m)): Bern_coeff(a,p,m)(s) <= Ma) AND 0<=x AND x<=1 AND m>=p IMPLIES polynomial(a,p)(x) <= Ma


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 220 2 221 110
body:
    Bernstein_lt: LEMMA 
      (FORALL (s:upto(m)): Bern_coeff(a,p,m)(s) < Ma) AND 0<=x AND x<=1 AND m>=p IMPLIES polynomial(a,p)(x) < Ma


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 223 2 224 112
body:
    Bernstein_ge: LEMMA 
      (FORALL (s:upto(m)): Bern_coeff(a,p,m)(s) >= Ma) AND 0<=x AND x<=1 AND m>=p IMPLIES polynomial(a,p)(x) >= Ma


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 226 2 227 110
body:
    Bernstein_gt: LEMMA 
      (FORALL (s:upto(m)): Bern_coeff(a,p,m)(s) > Ma) AND 0<=x AND x<=1 AND m>=p IMPLIES polynomial(a,p)(x) > Ma


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 231 2 232 99
body:
    Bern_poly_le: LEMMA 
      (FORALL (s:upto(b`index)): b`bern_seq(s) <= Ma) AND 0<=x AND x<=1 IMPLIES Bern_poly(b)(x) <= Ma


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 234 2 235 97
body:
    Bern_poly_lt: LEMMA 
      (FORALL (s:upto(b`index)): b`bern_seq(s) < Ma) AND 0<=x AND x<=1 IMPLIES Bern_poly(b)(x) < Ma


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 237 2 238 99
body:
    Bern_poly_ge: LEMMA 
      (FORALL (s:upto(b`index)): b`bern_seq(s) >= Ma) AND 0<=x AND x<=1 IMPLIES Bern_poly(b)(x) >= Ma


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 240 2 241 97
body:
    Bern_poly_gt: LEMMA 
      (FORALL (s:upto(b`index)): b`bern_seq(s) > Ma) AND 0<=x AND x<=1 IMPLIES Bern_poly(b)(x) > Ma


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 245 2 251 44
body:
    Bern_poly_quotient_le: LEMMA
      b1`index = b2`index AND
      (FORALL (s:upto(b2`index)): b2`bern_seq(s) > 0) AND
      (FORALL (s:upto(b1`index)): b1`bern_seq(s)/b2`bern_seq(s) <= Ma)
      AND 0<=x AND x<=1 IMPLIES
      (Bern_poly(b2)(x) > 0 AND
      Bern_poly(b1)(x)/Bern_poly(b2)(x) <= Ma)


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 255 2 259 76
body:
    Bern_poly_split_le: LEMMA
       LET bsl = Bern_subdiv_l(b),bsr = Bern_subdiv_r(b) IN
          (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(bsr)(x)<=Ma) AND 
          (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(bsl)(x)<=Ma)
          IMPLIES (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(b)(x)<=Ma)


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 261 2 265 75
body:
    Bern_poly_split_lt: LEMMA
       LET bsl = Bern_subdiv_l(b),bsr = Bern_subdiv_r(b) IN
          (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(bsr)(x)<Ma) AND 
          (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(bsl)(x)<Ma)
          IMPLIES (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(b)(x)<Ma)


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 267 2 271 76
body:
    Bern_poly_split_ge: LEMMA
       LET bsl = Bern_subdiv_l(b),bsr = Bern_subdiv_r(b) IN
          (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(bsr)(x)>=Ma) AND 
          (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(bsl)(x)>=Ma)
          IMPLIES (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(b)(x)>=Ma)


decl_type: formula
theory: bernstein_polynomials
library: reals
signature: nil
location: 273 2 277 75
body:
    Bern_poly_split_gt: LEMMA
       LET bsl = Bern_subdiv_l(b),bsr = Bern_subdiv_r(b) IN
          (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(bsr)(x)>Ma) AND 
          (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(bsl)(x)>Ma)
          IMPLIES (FORALL (x:real): 0<=x AND x<=1 IMPLIES Bern_poly(b)(x)>Ma)


decl_type: type
theory: bernstein_polynomials
library: reals
signature: nil
location: 326 2 327 102
body:
    Bernstein_MinMax_Collection: TYPE = [# number_polys : posnat, 
                                         bern_poly_number : [below(number_polys) -> Bernstein_MinMax] #]


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_Polynomial -> Bernstein_Polynomial]
location: 55 2 66 10
body:
    degree_raise(b): Bernstein_Polynomial =
      LET
        m = b`index,
        bseq = b`bern_seq
      IN
        (# index := m+1,
        bern_seq := (LAMBDA (i:upto(m+1)):
          IF i = 0 THEN bseq(0)
          ELSIF i = m+1 THEN bseq(m)
          ELSE
            (bseq(i)*(m+1-i) + bseq(i-1)*i)/(m+1)
          ENDIF) #)


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [[Bernstein_Polynomial, nat] -> Bernstein_Polynomial]
location: 68 2 72 13
body:
    degree_raise_power(b,j): RECURSIVE Bernstein_Polynomial =
      IF j=0 THEN b
      ELSE degree_raise(degree_raise_power(b,j-1))
      ENDIF 
      MEASURE j


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_Polynomial -> [real -> real]]
location: 93 2 94 104
body:
    Bern_poly(b): [real -> real] = LAMBDA (x:real):
      sigma(0,b`index,(LAMBDA (i:nat): IF i > b`index THEN 0 ELSE b`bern_seq(i)*Bern(i,b`index)(x) ENDIF))


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_Polynomial -> Bernstein_Polynomial]
location: 100 2 101 87
body:
    Bern_poly_reverse(b): Bernstein_Polynomial = 
      (# index:=b`index, bern_seq := (LAMBDA (i:upto(b`index)): b`bern_seq(b`index-i)) #)


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_Polynomial -> sequence[real]]
location: 107 2 112 6
body:
    Bern_poly_inverse(b): sequence[real] = LAMBDA (j:nat): 
          IF j>b`index THEN 
            0
          ELSE
            sigma(0,j,(LAMBDA (i:nat): IF i > j THEN 0 ELSE b`bern_seq(i)*(-1)^(j-i)*(C(b`index,j)*C(j,i)) ENDIF))
          ENDIF


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [[sequence[real], nat, nat] -> Bernstein_Polynomial]
location: 131 2 133 116
body:
    Bernstein_polynomial(a,p,m): Bernstein_Polynomial =
     (# index := m,
     bern_seq := LAMBDA (s: upto(m)): sigma(0,s,LAMBDA(i:nat):IF i>s OR i>p THEN 0 ELSE a(i)*(C(s,i)/C(m,i)) ENDIF) #)


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_Polynomial -> Bernstein_Polynomial]
location: 143 2 146 86
body:
    Bern_subdiv_left(b): Bernstein_Polynomial =
      (# index := b`index,
         bern_seq := LAMBDA (i:upto(b`index)): (1/2^i)*sigma(0,i,
                     LAMBDA (j:nat): IF j > i THEN 0 ELSE C(i,j)*b`bern_seq(j) ENDIF) #)


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_Polynomial -> Bernstein_Polynomial]
location: 148 2 151 107
body:
    Bern_subdiv_right(b): Bernstein_Polynomial =
      (# index := b`index,
      bern_seq := LAMBDA (i:upto(b`index)): (1/2^(b`index-i))*sigma(0,b`index-i,
                  LAMBDA (j:nat): IF j > b`index-i THEN 0 ELSE C(b`index-i,j)*b`bern_seq(b`index-j) ENDIF) #)


decl_type: function
theory: bernstein_polynomials
library: reals
location: 173 2 182 24
signature:
  [b: Bernstein_Polynomial ->
          [upto(b`index) ->
             {bp: Bernstein_Polynomial | bp`index = b`index}]]

body:
    Bern_sweep(b)(p:upto(b`index)): RECURSIVE {bp: Bernstein_Polynomial | bp`index = b`index}
      = (# index := b`index,
        bern_seq :=
        IF p = 0 THEN b`bern_seq
        ELSE
          (LAMBDA (i:upto(b`index)):
          IF i<p THEN Bern_sweep(b)(p-1)`bern_seq(i)
          ELSE (1/2)*(Bern_sweep(b)(p-1)`bern_seq(i-1) + Bern_sweep(b)(p-1)`bern_seq(i))
          ENDIF)
        ENDIF #) MEASURE p


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_Polynomial -> Bernstein_Polynomial]
location: 198 2 200 93
body:
    Bern_subdiv_r(b): Bernstein_Polynomial = 
                      (# index := b`index,
                      bern_seq := (LAMBDA (i:upto(b`index)): Bern_sweep(b)(b`index - i)`bern_seq(b`index)) #)


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [d: [sequence[real], nat, nat] -> [upto(d`3) -> real]]
location: 214 2 215 100
body:
    Bern_coeff(a,p,m)(s: upto(m)): real = 
      LET msp = min(s,p) IN sigma(0,msp,LAMBDA(i:nat):IF i>msp THEN 0 ELSE a(i)*(C(s,i)/C(m,i)) ENDIF)


decl_type: function
theory: bernstein_polynomials
library: reals
location: 283 2 288 13
signature:
  [b: Bernstein_Polynomial ->
          [q: upto(b`index) ->
             {r: real |
                      (EXISTS (iq: upto(q)): r = b`bern_seq(iq)) AND
                       (FORALL (iq: upto(q)): r <= b`bern_seq(iq))}]]

body:
    Bern_min_rec(b)(q:upto(b`index)): RECURSIVE 
      {r:real | (EXISTS (iq:upto(q)): r = b`bern_seq(iq)) AND (FORALL (iq:upto(q)): r <= b`bern_seq(iq))} =
      LET y = b`bern_seq(q),
          x = IF q = 0 THEN y ELSE Bern_min_rec(b)(q-1) ENDIF
      IN  min(y,x)
      MEASURE q


decl_type: function
theory: bernstein_polynomials
library: reals
location: 290 2 295 12
signature:
  [b: Bernstein_Polynomial ->
          [q: upto(b`index) ->
             {r: real |
                      (EXISTS (iq: upto(q)): r = b`bern_seq(iq)) AND
                       (FORALL (iq: upto(q)): r >= b`bern_seq(iq))}]]

body:
    Bern_max_rec(b)(q:upto(b`index)): RECURSIVE 
     {r:real | (EXISTS (iq:upto(q)): r = b`bern_seq(iq)) AND (FORALL (iq:upto(q)): r >= b`bern_seq(iq))} =
     LET y = b`bern_seq(q),
         x = IF q = 0 THEN y ELSE Bern_max_rec(b)(q-1) ENDIF
     IN   max(y,x)
     MEASURE q


decl_type: function
theory: bernstein_polynomials
library: reals
location: 297 2 300 27
signature:
  [b: Bernstein_Polynomial ->
          {r: real |
                   (EXISTS (ib: upto(b`index)): r = b`bern_seq(ib)) AND
                    (FORALL (ib: upto(b`index)):
                       r <= b`bern_seq(ib))}]

body:
    Bern_min(b) : 
     {r : real | (EXISTS (ib:upto(b`index)): r = b`bern_seq(ib)) AND 
                 (FORALL (ib:upto(b`index)): r<=b`bern_seq(ib))} = 
     Bern_min_rec(b)(b`index)


decl_type: function
theory: bernstein_polynomials
library: reals
location: 302 2 305 28
signature:
  [b: Bernstein_Polynomial ->
          {r: real |
                   (EXISTS (ib: upto(b`index)): r = b`bern_seq(ib)) AND
                    (FORALL (ib: upto(b`index)):
                       r >= b`bern_seq(ib))}]

body:
    Bern_max(b) : 
     {r : real | (EXISTS (ib:upto(b`index)): r = b`bern_seq(ib)) AND 
                 (FORALL (ib:upto(b`index)): r>=b`bern_seq(ib))} = 
      Bern_max_rec(b)(b`index)


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_Polynomial -> Bernstein_MinMax]
location: 324 2 324 105
body:
    Bern_minmax(b) : Bernstein_MinMax = (# bernpoly := b, bernmin := Bern_min(b), bernmax := Bern_max(b) #)


decl_type: function
theory: bernstein_polynomials
library: reals
signature:
  [[Bernstein_MinMax_Collection, Bernstein_MinMax_Collection] ->
  Bernstein_MinMax_Collection]

location: 331 2 335 103
body:
    Bern_concat(BC1,BC2): Bernstein_MinMax_Collection = 
      LET NN = BC1`number_polys + BC2`number_polys IN
      (# number_polys := NN, 
         bern_poly_number := LAMBDA (i:below(NN)): IF i<=BC1`number_polys-1 THEN BC1`bern_poly_number(i) 
                                                   ELSE BC2`bern_poly_number(i-BC1`number_polys) ENDIF #)


decl_type: function
theory: bernstein_polynomials
library: reals
signature:
  [BC: Bernstein_MinMax_Collection ->
  [below(BC`number_polys) -> real]]

location: 337 2 340 12
body:
    Bern_collection_min_est_rec(BC)(np:below(BC`number_polys)) : RECURSIVE real = 
      IF np = 0 THEN Bern_min_est(BC`bern_poly_number(0)`bernpoly)
      ELSE min(Bern_min_est(BC`bern_poly_number(0)`bernpoly),Bern_collection_min_est_rec(BC)(np-1)) ENDIF
    MEASURE np


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_MinMax_Collection -> real]
location: 342 2 343 96
body:
    Bern_collection_min_est(BC): real = 
      IF BC`number_polys /= 0 THEN Bern_collection_min_est_rec(BC)(BC`number_polys-1) ELSE 0 ENDIF


decl_type: function
theory: bernstein_polynomials
library: reals
location: 345 2 353 12
signature:
  [BC: Bernstein_MinMax_Collection ->
          [below(BC`number_polys) -> Bernstein_MinMax_Collection]]

body:
    Bern_collection_reduce_min_rec(BC)(np:below(BC`number_polys)): RECURSIVE Bernstein_MinMax_Collection = 
      LET minest = Bern_collection_min_est(BC),
          thispoly:Bernstein_MinMax_Collection = (# number_polys := 1, 
                                                    bern_poly_number := LAMBDA (i:below(1)): BC`bern_poly_number(np) #)
      IN
      IF np = 0 THEN thispoly
      ELSIF BC`bern_poly_number(np)`bernmin > minest THEN Bern_collection_reduce_min_rec(BC)(np-1)
      ELSE  Bern_concat(Bern_collection_reduce_min_rec(BC)(np-1),thispoly) ENDIF
    MEASURE np


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_MinMax_Collection -> Bernstein_MinMax_Collection]
location: 355 2 356 57
body:
    Bern_collection_reduce_min(BC) : Bernstein_MinMax_Collection = 
      Bern_collection_reduce_min_rec(BC)(BC`number_polys-1)


decl_type: function
theory: bernstein_polynomials
library: reals
signature:
  [BC: Bernstein_MinMax_Collection ->
  [below(BC`number_polys) -> real]]

location: 360 2 365 12
body:
    Bern_min_coeff_rec(BC)(np:below(BC`number_polys)) : RECURSIVE real =
      LET current_poly_min = BC`bern_poly_number(np)`bernmin
      IN
      IF np = 0 THEN current_poly_min
      ELSE min(current_poly_min,Bern_min_coeff_rec(BC)(np-1)) ENDIF 
    MEASURE np


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_MinMax_Collection -> Bernstein_MinMax_Collection]
location: 371 2 374 93
body:
    Bern_coll_subdiv_total_left(BC) : Bernstein_MinMax_Collection =
      (# number_polys := BC`number_polys, 
         bern_poly_number := LAMBDA (np: below(BC`number_polys)): 
                             Bern_minmax(Bern_subdiv_left(BC`bern_poly_number(np)`bernpoly)) #)


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_MinMax_Collection -> Bernstein_MinMax_Collection]
location: 376 2 379 94
body:
    Bern_coll_subdiv_total_right(BC) : Bernstein_MinMax_Collection =
      (# number_polys := BC`number_polys, 
         bern_poly_number := LAMBDA (np: below(BC`number_polys)): 
                             Bern_minmax(Bern_subdiv_right(BC`bern_poly_number(np)`bernpoly)) #)


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_MinMax_Collection -> Bernstein_MinMax_Collection]
location: 381 2 382 80
body:
    Bern_coll_subdiv_total(BC) : Bernstein_MinMax_Collection = 
     Bern_concat(Bern_coll_subdiv_total_left(BC),Bern_coll_subdiv_total_right(BC))


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_MinMax_Collection -> Bernstein_MinMax_Collection]
location: 384 2 385 58
body:
    Bern_coll_subdiv_reduced(BC) : Bernstein_MinMax_Collection = 
      Bern_collection_reduce_min(Bern_coll_subdiv_total(BC))


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [Bernstein_Polynomial -> [nat -> Bernstein_MinMax_Collection]]
location: 387 2 392 13
body:
    Bern_split(b)(n :nat) : recursive Bernstein_MinMax_Collection =
      IF n=0 THEN (# number_polys := 1, bern_poly_number := (LAMBDA (i:below(1)): Bern_minmax(b)) #)
      ELSE
      Bern_coll_subdiv_reduced(Bern_split(b)(n-1))
      ENDIF
      MEASURE n


decl_type: function
theory: bernstein_polynomials
library: reals
signature: [[sequence[real], nat, nat] -> [nat -> real]]
location: 394 2 396 39
body:
    Bern_split_min_coeff(a,p,m)(n:nat) : real =
      LET b = Bernstein_polynomial(a,p,m)
      IN Bern_min_coeff(Bern_split(b)(n))


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 403 0 405 999
body:
  % Subtype TCC generated (at line 27, column 41) for  n
      % expected type  nat
  Bern_TCC1: OBLIGATION FORALL (i: nat, n: above(i - 1)): n >= 0;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 407 0 409 999
body:
  % Subtype TCC generated (at line 27, column 43) for  i
      % expected type  {i_1: nat | i_1 <= n}
  Bern_TCC2: OBLIGATION FORALL (i: nat, n: above(i - 1)): i <= n;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 411 0 413 999
body:
  % Subtype TCC generated (at line 27, column 48) for  i
      % expected type  {i: int | x /= 0 OR i >= 0}
  Bern_TCC3: OBLIGATION FORALL (i: nat, x: real): x /= 0 OR i >= 0;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 415 0 418 999
body:
  % Subtype TCC generated (at line 27, column 57) for  (n - i)
      % expected type  {i: int | (1 - x) /= 0 OR i >= 0}
  Bern_TCC4: OBLIGATION
    FORALL (i: nat, n: above(i - 1), x: real): (1 - x) /= 0 OR (n - i) >= 0;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 420 0 422 999
body:
  % Subtype TCC generated (at line 29, column 25) for  p
      % expected type  above(p - 1)
  Bern_top_TCC1: OBLIGATION FORALL (p: nat): p > p - 1;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 424 0 426 999
body:
  % Subtype TCC generated (at line 31, column 28) for  k
      % expected type  above(-1)
  Bern_bottom_TCC1: OBLIGATION FORALL (k: posnat): k > -1;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 428 0 431 999
body:
  % Subtype TCC generated (at line 31, column 42) for  k
      % expected type  {i: int | (1 - x) /= 0 OR i >= 0}
  Bern_bottom_TCC2: OBLIGATION
    FORALL (k: posnat, x: real): (1 - x) /= 0 OR k >= 0;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 433 0 437 999
body:
  % Subtype TCC generated (at line 40, column 79) for  j
      % expected type  {i_1: nat | i_1 <= nn}
  Bern_Polynomial_TCC1: OBLIGATION
    FORALL (i: nat, nn: above(i - 1), j: nat):
      NOT j < i AND NOT j > nn IMPLIES j <= nn;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 439 0 443 999
body:
  % Subtype TCC generated (at line 40, column 86) for  i
      % expected type  {i: nat | i <= j}
  Bern_Polynomial_TCC2: OBLIGATION
    FORALL (i: nat, nn: above(i - 1), j: nat):
      NOT j < i AND NOT j > nn IMPLIES i <= j;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 445 0 448 999
body:
  % Subtype TCC generated (at line 42, column 48) for  k
      % expected type  above(r - 1)
  Bernstein_Recursion_TCC1: OBLIGATION
    FORALL (k, r: posnat): k > r IMPLIES k > r - 1;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 450 0 453 999
body:
  % Subtype TCC generated (at line 42, column 69) for  k - 1
      % expected type  above(r - 1)
  Bernstein_Recursion_TCC2: OBLIGATION
    FORALL (k, r: posnat): k > r IMPLIES k - 1 > r - 1;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 455 0 458 999
body:
  % Subtype TCC generated (at line 42, column 86) for  r - 1
      % expected type  nat
  Bernstein_Recursion_TCC3: OBLIGATION
    FORALL (k, r: posnat): k > r IMPLIES r - 1 >= 0;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 460 0 463 999
body:
  % Subtype TCC generated (at line 42, column 90) for  k - 1
      % expected type  above(r - 2)
  Bernstein_Recursion_TCC4: OBLIGATION
    FORALL (k, r: posnat): k > r IMPLIES k - 1 > r - 2;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 465 0 468 999
body:
  % Subtype TCC generated (at line 53, column 23) for  k - 1
      % expected type  above(p - 1)
  Bernstein_degree_raise_TCC1: OBLIGATION
    FORALL (k: posnat, p: nat): k > p IMPLIES k - 1 > p - 1;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 470 0 473 999
body:
  % Subtype TCC generated (at line 53, column 50) for  k
      % expected type  above(p - 1)
  Bernstein_degree_raise_TCC2: OBLIGATION
    FORALL (k: posnat, p: nat): k > p IMPLIES k > p - 1;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 475 0 482 999
body:
  % Subtype TCC generated (at line 62, column 27) for  0
      % expected type  upto(b`index)
  degree_raise_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial, m: nat):
      m = b`index IMPLIES
       (FORALL (bseq: [upto(b`index) -> real]):
          bseq = b`bern_seq IMPLIES
           (FORALL (i: upto(m + 1)): i = 0 IMPLIES 0 <= b`index));


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 484 0 492 999
body:
  % Subtype TCC generated (at line 63, column 25) for  m
      % expected type  upto(b`index)
  degree_raise_TCC2: OBLIGATION
    FORALL (b: Bernstein_Polynomial, m: nat):
      m = b`index IMPLIES
       (FORALL (bseq: [upto(b`index) -> real]):
          bseq = b`bern_seq IMPLIES
           (FORALL (i: upto(m + 1)):
              i = m + 1 AND NOT i = 0 IMPLIES m <= b`index));


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 494 0 502 999
body:
  % Subtype TCC generated (at line 65, column 9) for  i
      % expected type  upto(b`index)
  degree_raise_TCC3: OBLIGATION
    FORALL (b: Bernstein_Polynomial, m: nat):
      m = b`index IMPLIES
       (FORALL (bseq: [upto(b`index) -> real]):
          bseq = b`bern_seq IMPLIES
           (FORALL (i: upto(m + 1)):
              NOT i = m + 1 AND NOT i = 0 IMPLIES i <= b`index));


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 504 0 513 999
body:
  % Subtype TCC generated (at line 65, column 27) for  i - 1
      % expected type  upto(b`index)
  degree_raise_TCC4: OBLIGATION
    FORALL (b: Bernstein_Polynomial, m: nat):
      m = b`index IMPLIES
       (FORALL (bseq: [upto(b`index) -> real]):
          bseq = b`bern_seq IMPLIES
           (FORALL (i: upto(m + 1)):
              NOT i = m + 1 AND NOT i = 0 IMPLIES
               i - 1 >= 0 AND i - 1 <= b`index));


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 515 0 518 999
body:
  % Subtype TCC generated (at line 70, column 43) for  j - 1
      % expected type  nat
  degree_raise_power_TCC1: OBLIGATION
    FORALL (j: nat): NOT j = 0 IMPLIES j - 1 >= 0;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 520 0 523 999
body:
  % Termination TCC generated (at line 70, column 22) for
      % degree_raise_power(b, j - 1)
  degree_raise_power_TCC2: OBLIGATION
    FORALL (j: nat): NOT j = 0 IMPLIES j - 1 < j;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 525 0 528 999
body:
  % Subtype TCC generated (at line 74, column 60) for  k
      % expected type  above(p - 1)
  Bernstein_index_degree_raise_TCC1: OBLIGATION
    FORALL (k: posnat, p: nat): k >= p IMPLIES k > p - 1;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 530 0 533 999
body:
  % Subtype TCC generated (at line 74, column 91) for  k + 1
      % expected type  above(p)
  Bernstein_index_degree_raise_TCC2: OBLIGATION
    FORALL (k: posnat, p: nat): k >= p IMPLIES k + 1 > p;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 535 0 538 999
body:
  % Subtype TCC generated (at line 79, column 12) for  p
      % expected type  T_high[nat]
  Bernstein_partition_of_unity_TCC1: OBLIGATION
    FORALL (p: nat): p >= 0 OR (EXISTS (j: nat): p <= j);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 540 0 543 999
body:
  % Subtype TCC generated (at line 79, column 57) for  p
      % expected type  above(i - 1)
  Bernstein_partition_of_unity_TCC2: OBLIGATION
    FORALL (p, i: nat): NOT i > p IMPLIES p > i - 1;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 545 0 549 999
body:
  % Subtype TCC generated (at line 85, column 18) for  k
      % expected type  T_high[nat]
  Bernstein_conversion_TCC1: OBLIGATION
    FORALL (k: posnat, p: nat):
      k >= p IMPLIES k >= 0 OR (EXISTS (j: nat): k <= j);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 551 0 556 999
body:
  % Subtype TCC generated (at line 85, column 68) for  p
      % expected type  {i_1: nat | i_1 <= i}
  Bernstein_conversion_TCC2: OBLIGATION
    FORALL (k: posnat, p: nat):
      k >= p IMPLIES
       (FORALL (i: nat): NOT i < p AND NOT i > k IMPLIES p <= i);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 558 0 563 999
body:
  % Subtype TCC generated (at line 85, column 75) for  p
      % expected type  {i: nat | i <= k}
  Bernstein_conversion_TCC3: OBLIGATION
    FORALL (k: posnat, p: nat):
      k >= p IMPLIES
       (FORALL (i: nat): NOT i < p AND NOT i > k IMPLIES p <= k);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 565 0 570 999
body:
  % Subtype TCC generated (at line 85, column 86) for  k
      % expected type  above(i - 1)
  Bernstein_conversion_TCC4: OBLIGATION
    FORALL (k: posnat, p: nat):
      k >= p IMPLIES
       (FORALL (i: nat): NOT i < p AND NOT i > k IMPLIES k > i - 1);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 572 0 576 999
body:
  % Subtype TCC generated (at line 94, column 12) for  b`index
      % expected type  T_high[nat]
  Bern_poly_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial):
      b`index >= 0 OR (EXISTS (j: nat): b`index <= j);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 578 0 582 999
body:
  % Subtype TCC generated (at line 94, column 75) for  i
      % expected type  upto(b`index)
  Bern_poly_TCC2: OBLIGATION
    FORALL (b: Bernstein_Polynomial, i: nat):
      NOT i > b`index IMPLIES i <= b`index;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 584 0 588 999
body:
  % Subtype TCC generated (at line 94, column 85) for  b`index
      % expected type  above(i - 1)
  Bern_poly_TCC3: OBLIGATION
    FORALL (b: Bernstein_Polynomial, i: nat):
      NOT i > b`index IMPLIES b`index > i - 1;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 590 0 594 999
body:
  % Subtype TCC generated (at line 101, column 73) for  b`index - i
      % expected type  upto(b`index)
  Bern_poly_reverse_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial, i: upto(b`index)):
      b`index - i >= 0 AND b`index - i <= b`index;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 596 0 601 999
body:
  % Subtype TCC generated (at line 111, column 62) for  i
      % expected type  upto(b`index)
  Bern_poly_inverse_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial, j: nat):
      NOT j > b`index IMPLIES
       (FORALL (i: nat): NOT i > j IMPLIES i <= b`index);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 603 0 608 999
body:
  % Subtype TCC generated (at line 111, column 87) for  j
      % expected type  {i: nat | i <= b`index}
  Bern_poly_inverse_TCC2: OBLIGATION
    FORALL (b: Bernstein_Polynomial, j: nat):
      NOT j > b`index IMPLIES
       (FORALL (i: nat): NOT i > j IMPLIES j <= b`index);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 610 0 614 999
body:
  % Subtype TCC generated (at line 111, column 94) for  i
      % expected type  {i: nat | i <= j}
  Bern_poly_inverse_TCC3: OBLIGATION
    FORALL (b: Bernstein_Polynomial, j: nat):
      NOT j > b`index IMPLIES (FORALL (i: nat): NOT i > j IMPLIES i <= j);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 616 0 621 999
body:
  % Subtype TCC generated (at line 120, column 105) for  i
      % expected type  upto(b2`index)
  Bern_structural_decomp_TCC1: OBLIGATION
    FORALL (P: [Bernstein_Polynomial -> bool], b1, b2: Bernstein_Polynomial):
      b1`index = b2`index AND P(b1) AND P(b2) IMPLIES
       (FORALL (i: upto(b1`index)): i <= b2`index);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 623 0 626 999
body:
  % Subtype TCC generated (at line 133, column 44) for  s
      % expected type  T_high[nat]
  Bernstein_polynomial_TCC1: OBLIGATION
    FORALL (m: nat, s: upto(m)): s >= 0 OR (EXISTS (j: nat): s <= j);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 628 0 632 999
body:
  % Subtype TCC generated (at line 133, column 96) for  i
      % expected type  {i: nat | i <= s}
  Bernstein_polynomial_TCC2: OBLIGATION
    FORALL (p: nat, m: nat, s: upto(m), i: nat):
      NOT i > s AND NOT i > p IMPLIES i <= s;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 634 0 638 999
body:
  % Subtype TCC generated (at line 133, column 103) for  i
      % expected type  {i: nat | i <= m}
  Bernstein_polynomial_TCC3: OBLIGATION
    FORALL (p: nat, m: nat, s: upto(m), i: nat):
      NOT i > s AND NOT i > p IMPLIES i <= m;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 640 0 644 999
body:
  % Subtype TCC generated (at line 145, column 61) for  i
      % expected type  T_high[nat]
  Bern_subdiv_left_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial, i: upto(b`index)):
      i >= 0 OR (EXISTS (j: nat): i <= j);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 646 0 650 999
body:
  % Subtype TCC generated (at line 146, column 60) for  j
      % expected type  {i_1: nat | i_1 <= i}
  Bern_subdiv_left_TCC2: OBLIGATION
    FORALL (b: Bernstein_Polynomial, i: upto(b`index), j: nat):
      NOT j > i IMPLIES j <= i;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 652 0 656 999
body:
  % Subtype TCC generated (at line 146, column 74) for  j
      % expected type  upto(b`index)
  Bern_subdiv_left_TCC3: OBLIGATION
    FORALL (b: Bernstein_Polynomial, i: upto(b`index), j: nat):
      NOT j > i IMPLIES j <= b`index;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 658 0 662 999
body:
  % Subtype TCC generated (at line 150, column 68) for  b`index - i
      % expected type  T_high[nat]
  Bern_subdiv_right_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial, i: upto(b`index)):
      b`index - i >= 0 OR (EXISTS (j: nat): b`index - i <= j);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 664 0 668 999
body:
  % Subtype TCC generated (at line 151, column 63) for  b`index - i
      % expected type  nat
  Bern_subdiv_right_TCC2: OBLIGATION
    FORALL (b: Bernstein_Polynomial, i: upto(b`index), j: nat):
      NOT j > b`index - i IMPLIES b`index - i >= 0;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 670 0 674 999
body:
  % Subtype TCC generated (at line 151, column 73) for  j
      % expected type  {i_1: nat | i_1 <= b`index - i}
  Bern_subdiv_right_TCC3: OBLIGATION
    FORALL (b: Bernstein_Polynomial, i: upto(b`index), j: nat):
      NOT j > b`index - i IMPLIES j <= b`index - i;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 676 0 680 999
body:
  % Subtype TCC generated (at line 151, column 87) for  b`index - j
      % expected type  upto(b`index)
  Bern_subdiv_right_TCC4: OBLIGATION
    FORALL (b: Bernstein_Polynomial, i: upto(b`index), j: nat):
      NOT j > b`index - i IMPLIES b`index - j >= 0 AND b`index - j <= b`index;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 682 0 688 999
body:
  % Subtype TCC generated (at line 179, column 27) for  p - 1
      % expected type  upto(b`index)
  Bern_sweep_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial, p: upto(b`index)):
      NOT p = 0 IMPLIES
       (FORALL (i: upto(b`index)):
          i < p IMPLIES p - 1 >= 0 AND p - 1 <= b`index);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 690 0 694 999
body:
  % Termination TCC generated (at line 179, column 13) for
      % Bern_sweep(b)(p - 1)
  Bern_sweep_TCC2: OBLIGATION
    FORALL (b: Bernstein_Polynomial, p: upto(b`index)):
      NOT p = 0 IMPLIES (FORALL (i: upto(b`index)): i < p IMPLIES p - 1 < p);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 696 0 705 999
body:
  % Subtype TCC generated (at line 179, column 41) for  i
      % expected type  upto(Bern_sweep(b)(p - 1)`index)
  Bern_sweep_TCC3: OBLIGATION
    FORALL (b: Bernstein_Polynomial, p: upto(b`index),
            v:
              [b1: Bernstein_Polynomial ->
                 [{z: upto(b1`index) | z < p} ->
                    {bp: Bernstein_Polynomial | bp`index = b1`index}]]):
      NOT p = 0 IMPLIES
       (FORALL (i: upto(b`index)): i < p IMPLIES i <= v(b)(p - 1)`index);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 707 0 717 999
body:
  % Subtype TCC generated (at line 180, column 41) for  i - 1
      % expected type  upto(Bern_sweep(b)(p - 1)`index)
  Bern_sweep_TCC4: OBLIGATION
    FORALL (b: Bernstein_Polynomial, p: upto(b`index),
            v:
              [b1: Bernstein_Polynomial ->
                 [{z: upto(b1`index) | z < p} ->
                    {bp: Bernstein_Polynomial | bp`index = b1`index}]]):
      NOT p = 0 IMPLIES
       (FORALL (i: upto(b`index)):
          NOT i < p IMPLIES i - 1 >= 0 AND i - 1 <= v(b)(p - 1)`index);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 719 0 725 999
body:
  % Subtype TCC generated (at line 180, column 27) for  p - 1
      % expected type  upto(b`index)
  Bern_sweep_TCC5: OBLIGATION
    FORALL (b: Bernstein_Polynomial, p: upto(b`index)):
      NOT p = 0 IMPLIES
       (FORALL (i: upto(b`index)):
          NOT i < p IMPLIES p - 1 >= 0 AND p - 1 <= b`index);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 727 0 732 999
body:
  % Termination TCC generated (at line 180, column 13) for
      % Bern_sweep(b)(p - 1)
  Bern_sweep_TCC6: OBLIGATION
    FORALL (b: Bernstein_Polynomial, p: upto(b`index)):
      NOT p = 0 IMPLIES
       (FORALL (i: upto(b`index)): NOT i < p IMPLIES p - 1 < p);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 734 0 743 999
body:
  % Subtype TCC generated (at line 180, column 76) for  i
      % expected type  upto(Bern_sweep(b)(p - 1)`index)
  Bern_sweep_TCC7: OBLIGATION
    FORALL (b: Bernstein_Polynomial, p: upto(b`index),
            v:
              [b1: Bernstein_Polynomial ->
                 [{z: upto(b1`index) | z < p} ->
                    {bp: Bernstein_Polynomial | bp`index = b1`index}]]):
      NOT p = 0 IMPLIES
       (FORALL (i: upto(b`index)): NOT i < p IMPLIES i <= v(b)(p - 1)`index);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 745 0 753 999
body:
  % Subtype TCC generated (at line 193, column 72) for  j + (i - p)
      % expected type  upto(b`index)
  Bern_sweep_expand_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial, p: nat):
      p <= b`index IMPLIES
       (FORALL (i: upto(b`index)):
          NOT i <= p IMPLIES
           (FORALL (j: nat):
              NOT j > p IMPLIES j + (i - p) >= 0 AND j + (i - p) <= b`index));


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 755 0 761 999
body:
  % Subtype TCC generated (at line 193, column 85) for  j
      % expected type  {i: nat | i <= p}
  Bern_sweep_expand_TCC2: OBLIGATION
    FORALL (b: Bernstein_Polynomial, p: nat):
      p <= b`index IMPLIES
       (FORALL (i: upto(b`index)):
          NOT i <= p IMPLIES (FORALL (j: nat): NOT j > p IMPLIES j <= p));


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 763 0 766 999
body:
  % Subtype TCC generated (at line 196, column 57) for  b`index
      % expected type  upto(b`index)
  Bern_subdiv_l_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial): b`index <= b`index;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 768 0 772 999
body:
  % Subtype TCC generated (at line 200, column 81) for  b`index
      % expected type  upto(Bern_sweep(b)(b`index - i)`index)
  Bern_subdiv_r_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial, i: upto(b`index)):
      b`index <= Bern_sweep(b)(b`index - i)`index;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 774 0 778 999
body:
  % Subtype TCC generated (at line 215, column 34) for  msp
      % expected type  T_high[nat]
  Bern_coeff_TCC1: OBLIGATION
    FORALL (p: nat, m: nat, s: upto(m), msp: {k: nat | k <= s AND k <= p}):
      msp = min(s, p) IMPLIES msp >= 0 OR (EXISTS (j: nat): msp <= j);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 780 0 784 999
body:
  % Subtype TCC generated (at line 215, column 83) for  i
      % expected type  {i: nat | i <= s}
  Bern_coeff_TCC2: OBLIGATION
    FORALL (p: nat, m: nat, s: upto(m), msp: {k: nat | k <= s AND k <= p}):
      msp = min(s, p) IMPLIES (FORALL (i: nat): NOT i > msp IMPLIES i <= s);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 786 0 790 999
body:
  % Subtype TCC generated (at line 215, column 90) for  i
      % expected type  {i: nat | i <= m}
  Bern_coeff_TCC3: OBLIGATION
    FORALL (p: nat, m: nat, s: upto(m), msp: {k: nat | k <= s AND k <= p}):
      msp = min(s, p) IMPLIES (FORALL (i: nat): NOT i > msp IMPLIES i <= m);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 792 0 798 999
body:
  % Subtype TCC generated (at line 248, column 59) for  s
      % expected type  upto(b2`index)
  Bern_poly_quotient_le_TCC1: OBLIGATION
    FORALL (b1, b2: Bernstein_Polynomial):
      (b1`index = b2`index AND
        (FORALL (s: upto(b2`index)): b2`bern_seq(s) > 0))
       IMPLIES (FORALL (s1: upto(b1`index)): s1 <= b2`index);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 800 0 806 999
body:
  % Subtype TCC generated (at line 248, column 47) for  b2`bern_seq(s)
      % expected type  nznum
  Bern_poly_quotient_le_TCC2: OBLIGATION
    FORALL (b1, b2: Bernstein_Polynomial):
      (b1`index = b2`index AND
        (FORALL (s: upto(b2`index)): b2`bern_seq(s) > 0))
       IMPLIES (FORALL (s1: upto(b1`index)): b2`bern_seq(s1) /= 0);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 808 0 816 999
body:
  % Subtype TCC generated (at line 251, column 21) for  Bern_poly(b2)(x)
      % expected type  nznum
  Bern_poly_quotient_le_TCC3: OBLIGATION
    FORALL (Ma: real, b1, b2: Bernstein_Polynomial, x: real):
           x <= 1 AND 0 <= x
       AND FORALL (s: upto(b1`index)): b1`bern_seq(s) / b2`bern_seq(s) <= Ma
       AND FORALL (s: upto(b2`index)): b2`bern_seq(s) > 0
       AND b1`index = b2`index AND Bern_poly(b2)(x) > 0
       IMPLIES Bern_poly(b2)(x) /= 0;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 818 0 821 999
body:
  % Subtype TCC generated (at line 284, column 51) for  iq
      % expected type  upto(b`index)
  Bern_min_rec_TCC1: OBLIGATION
    FORALL (b, q: upto(b`index), iq: upto(q)): iq <= b`index;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 823 0 827 999
body:
  % Subtype TCC generated (at line 286, column 49) for  q - 1
      % expected type  q: upto(b`index)
  Bern_min_rec_TCC2: OBLIGATION
    FORALL (b: Bernstein_Polynomial, q: upto(b`index), y: real):
      NOT q = 0 AND y = b`bern_seq(q) IMPLIES q - 1 >= 0 AND q - 1 <= b`index;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 829 0 833 999
body:
  % Termination TCC generated (at line 286, column 33) for
      % Bern_min_rec(b)(q - 1)
  Bern_min_rec_TCC3: OBLIGATION
    FORALL (b: Bernstein_Polynomial, q: upto(b`index), y: real):
      NOT q = 0 AND y = b`bern_seq(q) IMPLIES q - 1 < q;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 835 0 854 999
body:
  % Subtype TCC generated (at line 287, column 7) for  min(y, x)
      % expected type  {r: real |
                     %          (EXISTS (iq: upto(q)): r = b`bern_seq(iq))
                     %           AND
                     %           (FORALL (iq: upto(q)): r <= b`bern_seq(iq))}
  Bern_min_rec_TCC4: OBLIGATION
    FORALL (b: Bernstein_Polynomial, q: upto(b`index),
            v:
              [b1: Bernstein_Polynomial ->
                 [q1: {z: upto(b1`index) | z < q} ->
                    {r: real |
                             (EXISTS (iq: upto(q1)): r = b1`bern_seq(iq)) AND
                              (FORALL (iq: upto(q1)):
                                 r <= b1`bern_seq(iq))}]],
            y: real):
      y = b`bern_seq(q) IMPLIES
       (FORALL (x: real):
          x = IF q = 0 THEN y ELSE v(b)(q - 1) ENDIF IMPLIES
           (EXISTS (iq: upto(q)): min(y, x) = b`bern_seq(iq)) AND
            (FORALL (iq: upto(q)): min(y, x) <= b`bern_seq(iq)));


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 856 0 875 999
body:
  % Subtype TCC generated (at line 294, column 6) for  max(y, x)
      % expected type  {r: real |
                     %          (EXISTS (iq: upto(q)): r = b`bern_seq(iq))
                     %           AND
                     %           (FORALL (iq: upto(q)): r >= b`bern_seq(iq))}
  Bern_max_rec_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial, q: upto(b`index),
            v:
              [b1: Bernstein_Polynomial ->
                 [q1: {z: upto(b1`index) | z < q} ->
                    {r: real |
                             (EXISTS (iq: upto(q1)): r = b1`bern_seq(iq)) AND
                              (FORALL (iq: upto(q1)):
                                 r >= b1`bern_seq(iq))}]],
            y: real):
      y = b`bern_seq(q) IMPLIES
       (FORALL (x: real):
          x = IF q = 0 THEN y ELSE v(b)(q - 1) ENDIF IMPLIES
           (EXISTS (iq: upto(q)): max(y, x) = b`bern_seq(iq)) AND
            (FORALL (iq: upto(q)): max(y, x) >= b`bern_seq(iq)));


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 877 0 880 999
body:
  % Subtype TCC generated (at line 315, column 41) for  0
      % expected type  upto(b`index)
  Bern_min_est_TCC1: OBLIGATION
    FORALL (b: Bernstein_Polynomial): 0 <= b`index;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 882 0 889 999
body:
  % Subtype TCC generated (at line 334, column 100) for  i
      % expected type  below(BC1`number_polys)
  Bern_concat_TCC1: OBLIGATION
    FORALL (BC1: Bernstein_MinMax_Collection,
            BC2: Bernstein_MinMax_Collection, NN: posint):
      NN = BC1`number_polys + BC2`number_polys IMPLIES
       (FORALL (i: below(NN)):
          i <= BC1`number_polys - 1 IMPLIES i < BC1`number_polys);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 891 0 900 999
body:
  % Subtype TCC generated (at line 335, column 75) for  i - BC1`number_polys
      % expected type  below(BC2`number_polys)
  Bern_concat_TCC2: OBLIGATION
    FORALL (BC1: Bernstein_MinMax_Collection,
            BC2: Bernstein_MinMax_Collection, NN: posint):
      NN = BC1`number_polys + BC2`number_polys IMPLIES
       (FORALL (i: below(NN)):
          NOT i <= BC1`number_polys - 1 IMPLIES
           i - BC1`number_polys >= 0 AND
            i - BC1`number_polys < BC2`number_polys);


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 902 0 906 999
body:
  % Subtype TCC generated (at line 338, column 52) for  0
      % expected type  below(BC`number_polys)
  Bern_collection_min_est_rec_TCC1: OBLIGATION
    FORALL (BC: Bernstein_MinMax_Collection, np: below(BC`number_polys)):
      np = 0 IMPLIES 0 < BC`number_polys;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 908 0 912 999
body:
  % Subtype TCC generated (at line 339, column 46) for  0
      % expected type  below(BC`number_polys)
  Bern_collection_min_est_rec_TCC2: OBLIGATION
    FORALL (BC: Bernstein_MinMax_Collection, np: below(BC`number_polys)):
      NOT np = 0 IMPLIES 0 < BC`number_polys;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 914 0 918 999
body:
  % Subtype TCC generated (at line 339, column 91) for  np - 1
      % expected type  below(BC`number_polys)
  Bern_collection_min_est_rec_TCC3: OBLIGATION
    FORALL (BC: Bernstein_MinMax_Collection, np: below(BC`number_polys)):
      NOT np = 0 IMPLIES np - 1 >= 0 AND np - 1 < BC`number_polys;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 920 0 924 999
body:
  % Termination TCC generated (at line 339, column 59) for
      % Bern_collection_min_est_rec(BC)(np - 1)
  Bern_collection_min_est_rec_TCC4: OBLIGATION
    FORALL (BC: Bernstein_MinMax_Collection, np: below(BC`number_polys)):
      NOT np = 0 IMPLIES np - 1 < np;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 926 0 931 999
body:
  % Subtype TCC generated (at line 343, column 65) for  BC`number_polys - 1
      % expected type  below(BC`number_polys)
  Bern_collection_min_est_TCC1: OBLIGATION
    FORALL (BC: Bernstein_MinMax_Collection):
      BC`number_polys /= 0 IMPLIES
       BC`number_polys - 1 >= 0 AND BC`number_polys - 1 < BC`number_polys;


decl_type: tcc
theory: bernstein_polynomials
library: reals
signature: nil
location: 933 0 937 999
body:
  % Subtype TCC generated (at line 356, column 39) for  BC`number_polys - 1
      % expected type  below(BC`number_polys)
  Bern_collection_reduce_min_TCC1: OBLIGATION
    FORALL (BC: Bernstein_MinMax_Collection):
      BC`number_polys - 1 >= 0 AND BC`number_polys - 1 < BC`number_polys;


decl_type: function
theory: min_max
library: reals
location: 112 2 117 13
signature:
  [d: [[nat -> real], j: nat, {k: nat | j <= k}] ->
          {r: real |
                   (EXISTS (i: nat):
                      d`2 <= i AND i <= d`3 AND d`1(i) = r)
                    AND
                    (FORALL (i: nat):
                       d`2 <= i AND i <= d`3 IMPLIES d`1(i) <= r)}]

body:
    max_rec(F:[nat->real],j:nat,(k:nat|j<=k)): RECURSIVE {r:real|
      (EXISTS (i:nat): j<=i AND i<=k AND F(i)=r) AND
      (FORALL (i:nat): j<=i AND i<=k IMPLIES F(i)<=r)} =
      IF k = j THEN F(j) ELSE
      max(F(k),max_rec(F,j,k-1)) ENDIF
      MEASURE k


decl_type: function
theory: min_max
library: reals
location: 119 2 124 13
signature:
  [d: [[nat -> real], j: nat, {k: nat | j <= k}] ->
          {r: real |
                   (EXISTS (i: nat):
                      d`2 <= i AND i <= d`3 AND d`1(i) = r)
                    AND
                    (FORALL (i: nat):
                       d`2 <= i AND i <= d`3 IMPLIES d`1(i) >= r)}]

body:
    min_rec(F:[nat->real],j:nat,(k:nat|j<=k)): RECURSIVE {r:real|
      (EXISTS (i:nat): j<=i AND i<=k AND F(i)=r) AND
      (FORALL (i:nat): j<=i AND i<=k IMPLIES F(i)>=r)} =
      IF k = j THEN F(j) ELSE
      min(F(k),min_rec(F,j,k-1)) ENDIF
      MEASURE k


decl_type: tcc
theory: min_max
library: reals
signature: nil
location: 143 0 154 999
body:
  % Subtype TCC generated (at line 115, column 18) for  F(j)
      % expected type  {r: real |
                     %          (EXISTS (i: nat):
                     %             j <= i AND i <= k AND F(i) = r)
                     %           AND
                     %           (FORALL (i: nat):
                     %              j <= i AND i <= k IMPLIES F(i) <= r)}
  max_rec_TCC1: OBLIGATION
    FORALL (F: [nat -> real], j: nat, (k: nat | j <= k)):
      k = j IMPLIES
       (EXISTS (i: nat): j <= i AND i <= k AND F(i) = F(j)) AND
        (FORALL (i: nat): j <= i AND i <= k IMPLIES F(i) <= F(j));


decl_type: tcc
theory: min_max
library: reals
signature: nil
location: 156 0 160 999
body:
  % Subtype TCC generated (at line 116, column 25) for  k - 1
      % expected type  {k: nat | j <= k}
  max_rec_TCC2: OBLIGATION
    FORALL (j: nat, (k: nat | j <= k)):
      NOT k = j IMPLIES k - 1 >= 0 AND j <= k - 1;


decl_type: tcc
theory: min_max
library: reals
signature: nil
location: 162 0 165 999
body:
  % Termination TCC generated (at line 116, column 13) for
      % max_rec(F, j, k - 1)
  max_rec_TCC3: OBLIGATION
    FORALL (j: nat, (k: nat | j <= k)): NOT k = j IMPLIES k - 1 < k;


decl_type: tcc
theory: min_max
library: reals
signature: nil
location: 167 0 192 999
body:
  % Subtype TCC generated (at line 116, column 4) for
      % max(F(k), max_rec(F, j, k - 1))
      % expected type  {r: real |
                     %          (EXISTS (i: nat):
                     %             j <= i AND i <= k AND F(i) = r)
                     %           AND
                     %           (FORALL (i: nat):
                     %              j <= i AND i <= k IMPLIES F(i) <= r)}
  max_rec_TCC4: OBLIGATION
    FORALL (F: [nat -> real], j: nat, (k: nat | j <= k),
            v:
              [d1:
                 {z: [[nat -> real], j: nat, {k: nat | j <= k}] | z`3 < k} ->
                 {r: real |
                          (EXISTS (i: nat):
                             d1`2 <= i AND i <= d1`3 AND d1`1(i) = r)
                           AND
                           (FORALL (i: nat):
                              d1`2 <= i AND i <= d1`3 IMPLIES
                               d1`1(i) <= r)}]):
      NOT k = j IMPLIES
       (EXISTS (i: nat):
          j <= i AND i <= k AND F(i) = max(F(k), v(F, j, k - 1)))
        AND
        (FORALL (i: nat):
           j <= i AND i <= k IMPLIES F(i) <= max(F(k), v(F, j, k - 1)));


decl_type: tcc
theory: min_max
library: reals
signature: nil
location: 194 0 205 999
body:
  % Subtype TCC generated (at line 122, column 18) for  F(j)
      % expected type  {r: real |
                     %          (EXISTS (i: nat):
                     %             j <= i AND i <= k AND F(i) = r)
                     %           AND
                     %           (FORALL (i: nat):
                     %              j <= i AND i <= k IMPLIES F(i) >= r)}
  min_rec_TCC1: OBLIGATION
    FORALL (F: [nat -> real], j: nat, (k: nat | j <= k)):
      k = j IMPLIES
       (EXISTS (i: nat): j <= i AND i <= k AND F(i) = F(j)) AND
        (FORALL (i: nat): j <= i AND i <= k IMPLIES F(i) >= F(j));


decl_type: tcc
theory: min_max
library: reals
signature: nil
location: 207 0 232 999
body:
  % Subtype TCC generated (at line 123, column 4) for
      % min(F(k), min_rec(F, j, k - 1))
      % expected type  {r: real |
                     %          (EXISTS (i: nat):
                     %             j <= i AND i <= k AND F(i) = r)
                     %           AND
                     %           (FORALL (i: nat):
                     %              j <= i AND i <= k IMPLIES F(i) >= r)}
  min_rec_TCC2: OBLIGATION
    FORALL (F: [nat -> real], j: nat, (k: nat | j <= k),
            v:
              [d1:
                 {z: [[nat -> real], j: nat, {k: nat | j <= k}] | z`3 < k} ->
                 {r: real |
                          (EXISTS (i: nat):
                             d1`2 <= i AND i <= d1`3 AND d1`1(i) = r)
                           AND
                           (FORALL (i: nat):
                              d1`2 <= i AND i <= d1`3 IMPLIES
                               d1`1(i) >= r)}]):
      NOT k = j IMPLIES
       (EXISTS (i: nat):
          j <= i AND i <= k AND F(i) = min(F(k), v(F, j, k - 1)))
        AND
        (FORALL (i: nat):
           j <= i AND i <= k IMPLIES F(i) >= min(F(k), v(F, j, k - 1)));


decl_type: formula
theory: more_polynomial_props
library: reals
signature: nil
location: 11 2 17 39
body:
    polynomial_degree_existence: LEMMA
      ((EXISTS (x): polynomial(a,n)(x)/=0) OR
       (EXISTS (i:upto(n)): a(i)/=0))
      IMPLIES
      EXISTS (i:upto(n)): a(i)/=0 AND
        (FORALL (j:nat): j>i AND j<=n IMPLIES a(j) = 0) AND
        polynomial(a,n) = polynomial(a,i)


decl_type: formula
theory: more_polynomial_props
library: reals
signature: nil
location: 25 2 29 61
body:
    poly_deriv_limit: LEMMA
      FORALL (y:real,epsil:posreal,pn:posnat): EXISTS (delta:posreal):
        FORALL (x:real): abs(x-y)<delta AND x/=y IMPLIES
          abs(polynomial(poly_deriv(a),pn-1)(y) - 
              (polynomial(a,pn)(x)-polynomial(a,pn)(y))/(x-y)) < epsil


decl_type: formula
theory: more_polynomial_props
library: reals
signature: nil
location: 31 2 35 40
body:
    square_free_min: LEMMA
      FORALL (epsil:posreal,y,c:real,pn:posnat): polynomial(a,pn)(y) = c AND 
          (FORALL (x:real): abs(x-y)<epsil IMPLIES polynomial(a,pn)(x)>=c)
          IMPLIES
          polynomial(poly_deriv(a),pn-1)(y) = 0


decl_type: formula
theory: more_polynomial_props
library: reals
signature: nil
location: 37 2 41 40
body:
    square_free_max: LEMMA
      FORALL (epsil:posreal,y,c:real,pn:posnat): polynomial(a,pn)(y) = c AND 
          (FORALL (x:real): abs(x-y)<epsil IMPLIES polynomial(a,pn)(x)<=c)
          IMPLIES
          polynomial(poly_deriv(a),pn-1)(y) = 0


decl_type: formula
theory: more_polynomial_props
library: reals
signature: nil
location: 46 2 49 43
body:
    deriv_poly_shift: LEMMA n>0 AND (FORALL (i:nat):i>n IMPLIES a(i)=0)
                            IMPLIES
                            poly_deriv(poly_shift(a,n)(y)) =
                            poly_shift(poly_deriv(a),n-1)(y)


decl_type: formula
theory: more_polynomial_props
library: reals
signature: nil
location: 51 2 55 64
body:
    linear_power_is_differentiable: LEMMA
      m>0 IMPLIES EXISTS (a): a(m)=1 AND
      (FORALL (i:nat): i>m IMPLIES a(i)=0) AND
      (FORALL (x): polynomial(a,m)(x) = (x-y)^m) AND
      (FORALL (x): polynomial(poly_deriv(a),m-1)(x)=m*(x-y)^(m-1))


decl_type: formula
theory: more_polynomial_props
library: reals
signature: nil
location: 57 2 61 79
body:
    polynomial_prod_degrees: LEMMA
      FORALL (a,b,g:[nat->real],n,m,p:nat):
      (FORALL (x): polynomial(a,n)(x) = polynomial(b,m)(x)*polynomial(g,p)(x)) AND
      a(n)/=0 AND b(m)/=0 AND g(p)/=0 IMPLIES
      (n=m+p AND FORALL (i:nat): i<=n IMPLIES a(i) = polynomial_prod(b,m,g,p)(i))


decl_type: formula
theory: more_polynomial_props
library: reals
signature: nil
location: 63 2 68 27
body:
    polynomial_div_linear_power_degree: LEMMA
      FORALL (a,b:[nat->real],n,m,k:nat):
        (FORALL (x): polynomial(a,n)(x) = (x-y)^k*polynomial(b,m)(x)) AND
        a(n)/=0 AND b(m)/=0
        IMPLIES
        (a(n)=b(m) AND n=m+k)


decl_type: formula
theory: more_polynomial_props
library: reals
signature: nil
location: 70 2 76 86
body:
    poly_deriv_signs_neq_around_root_left: LEMMA n>0 AND
      x < y AND 
      polynomial(a,n)(y) = 0 AND
      (FORALL (z:real): x<=z AND z<=y AND 
                        (polynomial(a,n)(z)=0 OR polynomial(poly_deriv(a),n-1)(z)=0)
                        IMPLIES z=y)
      IMPLIES sign_ext(polynomial(a,n)(x)) = -sign_ext(polynomial(poly_deriv(a),n-1)(x))


