reserve k,m,n for Element of NAT,
  i, j for Nat,
  a, b, c for object,
  X, Y, Z for set,
  D, D1, D2 for non empty set;
reserve p, q, r, s for FinSequence;
reserve t, u, v, w for GRZ-formula;
reserve R, R1, R2 for GRZ-rule;
reserve A, A1, A2 for non empty Subset of GRZ-formula-set;
reserve B, B1, B2 for Subset of GRZ-formula-set;
reserve P, P1, P2 for GRZ-formula-sequence;
reserve S, S1, S2 for GRZ-formula-finset;

theorem Th42:
  for A, R, P1, P2 st P1 is (A, R)-correct & P2 is (A, R)-correct holds
      P1^P2 is (A, R)-correct
proof
  let A, R, P1, P2;
  set P0 = <*>GRZ-formula-set;
  assume that
    A1: P1 is (A, R)-correct and
    A2: P2 is (A, R)-correct;
  let k;
  assume A3: k in dom (P1^P2);
  per cases;
    suppose A5: k in dom P1;
    then P1, k is_a_correct_step_wrt A, R by A1;
    then P1^P0, k is_a_correct_step_wrt A, R by FINSEQ_1:34;
    hence P1^P2, k is_a_correct_step_wrt A, R by A5, Lm41;
    end;
    suppose (P1^P2).k in A;
    hence thesis;
    end;
    suppose that A10: not k in dom P1 and A11: not (P1^P2).k in A;
    consider j such that A12: j in dom P2 and A13: k = (len P1) + j
        by A3, A10, FINSEQ_1:25;
    reconsider m = j as Element of NAT by ORDINAL1:def 12;
    A15: P2, m is_a_correct_step_wrt A, R by A2, A12;
    A16: (P1^P2).k = P2.m by A12, A13, FINSEQ_1:def 7;
    then consider Q being GRZ-formula-finset such that
        A20: [Q, P2.m] in R and
        A21: for q st q in Q ex i being Element of NAT
            st i in dom P2 & i < m & P2.i = q by A11, A15;
    for q st q in Q ex u being Element of NAT
        st u in dom (P1^P2) & u < k & (P1^P2).u = q
      proof
      let q;
      assume q in Q;
      then consider i being Element of NAT such that
        A25: i in dom P2 and
        A26: i < m and
        A27: P2.i = q by A21;
      reconsider j = i as Nat;
      reconsider u = len P1 + i as Element of NAT by ORDINAL1:def 12;
      take u;
      j in Seg len P2 by A25, FINSEQ_1:def 3;
      then A30: 1 <= j & j <= len P2 by FINSEQ_1:1;
      thus u in dom (P1^P2) by A25, FINSEQ_1:28;
      thus u < k by A13, A26, XREAL_1:6;
      thus (P1^P2).u = q by A27, A30, FINSEQ_1:65;
      end;
    hence thesis by A16, A20;
    end;
end;
