src/HOL/ex/Unification.thy
author haftmann
Fri, 11 Jun 2010 17:14:02 +0200
changeset 37407 61dd8c145da7
parent 32960 69916a850301
child 39754 150f831ce4a3
permissions -rw-r--r--
declare lex_prod_def [code del]
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
     1
(*  ID:         $Id$
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
     2
    Author:     Alexander Krauss, Technische Universitaet Muenchen
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
     3
*)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
     4
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
     5
header {* Case study: Unification Algorithm *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
     6
23219
87ad6e8a5f2c tuned document;
wenzelm
parents: 23024
diff changeset
     7
theory Unification
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
     8
imports Main
23219
87ad6e8a5f2c tuned document;
wenzelm
parents: 23024
diff changeset
     9
begin
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    10
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    11
text {* 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    12
  This is a formalization of a first-order unification
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    13
  algorithm. It uses the new "function" package to define recursive
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    14
  functions, which allows a better treatment of nested recursion. 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    15
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    16
  This is basically a modernized version of a previous formalization
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    17
  by Konrad Slind (see: HOL/Subst/Unify.thy), which itself builds on
23219
87ad6e8a5f2c tuned document;
wenzelm
parents: 23024
diff changeset
    18
  previous work by Paulson and Manna \& Waldinger (for details, see
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    19
  there).
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    20
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    21
  Unlike that formalization, where the proofs of termination and
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    22
  some partial correctness properties are intertwined, we can prove
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    23
  partial correctness and termination separately.
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    24
*}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    25
23219
87ad6e8a5f2c tuned document;
wenzelm
parents: 23024
diff changeset
    26
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    27
subsection {* Basic definitions *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    28
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    29
datatype 'a trm = 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    30
  Var 'a 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    31
  | Const 'a
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    32
  | App "'a trm" "'a trm" (infix "\<cdot>" 60)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    33
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    34
types
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    35
  'a subst = "('a \<times> 'a trm) list"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    36
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    37
text {* Applying a substitution to a variable: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    38
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    39
fun assoc :: "'a \<Rightarrow> 'b \<Rightarrow> ('a \<times> 'b) list \<Rightarrow> 'b"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    40
where
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    41
  "assoc x d [] = d"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    42
| "assoc x d ((p,q)#t) = (if x = p then q else assoc x d t)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    43
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    44
text {* Applying a substitution to a term: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    45
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    46
fun apply_subst :: "'a trm \<Rightarrow> 'a subst \<Rightarrow> 'a trm" (infixl "\<triangleleft>" 60)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    47
where
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    48
  "(Var v) \<triangleleft> s = assoc v (Var v) s"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    49
| "(Const c) \<triangleleft> s = (Const c)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    50
| "(M \<cdot> N) \<triangleleft> s = (M \<triangleleft> s) \<cdot> (N \<triangleleft> s)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    51
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    52
text {* Composition of substitutions: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    53
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    54
fun
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    55
  "compose" :: "'a subst \<Rightarrow> 'a subst \<Rightarrow> 'a subst" (infixl "\<bullet>" 80)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    56
where
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    57
  "[] \<bullet> bl = bl"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    58
| "((a,b) # al) \<bullet> bl = (a, b \<triangleleft> bl) # (al \<bullet> bl)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    59
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    60
text {* Equivalence of substitutions: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    61
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    62
definition eqv (infix "=\<^sub>s" 50)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    63
where
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    64
  "s1 =\<^sub>s s2 \<equiv> \<forall>t. t \<triangleleft> s1 = t \<triangleleft> s2" 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    65
23219
87ad6e8a5f2c tuned document;
wenzelm
parents: 23024
diff changeset
    66
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    67
subsection {* Basic lemmas *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    68
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    69
lemma apply_empty[simp]: "t \<triangleleft> [] = t"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    70
by (induct t) auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    71
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    72
lemma compose_empty[simp]: "\<sigma> \<bullet> [] = \<sigma>"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    73
by (induct \<sigma>) auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    74
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    75
lemma apply_compose[simp]: "t \<triangleleft> (s1 \<bullet> s2) = t \<triangleleft> s1 \<triangleleft> s2"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    76
proof (induct t)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    77
  case App thus ?case by simp
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    78
next 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    79
  case Const thus ?case by simp
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    80
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    81
  case (Var v) thus ?case
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    82
  proof (induct s1)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    83
    case Nil show ?case by simp
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    84
  next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    85
    case (Cons p s1s) thus ?case by (cases p, simp)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    86
  qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    87
qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    88
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    89
lemma eqv_refl[intro]: "s =\<^sub>s s"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    90
  by (auto simp:eqv_def)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    91
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    92
lemma eqv_trans[trans]: "\<lbrakk>s1 =\<^sub>s s2; s2 =\<^sub>s s3\<rbrakk> \<Longrightarrow> s1 =\<^sub>s s3"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    93
  by (auto simp:eqv_def)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    94
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    95
lemma eqv_sym[sym]: "\<lbrakk>s1 =\<^sub>s s2\<rbrakk> \<Longrightarrow> s2 =\<^sub>s s1"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    96
  by (auto simp:eqv_def)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    97
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    98
lemma eqv_intro[intro]: "(\<And>t. t \<triangleleft> \<sigma> = t \<triangleleft> \<theta>) \<Longrightarrow> \<sigma> =\<^sub>s \<theta>"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
    99
  by (auto simp:eqv_def)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   100
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   101
lemma eqv_dest[dest]: "s1 =\<^sub>s s2 \<Longrightarrow> t \<triangleleft> s1 = t \<triangleleft> s2"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   102
  by (auto simp:eqv_def)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   103
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   104
lemma compose_eqv: "\<lbrakk>\<sigma> =\<^sub>s \<sigma>'; \<theta> =\<^sub>s \<theta>'\<rbrakk> \<Longrightarrow> (\<sigma> \<bullet> \<theta>) =\<^sub>s (\<sigma>' \<bullet> \<theta>')"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   105
  by (auto simp:eqv_def)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   106
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   107
lemma compose_assoc: "(a \<bullet> b) \<bullet> c =\<^sub>s a \<bullet> (b \<bullet> c)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   108
  by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   109
23219
87ad6e8a5f2c tuned document;
wenzelm
parents: 23024
diff changeset
   110
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   111
subsection {* Specification: Most general unifiers *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   112
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   113
definition
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   114
  "Unifier \<sigma> t u \<equiv> (t\<triangleleft>\<sigma> = u\<triangleleft>\<sigma>)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   115
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   116
definition
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   117
  "MGU \<sigma> t u \<equiv> Unifier \<sigma> t u \<and> (\<forall>\<theta>. Unifier \<theta> t u 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   118
  \<longrightarrow> (\<exists>\<gamma>. \<theta> =\<^sub>s \<sigma> \<bullet> \<gamma>))"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   119
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   120
lemma MGUI[intro]:
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   121
  "\<lbrakk>t \<triangleleft> \<sigma> = u \<triangleleft> \<sigma>; \<And>\<theta>. t \<triangleleft> \<theta> = u \<triangleleft> \<theta> \<Longrightarrow> \<exists>\<gamma>. \<theta> =\<^sub>s \<sigma> \<bullet> \<gamma>\<rbrakk>
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   122
  \<Longrightarrow> MGU \<sigma> t u"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   123
  by (simp only:Unifier_def MGU_def, auto)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   124
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   125
lemma MGU_sym[sym]:
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   126
  "MGU \<sigma> s t \<Longrightarrow> MGU \<sigma> t s"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   127
  by (auto simp:MGU_def Unifier_def)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   128
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   129
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   130
subsection {* The unification algorithm *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   131
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   132
text {* Occurs check: Proper subterm relation *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   133
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   134
fun occ :: "'a trm \<Rightarrow> 'a trm \<Rightarrow> bool"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   135
where
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   136
  "occ u (Var v) = False"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   137
| "occ u (Const c) = False"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   138
| "occ u (M \<cdot> N) = (u = M \<or> u = N \<or> occ u M \<or> occ u N)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   139
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   140
text {* The unification algorithm: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   141
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   142
function unify :: "'a trm \<Rightarrow> 'a trm \<Rightarrow> 'a subst option"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   143
where
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   144
  "unify (Const c) (M \<cdot> N)   = None"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   145
| "unify (M \<cdot> N)   (Const c) = None"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   146
| "unify (Const c) (Var v)   = Some [(v, Const c)]"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   147
| "unify (M \<cdot> N)   (Var v)   = (if (occ (Var v) (M \<cdot> N)) 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   148
                                        then None
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   149
                                        else Some [(v, M \<cdot> N)])"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   150
| "unify (Var v)   M         = (if (occ (Var v) M) 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   151
                                        then None
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   152
                                        else Some [(v, M)])"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   153
| "unify (Const c) (Const d) = (if c=d then Some [] else None)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   154
| "unify (M \<cdot> N) (M' \<cdot> N') = (case unify M M' of
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   155
                                    None \<Rightarrow> None |
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   156
                                    Some \<theta> \<Rightarrow> (case unify (N \<triangleleft> \<theta>) (N' \<triangleleft> \<theta>)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   157
                                      of None \<Rightarrow> None |
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   158
                                         Some \<sigma> \<Rightarrow> Some (\<theta> \<bullet> \<sigma>)))"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   159
  by pat_completeness auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   160
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   161
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   162
subsection {* Partial correctness *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   163
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   164
text {* Some lemmas about occ and MGU: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   165
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   166
lemma subst_no_occ: "\<not>occ (Var v) t \<Longrightarrow> Var v \<noteq> t
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   167
  \<Longrightarrow> t \<triangleleft> [(v,s)] = t"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   168
by (induct t) auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   169
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   170
lemma MGU_Var[intro]: 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   171
  assumes no_occ: "\<not>occ (Var v) t"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   172
  shows "MGU [(v,t)] (Var v) t"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   173
proof (intro MGUI exI)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   174
  show "Var v \<triangleleft> [(v,t)] = t \<triangleleft> [(v,t)]" using no_occ
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   175
    by (cases "Var v = t", auto simp:subst_no_occ)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   176
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   177
  fix \<theta> assume th: "Var v \<triangleleft> \<theta> = t \<triangleleft> \<theta>" 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   178
  show "\<theta> =\<^sub>s [(v,t)] \<bullet> \<theta>" 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   179
  proof
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   180
    fix s show "s \<triangleleft> \<theta> = s \<triangleleft> [(v,t)] \<bullet> \<theta>" using th 
24444
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   181
      by (induct s) auto
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   182
  qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   183
qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   184
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   185
declare MGU_Var[symmetric, intro]
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   186
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   187
lemma MGU_Const[simp]: "MGU [] (Const c) (Const d) = (c = d)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   188
  unfolding MGU_def Unifier_def
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   189
  by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   190
  
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   191
text {* If unification terminates, then it computes most general unifiers: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   192
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   193
lemma unify_partial_correctness:
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   194
  assumes "unify_dom (M, N)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   195
  assumes "unify M N = Some \<sigma>"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   196
  shows "MGU \<sigma> M N"
24444
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   197
using assms
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   198
proof (induct M N arbitrary: \<sigma>)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   199
  case (7 M N M' N' \<sigma>) -- "The interesting case"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   200
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   201
  then obtain \<theta>1 \<theta>2 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   202
    where "unify M M' = Some \<theta>1"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   203
    and "unify (N \<triangleleft> \<theta>1) (N' \<triangleleft> \<theta>1) = Some \<theta>2"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   204
    and \<sigma>: "\<sigma> = \<theta>1 \<bullet> \<theta>2"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   205
    and MGU_inner: "MGU \<theta>1 M M'" 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   206
    and MGU_outer: "MGU \<theta>2 (N \<triangleleft> \<theta>1) (N' \<triangleleft> \<theta>1)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   207
    by (auto split:option.split_asm)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   208
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   209
  show ?case
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   210
  proof
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   211
    from MGU_inner and MGU_outer
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   212
    have "M \<triangleleft> \<theta>1 = M' \<triangleleft> \<theta>1" 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   213
      and "N \<triangleleft> \<theta>1 \<triangleleft> \<theta>2 = N' \<triangleleft> \<theta>1 \<triangleleft> \<theta>2"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   214
      unfolding MGU_def Unifier_def
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   215
      by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   216
    thus "M \<cdot> N \<triangleleft> \<sigma> = M' \<cdot> N' \<triangleleft> \<sigma>" unfolding \<sigma>
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   217
      by simp
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   218
  next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   219
    fix \<sigma>' assume "M \<cdot> N \<triangleleft> \<sigma>' = M' \<cdot> N' \<triangleleft> \<sigma>'"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   220
    hence "M \<triangleleft> \<sigma>' = M' \<triangleleft> \<sigma>'"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   221
      and Ns: "N \<triangleleft> \<sigma>' = N' \<triangleleft> \<sigma>'" by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   222
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   223
    with MGU_inner obtain \<delta>
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   224
      where eqv: "\<sigma>' =\<^sub>s \<theta>1 \<bullet> \<delta>"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   225
      unfolding MGU_def Unifier_def
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   226
      by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   227
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   228
    from Ns have "N \<triangleleft> \<theta>1 \<triangleleft> \<delta> = N' \<triangleleft> \<theta>1 \<triangleleft> \<delta>"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   229
      by (simp add:eqv_dest[OF eqv])
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   230
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   231
    with MGU_outer obtain \<rho>
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   232
      where eqv2: "\<delta> =\<^sub>s \<theta>2 \<bullet> \<rho>"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   233
      unfolding MGU_def Unifier_def
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   234
      by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   235
    
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   236
    have "\<sigma>' =\<^sub>s \<sigma> \<bullet> \<rho>" unfolding \<sigma>
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   237
      by (rule eqv_intro, auto simp:eqv_dest[OF eqv] eqv_dest[OF eqv2])
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   238
    thus "\<exists>\<gamma>. \<sigma>' =\<^sub>s \<sigma> \<bullet> \<gamma>" ..
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   239
  qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   240
qed (auto split:split_if_asm) -- "Solve the remaining cases automatically"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   241
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   242
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   243
subsection {* Properties used in termination proof *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   244
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   245
text {* The variables of a term: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   246
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   247
fun vars_of:: "'a trm \<Rightarrow> 'a set"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   248
where
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   249
  "vars_of (Var v) = { v }"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   250
| "vars_of (Const c) = {}"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   251
| "vars_of (M \<cdot> N) = vars_of M \<union> vars_of N"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   252
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   253
lemma vars_of_finite[intro]: "finite (vars_of t)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   254
  by (induct t) simp_all
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   255
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   256
text {* Elimination of variables by a substitution: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   257
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   258
definition
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   259
  "elim \<sigma> v \<equiv> \<forall>t. v \<notin> vars_of (t \<triangleleft> \<sigma>)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   260
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   261
lemma elim_intro[intro]: "(\<And>t. v \<notin> vars_of (t \<triangleleft> \<sigma>)) \<Longrightarrow> elim \<sigma> v"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   262
  by (auto simp:elim_def)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   263
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   264
lemma elim_dest[dest]: "elim \<sigma> v \<Longrightarrow> v \<notin> vars_of (t \<triangleleft> \<sigma>)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   265
  by (auto simp:elim_def)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   266
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   267
lemma elim_eqv: "\<sigma> =\<^sub>s \<theta> \<Longrightarrow> elim \<sigma> x = elim \<theta> x"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   268
  by (auto simp:elim_def eqv_def)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   269
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   270
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   271
text {* Replacing a variable by itself yields an identity subtitution: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   272
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   273
lemma var_self[intro]: "[(v, Var v)] =\<^sub>s []"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   274
proof
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   275
  fix t show "t \<triangleleft> [(v, Var v)] = t \<triangleleft> []"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   276
    by (induct t) simp_all
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   277
qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   278
30909
bd4f255837e5 tuned proof
krauss
parents: 24444
diff changeset
   279
lemma var_same: "([(v, t)] =\<^sub>s []) = (t = Var v)"
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   280
proof
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   281
  assume t_v: "t = Var v"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   282
  thus "[(v, t)] =\<^sub>s []"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   283
    by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   284
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   285
  assume id: "[(v, t)] =\<^sub>s []"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   286
  show "t = Var v"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   287
  proof -
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   288
    have "t = Var v \<triangleleft> [(v, t)]" by simp
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   289
    also from id have "\<dots> = Var v \<triangleleft> []" ..
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   290
    finally show ?thesis by simp
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   291
  qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   292
qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   293
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   294
text {* A lemma about occ and elim *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   295
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   296
lemma remove_var:
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   297
  assumes [simp]: "v \<notin> vars_of s"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   298
  shows "v \<notin> vars_of (t \<triangleleft> [(v, s)])"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   299
  by (induct t) simp_all
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   300
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   301
lemma occ_elim: "\<not>occ (Var v) t 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   302
  \<Longrightarrow> elim [(v,t)] v \<or> [(v,t)] =\<^sub>s []"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   303
proof (induct t)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   304
  case (Var x)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   305
  show ?case
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   306
  proof cases
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   307
    assume "v = x"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   308
    thus ?thesis
30909
bd4f255837e5 tuned proof
krauss
parents: 24444
diff changeset
   309
      by (simp add:var_same)
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   310
  next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   311
    assume neq: "v \<noteq> x"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   312
    have "elim [(v, Var x)] v"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   313
      by (auto intro!:remove_var simp:neq)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   314
    thus ?thesis ..
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   315
  qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   316
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   317
  case (Const c)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   318
  have "elim [(v, Const c)] v"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   319
    by (auto intro!:remove_var)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   320
  thus ?case ..
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   321
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   322
  case (App M N)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   323
  
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   324
  hence ih1: "elim [(v, M)] v \<or> [(v, M)] =\<^sub>s []"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   325
    and ih2: "elim [(v, N)] v \<or> [(v, N)] =\<^sub>s []"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   326
    and nonocc: "Var v \<noteq> M" "Var v \<noteq> N"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   327
    by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   328
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   329
  from nonocc have "\<not> [(v,M)] =\<^sub>s []"
30909
bd4f255837e5 tuned proof
krauss
parents: 24444
diff changeset
   330
    by (simp add:var_same)
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   331
  with ih1 have "elim [(v, M)] v" by blast
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   332
  hence "v \<notin> vars_of (Var v \<triangleleft> [(v,M)])" ..
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   333
  hence not_in_M: "v \<notin> vars_of M" by simp
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   334
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   335
  from nonocc have "\<not> [(v,N)] =\<^sub>s []"
30909
bd4f255837e5 tuned proof
krauss
parents: 24444
diff changeset
   336
    by (simp add:var_same)
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   337
  with ih2 have "elim [(v, N)] v" by blast
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   338
  hence "v \<notin> vars_of (Var v \<triangleleft> [(v,N)])" ..
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   339
  hence not_in_N: "v \<notin> vars_of N" by simp
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   340
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   341
  have "elim [(v, M \<cdot> N)] v"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   342
  proof 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   343
    fix t 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   344
    show "v \<notin> vars_of (t \<triangleleft> [(v, M \<cdot> N)])"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   345
    proof (induct t)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   346
      case (Var x) thus ?case by (simp add: not_in_M not_in_N)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   347
    qed auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   348
  qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   349
  thus ?case ..
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   350
qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   351
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   352
text {* The result of a unification never introduces new variables: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   353
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   354
lemma unify_vars: 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   355
  assumes "unify_dom (M, N)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   356
  assumes "unify M N = Some \<sigma>"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   357
  shows "vars_of (t \<triangleleft> \<sigma>) \<subseteq> vars_of M \<union> vars_of N \<union> vars_of t"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   358
  (is "?P M N \<sigma> t")
24444
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   359
using assms
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   360
proof (induct M N arbitrary:\<sigma> t)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   361
  case (3 c v) 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   362
  hence "\<sigma> = [(v, Const c)]" by simp
24444
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   363
  thus ?case by (induct t) auto
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   364
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   365
  case (4 M N v) 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   366
  hence "\<not>occ (Var v) (M\<cdot>N)" by (cases "occ (Var v) (M\<cdot>N)", auto)
24444
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   367
  with 4 have "\<sigma> = [(v, M\<cdot>N)]" by simp
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   368
  thus ?case by (induct t) auto
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   369
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   370
  case (5 v M)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   371
  hence "\<not>occ (Var v) M" by (cases "occ (Var v) M", auto)
24444
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   372
  with 5 have "\<sigma> = [(v, M)]" by simp
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   373
  thus ?case by (induct t) auto
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   374
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   375
  case (7 M N M' N' \<sigma>)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   376
  then obtain \<theta>1 \<theta>2 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   377
    where "unify M M' = Some \<theta>1"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   378
    and "unify (N \<triangleleft> \<theta>1) (N' \<triangleleft> \<theta>1) = Some \<theta>2"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   379
    and \<sigma>: "\<sigma> = \<theta>1 \<bullet> \<theta>2"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   380
    and ih1: "\<And>t. ?P M M' \<theta>1 t"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   381
    and ih2: "\<And>t. ?P (N\<triangleleft>\<theta>1) (N'\<triangleleft>\<theta>1) \<theta>2 t"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   382
    by (auto split:option.split_asm)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   383
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   384
  show ?case
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   385
  proof
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   386
    fix v assume a: "v \<in> vars_of (t \<triangleleft> \<sigma>)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   387
    
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   388
    show "v \<in> vars_of (M \<cdot> N) \<union> vars_of (M' \<cdot> N') \<union> vars_of t"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   389
    proof (cases "v \<notin> vars_of M \<and> v \<notin> vars_of M'
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   390
        \<and> v \<notin> vars_of N \<and> v \<notin> vars_of N'")
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   391
      case True
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   392
      with ih1 have l:"\<And>t. v \<in> vars_of (t \<triangleleft> \<theta>1) \<Longrightarrow> v \<in> vars_of t"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   393
        by auto
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   394
      
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   395
      from a and ih2[where t="t \<triangleleft> \<theta>1"]
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   396
      have "v \<in> vars_of (N \<triangleleft> \<theta>1) \<union> vars_of (N' \<triangleleft> \<theta>1) 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   397
        \<or> v \<in> vars_of (t \<triangleleft> \<theta>1)" unfolding \<sigma>
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   398
        by auto
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   399
      hence "v \<in> vars_of t"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   400
      proof
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   401
        assume "v \<in> vars_of (N \<triangleleft> \<theta>1) \<union> vars_of (N' \<triangleleft> \<theta>1)"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   402
        with True show ?thesis by (auto dest:l)
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   403
      next
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   404
        assume "v \<in> vars_of (t \<triangleleft> \<theta>1)" 
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   405
        thus ?thesis by (rule l)
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   406
      qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   407
      
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   408
      thus ?thesis by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   409
    qed auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   410
  qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   411
qed (auto split: split_if_asm)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   412
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   413
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   414
text {* The result of a unification is either the identity
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   415
substitution or it eliminates a variable from one of the terms: *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   416
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   417
lemma unify_eliminates: 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   418
  assumes "unify_dom (M, N)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   419
  assumes "unify M N = Some \<sigma>"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   420
  shows "(\<exists>v\<in>vars_of M \<union> vars_of N. elim \<sigma> v) \<or> \<sigma> =\<^sub>s []"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   421
  (is "?P M N \<sigma>")
24444
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   422
using assms
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   423
proof (induct M N arbitrary:\<sigma>)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   424
  case 1 thus ?case by simp
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   425
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   426
  case 2 thus ?case by simp
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   427
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   428
  case (3 c v)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   429
  have no_occ: "\<not> occ (Var v) (Const c)" by simp
24444
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   430
  with 3 have "\<sigma> = [(v, Const c)]" by simp
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   431
  with occ_elim[OF no_occ]
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   432
  show ?case by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   433
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   434
  case (4 M N v)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   435
  hence no_occ: "\<not>occ (Var v) (M\<cdot>N)" by (cases "occ (Var v) (M\<cdot>N)", auto)
24444
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   436
  with 4 have "\<sigma> = [(v, M\<cdot>N)]" by simp
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   437
  with occ_elim[OF no_occ]
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   438
  show ?case by auto 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   439
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   440
  case (5 v M) 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   441
  hence no_occ: "\<not>occ (Var v) M" by (cases "occ (Var v) M", auto)
24444
448978b61556 induct: proper separation of initial and terminal step;
wenzelm
parents: 23777
diff changeset
   442
  with 5 have "\<sigma> = [(v, M)]" by simp
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   443
  with occ_elim[OF no_occ]
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   444
  show ?case by auto 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   445
next 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   446
  case (6 c d) thus ?case
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   447
    by (cases "c = d") auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   448
next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   449
  case (7 M N M' N' \<sigma>)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   450
  then obtain \<theta>1 \<theta>2 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   451
    where "unify M M' = Some \<theta>1"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   452
    and "unify (N \<triangleleft> \<theta>1) (N' \<triangleleft> \<theta>1) = Some \<theta>2"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   453
    and \<sigma>: "\<sigma> = \<theta>1 \<bullet> \<theta>2"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   454
    and ih1: "?P M M' \<theta>1"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   455
    and ih2: "?P (N\<triangleleft>\<theta>1) (N'\<triangleleft>\<theta>1) \<theta>2"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   456
    by (auto split:option.split_asm)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   457
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   458
  from `unify_dom (M \<cdot> N, M' \<cdot> N')`
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   459
  have "unify_dom (M, M')"
23777
60b7800338d5 Renamed accessible part for predicates to accp.
berghofe
parents: 23373
diff changeset
   460
    by (rule accp_downward) (rule unify_rel.intros)
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   461
  hence no_new_vars: 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   462
    "\<And>t. vars_of (t \<triangleleft> \<theta>1) \<subseteq> vars_of M \<union> vars_of M' \<union> vars_of t"
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 23219
diff changeset
   463
    by (rule unify_vars) (rule `unify M M' = Some \<theta>1`)
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   464
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   465
  from ih2 show ?case 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   466
  proof 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   467
    assume "\<exists>v\<in>vars_of (N \<triangleleft> \<theta>1) \<union> vars_of (N' \<triangleleft> \<theta>1). elim \<theta>2 v"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   468
    then obtain v 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   469
      where "v\<in>vars_of (N \<triangleleft> \<theta>1) \<union> vars_of (N' \<triangleleft> \<theta>1)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   470
      and el: "elim \<theta>2 v" by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   471
    with no_new_vars show ?thesis unfolding \<sigma> 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   472
      by (auto simp:elim_def)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   473
  next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   474
    assume empty[simp]: "\<theta>2 =\<^sub>s []"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   475
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   476
    have "\<sigma> =\<^sub>s (\<theta>1 \<bullet> [])" unfolding \<sigma>
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   477
      by (rule compose_eqv) auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   478
    also have "\<dots> =\<^sub>s \<theta>1" by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   479
    finally have "\<sigma> =\<^sub>s \<theta>1" .
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   480
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   481
    from ih1 show ?thesis
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   482
    proof
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   483
      assume "\<exists>v\<in>vars_of M \<union> vars_of M'. elim \<theta>1 v"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   484
      with elim_eqv[OF `\<sigma> =\<^sub>s \<theta>1`]
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   485
      show ?thesis by auto
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   486
    next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   487
      note `\<sigma> =\<^sub>s \<theta>1`
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   488
      also assume "\<theta>1 =\<^sub>s []"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   489
      finally show ?thesis ..
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   490
    qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   491
  qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   492
qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   493
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   494
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   495
subsection {* Termination proof *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   496
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   497
termination unify
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   498
proof 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   499
  let ?R = "measures [\<lambda>(M,N). card (vars_of M \<union> vars_of N),
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   500
                           \<lambda>(M, N). size M]"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   501
  show "wf ?R" by simp
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   502
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   503
  fix M N M' N' 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   504
  show "((M, M'), (M \<cdot> N, M' \<cdot> N')) \<in> ?R" -- "Inner call"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   505
    by (rule measures_lesseq) (auto intro: card_mono)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   506
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   507
  fix \<theta>                                   -- "Outer call"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   508
  assume inner: "unify_dom (M, M')"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   509
    "unify M M' = Some \<theta>"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   510
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   511
  from unify_eliminates[OF inner]
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   512
  show "((N \<triangleleft> \<theta>, N' \<triangleleft> \<theta>), (M \<cdot> N, M' \<cdot> N')) \<in>?R"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   513
  proof
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   514
    -- {* Either a variable is eliminated \ldots *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   515
    assume "(\<exists>v\<in>vars_of M \<union> vars_of M'. elim \<theta> v)"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   516
    then obtain v 
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   517
      where "elim \<theta> v" 
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   518
      and "v\<in>vars_of M \<union> vars_of M'" by auto
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   519
    with unify_vars[OF inner]
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   520
    have "vars_of (N\<triangleleft>\<theta>) \<union> vars_of (N'\<triangleleft>\<theta>)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   521
      \<subset> vars_of (M\<cdot>N) \<union> vars_of (M'\<cdot>N')"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   522
      by auto
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   523
    
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   524
    thus ?thesis
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   525
      by (auto intro!: measures_less intro: psubset_card_mono)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   526
  next
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   527
    -- {* Or the substitution is empty *}
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   528
    assume "\<theta> =\<^sub>s []"
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   529
    hence "N \<triangleleft> \<theta> = N" 
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 30909
diff changeset
   530
      and "N' \<triangleleft> \<theta> = N'" by auto
22999
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   531
    thus ?thesis 
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   532
       by (auto intro!: measures_less intro: psubset_card_mono)
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   533
  qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   534
qed
c1ce129e6f9c Added unification case study (using new function package)
krauss
parents:
diff changeset
   535
23219
87ad6e8a5f2c tuned document;
wenzelm
parents: 23024
diff changeset
   536
end