src/HOL/Isar_examples/BasicLogic.thy
changeset 7740 2fbe5ce9845f
parent 7604 55566b9ec7d7
child 7748 5b9c45b21782
equal deleted inserted replaced
7739:bfe45b716dfc 7740:2fbe5ce9845f
     5 Basic propositional and quantifier reasoning.
     5 Basic propositional and quantifier reasoning.
     6 *)
     6 *)
     7 
     7 
     8 theory BasicLogic = Main:;
     8 theory BasicLogic = Main:;
     9 
     9 
       
    10 
       
    11 subsection {* Some trivialities *};
    10 
    12 
    11 text {* Just a few toy examples to get an idea of how Isabelle/Isar
    13 text {* Just a few toy examples to get an idea of how Isabelle/Isar
    12   proof documents may look like. *};
    14   proof documents may look like. *};
    13 
    15 
    14 lemma I: "A --> A";
    16 lemma I: "A --> A";
   101   from ab; have b: B; ..;
   103   from ab; have b: B; ..;
   102   from b a; show "B & A"; ..;
   104   from b a; show "B & A"; ..;
   103 qed;
   105 qed;
   104 
   106 
   105 
   107 
   106 section {* Examples from 'Introduction to Isabelle' *};
   108 subsection {* A few examples from ``Introduction to Isabelle'' *};
   107 
   109 
   108 text {* 'Propositional proof' *};
   110 subsubsection {* Propositional proof *};
   109 
   111 
   110 lemma "P | P --> P";
   112 lemma "P | P --> P";
   111 proof;
   113 proof;
   112   assume "P | P";
   114   assume "P | P";
   113   then; show P;
   115   then; show P;
   123   assume "P | P";
   125   assume "P | P";
   124   then; show P; ..;
   126   then; show P; ..;
   125 qed;
   127 qed;
   126 
   128 
   127 
   129 
   128 text {* 'Quantifier proof' *};
   130 subsubsection {* Quantifier proof *};
   129 
   131 
   130 lemma "(EX x. P(f(x))) --> (EX x. P(x))";
   132 lemma "(EX x. P(f(x))) --> (EX x. P(x))";
   131 proof;
   133 proof;
   132   assume "EX x. P(f(x))";
   134   assume "EX x. P(f(x))";
   133   then; show "EX x. P(x)";
   135   then; show "EX x. P(x)";
   151 
   153 
   152 lemma "(EX x. P(f(x))) --> (EX x. P(x))";
   154 lemma "(EX x. P(f(x))) --> (EX x. P(x))";
   153   by blast;
   155   by blast;
   154 
   156 
   155 
   157 
   156 subsection {* 'Deriving rules in Isabelle' *};
   158 subsubsection {* Deriving rules in Isabelle *};
   157 
   159 
   158 text {* We derive the conjunction elimination rule from the
   160 text {* We derive the conjunction elimination rule from the
   159  projections.  The proof below follows the basic reasoning of the
   161  projections.  The proof below follows the basic reasoning of the
   160  script given in the Isabelle Intro Manual closely.  Although, the
   162  script given in the Isabelle Intro Manual closely.  Although, the
   161  actual underlying operations on rules and proof states are quite
   163  actual underlying operations on rules and proof states are quite