Nominal/Ex/SFT/Theorem.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Fri, 24 Jun 2011 10:30:06 +0900
changeset 2893 589b1a0c75e6
child 2894 8ec94871de1e
permissions -rw-r--r--
Second Fixed Point Theorem
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2893
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
header {* The main lemma about Num and the Second Fixed Point Theorem *}
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
theory Theorem imports Consts begin
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
(*<*)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
lemmas [simp] = b3[OF bI] b1 b4 b5 supp_Num[unfolded Num_def supp_ltgt] Num_def lam.fresh[unfolded fresh_def] fresh_def b6
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
lemmas app = Ltgt1_app
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
(*>*)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
lemma Num:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
  shows "Num \<cdot> \<lbrace>M\<rbrace> \<approx> \<lbrace>\<lbrace>M\<rbrace>\<rbrace>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
proof (induct M rule: lam.induct)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
  case (V n)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
  have "Num \<cdot> \<lbrace>V n\<rbrace> = Num \<cdot> (Var \<cdot> V n)" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
  also have "... = \<guillemotleft>[\<guillemotleft>[A1,A2,A3]\<guillemotright>]\<guillemotright> \<cdot> (Var \<cdot> V n)" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
  also have "... \<approx> Var \<cdot> V n \<cdot> \<guillemotleft>[A1,A2,A3]\<guillemotright>" using app .
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
  also have "... \<approx> \<guillemotleft>[A1,A2,A3]\<guillemotright> \<cdot> Umn 2 2 \<cdot> V n \<cdot> \<guillemotleft>[A1,A2,A3]\<guillemotright>" using Var_app .
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
  also have "... \<approx> A1 \<cdot> V n \<cdot> \<guillemotleft>[A1,A2,A3]\<guillemotright>" using U_app by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
  also have "... \<approx> F1 \<cdot> V n" using A_app(1) .
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
  also have "... \<approx> App \<cdot> \<lbrace>Var\<rbrace> \<cdot> (Var \<cdot> V n)" using F_app(1) .
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
  also have "... = \<lbrace>\<lbrace>V n\<rbrace>\<rbrace>" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
  finally show "Num \<cdot> \<lbrace>V n\<rbrace> \<approx> \<lbrace>\<lbrace>V n\<rbrace>\<rbrace>".
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
next
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  case (Ap M N)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
  assume IH: "Num \<cdot> \<lbrace>M\<rbrace> \<approx> \<lbrace>\<lbrace>M\<rbrace>\<rbrace>" "Num \<cdot> \<lbrace>N\<rbrace> \<approx> \<lbrace>\<lbrace>N\<rbrace>\<rbrace>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
  have "Num \<cdot> \<lbrace>M \<cdot> N\<rbrace> = Num \<cdot> (App \<cdot> \<lbrace>M\<rbrace> \<cdot> \<lbrace>N\<rbrace>)" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  also have "... = \<guillemotleft>[\<guillemotleft>[A1,A2,A3]\<guillemotright>]\<guillemotright> \<cdot> (App \<cdot> \<lbrace>M\<rbrace> \<cdot> \<lbrace>N\<rbrace>)" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
  also have "... \<approx> App \<cdot> \<lbrace>M\<rbrace> \<cdot> \<lbrace>N\<rbrace> \<cdot> \<guillemotleft>[A1,A2,A3]\<guillemotright>" using app .
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
  also have "... \<approx> \<guillemotleft>[A1,A2,A3]\<guillemotright> \<cdot> Umn 2 1 \<cdot> \<lbrace>M\<rbrace> \<cdot> \<lbrace>N\<rbrace> \<cdot> \<guillemotleft>[A1,A2,A3]\<guillemotright>" using App_app .
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
  also have "... \<approx> A2 \<cdot> \<lbrace>M\<rbrace> \<cdot> \<lbrace>N\<rbrace> \<cdot> \<guillemotleft>[A1,A2,A3]\<guillemotright>" using U_app by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
  also have "... \<approx> F2 \<cdot> \<lbrace>M\<rbrace> \<cdot> \<lbrace>N\<rbrace> \<cdot> Num" using A_app(2) by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
  also have "... \<approx> App \<cdot> (App \<cdot> \<lbrace>App\<rbrace> \<cdot> (Num \<cdot> \<lbrace>M\<rbrace>)) \<cdot> (Num \<cdot> \<lbrace>N\<rbrace>)" using F_app(2) .
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
  also have "... \<approx> App \<cdot> (App \<cdot> \<lbrace>App\<rbrace> \<cdot> (\<lbrace>\<lbrace>M\<rbrace>\<rbrace>)) \<cdot> (Num \<cdot> \<lbrace>N\<rbrace>)" using IH by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
  also have "... \<approx> \<lbrace>\<lbrace>M \<cdot> N\<rbrace>\<rbrace>" using IH by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
  finally show "Num \<cdot> \<lbrace>M \<cdot> N\<rbrace> \<approx> \<lbrace>\<lbrace>M \<cdot> N\<rbrace>\<rbrace>".
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
next
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
  case (Lm x P)
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
  assume IH: "Num \<cdot> \<lbrace>P\<rbrace> \<approx> \<lbrace>\<lbrace>P\<rbrace>\<rbrace>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
  have "Num \<cdot> \<lbrace>\<integral> x. P\<rbrace> = Num \<cdot> (Abs \<cdot> \<integral> x. \<lbrace>P\<rbrace>)" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
  also have "... = \<guillemotleft>[\<guillemotleft>[A1,A2,A3]\<guillemotright>]\<guillemotright> \<cdot> (Abs \<cdot> \<integral> x. \<lbrace>P\<rbrace>)" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
  also have "... \<approx> Abs \<cdot> (\<integral> x. \<lbrace>P\<rbrace>) \<cdot> \<guillemotleft>[A1,A2,A3]\<guillemotright>" using app .
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
  also have "... \<approx> \<guillemotleft>[A1,A2,A3]\<guillemotright> \<cdot> Umn 2 0 \<cdot> (\<integral> x. \<lbrace>P\<rbrace>) \<cdot> \<guillemotleft>[A1,A2,A3]\<guillemotright>" using Abs_app .
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
  also have "... \<approx> A3 \<cdot> (\<integral> x. \<lbrace>P\<rbrace>) \<cdot> \<guillemotleft>[A1,A2,A3]\<guillemotright>" using U_app by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
  also have "... \<approx> F3 \<cdot> (\<integral> x. \<lbrace>P\<rbrace>) \<cdot> \<guillemotleft>[\<guillemotleft>[A1,A2,A3]\<guillemotright>]\<guillemotright>" using A_app(3) .
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
  also have "... = F3 \<cdot> (\<integral> x. \<lbrace>P\<rbrace>) \<cdot> Num" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
  also have "... \<approx> App \<cdot> \<lbrace>Abs\<rbrace> \<cdot> (Abs \<cdot> \<integral> x. (Num \<cdot> ((\<integral> x. \<lbrace>P\<rbrace>) \<cdot> V x)))" by (rule F3_app) simp_all
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
  also have "... \<approx> App \<cdot> \<lbrace>Abs\<rbrace> \<cdot> (Abs \<cdot> \<integral> x. (Num \<cdot> \<lbrace>P\<rbrace>))" using beta_app by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
  also have "... \<approx> App \<cdot> \<lbrace>Abs\<rbrace> \<cdot> (Abs \<cdot> \<integral> x. \<lbrace>\<lbrace>P\<rbrace>\<rbrace>)" using IH by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
  also have "... = \<lbrace>\<lbrace>\<integral> x. P\<rbrace>\<rbrace>" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
  finally show "Num \<cdot> \<lbrace>\<integral> x. P\<rbrace> \<approx> \<lbrace>\<lbrace>\<integral> x. P\<rbrace>\<rbrace>" .
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
qed
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
lemmas [simp] = Ap Num
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
lemmas [simp del] = fresh_def Num_def
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
theorem SFP:
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
  fixes F :: lam
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
  shows "\<exists>X. X \<approx> F \<cdot> \<lbrace>X\<rbrace>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
proof -
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
  obtain x :: var where [simp]:"atom x \<sharp> F" using obtain_fresh by blast
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
  def W \<equiv> "\<integral>x. (F \<cdot> (App \<cdot> V x \<cdot> (Num \<cdot> V x)))"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
  def X \<equiv> "W \<cdot> \<lbrace>W\<rbrace>"
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
  have a: "X = W \<cdot> \<lbrace>W\<rbrace>" unfolding X_def ..
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
  also have "... = (\<integral>x. (F \<cdot> (App \<cdot> V x \<cdot> (Num \<cdot> V x)))) \<cdot> \<lbrace>W\<rbrace>" unfolding W_def ..
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
  also have "... \<approx> F \<cdot> (App \<cdot> \<lbrace>W\<rbrace> \<cdot> (Num \<cdot> \<lbrace>W\<rbrace>))" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
  also have "... \<approx> F \<cdot> (App \<cdot> \<lbrace>W\<rbrace> \<cdot> \<lbrace>\<lbrace>W\<rbrace>\<rbrace>)" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
  also have "... \<approx> F \<cdot> \<lbrace>W \<cdot> \<lbrace>W\<rbrace>\<rbrace>" by simp
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
  also have "... = F \<cdot> \<lbrace>X\<rbrace>" unfolding X_def ..
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
  finally show ?thesis by blast
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
qed
589b1a0c75e6 Second Fixed Point Theorem
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
(*>*)