reserve a,b for object, I,J for set;
reserve b for bag of I;
reserve R for asymmetric transitive non empty RelStr,
  a,b,c for bag of the carrier of R,
  x,y,z for Element of R;
reserve p for partition of b-'a, q for partition of b;
reserve J for set, m for bag of I;

theorem Th34:
  q is ordered & q = <*a*>^p implies (x is_maximal_in support b iff a.x > 0)
  proof
    assume Z0: q is ordered;
    assume Z1: q = <*a*>^p;
    rng p c= Bags the carrier of R by RELAT_1:def 19;
    then reconsider p as FinSequence of Bags the carrier of R
    by FINSEQ_1:def 4;
    set I = the carrier of R;
    hereby assume x is_maximal_in support b;
      then
A7:   x in support b & not ex y st y in support b & x < y by WAYBEL_4:55;
      then x in support Sum q by PART;
      then consider d being bag of the carrier of R such that
A8:   d in rng q & x in support d by Th27;
      consider i being object such that
A9:   i in dom q & d = q.i by A8,FUNCT_1:def 3;
      reconsider i as Nat by A9;
      1 <= i by A9,FINSEQ_3:25;
      then per cases by XXREAL_0:1;
      suppose i = 1;
        then d = a by Z1,A9,FINSEQ_1:41;
        then a.x <> 0 by A8,PRE_POLY:def 7;
        hence a.x > 0;
      end;
      suppose i > 1;
        then i >= 1+1 by NAT_1:13;
        then consider k being Nat such that
A10:    i = 1+1+k by NAT_1:10;
        1 <= 1+k <= 1+k+1 = i <= len q by A9,A10,NAT_1:11,FINSEQ_3:25;
        then 1 <= 1+k <= len q by XXREAL_0:2;
        then
A11:    1+k in dom q by FINSEQ_3:25; then
A12:    q/.i = q.i & q/.(1+k) = q.(1+k) by A9,PARTFUN1:def 6;
        d.x <> 0 by A8,PRE_POLY:def 7;
        then d.x > 0 & i = 1+k+1 by A10;
        then consider y such that
A13:    (q/.(1+k)).y > 0 & x <= y by Z0,A9,A11,A12;
        q.(1+k) in rng q by A11,FUNCT_1:def 3;
        then y in support (q/.(1+k)) c= support Sum q = support b
        by A13,A12,Th26,PART,BAGORDER:21,PRE_POLY:def 7;
        hence a.x > 0 by A7,A13,Lem2;
      end;
    end;
    assume
B0: a.x > 0;
    then
B1: x in support a by PRE_POLY:def 7;
    a in {a} = rng <*a*> c= rng q by Z1,TARSKI:def 1,FINSEQ_1:39,29;
    then
B4: a divides Sum q = b by Th26,PART; then
AA: support a c= support b by BAGORDER:21;
    not ex y st y in support b & x < y
    proof let y;
      assume
B3:   y in support b & x <= y & x <> y;
      per cases;
      suppose a.y > 0;
        then x ## y by Z0,Z1,B0,B3,Th32;
        hence contradiction by B3;
      end;
      suppose
B5:     a.y = 0;
        consider d being bag of the carrier of R such that
B6:     d in rng q & y in support d by B4,B3,Th27;
B7:     d.y <> 0 by B6,PRE_POLY:def 7;
        then not d in {a} & {a} = rng <*a*> & rng q = rng <*a*> \/ rng p
        by Z1,B5,TARSKI:def 1,FINSEQ_1:31,39;
        then d.y > 0 & d in rng p by B6,B7,XBOOLE_0:def 3;
        then consider z such that
B8:     a.z > 0 & y <= z by Z0,Z1,Th36;
        x <= z & x ## z by Z0,Z1,B0,B3,B8,ORDERS_2:3,Th32;
        hence contradiction;
      end;
    end;
    hence x is_maximal_in support b by B1,AA,WAYBEL_4:55;
  end;
