reserve a, I for set,
  S for non empty non void ManySortedSign;
reserve A, M for ManySortedSet of I,
  B, C for non-empty ManySortedSet of I;

theorem
  for A being non-empty MSAlgebra over S for R being Subset of CongrLatt
A for F being SubsetFamily of [|the Sorts of A, the Sorts of A|] st R = F holds
  meet |:F:| is MSCongruence of A
proof
  let A be non-empty MSAlgebra over S, R be Subset of CongrLatt A, F be
  SubsetFamily of [|the Sorts of A, the Sorts of A|] such that
A1: R = F;
  set R0 = meet |:F:|, SF = the Sorts of A, I = the carrier of S;
  per cases;
  suppose
    F is non empty;
    then reconsider F1 = F as non empty SubsetFamily of [|SF,SF|];
A2: F1 c= the carrier of EqRelLatt SF
    proof
      let q be object;
      assume q in F1;
      then q is MSCongruence of A by A1,MSUALG_5:def 6;
      hence thesis by MSUALG_5:def 5;
    end;
    then
A3: R0 is MSEquivalence_Relation-like ManySortedRelation of SF by MSUALG_7:8;
    reconsider R0 as ManySortedRelation of A by A2,MSUALG_7:8;
    R0 is MSEquivalence-like
    by A3;
    then reconsider R0 as MSEquivalence-like ManySortedRelation of A;
    now
      let o be OperSymbol of S;
      let a,b be Element of Args(o,A) such that
A4:   for n being Nat st n in dom a holds [a.n,b.n] in R0.((
      the_arity_of o)/.n);
      set r = the_result_sort_of o;
      consider Q being Subset-Family of ([|SF,SF|].r) such that
A5:   Q = |:F1:|.r and
A6:   R0.r = Intersect Q by MSSUBFAM:def 1;
A7:   Q = { s.r where s is Element of Bool [|SF,SF|] : s in F1 } by A5,
CLOSURE2:14;
      now
        let Y be set;
        assume Y in Q;
        then consider s being Element of Bool [|SF,SF|] such that
A8:     Y = s.r and
A9:     s in F1 by A7;
        reconsider s as MSCongruence of A by A1,A9,MSUALG_5:def 6;
        now
          let n be Nat such that
A10:      n in dom a;
          set t = (the_arity_of o)/.n;
          consider G being Subset-Family of ([|SF,SF|].t) such that
A11:      G = |:F1:|.t and
A12:      R0.t = Intersect G by MSSUBFAM:def 1;
          G = { j.t where j is Element of Bool [|SF,SF|] : j in F1 } by A11,
CLOSURE2:14;
          then
A13:      s.t in G by A9;
          [a.n,b.n] in Intersect G by A4,A10,A12;
          then [a.n,b.n] in meet G by A11,SETFAM_1:def 9;
          hence [a.n,b.n] in s.t by A13,SETFAM_1:def 1;
        end;
        hence [Den(o,A).a,Den(o,A).b] in Y by A8,MSUALG_4:def 4;
      end;
      then [Den(o,A).a,Den(o,A).b] in meet Q by A5,SETFAM_1:def 1;
      hence [Den(o,A).a,Den(o,A).b] in R0.(the_result_sort_of o) by A5,A6,
SETFAM_1:def 9;
    end;
    hence thesis by MSUALG_4:def 4;
  end;
  suppose
    F is empty;
    then |:F:| = EmptyMS I;
    then meet |:F:| = [|the Sorts of A, the Sorts of A|] by MSSUBFAM:41;
    hence thesis by MSUALG_5:18;
  end;
end;
