Theory First_Order_Clause.Parallel_Induct

theory Parallel_Induct
  imports First_Order_Terms.Position
begin

lemma parallel_induct [case_names parallel base step]: 
  assumes
    parallel: "p1  p2" and
    base: "p1 p2 i j q1 q2. p1 = i # q1  p2 = j # q2  i  j  P p1 p2" and
    step: 
      "p1 p2 p k i j q1 q2.
        p1 = k # p @ i # q1 
        p2 = k # p @ j # q2 
        i  j 
        P (p @ i # q1) (p @ j # q2) 
        P p1 p2"
    shows "P p1 p2"
proof -

  from parallel_remove_prefix[OF parallel]
  obtain p i j q1 q2 where 
    p1: "p1 = p @ i # q1" and 
    p2: "p2 = p @ j # q2" and
    i_neq_j: "i  j" 
    by blast

  show ?thesis unfolding p1 p2
    using base step i_neq_j
    by (induction p) auto
qed

end