src/HOL/IMP/Hoare_Total.thy
changeset 52333 ac2fb87a12f3
parent 52290 9be30aa5a39b
child 52373 a231e6f89737
equal deleted inserted replaced
52332:8cc665635f83 52333:ac2fb87a12f3
    30 If: "\<lbrakk> \<turnstile>\<^sub>t {\<lambda>s. P s \<and> bval b s} c\<^isub>1 {Q}; \<turnstile>\<^sub>t {\<lambda>s. P s \<and> \<not> bval b s} c\<^isub>2 {Q} \<rbrakk>
    30 If: "\<lbrakk> \<turnstile>\<^sub>t {\<lambda>s. P s \<and> bval b s} c\<^isub>1 {Q}; \<turnstile>\<^sub>t {\<lambda>s. P s \<and> \<not> bval b s} c\<^isub>2 {Q} \<rbrakk>
    31   \<Longrightarrow> \<turnstile>\<^sub>t {P} IF b THEN c\<^isub>1 ELSE c\<^isub>2 {Q}"  |
    31   \<Longrightarrow> \<turnstile>\<^sub>t {P} IF b THEN c\<^isub>1 ELSE c\<^isub>2 {Q}"  |
    32 
    32 
    33 While:
    33 While:
    34   "(\<And>n::nat.
    34   "(\<And>n::nat.
    35     \<turnstile>\<^sub>t {\<lambda>s. P s \<and> bval b s \<and> T s n} c {\<lambda>s. P s \<and> (\<exists>n'. T s n' \<and> n' < n)})
    35     \<turnstile>\<^sub>t {\<lambda>s. P s \<and> bval b s \<and> T s n} c {\<lambda>s. P s \<and> (\<exists>n'<n. T s n')})
    36    \<Longrightarrow> \<turnstile>\<^sub>t {\<lambda>s. P s \<and> (\<exists>n. T s n)} WHILE b DO c {\<lambda>s. P s \<and> \<not>bval b s}"  |
    36    \<Longrightarrow> \<turnstile>\<^sub>t {\<lambda>s. P s \<and> (\<exists>n. T s n)} WHILE b DO c {\<lambda>s. P s \<and> \<not>bval b s}"  |
    37 
    37 
    38 conseq: "\<lbrakk> \<forall>s. P' s \<longrightarrow> P s; \<turnstile>\<^sub>t {P}c{Q}; \<forall>s. Q s \<longrightarrow> Q' s  \<rbrakk> \<Longrightarrow>
    38 conseq: "\<lbrakk> \<forall>s. P' s \<longrightarrow> P s; \<turnstile>\<^sub>t {P}c{Q}; \<forall>s. Q s \<longrightarrow> Q' s  \<rbrakk> \<Longrightarrow>
    39            \<turnstile>\<^sub>t {P'}c{Q'}"
    39            \<turnstile>\<^sub>t {P'}c{Q'}"
    40 
    40 
   175   let ?T = "Its b c"
   175   let ?T = "Its b c"
   176   have "\<forall>s. wp\<^sub>t ?w Q s \<longrightarrow> wp\<^sub>t ?w Q s \<and> (\<exists>n. Its b c s n)"
   176   have "\<forall>s. wp\<^sub>t ?w Q s \<longrightarrow> wp\<^sub>t ?w Q s \<and> (\<exists>n. Its b c s n)"
   177     unfolding wpt_def by (metis WHILE_Its)
   177     unfolding wpt_def by (metis WHILE_Its)
   178   moreover
   178   moreover
   179   { fix n
   179   { fix n
   180     let ?R = "\<lambda>s'. wp\<^sub>t ?w Q s' \<and> (\<exists>n'. ?T s' n' \<and> n' < n)"
   180     let ?R = "\<lambda>s'. wp\<^sub>t ?w Q s' \<and> (\<exists>n'<n. ?T s' n')"
   181     { fix s t assume "bval b s" and "?T s n" and "(?w, s) \<Rightarrow> t" and "Q t"
   181     { fix s t assume "bval b s" and "?T s n" and "(?w, s) \<Rightarrow> t" and "Q t"
   182       from `bval b s` and `(?w, s) \<Rightarrow> t` obtain s' where
   182       from `bval b s` and `(?w, s) \<Rightarrow> t` obtain s' where
   183         "(c,s) \<Rightarrow> s'" "(?w,s') \<Rightarrow> t" by auto
   183         "(c,s) \<Rightarrow> s'" "(?w,s') \<Rightarrow> t" by auto
   184       from `(?w, s') \<Rightarrow> t` obtain n' where "?T s' n'"
   184       from `(?w, s') \<Rightarrow> t` obtain n' where "?T s' n'"
   185         by (blast dest: WHILE_Its)
   185         by (blast dest: WHILE_Its)