(* sol.thy,v 1.1 2017/10/14 13:13:56 jdf Exp Original Author: Tjark Weber Updated to Isabelle 2016 by Jacques Fleuriot *) section {* Predicate Logic *} theory sol imports Main begin text {* We are again talking about proofs in the calculus of Natural Deduction. In addition to the rules given in the exercise ``Propositional Logic'', you may now also use exI: ?P ?x \ \x. ?P x exE:\\x. ?P x; \x. ?P x \ ?Q\ \ ?Q allI: (\x. ?P x) \ \x. ?P x allE: \\x. ?P x; ?P ?x \ ?R\ \ ?R Give a proof of the following propositions or an argument why the formula is not valid: *} lemma "(\x. \y. P x y) \ (\y. \x. P x y)" apply (rule impI) apply (erule exE) apply (rule allI) apply (erule allE) apply (rule exI) apply assumption done lemma "(\x. P x \ Q) = ((\x. P x) \ Q)" apply (rule iffI) apply (rule impI) apply (erule exE) apply (erule allE) apply (erule impE) apply assumption+ apply (rule allI) apply (rule impI) apply (erule impE) apply (rule exI) apply assumption+ done lemma "((\ x. P x) \ (\ x. Q x)) = (\ x. (P x \ Q x))" apply (rule iffI) apply (erule conjE) apply (rule allI) apply (erule allE)+ apply (rule conjI) apply assumption+ apply (rule conjI) apply (rule allI) apply (erule allE) apply (erule conjE) apply assumption apply (rule allI) apply (erule allE) apply (erule conjE) apply assumption done lemma "((\ x. P x) \ (\ x. Q x)) = (\ x. (P x \ Q x))" (* Quickcheck should find a counterexample automatically *) oops text {* A possible counterexample is: "P = even", "Q = odd", interpreted over the domain of the natural numbers. *} lemma "((\ x. P x) \ (\ x. Q x)) = (\ x. (P x \ Q x))" apply (rule iffI) apply (erule disjE) apply (erule exE) apply (rule exI) apply (rule disjI1) apply assumption apply (erule exE) apply (rule exI) apply (rule disjI2) apply assumption apply (erule exE) apply (erule disjE) apply (rule disjI1) apply (rule exI) apply assumption apply (rule disjI2) apply (rule exI) apply assumption done lemma "(\x. \y. P x y) \ (\y. \x. P x y)" (* Quickcheck should find a counterexample automatically *) oops text {* For a possible counterexample, let "P x y" be the statement "y is the successor of x", interpreted over the domain of the natural numbers. *} lemma "(\ (\ x. P x)) = (\ x. \ P x)" apply (rule iffI) apply (rule classical) apply (erule notE) apply (rule allI) apply (rule classical) apply (erule notE) apply (rule exI) apply assumption apply (erule exE) apply (rule notI) apply (erule allE) apply (erule notE) apply assumption done end