src/HOL/Library/List_Prefix.thy
author wenzelm
Fri, 03 Nov 2000 21:35:59 +0100
changeset 10390 1d54567bed24
parent 10389 c7d8901ab269
child 10408 d8b3613158b1
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
     1
(*  Title:      HOL/Library/List_Prefix.thy
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
     3
    Author:     Tobias Nipkow and Markus Wenzel, TU Muenchen
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
     4
*)
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
     5
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
     6
header {*
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
     7
  \title{List prefixes}
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
     8
  \author{Tobias Nipkow and Markus Wenzel}
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
     9
*}
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    10
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    11
theory List_Prefix = Main:
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    12
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    13
subsection {* Prefix order on lists *}
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    14
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    15
instance list :: ("term") ord ..
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    16
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    17
defs (overloaded)
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    18
  prefix_def: "xs \<le> ys == \<exists>zs. ys = xs @ zs"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    19
  strict_prefix_def: "xs < ys == xs \<le> ys \<and> xs \<noteq> (ys::'a list)"
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    20
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    21
instance list :: ("term") order
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    22
  by intro_classes (auto simp add: prefix_def strict_prefix_def)
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    23
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    24
lemma prefixI [intro?]: "ys = xs @ zs ==> xs \<le> ys"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    25
  by (unfold prefix_def) blast
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    26
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    27
lemma prefixE [elim?]: "xs \<le> ys ==> (!!zs. ys = xs @ zs ==> C) ==> C"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    28
  by (unfold prefix_def) blast
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    29
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    30
lemma strict_prefixI [intro?]: "xs \<le> ys ==> xs \<noteq> ys ==> xs < (ys::'a list)"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    31
  by (unfold strict_prefix_def) blast
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    32
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    33
lemma strict_prefixE [elim?]:
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    34
    "xs < ys ==> (xs \<le> ys ==> xs \<noteq> (ys::'a list) ==> C) ==> C"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    35
  by (unfold strict_prefix_def) blast
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    36
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    37
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    38
subsection {* Basic properties of prefixes *}
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    39
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    40
theorem Nil_prefix [iff]: "[] \<le> xs"
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    41
  by (simp add: prefix_def)
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    42
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    43
theorem prefix_Nil [simp]: "(xs \<le> []) = (xs = [])"
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    44
  by (induct xs) (simp_all add: prefix_def)
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    45
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    46
lemma prefix_snoc [simp]: "(xs \<le> ys @ [y]) = (xs = ys @ [y] \<or> xs \<le> ys)"
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    47
proof
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    48
  assume "xs \<le> ys @ [y]"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    49
  then obtain zs where zs: "ys @ [y] = xs @ zs" ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    50
  show "xs = ys @ [y] \<or> xs \<le> ys"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    51
  proof (cases zs rule: rev_cases)
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    52
    assume "zs = []"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    53
    with zs have "xs = ys @ [y]" by simp
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    54
    thus ?thesis ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    55
  next
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    56
    fix z zs' assume "zs = zs' @ [z]"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    57
    with zs have "ys = xs @ zs'" by simp
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    58
    hence "xs \<le> ys" ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    59
    thus ?thesis ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    60
  qed
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    61
next
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    62
  assume "xs = ys @ [y] \<or> xs \<le> ys"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    63
  thus "xs \<le> ys @ [y]"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    64
  proof
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    65
    assume "xs = ys @ [y]"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    66
    thus ?thesis by simp
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    67
  next
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    68
    assume "xs \<le> ys"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    69
    then obtain zs where "ys = xs @ zs" ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    70
    hence "ys @ [y] = xs @ (zs @ [y])" by simp
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    71
    thus ?thesis ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    72
  qed
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    73
qed
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    74
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    75
lemma Cons_prefix_Cons [simp]: "(x # xs \<le> y # ys) = (x = y \<and> xs \<le> ys)"
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    76
  by (auto simp add: prefix_def)
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    77
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    78
lemma same_prefix_prefix [simp]: "(xs @ ys \<le> xs @ zs) = (ys \<le> zs)"
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    79
  by (induct xs) simp_all
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    80
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    81
lemma same_prefix_nil [iff]: "(xs @ ys \<le> xs) = (ys = [])"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    82
proof -
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    83
  have "(xs @ ys \<le> xs @ []) = (ys \<le> [])" by (rule same_prefix_prefix)
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    84
  thus ?thesis by simp
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    85
qed
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    86
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    87
lemma prefix_prefix [simp]: "xs \<le> ys ==> xs \<le> ys @ zs"
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    88
proof -
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    89
  assume "xs \<le> ys"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    90
  then obtain us where "ys = xs @ us" ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    91
  hence "ys @ zs = xs @ (us @ zs)" by simp
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    92
  thus ?thesis ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    93
qed
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    94
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    95
theorem prefix_Cons: "(xs \<le> y # ys) = (xs = [] \<or> (\<exists>zs. xs = y # zs \<and> zs \<le> ys))"
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
    96
  by (cases xs) (auto simp add: prefix_def)
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    97
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    98
theorem prefix_append:
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
    99
    "(xs \<le> ys @ zs) = (xs \<le> ys \<or> (\<exists>us. xs = ys @ us \<and> us \<le> zs))"
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   100
  apply (induct zs rule: rev_induct)
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   101
   apply force
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   102
  apply (simp del: append_assoc add: append_assoc [symmetric])
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   103
  apply simp
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   104
  apply blast
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   105
  done
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   106
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   107
lemma append_one_prefix:
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   108
    "xs \<le> ys ==> length xs < length ys ==> xs @ [ys ! length xs] \<le> ys"
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   109
  apply (unfold prefix_def)
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   110
  apply (auto simp add: nth_append)
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   111
  apply (case_tac zs)
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   112
   apply auto
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   113
  done
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   114
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   115
theorem prefix_length_le: "xs \<le> ys ==> length xs \<le> length ys"
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   116
  by (auto simp add: prefix_def)
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   117
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   118
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   119
subsection {* Parallel lists *}
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   120
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   121
constdefs
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   122
  parallel :: "'a list => 'a list => bool"    (infixl "\<parallel>" 50)
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   123
  "xs \<parallel> ys == \<not> xs \<le> ys \<and> \<not> ys \<le> xs"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   124
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   125
lemma parallelI [intro]: "\<not> xs \<le> ys ==> \<not> ys \<le> xs ==> xs \<parallel> ys"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   126
  by (unfold parallel_def) blast
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   127
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   128
lemma parallelE [elim]:
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   129
    "xs \<parallel> ys ==> (\<not> xs \<le> ys ==> \<not> ys \<le> xs ==> C) ==> C"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   130
  by (unfold parallel_def) blast
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   131
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   132
theorem prefix_cases:
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   133
  "(xs \<le> ys ==> C) ==>
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   134
    (ys \<le> xs ==> C) ==>
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   135
    (xs \<parallel> ys ==> C) ==> C"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   136
  by (unfold parallel_def) blast
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   137
10389
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   138
theorem parallel_decomp:
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   139
  "xs \<parallel> ys ==> \<exists>as b bs c cs. b \<noteq> c \<and> xs = as @ b # bs \<and> ys = as @ c # cs"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   140
  (concl is "?E xs")
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   141
proof -
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   142
  assume "xs \<parallel> ys"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   143
  have "?this --> ?E xs" (is "?P xs")
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   144
  proof (induct (stripped) xs rule: rev_induct)
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   145
    assume "[] \<parallel> ys" hence False by auto
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   146
    thus "?E []" ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   147
  next
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   148
    fix x xs
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   149
    assume hyp: "?P xs"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   150
    assume asm: "xs @ [x] \<parallel> ys"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   151
    show "?E (xs @ [x])"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   152
    proof (rule prefix_cases)
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   153
      assume le: "xs \<le> ys"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   154
      then obtain ys' where ys: "ys = xs @ ys'" ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   155
      show ?thesis
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   156
      proof (cases ys')
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   157
        assume "ys' = []" with ys have "xs = ys" by simp
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   158
        with asm have "[x] \<parallel> []" by auto
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   159
        hence False by blast
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   160
        thus ?thesis ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   161
      next
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   162
        fix c cs assume ys': "ys' = c # cs"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   163
        with asm ys have "xs @ [x] \<parallel> xs @ c # cs" by (simp only:)
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   164
        hence "x \<noteq> c" by auto
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   165
        moreover have "xs @ [x] = xs @ x # []" by simp
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   166
        moreover from ys ys' have "ys = xs @ c # cs" by (simp only:)
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   167
        ultimately show ?thesis by blast
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   168
      qed
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   169
    next
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   170
      assume "ys \<le> xs" hence "ys \<le> xs @ [x]" by simp
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   171
      with asm have False by blast
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   172
      thus ?thesis ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   173
    next
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   174
      assume "xs \<parallel> ys"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   175
      with hyp obtain as b bs c cs where neq: "(b::'a) \<noteq> c"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   176
          and xs: "xs = as @ b # bs" and ys: "ys = as @ c # cs"
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   177
	by blast
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   178
      from xs have "xs @ [x] = as @ b # (bs @ [x])" by simp
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   179
      with neq ys show ?thesis by blast
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   180
    qed
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   181
  qed
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   182
  thus ?thesis ..
c7d8901ab269 proper setup of "parallel";
wenzelm
parents: 10330
diff changeset
   183
qed
10330
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   184
4362e906b745 "List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff changeset
   185
end