src/HOL/Subst/UTerm.ML
author clasohm
Wed, 04 Oct 1995 13:12:14 +0100
changeset 1266 3ae9fe3c0f68
parent 968 3cdaa8724175
child 1465 5d7a7e439cec
permissions -rw-r--r--
added local simpsets
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
     1
(*  Title: 	HOL/Subst/UTerm.ML
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
     2
    ID:         $Id$
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
     3
    Author: 	Martin Coen, Cambridge University Computer Laboratory
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
     5
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
     6
Simple term structure for unifiation.
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
     7
Binary trees with leaves that are constants or variables.
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
     8
*)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
     9
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    10
open UTerm;
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    11
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    12
val uterm_con_defs = [VAR_def, CONST_def, COMB_def];
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    13
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    14
goal UTerm.thy "uterm(A) = A <+> A <+> (uterm(A) <*> uterm(A))";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    15
let val rew = rewrite_rule uterm_con_defs in  
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    16
by (fast_tac (univ_cs addSIs (equalityI :: map rew uterm.intrs)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    17
                      addEs [rew uterm.elim]) 1)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    18
end;
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    19
qed "uterm_unfold";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    20
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    21
(** the uterm functional **)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    22
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    23
(*This justifies using uterm in other recursive type definitions*)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    24
goalw UTerm.thy uterm.defs "!!A B. A<=B ==> uterm(A) <= uterm(B)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    25
by (REPEAT (ares_tac (lfp_mono::basic_monos) 1));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    26
qed "uterm_mono";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    27
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    28
(** Type checking rules -- uterm creates well-founded sets **)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    29
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    30
goalw UTerm.thy (uterm_con_defs @ uterm.defs) "uterm(sexp) <= sexp";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    31
by (rtac lfp_lowerbound 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    32
by (fast_tac (univ_cs addIs sexp.intrs@[sexp_In0I,sexp_In1I]) 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    33
qed "uterm_sexp";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    34
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    35
(* A <= sexp ==> uterm(A) <= sexp *)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    36
bind_thm ("uterm_subset_sexp", ([uterm_mono, uterm_sexp] MRS subset_trans));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    37
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    38
(** Induction **)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    39
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    40
(*Induction for the type 'a uterm *)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    41
val prems = goalw UTerm.thy [Var_def,Const_def,Comb_def]
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    42
    "[| !!x.P(Var(x));  !!x.P(Const(x));  \
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    43
\       !!u v. [|  P(u);  P(v) |] ==> P(Comb u v) |]  ==> P(t)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    44
by (rtac (Rep_uterm_inverse RS subst) 1);   (*types force good instantiation*)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    45
by (rtac (Rep_uterm RS uterm.induct) 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    46
by (REPEAT (ares_tac prems 1
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    47
     ORELSE eresolve_tac [rangeE, ssubst, Abs_uterm_inverse RS subst] 1));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    48
qed "uterm_induct";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    49
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    50
(*Perform induction on xs. *)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    51
fun uterm_ind_tac a M = 
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    52
    EVERY [res_inst_tac [("t",a)] uterm_induct M,
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    53
	   rename_last_tac a ["1"] (M+1)];
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    54
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    55
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    56
(*** Isomorphisms ***)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    57
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    58
goal UTerm.thy "inj(Rep_uterm)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    59
by (rtac inj_inverseI 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    60
by (rtac Rep_uterm_inverse 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    61
qed "inj_Rep_uterm";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    62
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    63
goal UTerm.thy "inj_onto Abs_uterm (uterm (range Leaf))";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    64
by (rtac inj_onto_inverseI 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    65
by (etac Abs_uterm_inverse 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    66
qed "inj_onto_Abs_uterm";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    67
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    68
(** Distinctness of constructors **)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    69
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    70
goalw UTerm.thy uterm_con_defs "~ CONST(c) = COMB u v";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    71
by (rtac notI 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    72
by (etac (In1_inject RS (In0_not_In1 RS notE)) 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    73
qed "CONST_not_COMB";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    74
bind_thm ("COMB_not_CONST", (CONST_not_COMB RS not_sym));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    75
bind_thm ("CONST_neq_COMB", (CONST_not_COMB RS notE));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    76
val COMB_neq_CONST = sym RS CONST_neq_COMB;
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    77
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    78
goalw UTerm.thy uterm_con_defs "~ COMB u v = VAR(x)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    79
by (rtac In1_not_In0 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    80
qed "COMB_not_VAR";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    81
bind_thm ("VAR_not_COMB", (COMB_not_VAR RS not_sym));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    82
bind_thm ("COMB_neq_VAR", (COMB_not_VAR RS notE));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    83
val VAR_neq_COMB = sym RS COMB_neq_VAR;
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    84
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    85
goalw UTerm.thy uterm_con_defs "~ VAR(x) = CONST(c)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    86
by (rtac In0_not_In1 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    87
qed "VAR_not_CONST";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    88
bind_thm ("CONST_not_VAR", (VAR_not_CONST RS not_sym));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    89
bind_thm ("VAR_neq_CONST", (VAR_not_CONST RS notE));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    90
val CONST_neq_VAR = sym RS VAR_neq_CONST;
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    91
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    92
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    93
goalw UTerm.thy [Const_def,Comb_def] "~ Const(c) = Comb u v";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    94
by (rtac (CONST_not_COMB RS (inj_onto_Abs_uterm RS inj_onto_contraD)) 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    95
by (REPEAT (resolve_tac (uterm.intrs @ [rangeI, Rep_uterm]) 1));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    96
qed "Const_not_Comb";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    97
bind_thm ("Comb_not_Const", (Const_not_Comb RS not_sym));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    98
bind_thm ("Const_neq_Comb", (Const_not_Comb RS notE));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
    99
val Comb_neq_Const = sym RS Const_neq_Comb;
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   100
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   101
goalw UTerm.thy [Comb_def,Var_def] "~ Comb u v = Var(x)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   102
by (rtac (COMB_not_VAR RS (inj_onto_Abs_uterm RS inj_onto_contraD)) 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   103
by (REPEAT (resolve_tac (uterm.intrs @ [rangeI, Rep_uterm]) 1));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   104
qed "Comb_not_Var";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   105
bind_thm ("Var_not_Comb", (Comb_not_Var RS not_sym));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   106
bind_thm ("Comb_neq_Var", (Comb_not_Var RS notE));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   107
val Var_neq_Comb = sym RS Comb_neq_Var;
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   108
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   109
goalw UTerm.thy [Var_def,Const_def] "~ Var(x) = Const(c)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   110
by (rtac (VAR_not_CONST RS (inj_onto_Abs_uterm RS inj_onto_contraD)) 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   111
by (REPEAT (resolve_tac (uterm.intrs @ [rangeI, Rep_uterm]) 1));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   112
qed "Var_not_Const";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   113
bind_thm ("Const_not_Var", (Var_not_Const RS not_sym));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   114
bind_thm ("Var_neq_Const", (Var_not_Const RS notE));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   115
val Const_neq_Var = sym RS Var_neq_Const;
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   116
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   117
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   118
(** Injectiveness of CONST and Const **)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   119
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   120
val inject_cs = HOL_cs addSEs [Scons_inject] 
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   121
                       addSDs [In0_inject,In1_inject];
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   122
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   123
goalw UTerm.thy [VAR_def] "(VAR(M)=VAR(N)) = (M=N)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   124
by (fast_tac inject_cs 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   125
qed "VAR_VAR_eq";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   126
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   127
goalw UTerm.thy [CONST_def] "(CONST(M)=CONST(N)) = (M=N)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   128
by (fast_tac inject_cs 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   129
qed "CONST_CONST_eq";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   130
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   131
goalw UTerm.thy [COMB_def] "(COMB K L = COMB M N) = (K=M & L=N)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   132
by (fast_tac inject_cs 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   133
qed "COMB_COMB_eq";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   134
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   135
bind_thm ("VAR_inject", (VAR_VAR_eq RS iffD1));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   136
bind_thm ("CONST_inject", (CONST_CONST_eq RS iffD1));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   137
bind_thm ("COMB_inject", (COMB_COMB_eq RS iffD1 RS conjE));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   138
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   139
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   140
(*For reasoning about abstract uterm constructors*)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   141
val uterm_cs = set_cs addIs uterm.intrs @ [Rep_uterm]
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   142
	              addSEs [CONST_neq_COMB,COMB_neq_VAR,VAR_neq_CONST,
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   143
			      COMB_neq_CONST,VAR_neq_COMB,CONST_neq_VAR,
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   144
			      COMB_inject]
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   145
		      addSDs [VAR_inject,CONST_inject,
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   146
			      inj_onto_Abs_uterm RS inj_ontoD,
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   147
			      inj_Rep_uterm RS injD, Leaf_inject];
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   148
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   149
goalw UTerm.thy [Var_def] "(Var(x)=Var(y)) = (x=y)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   150
by (fast_tac uterm_cs 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   151
qed "Var_Var_eq";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   152
bind_thm ("Var_inject", (Var_Var_eq RS iffD1));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   153
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   154
goalw UTerm.thy [Const_def] "(Const(x)=Const(y)) = (x=y)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   155
by (fast_tac uterm_cs 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   156
qed "Const_Const_eq";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   157
bind_thm ("Const_inject", (Const_Const_eq RS iffD1));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   158
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   159
goalw UTerm.thy [Comb_def] "(Comb u v =Comb x y) = (u=x & v=y)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   160
by (fast_tac uterm_cs 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   161
qed "Comb_Comb_eq";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   162
bind_thm ("Comb_inject", (Comb_Comb_eq RS iffD1 RS conjE));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   163
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   164
val [major] = goal UTerm.thy "VAR(M): uterm(A) ==> M : A";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   165
by (rtac (major RS setup_induction) 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   166
by (etac uterm.induct 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   167
by (ALLGOALS (fast_tac uterm_cs));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   168
qed "VAR_D";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   169
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   170
val [major] = goal UTerm.thy "CONST(M): uterm(A) ==> M : A";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   171
by (rtac (major RS setup_induction) 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   172
by (etac uterm.induct 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   173
by (ALLGOALS (fast_tac uterm_cs));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   174
qed "CONST_D";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   175
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   176
val [major] = goal UTerm.thy
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   177
    "COMB M N: uterm(A) ==> M: uterm(A) & N: uterm(A)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   178
by (rtac (major RS setup_induction) 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   179
by (etac uterm.induct 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   180
by (ALLGOALS (fast_tac uterm_cs));
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   181
qed "COMB_D";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   182
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   183
(*Basic ss with constructors and their freeness*)
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   184
Addsimps (uterm.intrs @
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   185
          [Const_not_Comb,Comb_not_Var,Var_not_Const,
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   186
           Comb_not_Const,Var_not_Comb,Const_not_Var,
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   187
           Var_Var_eq,Const_Const_eq,Comb_Comb_eq,
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   188
           CONST_not_COMB,COMB_not_VAR,VAR_not_CONST,
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   189
           COMB_not_CONST,VAR_not_COMB,CONST_not_VAR,
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   190
           VAR_VAR_eq,CONST_CONST_eq,COMB_COMB_eq]);
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   191
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   192
goal UTerm.thy "!u. t~=Comb t u";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   193
by (uterm_ind_tac "t" 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   194
by (rtac (Var_not_Comb RS allI) 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   195
by (rtac (Const_not_Comb RS allI) 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   196
by (Asm_simp_tac 1);
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   197
qed "t_not_Comb_t";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   198
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   199
goal UTerm.thy "!t. u~=Comb t u";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   200
by (uterm_ind_tac "u" 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   201
by (rtac (Var_not_Comb RS allI) 1);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   202
by (rtac (Const_not_Comb RS allI) 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   203
by (Asm_simp_tac 1);
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   204
qed "u_not_Comb_u";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   205
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   206
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   207
(*** UTerm_rec -- by wf recursion on pred_sexp ***)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   208
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   209
val UTerm_rec_unfold =
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   210
    [UTerm_rec_def, wf_pred_sexp RS wf_trancl] MRS def_wfrec;
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   211
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   212
(** conversion rules **)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   213
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   214
goalw UTerm.thy [VAR_def] "UTerm_rec (VAR x) b c d = b(x)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   215
by (rtac (UTerm_rec_unfold RS trans) 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   216
by (simp_tac (!simpset addsimps [Case_In0]) 1);
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   217
qed "UTerm_rec_VAR";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   218
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   219
goalw UTerm.thy [CONST_def] "UTerm_rec (CONST x) b c d = c(x)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   220
by (rtac (UTerm_rec_unfold RS trans) 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   221
by (simp_tac (!simpset addsimps [Case_In0,Case_In1]) 1);
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   222
qed "UTerm_rec_CONST";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   223
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   224
goalw UTerm.thy [COMB_def]
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   225
    "!!M N. [| M: sexp;  N: sexp |] ==> 	\
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   226
\           UTerm_rec (COMB M N) b c d = \
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   227
\           d M N (UTerm_rec M b c d) (UTerm_rec N b c d)";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   228
by (rtac (UTerm_rec_unfold RS trans) 1);
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   229
by (simp_tac (!simpset addsimps [Split,Case_In1]) 1);
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   230
by (asm_simp_tac (!simpset addsimps [In1_def]) 1);
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   231
qed "UTerm_rec_COMB";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   232
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   233
(*** uterm_rec -- by UTerm_rec ***)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   234
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   235
val Rep_uterm_in_sexp =
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   236
    Rep_uterm RS (range_Leaf_subset_sexp RS uterm_subset_sexp RS subsetD);
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   237
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   238
Addsimps [UTerm_rec_VAR, UTerm_rec_CONST, UTerm_rec_COMB, 
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   239
          Abs_uterm_inverse, Rep_uterm_inverse, 
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   240
          Rep_uterm, rangeI, inj_Leaf, Inv_f_f, Rep_uterm_in_sexp];
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   241
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   242
goalw UTerm.thy [uterm_rec_def, Var_def] "uterm_rec (Var x) b c d = b(x)";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   243
by (Simp_tac 1);
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   244
qed "uterm_rec_Var";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   245
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   246
goalw UTerm.thy [uterm_rec_def, Const_def] "uterm_rec (Const x) b c d = c(x)";
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   247
by (Simp_tac 1);
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   248
qed "uterm_rec_Const";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   249
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   250
goalw UTerm.thy [uterm_rec_def, Comb_def]
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   251
  "uterm_rec (Comb u v) b c d = d u v (uterm_rec u b c d) (uterm_rec v b c d)";
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   252
by (Simp_tac 1);
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   253
qed "uterm_rec_Comb";
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   254
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   255
Addsimps [uterm_rec_Var, uterm_rec_Const, uterm_rec_Comb];
968
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   256
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   257
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   258
(**********)
3cdaa8724175 converted Subst with curried function application
clasohm
parents:
diff changeset
   259
1266
3ae9fe3c0f68 added local simpsets
clasohm
parents: 968
diff changeset
   260
val uterm_rews = [t_not_Comb_t,u_not_Comb_u];