src/FOLP/ex/Intro.thy
author wenzelm
Sat Jul 25 10:31:27 2009 +0200 (2009-07-25)
changeset 32187 cca43ca13f4f
parent 25991 31b38a39e589
child 35762 af3ff2ba4c54
permissions -rw-r--r--
renamed structure Display_Goal to Goal_Display;
wenzelm@25991
     1
(*  Title:      FOLP/ex/Intro.thy
wenzelm@25991
     2
    ID:         $Id$
wenzelm@25991
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
wenzelm@25991
     4
    Copyright   1992  University of Cambridge
wenzelm@25991
     5
wenzelm@25991
     6
Derives some inference rules, illustrating the use of definitions.
wenzelm@25991
     7
*)
wenzelm@25991
     8
wenzelm@25991
     9
header {* Examples for the manual ``Introduction to Isabelle'' *}
wenzelm@25991
    10
wenzelm@25991
    11
theory Intro
wenzelm@25991
    12
imports FOLP
wenzelm@25991
    13
begin
wenzelm@25991
    14
wenzelm@25991
    15
subsubsection {* Some simple backward proofs *}
wenzelm@25991
    16
wenzelm@25991
    17
lemma mythm: "?p : P|P --> P"
wenzelm@25991
    18
apply (rule impI)
wenzelm@25991
    19
apply (rule disjE)
wenzelm@25991
    20
prefer 3 apply (assumption)
wenzelm@25991
    21
prefer 2 apply (assumption)
wenzelm@25991
    22
apply assumption
wenzelm@25991
    23
done
wenzelm@25991
    24
wenzelm@25991
    25
lemma "?p : (P & Q) | R --> (P | R)"
wenzelm@25991
    26
apply (rule impI)
wenzelm@25991
    27
apply (erule disjE)
wenzelm@25991
    28
apply (drule conjunct1)
wenzelm@25991
    29
apply (rule disjI1)
wenzelm@25991
    30
apply (rule_tac [2] disjI2)
wenzelm@25991
    31
apply assumption+
wenzelm@25991
    32
done
wenzelm@25991
    33
wenzelm@25991
    34
(*Correct version, delaying use of "spec" until last*)
wenzelm@25991
    35
lemma "?p : (ALL x y. P(x,y)) --> (ALL z w. P(w,z))"
wenzelm@25991
    36
apply (rule impI)
wenzelm@25991
    37
apply (rule allI)
wenzelm@25991
    38
apply (rule allI)
wenzelm@25991
    39
apply (drule spec)
wenzelm@25991
    40
apply (drule spec)
wenzelm@25991
    41
apply assumption
wenzelm@25991
    42
done
wenzelm@25991
    43
wenzelm@25991
    44
wenzelm@25991
    45
subsubsection {* Demonstration of @{text "fast"} *}
wenzelm@25991
    46
wenzelm@25991
    47
lemma "?p : (EX y. ALL x. J(y,x) <-> ~J(x,x))
wenzelm@25991
    48
        -->  ~ (ALL x. EX y. ALL z. J(z,y) <-> ~ J(z,x))"
wenzelm@25991
    49
apply (tactic {* fast_tac FOLP_cs 1 *})
wenzelm@25991
    50
done
wenzelm@25991
    51
wenzelm@25991
    52
wenzelm@25991
    53
lemma "?p : ALL x. P(x,f(x)) <->
wenzelm@25991
    54
        (EX y. (ALL z. P(z,y) --> P(z,f(x))) & P(x,y))"
wenzelm@25991
    55
apply (tactic {* fast_tac FOLP_cs 1 *})
wenzelm@25991
    56
done
wenzelm@25991
    57
wenzelm@25991
    58
wenzelm@25991
    59
subsubsection {* Derivation of conjunction elimination rule *}
wenzelm@25991
    60
wenzelm@25991
    61
lemma
wenzelm@25991
    62
  assumes major: "p : P&Q"
wenzelm@25991
    63
    and minor: "!!x y. [| x : P; y : Q |] ==> f(x, y) : R"
wenzelm@25991
    64
  shows "?p : R"
wenzelm@25991
    65
apply (rule minor)
wenzelm@25991
    66
apply (rule major [THEN conjunct1])
wenzelm@25991
    67
apply (rule major [THEN conjunct2])
wenzelm@25991
    68
done
wenzelm@25991
    69
wenzelm@25991
    70
wenzelm@25991
    71
subsection {* Derived rules involving definitions *}
wenzelm@25991
    72
wenzelm@25991
    73
text {* Derivation of negation introduction *}
wenzelm@25991
    74
wenzelm@25991
    75
lemma
wenzelm@25991
    76
  assumes "!!x. x : P ==> f(x) : False"
wenzelm@25991
    77
  shows "?p : ~ P"
wenzelm@25991
    78
apply (unfold not_def)
wenzelm@25991
    79
apply (rule impI)
wenzelm@25991
    80
apply (rule prems)
wenzelm@25991
    81
apply assumption
wenzelm@25991
    82
done
wenzelm@25991
    83
wenzelm@25991
    84
lemma
wenzelm@25991
    85
  assumes major: "p : ~P"
wenzelm@25991
    86
    and minor: "q : P"
wenzelm@25991
    87
  shows "?p : R"
wenzelm@25991
    88
apply (rule FalseE)
wenzelm@25991
    89
apply (rule mp)
wenzelm@25991
    90
apply (rule major [unfolded not_def])
wenzelm@25991
    91
apply (rule minor)
wenzelm@25991
    92
done
wenzelm@25991
    93
wenzelm@25991
    94
text {* Alternative proof of the result above *}
wenzelm@25991
    95
lemma
wenzelm@25991
    96
  assumes major: "p : ~P"
wenzelm@25991
    97
    and minor: "q : P"
wenzelm@25991
    98
  shows "?p : R"
wenzelm@25991
    99
apply (rule minor [THEN major [unfolded not_def, THEN mp, THEN FalseE]])
wenzelm@25991
   100
done
wenzelm@25991
   101
wenzelm@25991
   102
end