src/HOL/ex/SList.ML
author clasohm
Wed, 04 Oct 1995 13:12:14 +0100
changeset 1266 3ae9fe3c0f68
parent 972 e61b058d58d2
child 1465 5d7a7e439cec
permissions -rw-r--r--
added local simpsets
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     1
(*  Title: 	HOL/ex/SList.ML
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     5
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     6
Definition of type 'a list by a least fixed point
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     7
*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     8
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
     9
open SList;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    10
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    11
val list_con_defs = [NIL_def, CONS_def];
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    12
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    13
goal SList.thy "list(A) = {Numb(0)} <+> (A <*> list(A))";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    14
let val rew = rewrite_rule list_con_defs in  
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    15
by (fast_tac (univ_cs addSIs (equalityI :: map rew list.intrs)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    16
                      addEs [rew list.elim]) 1)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    17
end;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    18
qed "list_unfold";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    19
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    20
(*This justifies using list in other recursive type definitions*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    21
goalw SList.thy list.defs "!!A B. A<=B ==> list(A) <= list(B)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    22
by (rtac lfp_mono 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    23
by (REPEAT (ares_tac basic_monos 1));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    24
qed "list_mono";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    25
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    26
(*Type checking -- list creates well-founded sets*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    27
goalw SList.thy (list_con_defs @ list.defs) "list(sexp) <= sexp";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    28
by (rtac lfp_lowerbound 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    29
by (fast_tac (univ_cs addIs sexp.intrs@[sexp_In0I,sexp_In1I]) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    30
qed "list_sexp";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    31
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    32
(* A <= sexp ==> list(A) <= sexp *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    33
bind_thm ("list_subset_sexp", ([list_mono, list_sexp] MRS subset_trans));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    34
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    35
(*Induction for the type 'a list *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    36
val prems = goalw SList.thy [Nil_def,Cons_def]
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    37
    "[| P(Nil);   \
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    38
\       !!x xs. P(xs) ==> P(x # xs) |]  ==> P(l)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    39
by (rtac (Rep_list_inverse RS subst) 1);   (*types force good instantiation*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    40
by (rtac (Rep_list RS list.induct) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    41
by (REPEAT (ares_tac prems 1
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    42
     ORELSE eresolve_tac [rangeE, ssubst, Abs_list_inverse RS subst] 1));
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
    43
qed "list_induct2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    44
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    45
(*Perform induction on xs. *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    46
fun list_ind_tac a M = 
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
    47
    EVERY [res_inst_tac [("l",a)] list_induct2 M,
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    48
	   rename_last_tac a ["1"] (M+1)];
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    49
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    50
(*** Isomorphisms ***)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    51
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    52
goal SList.thy "inj(Rep_list)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    53
by (rtac inj_inverseI 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    54
by (rtac Rep_list_inverse 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    55
qed "inj_Rep_list";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    56
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    57
goal SList.thy "inj_onto Abs_list (list(range Leaf))";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    58
by (rtac inj_onto_inverseI 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    59
by (etac Abs_list_inverse 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    60
qed "inj_onto_Abs_list";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    61
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    62
(** Distinctness of constructors **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    63
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    64
goalw SList.thy list_con_defs "CONS M N ~= NIL";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    65
by (rtac In1_not_In0 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    66
qed "CONS_not_NIL";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    67
bind_thm ("NIL_not_CONS", (CONS_not_NIL RS not_sym));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    68
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    69
bind_thm ("CONS_neq_NIL", (CONS_not_NIL RS notE));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    70
val NIL_neq_CONS = sym RS CONS_neq_NIL;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    71
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    72
goalw SList.thy [Nil_def,Cons_def] "x # xs ~= Nil";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    73
by (rtac (CONS_not_NIL RS (inj_onto_Abs_list RS inj_onto_contraD)) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    74
by (REPEAT (resolve_tac (list.intrs @ [rangeI, Rep_list]) 1));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    75
qed "Cons_not_Nil";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    76
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    77
bind_thm ("Nil_not_Cons", (Cons_not_Nil RS not_sym));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    78
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
    79
bind_thm ("Cons_neq_Nil2", (Cons_not_Nil RS notE));
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
    80
val Nil_neq_Cons = sym RS Cons_neq_Nil2;
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    81
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    82
(** Injectiveness of CONS and Cons **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    83
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    84
goalw SList.thy [CONS_def] "(CONS K M=CONS L N) = (K=L & M=N)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    85
by (fast_tac (HOL_cs addSEs [Scons_inject, make_elim In1_inject]) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    86
qed "CONS_CONS_eq";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    87
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    88
bind_thm ("CONS_inject", (CONS_CONS_eq RS iffD1 RS conjE));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    89
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    90
(*For reasoning about abstract list constructors*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    91
val list_cs = set_cs addIs [Rep_list] @ list.intrs
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    92
	             addSEs [CONS_neq_NIL,NIL_neq_CONS,CONS_inject]
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    93
		     addSDs [inj_onto_Abs_list RS inj_ontoD,
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    94
			     inj_Rep_list RS injD, Leaf_inject];
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    95
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    96
goalw SList.thy [Cons_def] "(x#xs=y#ys) = (x=y & xs=ys)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    97
by (fast_tac list_cs 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
    98
qed "Cons_Cons_eq";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
    99
bind_thm ("Cons_inject2", (Cons_Cons_eq RS iffD1 RS conjE));
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   100
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   101
val [major] = goal SList.thy "CONS M N: list(A) ==> M: A & N: list(A)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   102
by (rtac (major RS setup_induction) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   103
by (etac list.induct 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   104
by (ALLGOALS (fast_tac list_cs));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   105
qed "CONS_D";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   106
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   107
val prems = goalw SList.thy [CONS_def,In1_def]
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   108
    "CONS M N: sexp ==> M: sexp & N: sexp";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   109
by (cut_facts_tac prems 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   110
by (fast_tac (set_cs addSDs [Scons_D]) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   111
qed "sexp_CONS_D";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   112
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   113
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   114
(*Basic ss with constructors and their freeness*)
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   115
Addsimps ([Cons_not_Nil, Nil_not_Cons, Cons_Cons_eq, CONS_not_NIL,
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   116
           NIL_not_CONS, CONS_CONS_eq] @ list.intrs);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   117
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   118
goal SList.thy "!!N. N: list(A) ==> !M. N ~= CONS M N";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   119
by (etac list.induct 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   120
by (ALLGOALS Asm_simp_tac);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   121
qed "not_CONS_self";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   122
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   123
goal SList.thy "!x. l ~= x#l";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   124
by (list_ind_tac "l" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   125
by (ALLGOALS Asm_simp_tac);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   126
qed "not_Cons_self2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   127
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   128
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   129
goal SList.thy "(xs ~= []) = (? y ys. xs = y#ys)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   130
by(list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   131
by(Simp_tac 1);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   132
by(Asm_simp_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   133
by(REPEAT(resolve_tac [exI,refl,conjI] 1));
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   134
qed "neq_Nil_conv2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   135
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   136
(** Conversion rules for List_case: case analysis operator **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   137
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   138
goalw SList.thy [List_case_def,NIL_def] "List_case c h NIL = c";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   139
by (rtac Case_In0 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   140
qed "List_case_NIL";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   141
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   142
goalw SList.thy [List_case_def,CONS_def]  "List_case c h (CONS M N) = h M N";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   143
by (simp_tac (!simpset addsimps [Split,Case_In1]) 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   144
qed "List_case_CONS";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   145
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   146
(*** List_rec -- by wf recursion on pred_sexp ***)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   147
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   148
(* The trancl(pred_sexp) is essential because pred_sexp_CONS_I1,2 would not
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   149
   hold if pred_sexp^+ were changed to pred_sexp. *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   150
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   151
val List_rec_unfold = [List_rec_def, wf_pred_sexp RS wf_trancl] MRS def_wfrec
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   152
                      |> standard;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   153
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   154
(** pred_sexp lemmas **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   155
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   156
goalw SList.thy [CONS_def,In1_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
   157
    "!!M. [| M: sexp;  N: sexp |] ==> (M, CONS M N) : pred_sexp^+";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   158
by (Asm_simp_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   159
qed "pred_sexp_CONS_I1";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   160
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   161
goalw SList.thy [CONS_def,In1_def]
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
   162
    "!!M. [| M: sexp;  N: sexp |] ==> (N, CONS M N) : pred_sexp^+";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   163
by (Asm_simp_tac 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   164
qed "pred_sexp_CONS_I2";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   165
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   166
val [prem] = goal SList.thy
972
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
   167
    "(CONS M1 M2, N) : pred_sexp^+ ==> \
e61b058d58d2 changed syntax of tuples from <..., ...> to (..., ...)
clasohm
parents: 969
diff changeset
   168
\    (M1,N) : pred_sexp^+ & (M2,N) : pred_sexp^+";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   169
by (rtac (prem RS (pred_sexp_subset_Sigma RS trancl_subset_Sigma RS 
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   170
		   subsetD RS SigmaE2)) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   171
by (etac (sexp_CONS_D RS conjE) 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   172
by (REPEAT (ares_tac [conjI, pred_sexp_CONS_I1, pred_sexp_CONS_I2,
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   173
		      prem RSN (2, trans_trancl RS transD)] 1));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   174
qed "pred_sexp_CONS_D";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   175
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   176
(** Conversion rules for List_rec **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   177
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   178
goal SList.thy "List_rec NIL c h = c";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   179
by (rtac (List_rec_unfold RS trans) 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   180
by (simp_tac (!simpset addsimps [List_case_NIL]) 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   181
qed "List_rec_NIL";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   182
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   183
goal SList.thy "!!M. [| M: sexp;  N: sexp |] ==> \
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   184
\    List_rec (CONS M N) c h = h M N (List_rec N c h)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   185
by (rtac (List_rec_unfold RS trans) 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   186
by (asm_simp_tac (!simpset addsimps [List_case_CONS, pred_sexp_CONS_I2]) 1);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   187
qed "List_rec_CONS";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   188
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   189
(*** list_rec -- by List_rec ***)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   190
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   191
val Rep_list_in_sexp =
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   192
    [range_Leaf_subset_sexp RS list_subset_sexp, Rep_list] MRS subsetD;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   193
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   194
local
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   195
  val list_rec_simps = [List_rec_NIL, List_rec_CONS, 
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   196
                        Abs_list_inverse, Rep_list_inverse,
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   197
                        Rep_list, rangeI, inj_Leaf, Inv_f_f,
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   198
                        sexp.LeafI, Rep_list_in_sexp]
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   199
in
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   200
  val list_rec_Nil = prove_goalw SList.thy [list_rec_def, Nil_def]
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   201
      "list_rec Nil c h = c"
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   202
   (fn _=> [simp_tac (!simpset addsimps list_rec_simps) 1]);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   203
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   204
  val list_rec_Cons = prove_goalw SList.thy [list_rec_def, Cons_def]
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   205
      "list_rec (a#l) c h = h a l (list_rec l c h)"
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   206
   (fn _=> [simp_tac (!simpset addsimps list_rec_simps) 1]);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   207
end;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   208
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   209
Addsimps [List_rec_NIL, List_rec_CONS, list_rec_Nil, list_rec_Cons];
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   210
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   211
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   212
(*Type checking.  Useful?*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   213
val major::A_subset_sexp::prems = goal SList.thy
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   214
    "[| M: list(A);    	\
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   215
\       A<=sexp;      	\
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   216
\       c: C(NIL);      \
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   217
\       !!x y r. [| x: A;  y: list(A);  r: C(y) |] ==> h x y r: C(CONS x y) \
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   218
\    |] ==> List_rec M c h : C(M :: 'a item)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   219
val sexp_ListA_I = A_subset_sexp RS list_subset_sexp RS subsetD;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   220
val sexp_A_I = A_subset_sexp RS subsetD;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   221
by (rtac (major RS list.induct) 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   222
by (ALLGOALS(asm_simp_tac (!simpset addsimps ([sexp_A_I,sexp_ListA_I]@prems))));
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   223
qed "List_rec_type";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   224
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   225
(** Generalized map functionals **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   226
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   227
goalw SList.thy [Rep_map_def] "Rep_map f Nil = NIL";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   228
by (rtac list_rec_Nil 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   229
qed "Rep_map_Nil";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   230
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   231
goalw SList.thy [Rep_map_def]
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   232
    "Rep_map f (x#xs) = CONS (f x) (Rep_map f xs)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   233
by (rtac list_rec_Cons 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   234
qed "Rep_map_Cons";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   235
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   236
goalw SList.thy [Rep_map_def] "!!f. (!!x. f(x): A) ==> Rep_map f xs: list(A)";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   237
by (rtac list_induct2 1);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   238
by(ALLGOALS Asm_simp_tac);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   239
qed "Rep_map_type";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   240
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   241
goalw SList.thy [Abs_map_def] "Abs_map g NIL = Nil";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   242
by (rtac List_rec_NIL 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   243
qed "Abs_map_NIL";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   244
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   245
val prems = goalw SList.thy [Abs_map_def]
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   246
    "[| M: sexp;  N: sexp |] ==> \
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   247
\    Abs_map g (CONS M N) = g(M) # Abs_map g N";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   248
by (REPEAT (resolve_tac (List_rec_CONS::prems) 1));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   249
qed "Abs_map_CONS";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   250
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   251
(*These 2 rules ease the use of primitive recursion.  NOTE USE OF == *)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   252
val [rew] = goal SList.thy
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   253
    "[| !!xs. f(xs) == list_rec xs c h |] ==> f([]) = c";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   254
by (rewtac rew);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   255
by (rtac list_rec_Nil 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   256
qed "def_list_rec_Nil";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   257
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   258
val [rew] = goal SList.thy
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   259
    "[| !!xs. f(xs) == list_rec xs c h |] ==> f(x#xs) = h x xs (f xs)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   260
by (rewtac rew);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   261
by (rtac list_rec_Cons 1);
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   262
qed "def_list_rec_Cons";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   263
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   264
fun list_recs def =
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   265
      [standard (def RS def_list_rec_Nil),
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   266
       standard (def RS def_list_rec_Cons)];
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   267
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   268
(*** Unfolding the basic combinators ***)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   269
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   270
val [null_Nil,null_Cons] = list_recs null_def;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   271
val [_,hd_Cons] = list_recs hd_def;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   272
val [_,tl_Cons] = list_recs tl_def;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   273
val [ttl_Nil,ttl_Cons] = list_recs ttl_def;
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   274
val [append_Nil3,append_Cons] = list_recs append_def;
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   275
val [mem_Nil, mem_Cons] = list_recs mem_def;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   276
val [map_Nil,map_Cons] = list_recs map_def;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   277
val [list_case_Nil,list_case_Cons] = list_recs list_case_def;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   278
val [filter_Nil,filter_Cons] = list_recs filter_def;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   279
val [list_all_Nil,list_all_Cons] = list_recs list_all_def;
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   280
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   281
Addsimps
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   282
  [null_Nil, ttl_Nil,
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   283
   mem_Nil, mem_Cons,
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   284
   list_case_Nil, list_case_Cons,
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   285
   append_Nil3, append_Cons,
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   286
   map_Nil, map_Cons,
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   287
   list_all_Nil, list_all_Cons,
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   288
   filter_Nil, filter_Cons];
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   289
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   290
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   291
(** @ - append **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   292
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   293
goal SList.thy "(xs@ys)@zs = xs@(ys@zs)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   294
by(list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   295
by(ALLGOALS Asm_simp_tac);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   296
qed "append_assoc2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   297
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   298
goal SList.thy "xs @ [] = xs";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   299
by(list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   300
by(ALLGOALS Asm_simp_tac);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   301
qed "append_Nil4";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   302
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   303
(** mem **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   304
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   305
goal SList.thy "x mem (xs@ys) = (x mem xs | x mem ys)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   306
by(list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   307
by(ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   308
qed "mem_append2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   309
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   310
goal SList.thy "x mem [x:xs.P(x)] = (x mem xs & P(x))";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   311
by(list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   312
by(ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   313
qed "mem_filter2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   314
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   315
(** list_all **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   316
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   317
goal SList.thy "(Alls x:xs.True) = True";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   318
by(list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   319
by(ALLGOALS Asm_simp_tac);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   320
qed "list_all_True2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   321
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   322
goal SList.thy "list_all p (xs@ys) = (list_all p xs & list_all p ys)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   323
by(list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   324
by(ALLGOALS Asm_simp_tac);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   325
qed "list_all_conj2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   326
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   327
goal SList.thy "(Alls x:xs.P(x)) = (!x. x mem xs --> P(x))";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   328
by(list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   329
by(ALLGOALS(asm_simp_tac (!simpset setloop (split_tac [expand_if]))));
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   330
by(fast_tac HOL_cs 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   331
qed "list_all_mem_conv2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   332
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   333
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   334
(** The functional "map" **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   335
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   336
Addsimps [Rep_map_Nil, Rep_map_Cons, Abs_map_NIL, Abs_map_CONS];
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   337
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   338
val [major,A_subset_sexp,minor] = goal SList.thy 
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   339
    "[| M: list(A);  A<=sexp;  !!z. z: A ==> f(g(z)) = z |] \
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   340
\    ==> Rep_map f (Abs_map g M) = M";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   341
by (rtac (major RS list.induct) 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   342
by (ALLGOALS (asm_simp_tac (!simpset addsimps [sexp_A_I,sexp_ListA_I,minor])));
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   343
qed "Abs_map_inverse";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   344
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   345
(*Rep_map_inverse is obtained via Abs_Rep_map and map_ident*)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   346
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   347
(** list_case **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   348
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   349
goal SList.thy
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   350
 "P(list_case a f xs) = ((xs=[] --> P(a)) & \
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   351
\                        (!y ys. xs=y#ys --> P(f y ys)))";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   352
by(list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   353
by(ALLGOALS Asm_simp_tac);
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   354
by(fast_tac HOL_cs 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   355
qed "expand_list_case2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   356
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   357
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   358
(** Additional mapping lemmas **)
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   359
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   360
goal SList.thy "map (%x.x) xs = xs";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   361
by (list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   362
by (ALLGOALS Asm_simp_tac);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   363
qed "map_ident2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   364
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   365
goal SList.thy "map f (xs@ys) = map f xs @ map f ys";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   366
by (list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   367
by (ALLGOALS Asm_simp_tac);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   368
qed "map_append2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   369
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   370
goalw SList.thy [o_def] "map (f o g) xs = map f (map g xs)";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   371
by (list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   372
by (ALLGOALS Asm_simp_tac);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   373
qed "map_compose2";
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   374
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   375
goal SList.thy "!!f. (!!x. f(x): sexp) ==> \
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   376
\	Abs_map g (Rep_map f xs) = map (%t. g(f(t))) xs";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   377
by (list_ind_tac "xs" 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   378
by(ALLGOALS(asm_simp_tac(!simpset addsimps
969
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   379
       [Rep_map_type,list_sexp RS subsetD])));
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   380
qed "Abs_Rep_map";
b051e2fc2e34 converted ex with curried function application
clasohm
parents:
diff changeset
   381
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 972
diff changeset
   382
Addsimps [append_Nil4, map_ident2];