src/HOL/Metis_Examples/TransClosure.thy
author haftmann
Wed Feb 10 15:14:06 2010 +0100 (2010-02-10)
changeset 35096 f36965a1fd42
parent 33027 9cf389429f6d
child 36490 5abf45444a16
permissions -rw-r--r--
dropped Id
paulson@23449
     1
(*  Title:      HOL/MetisTest/TransClosure.thy
paulson@23449
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@23449
     3
paulson@23449
     4
Testing the metis method
paulson@23449
     5
*)
paulson@23449
     6
paulson@23449
     7
theory TransClosure
paulson@23449
     8
imports Main
paulson@23449
     9
begin
paulson@23449
    10
paulson@23449
    11
types addr = nat
paulson@23449
    12
paulson@23449
    13
datatype val
paulson@23449
    14
  = Unit        -- "dummy result value of void expressions"
paulson@23449
    15
  | Null        -- "null reference"
paulson@23449
    16
  | Bool bool   -- "Boolean value"
paulson@23449
    17
  | Intg int    -- "integer value" 
paulson@23449
    18
  | Addr addr   -- "addresses of objects in the heap"
paulson@23449
    19
paulson@23449
    20
consts R::"(addr \<times> addr) set"
paulson@23449
    21
paulson@23449
    22
consts f:: "addr \<Rightarrow> val"
paulson@23449
    23
boehmes@32864
    24
declare [[ atp_problem_prefix = "TransClosure__test" ]]
paulson@23449
    25
lemma "\<lbrakk> f c = Intg x; \<forall> y. f b = Intg y \<longrightarrow> y \<noteq> x; (a,b) \<in> R\<^sup>*; (b,c) \<in> R\<^sup>* \<rbrakk> 
paulson@23449
    26
   \<Longrightarrow> \<exists> c. (b,c) \<in> R \<and> (a,c) \<in> R\<^sup>*"  
paulson@23449
    27
by (metis Transitive_Closure.rtrancl_into_rtrancl converse_rtranclE trancl_reflcl)
paulson@23449
    28
paulson@23449
    29
lemma "\<lbrakk> f c = Intg x; \<forall> y. f b = Intg y \<longrightarrow> y \<noteq> x; (a,b) \<in> R\<^sup>*; (b,c) \<in> R\<^sup>* \<rbrakk> 
paulson@23449
    30
   \<Longrightarrow> \<exists> c. (b,c) \<in> R \<and> (a,c) \<in> R\<^sup>*"
paulson@23449
    31
proof (neg_clausify)
paulson@23449
    32
assume 0: "f c = Intg x"
paulson@23449
    33
assume 1: "(a, b) \<in> R\<^sup>*"
paulson@23449
    34
assume 2: "(b, c) \<in> R\<^sup>*"
paulson@23449
    35
assume 3: "f b \<noteq> Intg x"
paulson@23449
    36
assume 4: "\<And>A. (b, A) \<notin> R \<or> (a, A) \<notin> R\<^sup>*"
paulson@23449
    37
have 5: "b = c \<or> b \<in> Domain R"
paulson@23449
    38
  by (metis Not_Domain_rtrancl 2)
paulson@23449
    39
have 6: "\<And>X1. (a, X1) \<in> R\<^sup>* \<or> (b, X1) \<notin> R"
paulson@23449
    40
  by (metis Transitive_Closure.rtrancl_into_rtrancl 1)
paulson@23449
    41
have 7: "\<And>X1. (b, X1) \<notin> R"
paulson@23449
    42
  by (metis 6 4)
paulson@23449
    43
have 8: "b \<notin> Domain R"
paulson@23449
    44
  by (metis 7 DomainE)
paulson@23449
    45
have 9: "c = b"
paulson@23449
    46
  by (metis 5 8)
paulson@23449
    47
have 10: "f b = Intg x"
paulson@23449
    48
  by (metis 0 9)
paulson@23449
    49
show "False"
paulson@23449
    50
  by (metis 10 3)
paulson@23449
    51
qed
paulson@23449
    52
boehmes@32864
    53
declare [[ atp_problem_prefix = "TransClosure__test_simpler" ]]
paulson@23449
    54
lemma "\<lbrakk> f c = Intg x; \<forall> y. f b = Intg y \<longrightarrow> y \<noteq> x; (a,b) \<in> R\<^sup>*; (b,c) \<in> R\<^sup>* \<rbrakk> 
paulson@23449
    55
   \<Longrightarrow> \<exists> c. (b,c) \<in> R \<and> (a,c) \<in> R\<^sup>*"
paulson@23449
    56
apply (erule_tac x="b" in converse_rtranclE)
paulson@23449
    57
apply (metis rel_pow_0_E rel_pow_0_I)
paulson@23449
    58
apply (metis DomainE Domain_iff Transitive_Closure.rtrancl_into_rtrancl)
paulson@23449
    59
done
paulson@23449
    60
paulson@23449
    61
end