src/HOL/IMP/Complete_Lattice.thy
author wenzelm
Mon, 24 Oct 2016 15:00:13 +0200
changeset 64375 74a2af7c5145
parent 58889 5b7a9633cfa8
child 67613 ce654b0e6d69
permissions -rw-r--r--
remove old target: it is on the classpath and may break scalac;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58889
5b7a9633cfa8 modernized header uniformly as section;
wenzelm
parents: 49487
diff changeset
     1
section "Abstract Interpretation"
49487
7e7ac4956117 conected CS to big-step
nipkow
parents: 48759
diff changeset
     2
48759
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
     3
theory Complete_Lattice
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
     4
imports Main
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
     5
begin
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
     6
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
     7
locale Complete_Lattice =
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
     8
fixes L :: "'a::order set" and Glb :: "'a set \<Rightarrow> 'a"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
     9
assumes Glb_lower: "A \<subseteq> L \<Longrightarrow> a \<in> A \<Longrightarrow> Glb A \<le> a"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    10
and Glb_greatest: "b : L \<Longrightarrow> \<forall>a\<in>A. b \<le> a \<Longrightarrow> b \<le> Glb A"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    11
and Glb_in_L: "A \<subseteq> L \<Longrightarrow> Glb A : L"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    12
begin
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    13
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    14
definition lfp :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a" where
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    15
"lfp f = Glb {a : L. f a \<le> a}"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    16
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    17
lemma index_lfp: "lfp f : L"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    18
by(auto simp: lfp_def intro: Glb_in_L)
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    19
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    20
lemma lfp_lowerbound:
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    21
  "\<lbrakk> a : L;  f a \<le> a \<rbrakk> \<Longrightarrow> lfp f \<le> a"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    22
by (auto simp add: lfp_def intro: Glb_lower)
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    23
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    24
lemma lfp_greatest:
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    25
  "\<lbrakk> a : L;  \<And>u. \<lbrakk> u : L; f u \<le> u\<rbrakk> \<Longrightarrow> a \<le> u \<rbrakk> \<Longrightarrow> a \<le> lfp f"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    26
by (auto simp add: lfp_def intro: Glb_greatest)
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    27
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    28
lemma lfp_unfold: assumes "\<And>x. f x : L \<longleftrightarrow> x : L"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    29
and mono: "mono f" shows "lfp f = f (lfp f)"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    30
proof-
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    31
  note assms(1)[simp] index_lfp[simp]
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    32
  have 1: "f (lfp f) \<le> lfp f"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    33
    apply(rule lfp_greatest)
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    34
    apply simp
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    35
    by (blast intro: lfp_lowerbound monoD[OF mono] order_trans)
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    36
  have "lfp f \<le> f (lfp f)"
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    37
    by (fastforce intro: 1 monoD[OF mono] lfp_lowerbound)
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    38
  with 1 show ?thesis by(blast intro: order_antisym)
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    39
qed
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    40
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    41
end
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    42
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    43
end
ff570720ba1c Improved complete lattice formalisation - no more index set.
nipkow
parents:
diff changeset
    44