src/HOL/Library/Old_Datatype.thy
changeset 67613 ce654b0e6d69
parent 67319 07176d5b81d5
child 69605 a96320074298
equal deleted inserted replaced
67610:4939494ed791 67613:ce654b0e6d69
    57 
    57 
    58 (*the set of nodes with depth less than k*)
    58 (*the set of nodes with depth less than k*)
    59 definition ndepth :: "('a, 'b) node => nat"
    59 definition ndepth :: "('a, 'b) node => nat"
    60   where "ndepth(n) == (%(f,x). LEAST k. f k = Inr 0) (Rep_Node n)"
    60   where "ndepth(n) == (%(f,x). LEAST k. f k = Inr 0) (Rep_Node n)"
    61 definition ntrunc :: "[nat, ('a, 'b) dtree] => ('a, 'b) dtree"
    61 definition ntrunc :: "[nat, ('a, 'b) dtree] => ('a, 'b) dtree"
    62   where "ntrunc k N == {n. n:N \<and> ndepth(n)<k}"
    62   where "ntrunc k N == {n. n\<in>N \<and> ndepth(n)<k}"
    63 
    63 
    64 (*products and sums for the "universe"*)
    64 (*products and sums for the "universe"*)
    65 definition uprod :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
    65 definition uprod :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
    66   where "uprod A B == UN x:A. UN y:B. { Scons x y }"
    66   where "uprod A B == UN x:A. UN y:B. { Scons x y }"
    67 definition usum :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
    67 definition usum :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
   113 lemmas Abs_Node_inj = Abs_Node_inject [THEN [2] rev_iffD1]
   113 lemmas Abs_Node_inj = Abs_Node_inject [THEN [2] rev_iffD1]
   114 
   114 
   115 
   115 
   116 (*** Introduction rules for Node ***)
   116 (*** Introduction rules for Node ***)
   117 
   117 
   118 lemma Node_K0_I: "(%k. Inr 0, a) : Node"
   118 lemma Node_K0_I: "(\<lambda>k. Inr 0, a) \<in> Node"
   119 by (simp add: Node_def)
   119 by (simp add: Node_def)
   120 
   120 
   121 lemma Node_Push_I: "p: Node ==> apfst (Push i) p : Node"
   121 lemma Node_Push_I: "p \<in> Node \<Longrightarrow> apfst (Push i) p \<in> Node"
   122 apply (simp add: Node_def Push_def) 
   122 apply (simp add: Node_def Push_def) 
   123 apply (fast intro!: apfst_conv nat.case(2)[THEN trans])
   123 apply (fast intro!: apfst_conv nat.case(2)[THEN trans])
   124 done
   124 done
   125 
   125 
   126 
   126 
   297 subsection\<open>Set Constructions\<close>
   297 subsection\<open>Set Constructions\<close>
   298 
   298 
   299 
   299 
   300 (*** Cartesian Product ***)
   300 (*** Cartesian Product ***)
   301 
   301 
   302 lemma uprodI [intro!]: "[| M:A;  N:B |] ==> Scons M N : uprod A B"
   302 lemma uprodI [intro!]: "\<lbrakk>M\<in>A; N\<in>B\<rbrakk> \<Longrightarrow> Scons M N \<in> uprod A B"
   303 by (simp add: uprod_def)
   303 by (simp add: uprod_def)
   304 
   304 
   305 (*The general elimination rule*)
   305 (*The general elimination rule*)
   306 lemma uprodE [elim!]:
   306 lemma uprodE [elim!]:
   307     "[| c : uprod A B;   
   307     "\<lbrakk>c \<in> uprod A B;   
   308         !!x y. [| x:A;  y:B;  c = Scons x y |] ==> P  
   308         \<And>x y. \<lbrakk>x \<in> A; y \<in> B; c = Scons x y\<rbrakk> \<Longrightarrow> P  
   309      |] ==> P"
   309      \<rbrakk> \<Longrightarrow> P"
   310 by (auto simp add: uprod_def) 
   310 by (auto simp add: uprod_def) 
   311 
   311 
   312 
   312 
   313 (*Elimination of a pair -- introduces no eigenvariables*)
   313 (*Elimination of a pair -- introduces no eigenvariables*)
   314 lemma uprodE2: "[| Scons M N : uprod A B;  [| M:A;  N:B |] ==> P |] ==> P"
   314 lemma uprodE2: "\<lbrakk>Scons M N \<in> uprod A B; \<lbrakk>M \<in> A; N \<in> B\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
   315 by (auto simp add: uprod_def)
   315 by (auto simp add: uprod_def)
   316 
   316 
   317 
   317 
   318 (*** Disjoint Sum ***)
   318 (*** Disjoint Sum ***)
   319 
   319 
   320 lemma usum_In0I [intro]: "M:A ==> In0(M) : usum A B"
   320 lemma usum_In0I [intro]: "M \<in> A \<Longrightarrow> In0(M) \<in> usum A B"
   321 by (simp add: usum_def)
   321 by (simp add: usum_def)
   322 
   322 
   323 lemma usum_In1I [intro]: "N:B ==> In1(N) : usum A B"
   323 lemma usum_In1I [intro]: "N \<in> B \<Longrightarrow> In1(N) \<in> usum A B"
   324 by (simp add: usum_def)
   324 by (simp add: usum_def)
   325 
   325 
   326 lemma usumE [elim!]: 
   326 lemma usumE [elim!]: 
   327     "[| u : usum A B;   
   327     "\<lbrakk>u \<in> usum A B;   
   328         !!x. [| x:A;  u=In0(x) |] ==> P;  
   328         \<And>x. \<lbrakk>x \<in> A; u=In0(x)\<rbrakk> \<Longrightarrow> P;  
   329         !!y. [| y:B;  u=In1(y) |] ==> P  
   329         \<And>y. \<lbrakk>y \<in> B; u=In1(y)\<rbrakk> \<Longrightarrow> P  
   330      |] ==> P"
   330      \<rbrakk> \<Longrightarrow> P"
   331 by (auto simp add: usum_def)
   331 by (auto simp add: usum_def)
   332 
   332 
   333 
   333 
   334 (** Injection **)
   334 (** Injection **)
   335 
   335 
   438 
   438 
   439 
   439 
   440 (*** Equality for Cartesian Product ***)
   440 (*** Equality for Cartesian Product ***)
   441 
   441 
   442 lemma dprodI [intro!]: 
   442 lemma dprodI [intro!]: 
   443     "[| (M,M'):r;  (N,N'):s |] ==> (Scons M N, Scons M' N') : dprod r s"
   443     "\<lbrakk>(M,M') \<in> r; (N,N') \<in> s\<rbrakk> \<Longrightarrow> (Scons M N, Scons M' N') \<in> dprod r s"
   444 by (auto simp add: dprod_def)
   444 by (auto simp add: dprod_def)
   445 
   445 
   446 (*The general elimination rule*)
   446 (*The general elimination rule*)
   447 lemma dprodE [elim!]: 
   447 lemma dprodE [elim!]: 
   448     "[| c : dprod r s;   
   448     "\<lbrakk>c \<in> dprod r s;   
   449         !!x y x' y'. [| (x,x') : r;  (y,y') : s;  
   449         \<And>x y x' y'. \<lbrakk>(x,x') \<in> r; (y,y') \<in> s;  
   450                         c = (Scons x y, Scons x' y') |] ==> P  
   450                         c = (Scons x y, Scons x' y')\<rbrakk> \<Longrightarrow> P  
   451      |] ==> P"
   451      \<rbrakk> \<Longrightarrow> P"
   452 by (auto simp add: dprod_def)
   452 by (auto simp add: dprod_def)
   453 
   453 
   454 
   454 
   455 (*** Equality for Disjoint Sum ***)
   455 (*** Equality for Disjoint Sum ***)
   456 
   456 
   457 lemma dsum_In0I [intro]: "(M,M'):r ==> (In0(M), In0(M')) : dsum r s"
   457 lemma dsum_In0I [intro]: "(M,M') \<in> r \<Longrightarrow> (In0(M), In0(M')) \<in> dsum r s"
   458 by (auto simp add: dsum_def)
   458 by (auto simp add: dsum_def)
   459 
   459 
   460 lemma dsum_In1I [intro]: "(N,N'):s ==> (In1(N), In1(N')) : dsum r s"
   460 lemma dsum_In1I [intro]: "(N,N') \<in> s \<Longrightarrow> (In1(N), In1(N')) \<in> dsum r s"
   461 by (auto simp add: dsum_def)
   461 by (auto simp add: dsum_def)
   462 
   462 
   463 lemma dsumE [elim!]: 
   463 lemma dsumE [elim!]: 
   464     "[| w : dsum r s;   
   464     "\<lbrakk>w \<in> dsum r s;   
   465         !!x x'. [| (x,x') : r;  w = (In0(x), In0(x')) |] ==> P;  
   465         \<And>x x'. \<lbrakk> (x,x') \<in> r;  w = (In0(x), In0(x')) \<rbrakk> \<Longrightarrow> P;  
   466         !!y y'. [| (y,y') : s;  w = (In1(y), In1(y')) |] ==> P  
   466         \<And>y y'. \<lbrakk> (y,y') \<in> s;  w = (In1(y), In1(y')) \<rbrakk> \<Longrightarrow> P  
   467      |] ==> P"
   467      \<rbrakk> \<Longrightarrow> P"
   468 by (auto simp add: dsum_def)
   468 by (auto simp add: dsum_def)
   469 
   469 
   470 
   470 
   471 (*** Monotonicity ***)
   471 (*** Monotonicity ***)
   472 
   472