3 Author: Lawrence C Paulson, Cambridge University Computer Laboratory
4 Copyright 1991 University of Cambridge
6 First-Order Logic: the 'if' example.
13 "if(P,Q,R) == P&Q | ~P&R"
16 "[| P ==> Q; ~P ==> R |] ==> if(P,Q,R)"
17 --{* @{subgoals[display,indent=0,margin=65]} *}
18 apply (simp add: if_def)
19 --{* @{subgoals[display,indent=0,margin=65]} *}
24 "[| if(P,Q,R); [| P; Q |] ==> S; [| ~P; R |] ==> S |] ==> S"
25 --{* @{subgoals[display,indent=0,margin=65]} *}
26 apply (simp add: if_def)
27 --{* @{subgoals[display,indent=0,margin=65]} *}
31 lemma if_commute: "if(P, if(Q,A,B), if(Q,C,D)) <-> if(Q, if(P,A,C), if(P,B,D))"
32 --{* @{subgoals[display,indent=0,margin=65]} *}
34 --{* @{subgoals[display,indent=0,margin=65]} *}
36 --{* @{subgoals[display,indent=0,margin=65]} *}
38 --{* @{subgoals[display,indent=0,margin=65]} *}
40 --{* @{subgoals[display,indent=0,margin=65]} *}
42 --{* @{subgoals[display,indent=0,margin=65]} *}
45 text{*Trying again from the beginning in order to use @{text blast}*}
49 lemma if_commute: "if(P, if(Q,A,B), if(Q,C,D)) <-> if(Q, if(P,A,C), if(P,B,D))"
53 lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,A,B))"
54 --{* @{subgoals[display,indent=0,margin=65]} *}
57 text{*Trying again from the beginning in order to prove from the definitions*}
58 lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,A,B))"
59 --{* @{subgoals[display,indent=0,margin=65]} *}
60 apply (simp add: if_def)
61 --{* @{subgoals[display,indent=0,margin=65]} *}
66 text{*An invalid formula. High-level rules permit a simpler diagnosis*}
67 lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,B,A))"
68 --{* @{subgoals[display,indent=0,margin=65]} *}
70 --{* @{subgoals[display,indent=0,margin=65]} *}
71 (*The next step will fail unless subgoals remain*)
72 apply (tactic all_tac)
75 text{*Trying again from the beginning in order to prove from the definitions*}
76 lemma "if(if(P,Q,R), A, B) <-> if(P, if(Q,A,B), if(R,B,A))"
77 --{* @{subgoals[display,indent=0,margin=65]} *}
78 apply (simp add: if_def)
79 --{* @{subgoals[display,indent=0,margin=65]} *}
81 --{* @{subgoals[display,indent=0,margin=65]} *}
82 (*The next step will fail unless subgoals remain*)
83 apply (tactic all_tac)