theory Demo1 imports Main begin section{* Propositional logic *} subsection{* Basic rules *} text{* \ *} thm conjI conjE conjunct1 conjunct2 text{* \ *} thm disjI1 disjI2 disjE text{* \ *} thm impI impE mp text{* = (iff) *} thm iffI iffE iffD1 iffD2 text{* \ *} thm notI notE text{* Contradictions *} thm FalseE ccontr classical subsection{* Examples *} text{* a simple backward step: *} lemma "A \ B" apply(rule conjI) oops text{* a simple backward proof: *} lemma "B \ A \ A \ B" apply(rule impI) apply(rule conjI) apply(rule conjE) apply(assumption) apply(assumption) apply(rule conjE) apply(assumption) apply(assumption) done text{* a shorter version: *} lemma "B \ A \ A \ B" apply(rule impI) apply(rule conjE) apply(assumption) apply(rule conjI) apply(assumption) apply(assumption) done text{* Elimination rules should be applied with erule: *} lemma "B \ A \ A \ B" apply(rule impI) apply(erule conjE) apply(rule conjI) apply(assumption) apply(assumption) done (* For interactive proofs developed together with the students: *) lemma "A \ B \ B \ A" oops lemma "\ A \ B; B \ C \ \ A \ C" oops lemma "\A \ \B \ \(A \ B)" oops text{* This one is tricky! *} lemma "\(A \ B) \ \A \ \B" oops subsection{* Further useful techniques *} text{* Of course, simple proofs are performed automatically: *} lemma "B \ A \ A \ B" apply(blast) done text{* Similar to "blast": "fast" *} text{* How to convert @{text"\"} back to @{text"\"} automatically: *} lemma [rule_format]: "A \ A \ A" apply blast done text{* Explicit case distinctions: *} lemma "((P \ Q) \ P) \ P" apply(case_tac P) apply(simp) apply(simp) done text{* Explicit backtracking: *} lemma "\ P \ Q; A \ B \ \ A" apply(erule conjE) back apply(assumption) done text{* UGLY! NOT ALLOWED IN FINAL SOLUTION! *} text{* Implict backtracking: *} lemma "\ P \ Q; A \ B \ \ A" apply(erule conjE, assumption) done end