src/FOL/ex/If.thy
author wenzelm
Sun, 26 Nov 2006 23:43:53 +0100
changeset 21539 c5cf9243ad62
parent 19796 d86e7b1fc472
child 31974 e81979a703a4
permissions -rw-r--r--
converted legacy ML scripts;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
     1
(*  Title:      FOL/ex/If.ML
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
     2
    ID:         $Id$
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
     4
    Copyright   1991  University of Cambridge
14957
0e94a1ccc6ae tuned document;
wenzelm
parents: 14151
diff changeset
     5
*)
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
     6
14957
0e94a1ccc6ae tuned document;
wenzelm
parents: 14151
diff changeset
     7
header {* First-Order Logic: the 'if' example *}
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
     8
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 14957
diff changeset
     9
theory If imports FOL begin
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    10
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    11
constdefs
19796
d86e7b1fc472 quoted "if";
wenzelm
parents: 16417
diff changeset
    12
  "if" :: "[o,o,o]=>o"
d86e7b1fc472 quoted "if";
wenzelm
parents: 16417
diff changeset
    13
  "if(P,Q,R) == P&Q | ~P&R"
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    14
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    15
lemma ifI:
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    16
    "[| P ==> Q; ~P ==> R |] ==> if(P,Q,R)"
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    17
apply (simp add: if_def, blast)
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    18
done
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    19
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    20
lemma ifE:
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    21
   "[| if(P,Q,R);  [| P; Q |] ==> S; [| ~P; R |] ==> S |] ==> S"
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    22
apply (simp add: if_def, blast)
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    23
done
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    24
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    25
lemma if_commute: "if(P, if(Q,A,B), if(Q,C,D)) <-> if(Q, if(P,A,C), if(P,B,D))"
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    26
apply (rule iffI)
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    27
apply (erule ifE)
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    28
apply (erule ifE)
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    29
apply (rule ifI)
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    30
apply (rule ifI)
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    31
oops
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    32
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    33
text{*Trying again from the beginning in order to use @{text blast}*}
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    34
declare ifI [intro!]
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    35
declare ifE [elim!]
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    36
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    37
lemma if_commute: "if(P, if(Q,A,B), if(Q,C,D)) <-> if(Q, if(P,A,C), if(P,B,D))"
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    38
by blast
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    39
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    40
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    41
lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,A,B))"
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    42
by blast
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
text{*Trying again from the beginning in order to prove from the definitions*}
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    45
lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,A,B))"
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    46
by (simp add: if_def, blast)
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    47
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    48
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    49
text{*An invalid formula.  High-level rules permit a simpler diagnosis*}
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    50
lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,B,A))"
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    51
apply auto
14957
0e94a1ccc6ae tuned document;
wenzelm
parents: 14151
diff changeset
    52
  -- {*The next step will fail unless subgoals remain*}
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    53
apply (tactic all_tac)
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    54
oops
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    55
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    56
text{*Trying again from the beginning in order to prove from the definitions*}
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    57
lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,B,A))"
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    58
apply (simp add: if_def, auto) 
14957
0e94a1ccc6ae tuned document;
wenzelm
parents: 14151
diff changeset
    59
  -- {*The next step will fail unless subgoals remain*}
14151
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    60
apply (tactic all_tac)
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    61
oops
b8bb6a6a2c46 converting ex/If to Isar script
paulson
parents: 1322
diff changeset
    62
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
end