src/FOL/ex/If.thy
author wenzelm
Thu, 03 Jan 2019 22:19:19 +0100
changeset 69590 e65314985426
parent 62020 5d208fd2507d
permissions -rw-r--r--
isabelle update_inner_syntax_cartouches;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41777
1f7cbe39d425 more precise headers;
wenzelm
parents: 35416
diff changeset
     1
(*  Title:      FOL/ex/If.thy
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
     3
    Copyright   1991  University of Cambridge
14957
0e94a1ccc6ae tuned document;
wenzelm
parents: 14151
diff changeset
     4
*)
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
     5
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
     6
section \<open>First-Order Logic: the 'if' example\<close>
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
     7
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
     8
theory If
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
     9
imports FOL
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    10
begin
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    11
69590
e65314985426 isabelle update_inner_syntax_cartouches;
wenzelm
parents: 62020
diff changeset
    12
definition "if" :: \<open>[o,o,o]=>o\<close>
e65314985426 isabelle update_inner_syntax_cartouches;
wenzelm
parents: 62020
diff changeset
    13
  where \<open>if(P,Q,R) \<equiv> P \<and> Q \<or> \<not> P \<and> R\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    14
69590
e65314985426 isabelle update_inner_syntax_cartouches;
wenzelm
parents: 62020
diff changeset
    15
lemma ifI: \<open>\<lbrakk>P \<Longrightarrow> Q; \<not> P \<Longrightarrow> R\<rbrakk> \<Longrightarrow> if(P,Q,R)\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    16
  unfolding if_def by blast
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    17
69590
e65314985426 isabelle update_inner_syntax_cartouches;
wenzelm
parents: 62020
diff changeset
    18
lemma ifE: \<open>\<lbrakk>if(P,Q,R); \<lbrakk>P; Q\<rbrakk> \<Longrightarrow> S; \<lbrakk>\<not> P; R\<rbrakk> \<Longrightarrow> S\<rbrakk> \<Longrightarrow> S\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    19
  unfolding if_def by blast
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    20
69590
e65314985426 isabelle update_inner_syntax_cartouches;
wenzelm
parents: 62020
diff changeset
    21
lemma if_commute: \<open>if(P, if(Q,A,B), if(Q,C,D)) \<longleftrightarrow> if(Q, if(P,A,C), if(P,B,D))\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    22
  apply (rule iffI)
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    23
  apply (erule ifE)
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    24
  apply (erule ifE)
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    25
  apply (rule ifI)
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    26
  apply (rule ifI)
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    27
  oops
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    28
62020
5d208fd2507d isabelle update_cartouches -c -t;
wenzelm
parents: 61489
diff changeset
    29
text\<open>Trying again from the beginning in order to use \<open>blast\<close>\<close>
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    30
declare ifI [intro!]
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    31
declare ifE [elim!]
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    32
69590
e65314985426 isabelle update_inner_syntax_cartouches;
wenzelm
parents: 62020
diff changeset
    33
lemma if_commute: \<open>if(P, if(Q,A,B), if(Q,C,D)) \<longleftrightarrow> if(Q, if(P,A,C), if(P,B,D))\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    34
  by blast
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    35
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    36
69590
e65314985426 isabelle update_inner_syntax_cartouches;
wenzelm
parents: 62020
diff changeset
    37
lemma \<open>if(if(P,Q,R), A, B) \<longleftrightarrow> if(P, if(Q,A,B), if(R,A,B))\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    38
  by blast
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    39
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    40
text\<open>Trying again from the beginning in order to prove from the definitions\<close>
69590
e65314985426 isabelle update_inner_syntax_cartouches;
wenzelm
parents: 62020
diff changeset
    41
lemma \<open>if(if(P,Q,R), A, B) \<longleftrightarrow> if(P, if(Q,A,B), if(R,A,B))\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    42
  unfolding if_def by blast
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    43
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    44
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    45
text \<open>An invalid formula. High-level rules permit a simpler diagnosis.\<close>
69590
e65314985426 isabelle update_inner_syntax_cartouches;
wenzelm
parents: 62020
diff changeset
    46
lemma \<open>if(if(P,Q,R), A, B) \<longleftrightarrow> if(P, if(Q,A,B), if(R,B,A))\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    47
  apply auto
62020
5d208fd2507d isabelle update_cartouches -c -t;
wenzelm
parents: 61489
diff changeset
    48
    \<comment> \<open>The next step will fail unless subgoals remain\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    49
  apply (tactic all_tac)
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    50
  oops
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    51
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    52
text \<open>Trying again from the beginning in order to prove from the definitions.\<close>
69590
e65314985426 isabelle update_inner_syntax_cartouches;
wenzelm
parents: 62020
diff changeset
    53
lemma \<open>if(if(P,Q,R), A, B) \<longleftrightarrow> if(P, if(Q,A,B), if(R,B,A))\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    54
  unfolding if_def
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    55
  apply auto
62020
5d208fd2507d isabelle update_cartouches -c -t;
wenzelm
parents: 61489
diff changeset
    56
    \<comment> \<open>The next step will fail unless subgoals remain\<close>
61489
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    57
  apply (tactic all_tac)
b8d375aee0df more symbols;
wenzelm
parents: 60770
diff changeset
    58
  oops
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    59
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
end