theory Foo imports Main begin lemma list_prefix_decomp: shows "\ps xs' ys'. xs = ps @ xs' \ ys = ps @ ys' \ (xs' = Nil \ ys' = Nil \ hd xs' \ hd ys')" proof- { text {* Exclude some trivial cases. *} assume "\(\ys'. ys = xs @ ys')" "\(\xs'. xs = ys @ xs')" "xs \ ys" text {* Determine an index where the lists diverge. *} hence "\n. n < length xs \ n < length ys \ xs ! n \ ys ! n" proof(induct xs arbitrary: ys, simp) case (Cons x xs ys) show ?case proof(cases) assume "ys = Nil" thus ?thesis sledgehammer (* ... *)