doc-src/ZF/If.thy
author haftmann
Fri, 17 Jun 2005 16:12:49 +0200
changeset 16417 9bc16273c2d4
parent 14205 4ae8d65bc97c
child 19792 e8e3da6d3ff7
permissions -rw-r--r--
migrated theory headers to new format
paulson@14205
     1
(*  Title:      FOL/ex/If.ML
paulson@14205
     2
    ID:         $Id$
paulson@14205
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@14205
     4
    Copyright   1991  University of Cambridge
paulson@14205
     5
paulson@14205
     6
First-Order Logic: the 'if' example.
paulson@14205
     7
*)
paulson@14205
     8
haftmann@16417
     9
theory If imports FOL begin
paulson@14205
    10
paulson@14205
    11
constdefs
paulson@14205
    12
  if :: "[o,o,o]=>o"
paulson@14205
    13
   "if(P,Q,R) == P&Q | ~P&R"
paulson@14205
    14
paulson@14205
    15
lemma ifI:
paulson@14205
    16
    "[| P ==> Q; ~P ==> R |] ==> if(P,Q,R)"
paulson@14205
    17
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    18
apply (simp add: if_def)
paulson@14205
    19
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    20
apply blast
paulson@14205
    21
done
paulson@14205
    22
paulson@14205
    23
lemma ifE:
paulson@14205
    24
   "[| if(P,Q,R);  [| P; Q |] ==> S; [| ~P; R |] ==> S |] ==> S"
paulson@14205
    25
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    26
apply (simp add: if_def)
paulson@14205
    27
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    28
apply blast
paulson@14205
    29
done
paulson@14205
    30
paulson@14205
    31
lemma if_commute: "if(P, if(Q,A,B), if(Q,C,D)) <-> if(Q, if(P,A,C), if(P,B,D))"
paulson@14205
    32
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    33
apply (rule iffI)
paulson@14205
    34
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    35
apply (erule ifE)
paulson@14205
    36
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    37
apply (erule ifE)
paulson@14205
    38
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    39
apply (rule ifI)
paulson@14205
    40
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    41
apply (rule ifI)
paulson@14205
    42
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    43
oops
paulson@14205
    44
paulson@14205
    45
text{*Trying again from the beginning in order to use @{text blast}*}
paulson@14205
    46
declare ifI [intro!]
paulson@14205
    47
declare ifE [elim!]
paulson@14205
    48
paulson@14205
    49
lemma if_commute: "if(P, if(Q,A,B), if(Q,C,D)) <-> if(Q, if(P,A,C), if(P,B,D))"
paulson@14205
    50
by blast
paulson@14205
    51
paulson@14205
    52
paulson@14205
    53
lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,A,B))"
paulson@14205
    54
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    55
by blast
paulson@14205
    56
paulson@14205
    57
text{*Trying again from the beginning in order to prove from the definitions*}
paulson@14205
    58
lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,A,B))"
paulson@14205
    59
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    60
apply (simp add: if_def)
paulson@14205
    61
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    62
apply blast
paulson@14205
    63
done
paulson@14205
    64
paulson@14205
    65
paulson@14205
    66
text{*An invalid formula.  High-level rules permit a simpler diagnosis*}
paulson@14205
    67
lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,B,A))"
paulson@14205
    68
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    69
apply auto
paulson@14205
    70
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    71
(*The next step will fail unless subgoals remain*)
paulson@14205
    72
apply (tactic all_tac)
paulson@14205
    73
oops
paulson@14205
    74
paulson@14205
    75
text{*Trying again from the beginning in order to prove from the definitions*}
paulson@14205
    76
lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,B,A))"
paulson@14205
    77
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    78
apply (simp add: if_def)
paulson@14205
    79
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    80
apply (auto) 
paulson@14205
    81
  --{* @{subgoals[display,indent=0,margin=65]} *}
paulson@14205
    82
(*The next step will fail unless subgoals remain*)
paulson@14205
    83
apply (tactic all_tac)
paulson@14205
    84
oops
paulson@14205
    85
paulson@14205
    86
paulson@14205
    87
end