Quot/Examples/IntEx.thy
changeset 610 2bee5ca44ef5
parent 606 38aa6b67a80b
child 612 ec37a279ca55
equal deleted inserted replaced
606:38aa6b67a80b 610:2bee5ca44ef5
   134 
   134 
   135 lemma plus_rsp[quotient_rsp]:
   135 lemma plus_rsp[quotient_rsp]:
   136   shows "(intrel ===> intrel ===> intrel) my_plus my_plus"
   136   shows "(intrel ===> intrel ===> intrel) my_plus my_plus"
   137 by (simp)
   137 by (simp)
   138 
   138 
   139 ML {* val qty = @{typ "my_int"} *}
       
   140 ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *}
       
   141 ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "my_int"; *}
       
   142 
       
   143 ML {* fun lift_tac_intex lthy t = lift_tac lthy t *}
       
   144 
       
   145 ML {* fun inj_repabs_tac_intex lthy = inj_repabs_tac lthy [rel_refl] [trans2] *}
       
   146 ML {* fun all_inj_repabs_tac_intex lthy = all_inj_repabs_tac lthy [rel_refl] [trans2] *}
       
   147 
       
   148 lemma test1: "my_plus a b = my_plus a b"
   139 lemma test1: "my_plus a b = my_plus a b"
   149 apply(rule refl)
   140 apply(rule refl)
   150 done
   141 done
   151 
   142 
   152 lemma "PLUS a b = PLUS a b"
   143 lemma "PLUS a b = PLUS a b"
   153 apply(tactic {* procedure_tac @{context} @{thm test1} 1 *})
   144 apply(tactic {* procedure_tac @{context} @{thm test1} 1 *})
   154 apply(tactic {* regularize_tac @{context} 1 *})
   145 apply(tactic {* regularize_tac @{context} 1 *})
   155 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
   146 apply(tactic {* all_inj_repabs_tac @{context} 1*})
   156 apply(tactic {* clean_tac @{context} 1 *}) 
   147 apply(tactic {* clean_tac @{context} 1 *}) 
   157 done
   148 done
   158 
   149 
   159 thm lambda_prs
   150 thm lambda_prs
   160 
   151 
   161 lemma test2: "my_plus a = my_plus a"
   152 lemma test2: "my_plus a = my_plus a"
   162 apply(rule refl)
   153 apply(rule refl)
   163 done
   154 done
       
   155 
       
   156 
   164 
   157 
   165 lemma "PLUS a = PLUS a"
   158 lemma "PLUS a = PLUS a"
   166 apply(tactic {* procedure_tac @{context} @{thm test2} 1 *})
   159 apply(tactic {* procedure_tac @{context} @{thm test2} 1 *})
   167 apply(rule impI)
   160 apply(rule impI)
   168 apply(rule ballI)
   161 apply(rule ballI)
   169 apply(rule apply_rsp[OF Quotient_my_int plus_rsp])
   162 apply(rule apply_rsp[OF Quotient_my_int plus_rsp])
   170 apply(simp only: in_respects)
   163 apply(simp only: in_respects)
   171 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
   164 apply(tactic {* all_inj_repabs_tac @{context} 1*})
   172 apply(tactic {* clean_tac @{context} 1 *})
   165 apply(tactic {* clean_tac @{context} 1 *})
   173 done
   166 done
   174 
   167 
   175 lemma test3: "my_plus = my_plus"
   168 lemma test3: "my_plus = my_plus"
   176 apply(rule refl)
   169 apply(rule refl)
   178 
   171 
   179 lemma "PLUS = PLUS"
   172 lemma "PLUS = PLUS"
   180 apply(tactic {* procedure_tac @{context} @{thm test3} 1 *})
   173 apply(tactic {* procedure_tac @{context} @{thm test3} 1 *})
   181 apply(rule impI)
   174 apply(rule impI)
   182 apply(rule plus_rsp)
   175 apply(rule plus_rsp)
   183 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
   176 apply(tactic {* all_inj_repabs_tac @{context} 1*})
   184 apply(tactic {* clean_tac @{context} 1 *})
   177 apply(tactic {* clean_tac @{context} 1 *})
   185 done
   178 done
   186 
   179 
   187 
   180 
   188 lemma "PLUS a b = PLUS b a"
   181 lemma "PLUS a b = PLUS b a"
   189 apply(tactic {* procedure_tac @{context} @{thm plus_sym_pre} 1 *})
   182 apply(tactic {* procedure_tac @{context} @{thm plus_sym_pre} 1 *})
   190 apply(tactic {* regularize_tac @{context} 1 *})
   183 apply(tactic {* regularize_tac @{context} 1 *})
   191 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
   184 apply(tactic {* all_inj_repabs_tac @{context} 1*})
   192 apply(tactic {* clean_tac @{context} 1 *})
   185 apply(tactic {* clean_tac @{context} 1 *})
   193 done
   186 done
   194 
   187 
   195 lemma plus_assoc_pre:
   188 lemma plus_assoc_pre:
   196   shows "my_plus (my_plus i j) k \<approx> my_plus i (my_plus j k)"
   189   shows "my_plus (my_plus i j) k \<approx> my_plus i (my_plus j k)"
   201   done
   194   done
   202 
   195 
   203 lemma plus_assoc: "PLUS (PLUS x xa) xb = PLUS x (PLUS xa xb)"
   196 lemma plus_assoc: "PLUS (PLUS x xa) xb = PLUS x (PLUS xa xb)"
   204 apply(tactic {* procedure_tac @{context} @{thm plus_assoc_pre} 1 *})
   197 apply(tactic {* procedure_tac @{context} @{thm plus_assoc_pre} 1 *})
   205 apply(tactic {* regularize_tac @{context} 1 *})
   198 apply(tactic {* regularize_tac @{context} 1 *})
   206 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
   199 apply(tactic {* all_inj_repabs_tac @{context} 1*})
   207 apply(tactic {* clean_tac @{context} 1 *})
   200 apply(tactic {* clean_tac @{context} 1 *})
   208 done
   201 done
   209 
   202 
   210 lemma ho_tst: "foldl my_plus x [] = x"
   203 lemma ho_tst: "foldl my_plus x [] = x"
   211 apply simp
   204 apply simp
   212 done
   205 done
   213 
   206 
   214 lemma "foldl PLUS x [] = x"
   207 lemma "foldl PLUS x [] = x"
   215 apply(tactic {* procedure_tac @{context} @{thm ho_tst} 1 *})
   208 apply(tactic {* procedure_tac @{context} @{thm ho_tst} 1 *})
   216 apply(tactic {* regularize_tac @{context} 1 *})
   209 apply(tactic {* regularize_tac @{context} 1 *})
   217 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
   210 apply(tactic {* all_inj_repabs_tac @{context} 1*})
   218 apply(tactic {* clean_tac @{context} 1 *})
   211 apply(tactic {* clean_tac @{context} 1 *})
   219 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] nil_prs[OF Quotient_my_int])
   212 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] nil_prs[OF Quotient_my_int])
   220 done
   213 done
   221 
   214 
   222 lemma ho_tst2: "foldl my_plus x (h # t) \<approx> my_plus h (foldl my_plus x t)"
   215 lemma ho_tst2: "foldl my_plus x (h # t) \<approx> my_plus h (foldl my_plus x t)"
   223 sorry
   216 sorry
   224 
   217 
   225 lemma "foldl PLUS x (h # t) = PLUS h (foldl PLUS x t)"
   218 lemma "foldl PLUS x (h # t) = PLUS h (foldl PLUS x t)"
   226 apply(tactic {* procedure_tac @{context} @{thm ho_tst2} 1 *})
   219 apply(tactic {* procedure_tac @{context} @{thm ho_tst2} 1 *})
   227 apply(tactic {* regularize_tac @{context} 1 *})
   220 apply(tactic {* regularize_tac @{context} 1 *})
   228 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
   221 apply(tactic {* all_inj_repabs_tac @{context} 1*})
   229 apply(tactic {* clean_tac @{context} 1 *})
   222 apply(tactic {* clean_tac @{context} 1 *})
   230 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] cons_prs[OF Quotient_my_int])
   223 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] cons_prs[OF Quotient_my_int])
   231 done
   224 done
   232 
   225 
   233 lemma ho_tst3: "foldl f (s::nat \<times> nat) ([]::(nat \<times> nat) list) = s"
   226 lemma ho_tst3: "foldl f (s::nat \<times> nat) ([]::(nat \<times> nat) list) = s"
   234 by simp
   227 by simp
   235 
   228 
   236 lemma "foldl f (x::my_int) ([]::my_int list) = x"
   229 lemma "foldl f (x::my_int) ([]::my_int list) = x"
   237 apply(tactic {* procedure_tac @{context} @{thm ho_tst3} 1 *})
   230 apply(tactic {* procedure_tac @{context} @{thm ho_tst3} 1 *})
   238 apply(tactic {* regularize_tac @{context} 1 *})
   231 apply(tactic {* regularize_tac @{context} 1 *})
   239 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
   232 apply(tactic {* all_inj_repabs_tac @{context} 1*})
   240 (* TODO: does not work when this is added *)
   233 (* TODO: does not work when this is added *)
   241 (* apply(tactic {* lambda_prs_tac @{context} 1 *})*)
   234 (* apply(tactic {* lambda_prs_tac @{context} 1 *})*)
   242 apply(tactic {* clean_tac @{context} 1 *})
   235 apply(tactic {* clean_tac @{context} 1 *})
   243 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] nil_prs[OF Quotient_my_int])
   236 apply(simp only: foldl_prs[OF Quotient_my_int Quotient_my_int] nil_prs[OF Quotient_my_int])
   244 done
   237 done
   247 by simp
   240 by simp
   248 
   241 
   249 lemma "(\<lambda>x. (x, x)) (y::my_int) = (y, y)"
   242 lemma "(\<lambda>x. (x, x)) (y::my_int) = (y, y)"
   250 apply(tactic {* procedure_tac @{context} @{thm lam_tst} 1 *})
   243 apply(tactic {* procedure_tac @{context} @{thm lam_tst} 1 *})
   251 apply(tactic {* regularize_tac @{context} 1 *})
   244 apply(tactic {* regularize_tac @{context} 1 *})
   252 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
   245 apply(tactic {* all_inj_repabs_tac @{context} 1*})
   253 apply(tactic {* clean_tac @{context} 1 *})
   246 apply(tactic {* clean_tac @{context} 1 *})
   254 apply(simp add: pair_prs)
   247 apply(simp add: pair_prs)
   255 done
   248 done
   256 
   249 
   257 lemma lam_tst2: "(\<lambda>(y :: nat \<times> nat). y) = (\<lambda>(x :: nat \<times> nat). x)"
   250 lemma lam_tst2: "(\<lambda>(y :: nat \<times> nat). y) = (\<lambda>(x :: nat \<times> nat). x)"
   309 by auto
   302 by auto
   310 
   303 
   311 lemma "(\<lambda>(y :: my_int). y) = (\<lambda>(x :: my_int). x)"
   304 lemma "(\<lambda>(y :: my_int). y) = (\<lambda>(x :: my_int). x)"
   312 apply(tactic {* procedure_tac @{context} @{thm lam_tst3a} 1 *})
   305 apply(tactic {* procedure_tac @{context} @{thm lam_tst3a} 1 *})
   313 defer
   306 defer
   314 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
   307 apply(tactic {* all_inj_repabs_tac @{context} 1*})
   315 apply(tactic {* clean_tac  @{context} 1 *})
   308 apply(tactic {* clean_tac  @{context} 1 *})
   316 apply(subst babs_rsp)
   309 apply(subst babs_rsp)
   317 apply(tactic {* clean_tac  @{context} 1 *})
   310 apply(tactic {* clean_tac  @{context} 1 *})
   318 apply(simp)
   311 apply(simp)
   319 apply(tactic {* regularize_tac @{context} 1*})?
   312 apply(tactic {* regularize_tac @{context} 1*})?
   327 by auto
   320 by auto
   328 
   321 
   329 lemma "(\<lambda>(y :: my_int => my_int). y) = (\<lambda>(x :: my_int => my_int). x)"
   322 lemma "(\<lambda>(y :: my_int => my_int). y) = (\<lambda>(x :: my_int => my_int). x)"
   330 apply(tactic {* procedure_tac @{context} @{thm lam_tst3b} 1 *})
   323 apply(tactic {* procedure_tac @{context} @{thm lam_tst3b} 1 *})
   331 defer
   324 defer
   332 apply(tactic {* all_inj_repabs_tac_intex @{context} 1*})
   325 apply(tactic {* all_inj_repabs_tac @{context} 1*})
   333 apply(tactic {* clean_tac  @{context} 1 *})
   326 apply(tactic {* clean_tac  @{context} 1 *})
   334 apply(subst babs_rsp)
   327 apply(subst babs_rsp)
   335 apply(tactic {* clean_tac  @{context} 1 *})
   328 apply(tactic {* clean_tac  @{context} 1 *})
   336 apply(simp)
   329 apply(simp)
   337 apply(tactic {* regularize_tac @{context} 1*})?
   330 apply(tactic {* regularize_tac @{context} 1*})?