src/HOL/Isar_Examples/Structured_Statements.thy
changeset 62314 ec0fbd1a852b
parent 61799 4cf66f21b764
child 63583 a39baba12732
equal deleted inserted replaced
62313:aaeee16a56f5 62314:ec0fbd1a852b
    15   fix A B :: bool
    15   fix A B :: bool
    16   fix P :: "'a \<Rightarrow> bool"
    16   fix P :: "'a \<Rightarrow> bool"
    17 
    17 
    18   have "A \<longrightarrow> B"
    18   have "A \<longrightarrow> B"
    19   proof
    19   proof
    20     show B if A using that sorry
    20     show B if A using that \<proof>
    21   qed
    21   qed
    22 
    22 
    23   have "\<not> A"
    23   have "\<not> A"
    24   proof
    24   proof
    25     show False if A using that sorry
    25     show False if A using that \<proof>
    26   qed
    26   qed
    27 
    27 
    28   have "\<forall>x. P x"
    28   have "\<forall>x. P x"
    29   proof
    29   proof
    30     show "P x" for x sorry
    30     show "P x" for x \<proof>
    31   qed
    31   qed
    32 end
    32 end
    33 
    33 
    34 
    34 
    35 subsection \<open>If-and-only-if\<close>
    35 subsection \<open>If-and-only-if\<close>
    38 begin
    38 begin
    39   fix A B :: bool
    39   fix A B :: bool
    40 
    40 
    41   have "A \<longleftrightarrow> B"
    41   have "A \<longleftrightarrow> B"
    42   proof
    42   proof
    43     show B if A sorry
    43     show B if A \<proof>
    44     show A if B sorry
    44     show A if B \<proof>
    45   qed
    45   qed
    46 next
    46 next
    47   fix A B :: bool
    47   fix A B :: bool
    48 
    48 
    49   have iff_comm: "(A \<and> B) \<longleftrightarrow> (B \<and> A)"
    49   have iff_comm: "(A \<and> B) \<longleftrightarrow> (B \<and> A)"
    84   consider (a) A | (b) B | (c) C | (d) D
    84   consider (a) A | (b) B | (c) C | (d) D
    85     using * by blast
    85     using * by blast
    86   then have something
    86   then have something
    87   proof cases
    87   proof cases
    88     case a  thm \<open>A\<close>
    88     case a  thm \<open>A\<close>
    89     then show ?thesis sorry
    89     then show ?thesis \<proof>
    90   next
    90   next
    91     case b  thm \<open>B\<close>
    91     case b  thm \<open>B\<close>
    92     then show ?thesis sorry
    92     then show ?thesis \<proof>
    93   next
    93   next
    94     case c  thm \<open>C\<close>
    94     case c  thm \<open>C\<close>
    95     then show ?thesis sorry
    95     then show ?thesis \<proof>
    96   next
    96   next
    97     case d  thm \<open>D\<close>
    97     case d  thm \<open>D\<close>
    98     then show ?thesis sorry
    98     then show ?thesis \<proof>
    99   qed
    99   qed
   100 next
   100 next
   101   fix A :: "'a \<Rightarrow> bool"
   101   fix A :: "'a \<Rightarrow> bool"
   102   fix B :: "'b \<Rightarrow> 'c \<Rightarrow> bool"
   102   fix B :: "'b \<Rightarrow> 'c \<Rightarrow> bool"
   103   assume *: "(\<exists>x. A x) \<or> (\<exists>y z. B y z)"
   103   assume *: "(\<exists>x. A x) \<or> (\<exists>y z. B y z)"
   105   consider (a) x where "A x" | (b) y z where "B y z"
   105   consider (a) x where "A x" | (b) y z where "B y z"
   106     using * by blast
   106     using * by blast
   107   then have something
   107   then have something
   108   proof cases
   108   proof cases
   109     case a  thm \<open>A x\<close>
   109     case a  thm \<open>A x\<close>
   110     then show ?thesis sorry
   110     then show ?thesis \<proof>
   111   next
   111   next
   112     case b  thm \<open>B y z\<close>
   112     case b  thm \<open>B y z\<close>
   113     then show ?thesis sorry
   113     then show ?thesis \<proof>
   114   qed
   114   qed
   115 end
   115 end
   116 
   116 
   117 
   117 
   118 subsection \<open>Induction\<close>
   118 subsection \<open>Induction\<close>
   122   fix P :: "nat \<Rightarrow> bool"
   122   fix P :: "nat \<Rightarrow> bool"
   123   fix n :: nat
   123   fix n :: nat
   124 
   124 
   125   have "P n"
   125   have "P n"
   126   proof (induct n)
   126   proof (induct n)
   127     show "P 0" sorry
   127     show "P 0" \<proof>
   128     show "P (Suc n)" if "P n" for n  thm \<open>P n\<close>
   128     show "P (Suc n)" if "P n" for n  thm \<open>P n\<close>
   129       using that sorry
   129       using that \<proof>
   130   qed
   130   qed
   131 end
   131 end
   132 
   132 
   133 
   133 
   134 subsection \<open>Suffices-to-show\<close>
   134 subsection \<open>Suffices-to-show\<close>
   140 
   140 
   141   have C
   141   have C
   142   proof -
   142   proof -
   143     show ?thesis when A (is ?A) and B (is ?B)
   143     show ?thesis when A (is ?A) and B (is ?B)
   144       using that by (rule r)
   144       using that by (rule r)
   145     show ?A sorry
   145     show ?A \<proof>
   146     show ?B sorry
   146     show ?B \<proof>
   147   qed
   147   qed
   148 next
   148 next
   149   fix a :: 'a
   149   fix a :: 'a
   150   fix A :: "'a \<Rightarrow> bool"
   150   fix A :: "'a \<Rightarrow> bool"
   151   fix C
   151   fix C
   152 
   152 
   153   have C
   153   have C
   154   proof -
   154   proof -
   155     show ?thesis when "A x" (is ?A) for x :: 'a  \<comment> \<open>abstract @{term x}\<close>
   155     show ?thesis when "A x" (is ?A) for x :: 'a  \<comment> \<open>abstract @{term x}\<close>
   156       using that sorry
   156       using that \<proof>
   157     show "?A a"  \<comment> \<open>concrete @{term a}\<close>
   157     show "?A a"  \<comment> \<open>concrete @{term a}\<close>
   158       sorry
   158       \<proof>
   159   qed
   159   qed
   160 end
   160 end
   161 
   161 
   162 end
   162 end