(* Load this file with "Isabelle Propositional.thy &" *) theory Propositional imports Main begin section {* Prelude *} text {* Provide syntax for <->. *} syntax iff :: "[bool, bool] => bool" (infixr "<->" 25) syntax (xsymbol) iff :: "[bool, bool] => bool" (infixr "\" 25) translations "P <-> Q" == "P = Q" text {* Provide rule names similar to those in Huth and Ryan's textbook. *} theorems conjE1 = conjunct1 theorems conjE2 = conjunct2 theorem mp: "[| P; P --> Q |] ==> Q" by blast theorems impE = mp theorem notE: "[| P; ~P |] ==> False" by blast theorem notnotE: "~ ~ P ==> P" by blast theorem PBC: "(~ P ==> False) ==> P" by blast section {* Introduction *} text {* Start reading from here! *} text {* To use Isabelle, invoke from zid-gpl.uibk.ac.at with the command: Isabelle Propositional.thy This starts xemacs with an Isabelle process in the background and opens the theory file Propositional.thy. For documentation see http://isabelle.in.tum.de. *} text {* A theory file has the following format: theory Filename imports Main begin end *} text {* The following commands are important for us: text A (usually long) textual comment. thm + Display theorems . theorem : "" State and prove proposition . The theorem will be named . (* *) A short comment. Can appear anywhere, even in formulas. *} text {* Proof commands: by (rule rule_name) Proof by application of a single natural-deduction rule. by blast Proof by automatic method. oops Aborts a failed proof attempt. And many more proof commands we are not concerned with. *} text {* Propositional connectives: ASCII symbol token, put between \ < and > negation: ~ \ not conjunction: & \ and disjunction: | \ or implication: --> \ longrightarrow if and only if: <-> \ longleftrightarrow contradiction: False derivability: ==> \ Longrightarrow Formulas must be put between quotes --- for example: "P & Q --> P", "P & Q ==> P". Notation for sequents: [| P1; P2; ...; Pn |] ==> P is Isabelle's notation for P1 P2 ... Pn P1, P2, ..., Pn \ P and --------------- P Note that in Isabelle "[| P1; P2; ...; Pn |] ==> P" is a formula. *} text {* xemacs commands: Invoking Isabelle Button Keystroke Process next command Next Ctrl-c Ctrl-n Undo command Undo Ctrl-c Ctrl-u Process up to point Goto Ctrl-c Ctrl-RET Interrupt Isabelle Stop Make pdf of current theory file: Menu: Isabelle > Commands > display draft Turn on display of math symbols: Menu: Proof-General > Options > X-Symbol *} section {* Propositional Logic *} subsection {* Natural Deduction Rules *} text {* conjunction *} thm conjI conjE1 conjE2 text {* disjunction *} thm disjI1 disjI2 disjE text {* implication *} thm impI impE text {* negation *} thm notI notE FalseE notnotE text {* derived rule *} thm PBC subsection {* Proofs *} text {* Proof of a distributive law. *} theorem "P | (Q & R) ==> (P | Q) & (P | R)" by blast text {* Proof of Pierce's law *} theorem Pierce: "((p --> q) --> p) --> p" by blast text {* One can also write natural deduction proofs in Isabelle, but you won't need to know how to do that. *} theorem "((p --> q) --> p) --> p" proof - { assume 1: "(p --> q) --> p" { assume 2: "~p" { assume 3: "p" from 3 and 2 have 4: "False" by (rule notE) from 4 have 5: "q" by (rule FalseE) } from this have 6: "p --> q" by (rule impI) from 6 and 1 have 7: "p" by (rule impE) from 7 and 2 have 8: "False" by (rule notE) } from this have 9: "p" by (rule PBC) } from this show "((p --> q) --> p) --> p" by (rule impI) qed subsection {* Modelling *} theorem "[| rainy | cloudy | sunny; sunny --> hot; rainy --> wet; ~hot; ~wet |] ==> cloudy" by blast theorem "[| rainy | cloudy | sunny; sunny --> hot; rainy --> wet; ~hot; ~wet |] ==> sunny" oops text {* Vier Kinder spielen mit dem Ball, bis ihn eines in ein Fenster wirft. Anna schreit: "Boris war es." Boris erwidert: "Nein, Christa war's." Christa meint: "Der Boris luegt!" Detlef sagt: "Ich war es nicht." Genau eines der Kinder sagt die Wahrheit. *} theorem "[| A <-> b; B <-> ~b; B <-> c; C <-> ~B; D <-> ~d; A --> ~B & ~C & ~D; B --> ~A & ~C & ~D; C --> ~A & ~B & ~D; D --> ~A & ~B & ~C |] ==> d" by blast text {* Transsylvanien wird bekanntlich ausser von ehrlichen Menschen von lügenhaften Vampiren bewohnt. Nicht jedermann ist geläufig, daß ausserdem jeder zweite Transsylvanier, ob Mensch oder Vampir, nicht ganz klar im Kopf ist. Die armen Irren halten Richtiges für falsch und Falsches für richtig. So wissen und sagen auch dort alle gesunden Menschen, dass die Erde rund ist. Die menschlichen Verrückten hingegen halten sie für flach. Gesunde Vampire kennen zwar den Globus, leugnen seine Kugelgestalt aber ab. Und die verrückten Vampire schließlich meinen, die Erde sei eine Scheibe, behaupten aber das Gegenteil. Auf einer Balkan-Reise traf Inspektor Craig in einer verdächtigen Gegend die hübschen Mädchen Minna und Lucy. Er war gewarnt worden, dass eine der beiden geheimnisvollen Schönen zur Sippschaft des Grafen Dracula gehöre; welche, vermochte der Engländer ihnen allerdings nicht anzusehen. Da sich Craig auch nach Sonnenuntergang keine Sorgen um seine Halsschlagadern machen wollte, bar er: "Erzählt mir etwas über euch!" Lucy: "Wir sind beide bescheuert." Craig: "Stimmt das?" Minna: "Natürlich nicht!" Mit welchem Mädchen verbrachte der Inspektor einen vergnüglichen Abend? *} end