author | desharna |
Wed, 29 Jun 2022 20:41:29 +0200 | |
changeset 75638 | aaa22adef039 |
parent 75637 | 66a9aa769d63 |
child 75639 | b8bd01897578 |
permissions | -rw-r--r-- |
44372 | 1 |
(* Title: HOL/ex/Unification.thy |
2 |
Author: Martin Coen, Cambridge University Computer Laboratory |
|
3 |
Author: Konrad Slind, TUM & Cambridge University Computer Laboratory |
|
4 |
Author: Alexander Krauss, TUM |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
5 |
*) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
6 |
|
61343 | 7 |
section \<open>Substitution and Unification\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
8 |
|
23219 | 9 |
theory Unification |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
10 |
imports Main |
23219 | 11 |
begin |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
12 |
|
61343 | 13 |
text \<open> |
44428 | 14 |
Implements Manna \& Waldinger's formalization, with Paulson's |
44372 | 15 |
simplifications, and some new simplifications by Slind and Krauss. |
16 |
||
44428 | 17 |
Z Manna \& R Waldinger, Deductive Synthesis of the Unification |
44372 | 18 |
Algorithm. SCP 1 (1981), 5-48 |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
19 |
|
44372 | 20 |
L C Paulson, Verifying the Unification Algorithm in LCF. SCP 5 |
21 |
(1985), 143-170 |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
22 |
|
44372 | 23 |
K Slind, Reasoning about Terminating Functional Programs, |
24 |
Ph.D. thesis, TUM, 1999, Sect. 5.8 |
|
25 |
||
26 |
A Krauss, Partial and Nested Recursive Function Definitions in |
|
56790
f54097170704
prefer plain ASCII / latex over not-so-universal Unicode;
wenzelm
parents:
44428
diff
changeset
|
27 |
Higher-Order Logic, JAR 44(4):303-336, 2010. Sect. 6.3 |
61343 | 28 |
\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
29 |
|
23219 | 30 |
|
61343 | 31 |
subsection \<open>Terms\<close> |
44368 | 32 |
|
61343 | 33 |
text \<open>Binary trees with leaves that are constants or variables.\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
34 |
|
58310 | 35 |
datatype 'a trm = |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
36 |
Var 'a |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
37 |
| Const 'a |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
38 |
| Comb "'a trm" "'a trm" (infix "\<cdot>" 60) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
39 |
|
44368 | 40 |
primrec vars_of :: "'a trm \<Rightarrow> 'a set" |
41 |
where |
|
42 |
"vars_of (Var v) = {v}" |
|
43 |
| "vars_of (Const c) = {}" |
|
44 |
| "vars_of (M \<cdot> N) = vars_of M \<union> vars_of N" |
|
45 |
||
46 |
fun occs :: "'a trm \<Rightarrow> 'a trm \<Rightarrow> bool" (infixl "\<prec>" 54) |
|
47 |
where |
|
44369 | 48 |
"u \<prec> Var v \<longleftrightarrow> False" |
49 |
| "u \<prec> Const c \<longleftrightarrow> False" |
|
50 |
| "u \<prec> M \<cdot> N \<longleftrightarrow> u = M \<or> u = N \<or> u \<prec> M \<or> u \<prec> N" |
|
44368 | 51 |
|
52 |
||
53 |
lemma finite_vars_of[intro]: "finite (vars_of t)" |
|
54 |
by (induct t) simp_all |
|
55 |
||
56 |
lemma vars_iff_occseq: "x \<in> vars_of t \<longleftrightarrow> Var x \<prec> t \<or> Var x = t" |
|
57 |
by (induct t) auto |
|
58 |
||
59 |
lemma occs_vars_subset: "M \<prec> N \<Longrightarrow> vars_of M \<subseteq> vars_of N" |
|
60 |
by (induct N) auto |
|
61 |
||
62 |
||
61343 | 63 |
subsection \<open>Substitutions\<close> |
44368 | 64 |
|
42463 | 65 |
type_synonym 'a subst = "('a \<times> 'a trm) list" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
66 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
67 |
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
|
68 |
where |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
69 |
"assoc x d [] = d" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
70 |
| "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
|
71 |
|
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
72 |
primrec subst :: "'a trm \<Rightarrow> 'a subst \<Rightarrow> 'a trm" (infixl "\<lhd>" 55) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
73 |
where |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
74 |
"(Var v) \<lhd> s = assoc v (Var v) s" |
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
75 |
| "(Const c) \<lhd> s = (Const c)" |
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
76 |
| "(M \<cdot> N) \<lhd> s = (M \<lhd> s) \<cdot> (N \<lhd> s)" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
77 |
|
44368 | 78 |
definition subst_eq (infixr "\<doteq>" 52) |
79 |
where |
|
80 |
"s1 \<doteq> s2 \<longleftrightarrow> (\<forall>t. t \<lhd> s1 = t \<lhd> s2)" |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
81 |
|
44368 | 82 |
fun comp :: "'a subst \<Rightarrow> 'a subst \<Rightarrow> 'a subst" (infixl "\<lozenge>" 56) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
83 |
where |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
84 |
"[] \<lozenge> bl = bl" |
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
85 |
| "((a,b) # al) \<lozenge> bl = (a, b \<lhd> bl) # (al \<lozenge> bl)" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
86 |
|
44368 | 87 |
lemma subst_Nil[simp]: "t \<lhd> [] = t" |
88 |
by (induct t) auto |
|
89 |
||
90 |
lemma subst_mono: "t \<prec> u \<Longrightarrow> t \<lhd> s \<prec> u \<lhd> s" |
|
91 |
by (induct u) auto |
|
92 |
||
93 |
lemma agreement: "(t \<lhd> r = t \<lhd> s) \<longleftrightarrow> (\<forall>v \<in> vars_of t. Var v \<lhd> r = Var v \<lhd> s)" |
|
94 |
by (induct t) auto |
|
95 |
||
96 |
lemma repl_invariance: "v \<notin> vars_of t \<Longrightarrow> t \<lhd> (v,u) # s = t \<lhd> s" |
|
97 |
by (simp add: agreement) |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
98 |
|
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
99 |
lemma remove_var: "v \<notin> vars_of s \<Longrightarrow> v \<notin> vars_of (t \<lhd> [(v, s)])" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
100 |
by (induct t) simp_all |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
101 |
|
44368 | 102 |
lemma subst_refl[iff]: "s \<doteq> s" |
103 |
by (auto simp:subst_eq_def) |
|
104 |
||
105 |
lemma subst_sym[sym]: "\<lbrakk>s1 \<doteq> s2\<rbrakk> \<Longrightarrow> s2 \<doteq> s1" |
|
106 |
by (auto simp:subst_eq_def) |
|
107 |
||
108 |
lemma subst_trans[trans]: "\<lbrakk>s1 \<doteq> s2; s2 \<doteq> s3\<rbrakk> \<Longrightarrow> s1 \<doteq> s3" |
|
109 |
by (auto simp:subst_eq_def) |
|
110 |
||
44371
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
111 |
lemma subst_no_occs: "\<not> Var v \<prec> t \<Longrightarrow> Var v \<noteq> t |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
112 |
\<Longrightarrow> t \<lhd> [(v,s)] = t" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
113 |
by (induct t) auto |
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
114 |
|
44368 | 115 |
lemma comp_Nil[simp]: "\<sigma> \<lozenge> [] = \<sigma>" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
116 |
by (induct \<sigma>) auto |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
117 |
|
44368 | 118 |
lemma subst_comp[simp]: "t \<lhd> (r \<lozenge> s) = t \<lhd> r \<lhd> s" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
119 |
proof (induct t) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
120 |
case (Var v) thus ?case |
44368 | 121 |
by (induct r) auto |
122 |
qed auto |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
123 |
|
44368 | 124 |
lemma subst_eq_intro[intro]: "(\<And>t. t \<lhd> \<sigma> = t \<lhd> \<theta>) \<Longrightarrow> \<sigma> \<doteq> \<theta>" |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
125 |
by (auto simp:subst_eq_def) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
126 |
|
44368 | 127 |
lemma subst_eq_dest[dest]: "s1 \<doteq> s2 \<Longrightarrow> t \<lhd> s1 = t \<lhd> s2" |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
128 |
by (auto simp:subst_eq_def) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
129 |
|
44368 | 130 |
lemma comp_assoc: "(a \<lozenge> b) \<lozenge> c \<doteq> a \<lozenge> (b \<lozenge> c)" |
131 |
by auto |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
132 |
|
44368 | 133 |
lemma subst_cong: "\<lbrakk>\<sigma> \<doteq> \<sigma>'; \<theta> \<doteq> \<theta>'\<rbrakk> \<Longrightarrow> (\<sigma> \<lozenge> \<theta>) \<doteq> (\<sigma>' \<lozenge> \<theta>')" |
134 |
by (auto simp: subst_eq_def) |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
135 |
|
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
136 |
lemma var_self: "[(v, Var v)] \<doteq> []" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
137 |
proof |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
138 |
fix t show "t \<lhd> [(v, Var v)] = t \<lhd> []" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
139 |
by (induct t) simp_all |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
140 |
qed |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
141 |
|
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
142 |
lemma var_same[simp]: "[(v, t)] \<doteq> [] \<longleftrightarrow> t = Var v" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
143 |
by (metis assoc.simps(2) subst.simps(1) subst_eq_def var_self) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
144 |
|
75637
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
145 |
lemma vars_of_subst_conv_Union: "vars_of (t \<lhd> \<eta>) = \<Union>(vars_of ` (\<lambda>x. Var x \<lhd> \<eta>) ` vars_of t)" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
146 |
by (induction t) simp_all |
23219 | 147 |
|
75638
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
148 |
lemma domain_comp: "fst ` set (\<sigma> \<lozenge> \<theta>) = fst ` (set \<sigma> \<union> set \<theta>)" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
149 |
by (induction \<sigma> \<theta> rule: comp.induct) auto |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
150 |
|
61343 | 151 |
subsection \<open>Unifiers and Most General Unifiers\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
152 |
|
44368 | 153 |
definition Unifier :: "'a subst \<Rightarrow> 'a trm \<Rightarrow> 'a trm \<Rightarrow> bool" |
154 |
where "Unifier \<sigma> t u \<longleftrightarrow> (t \<lhd> \<sigma> = u \<lhd> \<sigma>)" |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
155 |
|
44368 | 156 |
definition MGU :: "'a subst \<Rightarrow> 'a trm \<Rightarrow> 'a trm \<Rightarrow> bool" where |
157 |
"MGU \<sigma> t u \<longleftrightarrow> |
|
158 |
Unifier \<sigma> t u \<and> (\<forall>\<theta>. Unifier \<theta> t u \<longrightarrow> (\<exists>\<gamma>. \<theta> \<doteq> \<sigma> \<lozenge> \<gamma>))" |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
159 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
160 |
lemma MGUI[intro]: |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
161 |
"\<lbrakk>t \<lhd> \<sigma> = u \<lhd> \<sigma>; \<And>\<theta>. t \<lhd> \<theta> = u \<lhd> \<theta> \<Longrightarrow> \<exists>\<gamma>. \<theta> \<doteq> \<sigma> \<lozenge> \<gamma>\<rbrakk> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
162 |
\<Longrightarrow> MGU \<sigma> t u" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
163 |
by (simp only:Unifier_def MGU_def, auto) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
164 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
165 |
lemma MGU_sym[sym]: |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
166 |
"MGU \<sigma> s t \<Longrightarrow> MGU \<sigma> t s" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
167 |
by (auto simp:MGU_def Unifier_def) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
168 |
|
44371
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
169 |
lemma MGU_is_Unifier: "MGU \<sigma> t u \<Longrightarrow> Unifier \<sigma> t u" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
170 |
unfolding MGU_def by (rule conjunct1) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
171 |
|
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
172 |
lemma MGU_Var: |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
173 |
assumes "\<not> Var v \<prec> t" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
174 |
shows "MGU [(v,t)] (Var v) t" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
175 |
proof (intro MGUI exI) |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
176 |
show "Var v \<lhd> [(v,t)] = t \<lhd> [(v,t)]" using assms |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
177 |
by (metis assoc.simps(2) repl_invariance subst.simps(1) subst_Nil vars_iff_occseq) |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
178 |
next |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
179 |
fix \<theta> assume th: "Var v \<lhd> \<theta> = t \<lhd> \<theta>" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
180 |
show "\<theta> \<doteq> [(v,t)] \<lozenge> \<theta>" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
181 |
proof |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
182 |
fix s show "s \<lhd> \<theta> = s \<lhd> [(v,t)] \<lozenge> \<theta>" using th |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
183 |
by (induct s) auto |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
184 |
qed |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
185 |
qed |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
186 |
|
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
187 |
lemma MGU_Const: "MGU [] (Const c) (Const d) \<longleftrightarrow> c = d" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
188 |
by (auto simp: MGU_def Unifier_def) |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
189 |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
190 |
|
61343 | 191 |
subsection \<open>The unification algorithm\<close> |
22999
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 |
function unify :: "'a trm \<Rightarrow> 'a trm \<Rightarrow> 'a subst option" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
194 |
where |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
195 |
"unify (Const c) (M \<cdot> N) = None" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
196 |
| "unify (M \<cdot> N) (Const c) = None" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
197 |
| "unify (Const c) (Var v) = Some [(v, Const c)]" |
44369 | 198 |
| "unify (M \<cdot> N) (Var v) = (if Var v \<prec> M \<cdot> N |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
199 |
then None |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
200 |
else Some [(v, M \<cdot> N)])" |
44369 | 201 |
| "unify (Var v) M = (if Var v \<prec> M |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
202 |
then None |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
203 |
else Some [(v, M)])" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
204 |
| "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
|
205 |
| "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
|
206 |
None \<Rightarrow> None | |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
207 |
Some \<theta> \<Rightarrow> (case unify (N \<lhd> \<theta>) (N' \<lhd> \<theta>) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
208 |
of None \<Rightarrow> None | |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
209 |
Some \<sigma> \<Rightarrow> Some (\<theta> \<lozenge> \<sigma>)))" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
210 |
by pat_completeness auto |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
211 |
|
61343 | 212 |
subsection \<open>Properties used in termination proof\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
213 |
|
61343 | 214 |
text \<open>Elimination of variables by a substitution:\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
215 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
216 |
definition |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
217 |
"elim \<sigma> v \<equiv> \<forall>t. v \<notin> vars_of (t \<lhd> \<sigma>)" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
218 |
|
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
219 |
lemma elim_intro[intro]: "(\<And>t. v \<notin> vars_of (t \<lhd> \<sigma>)) \<Longrightarrow> elim \<sigma> v" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
220 |
by (auto simp:elim_def) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
221 |
|
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
222 |
lemma elim_dest[dest]: "elim \<sigma> v \<Longrightarrow> v \<notin> vars_of (t \<lhd> \<sigma>)" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
223 |
by (auto simp:elim_def) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
224 |
|
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
225 |
lemma elim_eq: "\<sigma> \<doteq> \<theta> \<Longrightarrow> elim \<sigma> x = elim \<theta> x" |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
226 |
by (auto simp:elim_def subst_eq_def) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
227 |
|
44369 | 228 |
lemma occs_elim: "\<not> Var v \<prec> t |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
229 |
\<Longrightarrow> elim [(v,t)] v \<or> [(v,t)] \<doteq> []" |
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
230 |
by (metis elim_intro remove_var var_same vars_iff_occseq) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
231 |
|
61343 | 232 |
text \<open>The result of a unification never introduces new variables:\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
233 |
|
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
234 |
declare unify.psimps[simp] |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
235 |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
236 |
lemma unify_vars: |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
237 |
assumes "unify_dom (M, N)" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
238 |
assumes "unify M N = Some \<sigma>" |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
239 |
shows "vars_of (t \<lhd> \<sigma>) \<subseteq> vars_of M \<union> vars_of N \<union> vars_of t" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
240 |
(is "?P M N \<sigma> t") |
24444
448978b61556
induct: proper separation of initial and terminal step;
wenzelm
parents:
23777
diff
changeset
|
241 |
using assms |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
242 |
proof (induct M N arbitrary:\<sigma> t) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
243 |
case (3 c v) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
244 |
hence "\<sigma> = [(v, Const c)]" by simp |
24444
448978b61556
induct: proper separation of initial and terminal step;
wenzelm
parents:
23777
diff
changeset
|
245 |
thus ?case by (induct t) auto |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
246 |
next |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
247 |
case (4 M N v) |
44369 | 248 |
hence "\<not> Var v \<prec> M \<cdot> N" by auto |
24444
448978b61556
induct: proper separation of initial and terminal step;
wenzelm
parents:
23777
diff
changeset
|
249 |
with 4 have "\<sigma> = [(v, M\<cdot>N)]" by simp |
448978b61556
induct: proper separation of initial and terminal step;
wenzelm
parents:
23777
diff
changeset
|
250 |
thus ?case by (induct t) auto |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
251 |
next |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
252 |
case (5 v M) |
44369 | 253 |
hence "\<not> Var v \<prec> M" by auto |
24444
448978b61556
induct: proper separation of initial and terminal step;
wenzelm
parents:
23777
diff
changeset
|
254 |
with 5 have "\<sigma> = [(v, M)]" by simp |
448978b61556
induct: proper separation of initial and terminal step;
wenzelm
parents:
23777
diff
changeset
|
255 |
thus ?case by (induct t) auto |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
256 |
next |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
257 |
case (7 M N M' N' \<sigma>) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
258 |
then obtain \<theta>1 \<theta>2 |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
259 |
where "unify M M' = Some \<theta>1" |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
260 |
and "unify (N \<lhd> \<theta>1) (N' \<lhd> \<theta>1) = Some \<theta>2" |
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
261 |
and \<sigma>: "\<sigma> = \<theta>1 \<lozenge> \<theta>2" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
262 |
and ih1: "\<And>t. ?P M M' \<theta>1 t" |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
263 |
and ih2: "\<And>t. ?P (N\<lhd>\<theta>1) (N'\<lhd>\<theta>1) \<theta>2 t" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
264 |
by (auto split:option.split_asm) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
265 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
266 |
show ?case |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
267 |
proof |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
268 |
fix v assume a: "v \<in> vars_of (t \<lhd> \<sigma>)" |
22999
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 |
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
|
271 |
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
|
272 |
\<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
|
273 |
case True |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
274 |
with ih1 have l:"\<And>t. v \<in> vars_of (t \<lhd> \<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
|
275 |
by auto |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
276 |
|
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
277 |
from a and ih2[where t="t \<lhd> \<theta>1"] |
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
278 |
have "v \<in> vars_of (N \<lhd> \<theta>1) \<union> vars_of (N' \<lhd> \<theta>1) |
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
279 |
\<or> v \<in> vars_of (t \<lhd> \<theta>1)" unfolding \<sigma> |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30909
diff
changeset
|
280 |
by auto |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
281 |
hence "v \<in> vars_of t" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
282 |
proof |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
283 |
assume "v \<in> vars_of (N \<lhd> \<theta>1) \<union> vars_of (N' \<lhd> \<theta>1)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30909
diff
changeset
|
284 |
with True show ?thesis by (auto dest:l) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
285 |
next |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
286 |
assume "v \<in> vars_of (t \<lhd> \<theta>1)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30909
diff
changeset
|
287 |
thus ?thesis by (rule l) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
288 |
qed |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
289 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
290 |
thus ?thesis by auto |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
291 |
qed auto |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
292 |
qed |
62390 | 293 |
qed (auto split: if_split_asm) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
294 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
295 |
|
61343 | 296 |
text \<open>The result of a unification is either the identity |
297 |
substitution or it eliminates a variable from one of the terms:\<close> |
|
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
298 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
299 |
lemma unify_eliminates: |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
300 |
assumes "unify_dom (M, N)" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
301 |
assumes "unify M N = Some \<sigma>" |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
302 |
shows "(\<exists>v\<in>vars_of M \<union> vars_of N. elim \<sigma> v) \<or> \<sigma> \<doteq> []" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
303 |
(is "?P M N \<sigma>") |
24444
448978b61556
induct: proper separation of initial and terminal step;
wenzelm
parents:
23777
diff
changeset
|
304 |
using assms |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
305 |
proof (induct M N arbitrary:\<sigma>) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
306 |
case 1 thus ?case by simp |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
307 |
next |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
308 |
case 2 thus ?case by simp |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
309 |
next |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
310 |
case (3 c v) |
44369 | 311 |
have no_occs: "\<not> Var v \<prec> Const c" by simp |
24444
448978b61556
induct: proper separation of initial and terminal step;
wenzelm
parents:
23777
diff
changeset
|
312 |
with 3 have "\<sigma> = [(v, Const c)]" by simp |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
313 |
with occs_elim[OF no_occs] |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
314 |
show ?case by auto |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
315 |
next |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
316 |
case (4 M N v) |
44369 | 317 |
hence no_occs: "\<not> Var v \<prec> M \<cdot> N" by auto |
24444
448978b61556
induct: proper separation of initial and terminal step;
wenzelm
parents:
23777
diff
changeset
|
318 |
with 4 have "\<sigma> = [(v, M\<cdot>N)]" by simp |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
319 |
with occs_elim[OF no_occs] |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
320 |
show ?case by auto |
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 (5 v M) |
44369 | 323 |
hence no_occs: "\<not> Var v \<prec> M" by auto |
24444
448978b61556
induct: proper separation of initial and terminal step;
wenzelm
parents:
23777
diff
changeset
|
324 |
with 5 have "\<sigma> = [(v, M)]" by simp |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
325 |
with occs_elim[OF no_occs] |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
326 |
show ?case by auto |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
327 |
next |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
328 |
case (6 c d) thus ?case |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
329 |
by (cases "c = d") auto |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
330 |
next |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
331 |
case (7 M N M' N' \<sigma>) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
332 |
then obtain \<theta>1 \<theta>2 |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
333 |
where "unify M M' = Some \<theta>1" |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
334 |
and "unify (N \<lhd> \<theta>1) (N' \<lhd> \<theta>1) = Some \<theta>2" |
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
335 |
and \<sigma>: "\<sigma> = \<theta>1 \<lozenge> \<theta>2" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
336 |
and ih1: "?P M M' \<theta>1" |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
337 |
and ih2: "?P (N\<lhd>\<theta>1) (N'\<lhd>\<theta>1) \<theta>2" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
338 |
by (auto split:option.split_asm) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
339 |
|
61343 | 340 |
from \<open>unify_dom (M \<cdot> N, M' \<cdot> N')\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
341 |
have "unify_dom (M, M')" |
23777 | 342 |
by (rule accp_downward) (rule unify_rel.intros) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
343 |
hence no_new_vars: |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
344 |
"\<And>t. vars_of (t \<lhd> \<theta>1) \<subseteq> vars_of M \<union> vars_of M' \<union> vars_of t" |
61343 | 345 |
by (rule unify_vars) (rule \<open>unify M M' = Some \<theta>1\<close>) |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
346 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
347 |
from ih2 show ?case |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
348 |
proof |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
349 |
assume "\<exists>v\<in>vars_of (N \<lhd> \<theta>1) \<union> vars_of (N' \<lhd> \<theta>1). elim \<theta>2 v" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
350 |
then obtain v |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
351 |
where "v\<in>vars_of (N \<lhd> \<theta>1) \<union> vars_of (N' \<lhd> \<theta>1)" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
352 |
and el: "elim \<theta>2 v" by auto |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
353 |
with no_new_vars show ?thesis unfolding \<sigma> |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
354 |
by (auto simp:elim_def) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
355 |
next |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
356 |
assume empty[simp]: "\<theta>2 \<doteq> []" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
357 |
|
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
358 |
have "\<sigma> \<doteq> (\<theta>1 \<lozenge> [])" unfolding \<sigma> |
44368 | 359 |
by (rule subst_cong) auto |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
360 |
also have "\<dots> \<doteq> \<theta>1" by auto |
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
361 |
finally have "\<sigma> \<doteq> \<theta>1" . |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
362 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
363 |
from ih1 show ?thesis |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
364 |
proof |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
365 |
assume "\<exists>v\<in>vars_of M \<union> vars_of M'. elim \<theta>1 v" |
61343 | 366 |
with elim_eq[OF \<open>\<sigma> \<doteq> \<theta>1\<close>] |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
367 |
show ?thesis by auto |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
368 |
next |
61343 | 369 |
note \<open>\<sigma> \<doteq> \<theta>1\<close> |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
370 |
also assume "\<theta>1 \<doteq> []" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
371 |
finally show ?thesis .. |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
372 |
qed |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
373 |
qed |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
374 |
qed |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
375 |
|
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
376 |
declare unify.psimps[simp del] |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
377 |
|
61343 | 378 |
subsection \<open>Termination proof\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
379 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
380 |
termination unify |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
381 |
proof |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
382 |
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
|
383 |
\<lambda>(M, N). size M]" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
384 |
show "wf ?R" by simp |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
385 |
|
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
386 |
fix M N M' N' :: "'a trm" |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
62390
diff
changeset
|
387 |
show "((M, M'), (M \<cdot> N, M' \<cdot> N')) \<in> ?R" \<comment> \<open>Inner call\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
388 |
by (rule measures_lesseq) (auto intro: card_mono) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
389 |
|
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
62390
diff
changeset
|
390 |
fix \<theta> \<comment> \<open>Outer call\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
391 |
assume inner: "unify_dom (M, M')" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
392 |
"unify M M' = Some \<theta>" |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
393 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
394 |
from unify_eliminates[OF inner] |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
395 |
show "((N \<lhd> \<theta>, N' \<lhd> \<theta>), (M \<cdot> N, M' \<cdot> N')) \<in>?R" |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
396 |
proof |
61933 | 397 |
\<comment> \<open>Either a variable is eliminated \ldots\<close> |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
398 |
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
|
399 |
then obtain v |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30909
diff
changeset
|
400 |
where "elim \<theta> v" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30909
diff
changeset
|
401 |
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
|
402 |
with unify_vars[OF inner] |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
403 |
have "vars_of (N\<lhd>\<theta>) \<union> vars_of (N'\<lhd>\<theta>) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
30909
diff
changeset
|
404 |
\<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
|
405 |
by auto |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
406 |
|
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
407 |
thus ?thesis |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
408 |
by (auto intro!: measures_less intro: psubset_card_mono) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
409 |
next |
61933 | 410 |
\<comment> \<open>Or the substitution is empty\<close> |
44367
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
411 |
assume "\<theta> \<doteq> []" |
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
412 |
hence "N \<lhd> \<theta> = N" |
74c08021ab2e
changed constant names and notation to match HOL/Subst/*.thy, from which this theory is a clone.
krauss
parents:
42463
diff
changeset
|
413 |
and "N' \<lhd> \<theta> = N'" by auto |
22999
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
414 |
thus ?thesis |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
415 |
by (auto intro!: measures_less intro: psubset_card_mono) |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
416 |
qed |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
417 |
qed |
c1ce129e6f9c
Added unification case study (using new function package)
krauss
parents:
diff
changeset
|
418 |
|
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
419 |
|
61343 | 420 |
subsection \<open>Unification returns a Most General Unifier\<close> |
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
421 |
|
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
422 |
lemma unify_computes_MGU: |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
423 |
"unify M N = Some \<sigma> \<Longrightarrow> MGU \<sigma> M N" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
424 |
proof (induct M N arbitrary: \<sigma> rule: unify.induct) |
67443
3abf6a722518
standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents:
62390
diff
changeset
|
425 |
case (7 M N M' N' \<sigma>) \<comment> \<open>The interesting case\<close> |
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
426 |
|
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
427 |
then obtain \<theta>1 \<theta>2 |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
428 |
where "unify M M' = Some \<theta>1" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
429 |
and "unify (N \<lhd> \<theta>1) (N' \<lhd> \<theta>1) = Some \<theta>2" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
430 |
and \<sigma>: "\<sigma> = \<theta>1 \<lozenge> \<theta>2" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
431 |
and MGU_inner: "MGU \<theta>1 M M'" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
432 |
and MGU_outer: "MGU \<theta>2 (N \<lhd> \<theta>1) (N' \<lhd> \<theta>1)" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
433 |
by (auto split:option.split_asm) |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
434 |
|
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
435 |
show ?case |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
436 |
proof |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
437 |
from MGU_inner and MGU_outer |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
438 |
have "M \<lhd> \<theta>1 = M' \<lhd> \<theta>1" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
439 |
and "N \<lhd> \<theta>1 \<lhd> \<theta>2 = N' \<lhd> \<theta>1 \<lhd> \<theta>2" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
440 |
unfolding MGU_def Unifier_def |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
441 |
by auto |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
442 |
thus "M \<cdot> N \<lhd> \<sigma> = M' \<cdot> N' \<lhd> \<sigma>" unfolding \<sigma> |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
443 |
by simp |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
444 |
next |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
445 |
fix \<sigma>' assume "M \<cdot> N \<lhd> \<sigma>' = M' \<cdot> N' \<lhd> \<sigma>'" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
446 |
hence "M \<lhd> \<sigma>' = M' \<lhd> \<sigma>'" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
447 |
and Ns: "N \<lhd> \<sigma>' = N' \<lhd> \<sigma>'" by auto |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
448 |
|
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
449 |
with MGU_inner obtain \<delta> |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
450 |
where eqv: "\<sigma>' \<doteq> \<theta>1 \<lozenge> \<delta>" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
451 |
unfolding MGU_def Unifier_def |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
452 |
by auto |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
453 |
|
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
454 |
from Ns have "N \<lhd> \<theta>1 \<lhd> \<delta> = N' \<lhd> \<theta>1 \<lhd> \<delta>" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
455 |
by (simp add:subst_eq_dest[OF eqv]) |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
456 |
|
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
457 |
with MGU_outer obtain \<rho> |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
458 |
where eqv2: "\<delta> \<doteq> \<theta>2 \<lozenge> \<rho>" |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
459 |
unfolding MGU_def Unifier_def |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
460 |
by auto |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
461 |
|
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
462 |
have "\<sigma>' \<doteq> \<sigma> \<lozenge> \<rho>" unfolding \<sigma> |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
463 |
by (rule subst_eq_intro, auto simp:subst_eq_dest[OF eqv] subst_eq_dest[OF eqv2]) |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
464 |
thus "\<exists>\<gamma>. \<sigma>' \<doteq> \<sigma> \<lozenge> \<gamma>" .. |
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
465 |
qed |
62390 | 466 |
qed (auto simp: MGU_Const intro: MGU_Var MGU_Var[symmetric] split: if_split_asm) |
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
467 |
|
44372 | 468 |
|
61343 | 469 |
subsection \<open>Unification returns Idempotent Substitution\<close> |
44372 | 470 |
|
471 |
definition Idem :: "'a subst \<Rightarrow> bool" |
|
472 |
where "Idem s \<longleftrightarrow> (s \<lozenge> s) \<doteq> s" |
|
473 |
||
44371
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
474 |
lemma Idem_Nil [iff]: "Idem []" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
475 |
by (simp add: Idem_def) |
44370
03d91bfad83b
tuned proofs, sledgehammering overly verbose parts
krauss
parents:
44369
diff
changeset
|
476 |
|
44371
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
477 |
lemma Var_Idem: |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
478 |
assumes "~ (Var v \<prec> t)" shows "Idem [(v,t)]" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
479 |
unfolding Idem_def |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
480 |
proof |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
481 |
from assms have [simp]: "t \<lhd> [(v, t)] = t" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
482 |
by (metis assoc.simps(2) subst.simps(1) subst_no_occs) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
483 |
|
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
484 |
fix s show "s \<lhd> [(v, t)] \<lozenge> [(v, t)] = s \<lhd> [(v, t)]" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
485 |
by (induct s) auto |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
486 |
qed |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
487 |
|
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
488 |
lemma Unifier_Idem_subst: |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
489 |
"Idem(r) \<Longrightarrow> Unifier s (t \<lhd> r) (u \<lhd> r) \<Longrightarrow> |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
490 |
Unifier (r \<lozenge> s) (t \<lhd> r) (u \<lhd> r)" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
491 |
by (simp add: Idem_def Unifier_def subst_eq_def) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
492 |
|
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
493 |
lemma Idem_comp: |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
494 |
"Idem r \<Longrightarrow> Unifier s (t \<lhd> r) (u \<lhd> r) \<Longrightarrow> |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
495 |
(!!q. Unifier q (t \<lhd> r) (u \<lhd> r) \<Longrightarrow> s \<lozenge> q \<doteq> q) \<Longrightarrow> |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
496 |
Idem (r \<lozenge> s)" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
497 |
apply (frule Unifier_Idem_subst, blast) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
498 |
apply (force simp add: Idem_def subst_eq_def) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
499 |
done |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
500 |
|
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
501 |
theorem unify_gives_Idem: |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
502 |
"unify M N = Some \<sigma> \<Longrightarrow> Idem \<sigma>" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
503 |
proof (induct M N arbitrary: \<sigma> rule: unify.induct) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
504 |
case (7 M M' N N' \<sigma>) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
505 |
|
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
506 |
then obtain \<theta>1 \<theta>2 |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
507 |
where "unify M N = Some \<theta>1" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
508 |
and \<theta>2: "unify (M' \<lhd> \<theta>1) (N' \<lhd> \<theta>1) = Some \<theta>2" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
509 |
and \<sigma>: "\<sigma> = \<theta>1 \<lozenge> \<theta>2" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
510 |
and "Idem \<theta>1" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
511 |
and "Idem \<theta>2" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
512 |
by (auto split: option.split_asm) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
513 |
|
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
514 |
from \<theta>2 have "Unifier \<theta>2 (M' \<lhd> \<theta>1) (N' \<lhd> \<theta>1)" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
515 |
by (rule unify_computes_MGU[THEN MGU_is_Unifier]) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
516 |
|
61343 | 517 |
with \<open>Idem \<theta>1\<close> |
44371
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
518 |
show "Idem \<sigma>" unfolding \<sigma> |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
519 |
proof (rule Idem_comp) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
520 |
fix \<sigma> assume "Unifier \<sigma> (M' \<lhd> \<theta>1) (N' \<lhd> \<theta>1)" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
521 |
with \<theta>2 obtain \<gamma> where \<sigma>: "\<sigma> \<doteq> \<theta>2 \<lozenge> \<gamma>" |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
522 |
using unify_computes_MGU MGU_def by blast |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
523 |
|
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
524 |
have "\<theta>2 \<lozenge> \<sigma> \<doteq> \<theta>2 \<lozenge> (\<theta>2 \<lozenge> \<gamma>)" by (rule subst_cong) (auto simp: \<sigma>) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
525 |
also have "... \<doteq> (\<theta>2 \<lozenge> \<theta>2) \<lozenge> \<gamma>" by (rule comp_assoc[symmetric]) |
61343 | 526 |
also have "... \<doteq> \<theta>2 \<lozenge> \<gamma>" by (rule subst_cong) (auto simp: \<open>Idem \<theta>2\<close>[unfolded Idem_def]) |
44371
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
527 |
also have "... \<doteq> \<sigma>" by (rule \<sigma>[symmetric]) |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
528 |
finally show "\<theta>2 \<lozenge> \<sigma> \<doteq> \<sigma>" . |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
529 |
qed |
3a10392fb8c3
added proof of idempotence, roughly after HOL/Subst/Unify.thy
krauss
parents:
44370
diff
changeset
|
530 |
qed (auto intro!: Var_Idem split: option.splits if_splits) |
39754 | 531 |
|
75635
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
532 |
|
75637
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
533 |
subsection \<open>Unification Returns Substitution With Minimal Range \<close> |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
534 |
|
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
535 |
definition range_vars where |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
536 |
"range_vars \<sigma> = \<Union> {vars_of (Var x \<lhd> \<sigma>) |x. Var x \<lhd> \<sigma> \<noteq> Var x}" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
537 |
|
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
538 |
lemma vars_of_subst_subset: "vars_of (N \<lhd> \<sigma>) \<subseteq> vars_of N \<union> range_vars \<sigma>" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
539 |
proof (rule subsetI) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
540 |
fix x assume "x \<in> vars_of (N \<lhd> \<sigma>)" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
541 |
thus "x \<in> vars_of N \<union> range_vars \<sigma>" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
542 |
proof (induction N) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
543 |
case (Var y) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
544 |
then show ?case |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
545 |
unfolding range_vars_def vars_of.simps |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
546 |
by force |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
547 |
next |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
548 |
case (Const y) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
549 |
then show ?case by simp |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
550 |
next |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
551 |
case (Comb N1 N2) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
552 |
then show ?case |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
553 |
by auto |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
554 |
qed |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
555 |
qed |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
556 |
|
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
557 |
lemma range_vars_comp_subset: "range_vars (\<sigma>\<^sub>1 \<lozenge> \<sigma>\<^sub>2) \<subseteq> range_vars \<sigma>\<^sub>1 \<union> range_vars \<sigma>\<^sub>2" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
558 |
proof (rule subsetI) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
559 |
fix x assume "x \<in> range_vars (\<sigma>\<^sub>1 \<lozenge> \<sigma>\<^sub>2)" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
560 |
then obtain x' where |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
561 |
x'_\<sigma>\<^sub>1_\<sigma>\<^sub>2: "Var x' \<lhd> \<sigma>\<^sub>1 \<lhd> \<sigma>\<^sub>2 \<noteq> Var x'" and x_in: "x \<in> vars_of (Var x' \<lhd> \<sigma>\<^sub>1 \<lhd> \<sigma>\<^sub>2)" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
562 |
unfolding range_vars_def by auto |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
563 |
|
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
564 |
show "x \<in> range_vars \<sigma>\<^sub>1 \<union> range_vars \<sigma>\<^sub>2" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
565 |
proof (cases "Var x' \<lhd> \<sigma>\<^sub>1 = Var x'") |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
566 |
case True |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
567 |
with x'_\<sigma>\<^sub>1_\<sigma>\<^sub>2 x_in show ?thesis |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
568 |
unfolding range_vars_def by auto |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
569 |
next |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
570 |
case x'_\<sigma>\<^sub>1_neq: False |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
571 |
show ?thesis |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
572 |
proof (cases "Var x' \<lhd> \<sigma>\<^sub>1 \<lhd> \<sigma>\<^sub>2 = Var x' \<lhd> \<sigma>\<^sub>1") |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
573 |
case True |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
574 |
with x'_\<sigma>\<^sub>1_\<sigma>\<^sub>2 x_in x'_\<sigma>\<^sub>1_neq show ?thesis |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
575 |
unfolding range_vars_def by auto |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
576 |
next |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
577 |
case False |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
578 |
with x_in obtain y where "y \<in> vars_of (Var x' \<lhd> \<sigma>\<^sub>1)" and "x \<in> vars_of (Var y \<lhd> \<sigma>\<^sub>2)" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
579 |
by (smt (verit, best) UN_iff image_iff vars_of_subst_conv_Union) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
580 |
with x'_\<sigma>\<^sub>1_neq show ?thesis |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
581 |
unfolding range_vars_def by force |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
582 |
qed |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
583 |
qed |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
584 |
qed |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
585 |
|
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
586 |
theorem unify_gives_minimal_range: |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
587 |
"unify M N = Some \<sigma> \<Longrightarrow> range_vars \<sigma> \<subseteq> vars_of M \<union> vars_of N" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
588 |
proof (induct M N arbitrary: \<sigma> rule: unify.induct) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
589 |
case (1 c M N) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
590 |
thus ?case by simp |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
591 |
next |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
592 |
case (2 M N c) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
593 |
thus ?case by simp |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
594 |
next |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
595 |
case (3 c v) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
596 |
hence "\<sigma> = [(v, Const c)]" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
597 |
by simp |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
598 |
thus ?case |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
599 |
by (simp add: range_vars_def) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
600 |
next |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
601 |
case (4 M N v) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
602 |
hence "\<sigma> = [(v, M \<cdot> N)]" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
603 |
by (metis option.discI option.sel unify.simps(4)) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
604 |
thus ?case |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
605 |
by (auto simp: range_vars_def) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
606 |
next |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
607 |
case (5 v M) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
608 |
hence "\<sigma> = [(v, M)]" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
609 |
by (metis option.discI option.inject unify.simps(5)) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
610 |
thus ?case |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
611 |
by (auto simp: range_vars_def) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
612 |
next |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
613 |
case (6 c d) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
614 |
hence "\<sigma> = []" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
615 |
by (metis option.distinct(1) option.sel unify.simps(6)) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
616 |
thus ?case |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
617 |
by (simp add: range_vars_def) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
618 |
next |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
619 |
case (7 M N M' N') |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
620 |
from "7.prems" obtain \<theta>\<^sub>1 \<theta>\<^sub>2 where |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
621 |
"unify M M' = Some \<theta>\<^sub>1" and "unify (N \<lhd> \<theta>\<^sub>1) (N' \<lhd> \<theta>\<^sub>1) = Some \<theta>\<^sub>2" and "\<sigma> = \<theta>\<^sub>1 \<lozenge> \<theta>\<^sub>2" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
622 |
apply simp |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
623 |
by (metis (no_types, lifting) option.case_eq_if option.collapse option.discI option.sel) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
624 |
|
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
625 |
from "7.hyps"(1) have range_\<theta>\<^sub>1: "range_vars \<theta>\<^sub>1 \<subseteq> vars_of M \<union> vars_of M'" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
626 |
using \<open>unify M M' = Some \<theta>\<^sub>1\<close> by simp |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
627 |
|
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
628 |
from "7.hyps"(2) have "range_vars \<theta>\<^sub>2 \<subseteq> vars_of (N \<lhd> \<theta>\<^sub>1) \<union> vars_of (N' \<lhd> \<theta>\<^sub>1)" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
629 |
using \<open>unify M M' = Some \<theta>\<^sub>1\<close> \<open>unify (N \<lhd> \<theta>\<^sub>1) (N' \<lhd> \<theta>\<^sub>1) = Some \<theta>\<^sub>2\<close> by simp |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
630 |
hence range_\<theta>\<^sub>2: "range_vars \<theta>\<^sub>2 \<subseteq> vars_of N \<union> vars_of N' \<union> range_vars \<theta>\<^sub>1" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
631 |
using vars_of_subst_subset[of _ \<theta>\<^sub>1] by auto |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
632 |
|
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
633 |
have "range_vars \<sigma> = range_vars (\<theta>\<^sub>1 \<lozenge> \<theta>\<^sub>2)" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
634 |
unfolding \<open>\<sigma> = \<theta>\<^sub>1 \<lozenge> \<theta>\<^sub>2\<close> by simp |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
635 |
also have "... \<subseteq> range_vars \<theta>\<^sub>1 \<union> range_vars \<theta>\<^sub>2" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
636 |
by (rule range_vars_comp_subset) |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
637 |
also have "... \<subseteq> range_vars \<theta>\<^sub>1 \<union> vars_of N \<union> vars_of N'" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
638 |
using range_\<theta>\<^sub>2 by auto |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
639 |
also have "... \<subseteq> vars_of M \<union> vars_of M' \<union> vars_of N \<union> vars_of N'" |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
640 |
using range_\<theta>\<^sub>1 by auto |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
641 |
finally show ?case |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
642 |
by auto |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
643 |
qed |
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
644 |
|
75638
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
645 |
theorem unify_gives_minimal_domain: |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
646 |
"unify M N = Some \<sigma> \<Longrightarrow> fst ` set \<sigma> \<subseteq> vars_of M \<union> vars_of N" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
647 |
proof (induct M N arbitrary: \<sigma> rule: unify.induct) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
648 |
case (1 c M N) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
649 |
thus ?case |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
650 |
by simp |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
651 |
next |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
652 |
case (2 M N c) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
653 |
thus ?case |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
654 |
by simp |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
655 |
next |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
656 |
case (3 c v) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
657 |
hence "\<sigma> = [(v, Const c)]" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
658 |
by simp |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
659 |
thus ?case |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
660 |
by (simp add: dom_def) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
661 |
next |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
662 |
case (4 M N v) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
663 |
hence "\<sigma> = [(v, M \<cdot> N)]" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
664 |
by (metis option.distinct(1) option.inject unify.simps(4)) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
665 |
thus ?case |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
666 |
by (simp add: dom_def) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
667 |
next |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
668 |
case (5 v M) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
669 |
hence "\<sigma> = [(v, M)]" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
670 |
by (metis option.distinct(1) option.inject unify.simps(5)) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
671 |
thus ?case |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
672 |
by (simp add: dom_def) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
673 |
next |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
674 |
case (6 c d) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
675 |
then show ?case |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
676 |
by (cases "c = d") simp_all |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
677 |
next |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
678 |
case (7 M N M' N') |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
679 |
from "7.prems" obtain \<theta>\<^sub>1 \<theta>\<^sub>2 where |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
680 |
"unify M M' = Some \<theta>\<^sub>1" and "unify (N \<lhd> \<theta>\<^sub>1) (N' \<lhd> \<theta>\<^sub>1) = Some \<theta>\<^sub>2" and "\<sigma> = \<theta>\<^sub>1 \<lozenge> \<theta>\<^sub>2" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
681 |
apply simp |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
682 |
by (metis (no_types, lifting) option.case_eq_if option.collapse option.discI option.sel) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
683 |
|
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
684 |
from "7.hyps"(1) have dom_\<theta>\<^sub>1: "fst ` set \<theta>\<^sub>1 \<subseteq> vars_of M \<union> vars_of M'" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
685 |
using \<open>unify M M' = Some \<theta>\<^sub>1\<close> by simp |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
686 |
|
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
687 |
from "7.hyps"(2) have "fst ` set \<theta>\<^sub>2 \<subseteq> vars_of (N \<lhd> \<theta>\<^sub>1) \<union> vars_of (N' \<lhd> \<theta>\<^sub>1)" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
688 |
using \<open>unify M M' = Some \<theta>\<^sub>1\<close> \<open>unify (N \<lhd> \<theta>\<^sub>1) (N' \<lhd> \<theta>\<^sub>1) = Some \<theta>\<^sub>2\<close> by simp |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
689 |
hence dom_\<theta>\<^sub>2': "fst ` set \<theta>\<^sub>2 \<subseteq> vars_of N \<union> vars_of N' \<union> range_vars \<theta>\<^sub>1" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
690 |
using vars_of_subst_subset[of _ \<theta>\<^sub>1] by auto |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
691 |
|
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
692 |
have "fst ` set \<sigma> = fst ` set (\<theta>\<^sub>1 \<lozenge> \<theta>\<^sub>2)" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
693 |
unfolding \<open>\<sigma> = \<theta>\<^sub>1 \<lozenge> \<theta>\<^sub>2\<close> by simp |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
694 |
also have "... = fst ` set \<theta>\<^sub>1 \<union> fst ` set \<theta>\<^sub>2" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
695 |
by (auto simp: domain_comp) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
696 |
also have "... \<subseteq> vars_of M \<union> vars_of M' \<union> fst ` set \<theta>\<^sub>2" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
697 |
using dom_\<theta>\<^sub>1 by (auto simp: dom_map_of_conv_image_fst) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
698 |
also have "... \<subseteq> vars_of M \<union> vars_of M' \<union> vars_of N \<union> vars_of N' \<union> range_vars \<theta>\<^sub>1" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
699 |
using dom_\<theta>\<^sub>2' by (auto simp: dom_map_of_conv_image_fst) |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
700 |
also have "... \<subseteq> vars_of M \<union> vars_of M' \<union> vars_of N \<union> vars_of N'" |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
701 |
using unify_gives_minimal_range[OF \<open>unify M M' = Some \<theta>\<^sub>1\<close>] by auto |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
702 |
finally show ?case |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
703 |
by auto |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
704 |
qed |
aaa22adef039
added lemmas domain_comp and unify_gives_minimal_domain
desharna
parents:
75637
diff
changeset
|
705 |
|
75637
66a9aa769d63
added definition range_vars and lemmas vars_of_subst_conv_Union, vars_of_subst_subset, range_vars_comp_subset, and unify_gives_minimal_range
desharna
parents:
75635
diff
changeset
|
706 |
|
75635
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
707 |
subsection \<open>Idempotent Most General Unifier\<close> |
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
708 |
|
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
709 |
definition IMGU :: "'a subst \<Rightarrow> 'a trm \<Rightarrow> 'a trm \<Rightarrow> bool" where |
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
710 |
"IMGU \<mu> t u \<longleftrightarrow> Unifier \<mu> t u \<and> (\<forall>\<theta>. Unifier \<theta> t u \<longrightarrow> \<theta> \<doteq> \<mu> \<lozenge> \<theta>)" |
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
711 |
|
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
712 |
lemma IMGU_iff_Idem_and_MGU: "IMGU \<mu> t u \<longleftrightarrow> Idem \<mu> \<and> MGU \<mu> t u" |
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
713 |
unfolding IMGU_def Idem_def MGU_def |
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
714 |
by (smt (verit, best) subst_comp subst_eq_def) |
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
715 |
|
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
716 |
lemma unify_computes_IMGU: |
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
717 |
"unify M N = Some \<sigma> \<Longrightarrow> IMGU \<sigma> M N" |
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
718 |
by (simp add: IMGU_iff_Idem_and_MGU unify_computes_MGU unify_gives_Idem) |
3ba38a119739
added definition IMGU and lemmas IMGU_iff_Idem_and_MGU and unify_computes_IMGU
desharna
parents:
67443
diff
changeset
|
719 |
|
23219 | 720 |
end |