author | lcp |
Mon, 15 Nov 1993 14:41:25 +0100 | |
changeset 120 | 09287f26bfb8 |
parent 95 | 2246a80b1cb5 |
child 173 | 85071e6ad295 |
permissions | -rw-r--r-- |
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
1 |
(* Title: ZF/ex/llist_eq.ML |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
2 |
ID: $Id$ |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
4 |
Copyright 1993 University of Cambridge |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
5 |
|
120 | 6 |
Equality for llist(A) as a greatest fixed point |
7 |
***) |
|
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
8 |
|
120 | 9 |
(*Previously used <*> in the domain and variant pairs as elements. But |
10 |
standard pairs work just as well. To use variant pairs, must change prefix |
|
11 |
a q/Q to the Sigma, Pair and converse rules.*) |
|
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
12 |
|
120 | 13 |
structure LList_Eq = CoInductive_Fun |
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
14 |
(val thy = LList.thy addconsts [(["lleq"],"i=>i")]; |
120 | 15 |
val rec_doms = [("lleq", "llist(A) * llist(A)")]; |
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
16 |
val sintrs = |
120 | 17 |
["<LNil, LNil> : lleq(A)", |
18 |
"[| a:A; <l, l'>: lleq(A) |] ==> <LCons(a,l), LCons(a,l')> : lleq(A)"]; |
|
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
19 |
val monos = []; |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
20 |
val con_defs = []; |
120 | 21 |
val type_intrs = LList.intrs@[SigmaI]; |
22 |
val type_elims = [SigmaE2]); |
|
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
23 |
|
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
24 |
(** Alternatives for above: |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
25 |
val con_defs = LList.con_defs |
120 | 26 |
val type_intrs = codatatype_intrs |
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
27 |
val type_elims = [quniv_QPair_E] |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
28 |
**) |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
29 |
|
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
30 |
val lleq_cs = subset_cs |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
31 |
addSIs [succI1, Int_Vset_0_subset, |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
32 |
QPair_Int_Vset_succ_subset_trans, |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
33 |
QPair_Int_Vset_subset_trans]; |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
34 |
|
95 | 35 |
(** Some key feature of this proof needs to be made a general theorem! **) |
36 |
||
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
37 |
(*Keep unfolding the lazy list until the induction hypothesis applies*) |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
38 |
goal LList_Eq.thy |
120 | 39 |
"!!i. Ord(i) ==> ALL l l'. <l,l'> : lleq(A) --> l Int Vset(i) <= l'"; |
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
40 |
by (etac trans_induct 1); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
41 |
by (safe_tac subset_cs); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
42 |
by (etac LList_Eq.elim 1); |
120 | 43 |
by (safe_tac (subset_cs addSEs [Pair_inject])); |
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
44 |
by (rewrite_goals_tac LList.con_defs); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
45 |
by (etac Ord_cases 1 THEN REPEAT_FIRST hyp_subst_tac); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
46 |
(*0 case*) |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
47 |
by (fast_tac lleq_cs 1); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
48 |
(*succ(j) case*) |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
49 |
by (rewtac QInr_def); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
50 |
by (fast_tac lleq_cs 1); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
51 |
(*Limit(i) case*) |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
52 |
by (etac (Limit_Vfrom_eq RS ssubst) 1); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
53 |
by (rtac (Int_UN_distrib RS ssubst) 1); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
54 |
by (fast_tac lleq_cs 1); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
55 |
val lleq_Int_Vset_subset_lemma = result(); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
56 |
|
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
57 |
val lleq_Int_Vset_subset = standard |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
58 |
(lleq_Int_Vset_subset_lemma RS spec RS spec RS mp); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
59 |
|
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
60 |
|
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
61 |
(*lleq(A) is a symmetric relation because qconverse(lleq(A)) is a fixedpoint*) |
120 | 62 |
val [prem] = goal LList_Eq.thy "<l,l'> : lleq(A) ==> <l',l> : lleq(A)"; |
63 |
by (rtac (prem RS converseI RS LList_Eq.coinduct) 1); |
|
64 |
by (rtac (LList_Eq.dom_subset RS converse_type) 1); |
|
65 |
by (safe_tac converse_cs); |
|
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
66 |
by (etac LList_Eq.elim 1); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
67 |
by (ALLGOALS (fast_tac qconverse_cs)); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
68 |
val lleq_symmetric = result(); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
69 |
|
120 | 70 |
goal LList_Eq.thy "!!l l'. <l,l'> : lleq(A) ==> l=l'"; |
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
71 |
by (rtac equalityI 1); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
72 |
by (REPEAT (ares_tac [lleq_Int_Vset_subset RS Int_Vset_subset] 1 |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
73 |
ORELSE etac lleq_symmetric 1)); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
74 |
val lleq_implies_equal = result(); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
75 |
|
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
76 |
val [eqprem,lprem] = goal LList_Eq.thy |
120 | 77 |
"[| l=l'; l: llist(A) |] ==> <l,l'> : lleq(A)"; |
78 |
by (res_inst_tac [("X", "{<l,l>. l: llist(A)}")] LList_Eq.coinduct 1); |
|
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
79 |
by (rtac (lprem RS RepFunI RS (eqprem RS subst)) 1); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
80 |
by (safe_tac qpair_cs); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
81 |
by (etac LList.elim 1); |
120 | 82 |
by (ALLGOALS (fast_tac pair_cs)); |
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
83 |
val equal_llist_implies_leq = result(); |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
diff
changeset
|
84 |