author | nipkow |
Fri, 17 Oct 1997 15:25:12 +0200 | |
changeset 3919 | c036caebfc75 |
parent 3724 | f33e301a89f5 |
child 4089 | 96fba19bcbe2 |
permissions | -rw-r--r-- |
3268
012c43174664
Mostly cosmetic changes: updated headers, ID lines, etc.
paulson
parents:
3192
diff
changeset
|
1 |
(* Title: HOL/Subst/Unifier.ML |
1266 | 2 |
ID: $Id$ |
1465 | 3 |
Author: Martin Coen, Cambridge University Computer Laboratory |
968 | 4 |
Copyright 1993 University of Cambridge |
5 |
||
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
6 |
For Unifier.thy. |
968 | 7 |
Properties of unifiers. |
8 |
*) |
|
9 |
||
10 |
open Unifier; |
|
11 |
||
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
12 |
val unify_defs = [Unifier_def, MoreGeneral_def, MGUnifier_def]; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
13 |
|
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
14 |
(*--------------------------------------------------------------------------- |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
15 |
* Unifiers |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
16 |
*---------------------------------------------------------------------------*) |
968 | 17 |
|
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
18 |
goal Unifier.thy |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
19 |
"Unifier s (Comb t u) (Comb v w) = (Unifier s t v & Unifier s u w)"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
20 |
by (simp_tac (!simpset addsimps [Unifier_def]) 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
21 |
qed "Unifier_Comb"; |
968 | 22 |
|
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
23 |
AddIffs [Unifier_Comb]; |
968 | 24 |
|
25 |
goal Unifier.thy |
|
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
26 |
"!!v. [| v ~: vars_of t; v ~: vars_of u; Unifier s t u |] ==> \ |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
27 |
\ Unifier ((v,r)#s) t u"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
28 |
by (asm_full_simp_tac (!simpset addsimps [Unifier_def, repl_invariance]) 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
29 |
qed "Cons_Unifier"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
30 |
|
968 | 31 |
|
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
32 |
(*--------------------------------------------------------------------------- |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
33 |
* Most General Unifiers |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
34 |
*---------------------------------------------------------------------------*) |
968 | 35 |
|
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
36 |
goalw Unifier.thy unify_defs "MGUnifier s t u = MGUnifier s u t"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
37 |
by (blast_tac (!claset addIs [sym]) 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
38 |
qed "mgu_sym"; |
968 | 39 |
|
40 |
||
41 |
goal Unifier.thy "[] >> s"; |
|
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
42 |
by (simp_tac (!simpset addsimps [MoreGeneral_def]) 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
43 |
by (Blast_tac 1); |
968 | 44 |
qed "MoreGen_Nil"; |
45 |
||
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
46 |
AddIffs [MoreGen_Nil]; |
968 | 47 |
|
48 |
goalw Unifier.thy unify_defs |
|
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
49 |
"MGUnifier s t u = (ALL r. Unifier r t u = s >> r)"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
50 |
by (auto_tac (!claset addIs [ssubst_subst2, subst_comp_Nil], !simpset)); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
51 |
qed "MGU_iff"; |
2088 | 52 |
|
53 |
||
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
54 |
goal Unifier.thy |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
55 |
"!!v. ~ Var v <: t ==> MGUnifier [(v,t)] (Var v) t"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
56 |
by (simp_tac(!simpset addsimps [MGU_iff, Unifier_def, MoreGeneral_def] |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
57 |
delsimps [subst_Var]) 1); |
3724 | 58 |
by Safe_tac; |
3457 | 59 |
by (rtac exI 1); |
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
60 |
by (etac subst 1 THEN rtac (Cons_trivial RS subst_sym) 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
61 |
by (etac ssubst_subst2 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
62 |
by (asm_simp_tac (!simpset addsimps [Var_not_occs]) 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
63 |
qed "MGUnifier_Var"; |
968 | 64 |
|
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
65 |
AddSIs [MGUnifier_Var]; |
968 | 66 |
|
67 |
||
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
68 |
(*--------------------------------------------------------------------------- |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
69 |
* Idempotence. |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
70 |
*---------------------------------------------------------------------------*) |
968 | 71 |
|
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
72 |
goalw Unifier.thy [Idem_def] "Idem([])"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
73 |
by (Simp_tac 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
74 |
qed "Idem_Nil"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
75 |
|
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
76 |
AddIffs [Idem_Nil]; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
77 |
|
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
78 |
goalw Unifier.thy [Idem_def] "Idem(s) = (sdom(s) Int srange(s) = {})"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
79 |
by (simp_tac (!simpset addsimps [subst_eq_iff, invariance, |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
80 |
dom_range_disjoint]) 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
81 |
qed "Idem_iff"; |
968 | 82 |
|
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
83 |
goal Unifier.thy "~ (Var(v) <: t) --> Idem([(v,t)])"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
84 |
by (simp_tac (!simpset addsimps [vars_iff_occseq, Idem_iff, srange_iff, |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
85 |
empty_iff_all_not] |
3919 | 86 |
addsplits [expand_if]) 1); |
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
87 |
by (Blast_tac 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
88 |
qed_spec_mp "Var_Idem"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
89 |
|
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
90 |
AddSIs [Var_Idem]; |
968 | 91 |
|
3192
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
92 |
goalw Unifier.thy [Idem_def] |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
93 |
"!!r. [| Idem(r); Unifier s (t<|r) (u<|r) |] \ |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
94 |
\ ==> Unifier (r <> s) (t <| r) (u <| r)"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
95 |
by (asm_full_simp_tac (!simpset addsimps [Unifier_def, comp_subst_subst]) 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
96 |
qed "Unifier_Idem_subst"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
97 |
|
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
98 |
val [idemr,unifier,minor] = goal Unifier.thy |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
99 |
"[| Idem(r); Unifier s (t <| r) (u <| r); \ |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
100 |
\ !!q. Unifier q (t <| r) (u <| r) ==> s <> q =$= q \ |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
101 |
\ |] ==> Idem(r <> s)"; |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
102 |
by (cut_facts_tac [idemr, |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
103 |
unifier RS (idemr RS Unifier_Idem_subst RS minor)] 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
104 |
by (asm_full_simp_tac (!simpset addsimps [Idem_def, subst_eq_iff]) 1); |
a75558a4ed37
New version, modified by Konrad Slind and LCP for TFL
paulson
parents:
2088
diff
changeset
|
105 |
qed "Idem_comp"; |