src/HOL/Datatype.thy
changeset 35216 7641e8d831d2
parent 33968 f94fb13ecbb3
child 36176 3fe7e97ccca8
equal deleted inserted replaced
35215:a03462cbf86f 35216:7641e8d831d2
   142 subsection{*Freeness: Distinctness of Constructors*}
   142 subsection{*Freeness: Distinctness of Constructors*}
   143 
   143 
   144 (** Scons vs Atom **)
   144 (** Scons vs Atom **)
   145 
   145 
   146 lemma Scons_not_Atom [iff]: "Scons M N \<noteq> Atom(a)"
   146 lemma Scons_not_Atom [iff]: "Scons M N \<noteq> Atom(a)"
   147 apply (simp add: Atom_def Scons_def Push_Node_def One_nat_def)
   147 unfolding Atom_def Scons_def Push_Node_def One_nat_def
   148 apply (blast intro: Node_K0_I Rep_Node [THEN Node_Push_I] 
   148 by (blast intro: Node_K0_I Rep_Node [THEN Node_Push_I] 
   149          dest!: Abs_Node_inj 
   149          dest!: Abs_Node_inj 
   150          elim!: apfst_convE sym [THEN Push_neq_K0])  
   150          elim!: apfst_convE sym [THEN Push_neq_K0])  
   151 done
       
   152 
   151 
   153 lemmas Atom_not_Scons [iff] = Scons_not_Atom [THEN not_sym, standard]
   152 lemmas Atom_not_Scons [iff] = Scons_not_Atom [THEN not_sym, standard]
   154 
   153 
   155 
   154 
   156 (*** Injectiveness ***)
   155 (*** Injectiveness ***)
   197 
   196 
   198 
   197 
   199 (** Injectiveness of Scons **)
   198 (** Injectiveness of Scons **)
   200 
   199 
   201 lemma Scons_inject_lemma1: "Scons M N <= Scons M' N' ==> M<=M'"
   200 lemma Scons_inject_lemma1: "Scons M N <= Scons M' N' ==> M<=M'"
   202 apply (simp add: Scons_def One_nat_def)
   201 unfolding Scons_def One_nat_def
   203 apply (blast dest!: Push_Node_inject)
   202 by (blast dest!: Push_Node_inject)
   204 done
       
   205 
   203 
   206 lemma Scons_inject_lemma2: "Scons M N <= Scons M' N' ==> N<=N'"
   204 lemma Scons_inject_lemma2: "Scons M N <= Scons M' N' ==> N<=N'"
   207 apply (simp add: Scons_def One_nat_def)
   205 unfolding Scons_def One_nat_def
   208 apply (blast dest!: Push_Node_inject)
   206 by (blast dest!: Push_Node_inject)
   209 done
       
   210 
   207 
   211 lemma Scons_inject1: "Scons M N = Scons M' N' ==> M=M'"
   208 lemma Scons_inject1: "Scons M N = Scons M' N' ==> M=M'"
   212 apply (erule equalityE)
   209 apply (erule equalityE)
   213 apply (iprover intro: equalityI Scons_inject_lemma1)
   210 apply (iprover intro: equalityI Scons_inject_lemma1)
   214 done
   211 done
   228 (*** Distinctness involving Leaf and Numb ***)
   225 (*** Distinctness involving Leaf and Numb ***)
   229 
   226 
   230 (** Scons vs Leaf **)
   227 (** Scons vs Leaf **)
   231 
   228 
   232 lemma Scons_not_Leaf [iff]: "Scons M N \<noteq> Leaf(a)"
   229 lemma Scons_not_Leaf [iff]: "Scons M N \<noteq> Leaf(a)"
   233 by (simp add: Leaf_def o_def Scons_not_Atom)
   230 unfolding Leaf_def o_def by (rule Scons_not_Atom)
   234 
   231 
   235 lemmas Leaf_not_Scons  [iff] = Scons_not_Leaf [THEN not_sym, standard]
   232 lemmas Leaf_not_Scons  [iff] = Scons_not_Leaf [THEN not_sym, standard]
   236 
   233 
   237 (** Scons vs Numb **)
   234 (** Scons vs Numb **)
   238 
   235 
   239 lemma Scons_not_Numb [iff]: "Scons M N \<noteq> Numb(k)"
   236 lemma Scons_not_Numb [iff]: "Scons M N \<noteq> Numb(k)"
   240 by (simp add: Numb_def o_def Scons_not_Atom)
   237 unfolding Numb_def o_def by (rule Scons_not_Atom)
   241 
   238 
   242 lemmas Numb_not_Scons [iff] = Scons_not_Numb [THEN not_sym, standard]
   239 lemmas Numb_not_Scons [iff] = Scons_not_Numb [THEN not_sym, standard]
   243 
   240 
   244 
   241 
   245 (** Leaf vs Numb **)
   242 (** Leaf vs Numb **)
   279 
   276 
   280 lemma ntrunc_Atom [simp]: "ntrunc (Suc k) (Atom a) = Atom(a)"
   277 lemma ntrunc_Atom [simp]: "ntrunc (Suc k) (Atom a) = Atom(a)"
   281 by (auto simp add: Atom_def ntrunc_def ndepth_K0)
   278 by (auto simp add: Atom_def ntrunc_def ndepth_K0)
   282 
   279 
   283 lemma ntrunc_Leaf [simp]: "ntrunc (Suc k) (Leaf a) = Leaf(a)"
   280 lemma ntrunc_Leaf [simp]: "ntrunc (Suc k) (Leaf a) = Leaf(a)"
   284 by (simp add: Leaf_def o_def ntrunc_Atom)
   281 unfolding Leaf_def o_def by (rule ntrunc_Atom)
   285 
   282 
   286 lemma ntrunc_Numb [simp]: "ntrunc (Suc k) (Numb i) = Numb(i)"
   283 lemma ntrunc_Numb [simp]: "ntrunc (Suc k) (Numb i) = Numb(i)"
   287 by (simp add: Numb_def o_def ntrunc_Atom)
   284 unfolding Numb_def o_def by (rule ntrunc_Atom)
   288 
   285 
   289 lemma ntrunc_Scons [simp]: 
   286 lemma ntrunc_Scons [simp]: 
   290     "ntrunc (Suc k) (Scons M N) = Scons (ntrunc k M) (ntrunc k N)"
   287     "ntrunc (Suc k) (Scons M N) = Scons (ntrunc k M) (ntrunc k N)"
   291 by (auto simp add: Scons_def ntrunc_def One_nat_def ndepth_Push_Node) 
   288 unfolding Scons_def ntrunc_def One_nat_def
       
   289 by (auto simp add: ndepth_Push_Node)
   292 
   290 
   293 
   291 
   294 
   292 
   295 (** Injection nodes **)
   293 (** Injection nodes **)
   296 
   294 
   349 
   347 
   350 
   348 
   351 (** Injection **)
   349 (** Injection **)
   352 
   350 
   353 lemma In0_not_In1 [iff]: "In0(M) \<noteq> In1(N)"
   351 lemma In0_not_In1 [iff]: "In0(M) \<noteq> In1(N)"
   354 by (auto simp add: In0_def In1_def One_nat_def)
   352 unfolding In0_def In1_def One_nat_def by auto
   355 
   353 
   356 lemmas In1_not_In0 [iff] = In0_not_In1 [THEN not_sym, standard]
   354 lemmas In1_not_In0 [iff] = In0_not_In1 [THEN not_sym, standard]
   357 
   355 
   358 lemma In0_inject: "In0(M) = In0(N) ==>  M=N"
   356 lemma In0_inject: "In0(M) = In0(N) ==>  M=N"
   359 by (simp add: In0_def)
   357 by (simp add: In0_def)
   415 
   413 
   416 lemma Scons_mono: "[| M<=M';  N<=N' |] ==> Scons M N <= Scons M' N'"
   414 lemma Scons_mono: "[| M<=M';  N<=N' |] ==> Scons M N <= Scons M' N'"
   417 by (simp add: Scons_def, blast)
   415 by (simp add: Scons_def, blast)
   418 
   416 
   419 lemma In0_mono: "M<=N ==> In0(M) <= In0(N)"
   417 lemma In0_mono: "M<=N ==> In0(M) <= In0(N)"
   420 by (simp add: In0_def subset_refl Scons_mono)
   418 by (simp add: In0_def Scons_mono)
   421 
   419 
   422 lemma In1_mono: "M<=N ==> In1(M) <= In1(N)"
   420 lemma In1_mono: "M<=N ==> In1(M) <= In1(N)"
   423 by (simp add: In1_def subset_refl Scons_mono)
   421 by (simp add: In1_def Scons_mono)
   424 
   422 
   425 
   423 
   426 (*** Split and Case ***)
   424 (*** Split and Case ***)
   427 
   425 
   428 lemma Split [simp]: "Split c (Scons M N) = c M N"
   426 lemma Split [simp]: "Split c (Scons M N) = c M N"