150 likes | 250 Views
MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson, A207 paul.gibson@it-sudparis.eu http://www-public. it-sudparis.eu /~gibson/Teaching/MAT7003/. Logic – Sample Answers …/~gibson/Teaching/MAT7003/L4-Logic-SampleAnswers.pdf. How to Use Propositional Logic?.
E N D
MAT 7003 : MathematicalFoundations (for Software Engineering) J Paul Gibson, A207 paul.gibson@it-sudparis.eu http://www-public.it-sudparis.eu/~gibson/Teaching/MAT7003/ Logic – SampleAnswers …/~gibson/Teaching/MAT7003/L4-Logic-SampleAnswers.pdf TSP: MathematicalFoundations
How to Use Propositional Logic? Problem: Determine the validity of the followingreasoning « Paul caneat if he has cooked a meal in the last 30 minutes and heishungry. He ishungryprovidedhe has not eaten in the last 15 minutes and in the last 30 minutes he has not doneany sport. If heisdoing sport hecannotcook a mealat the sametime.Therefore if Paul did not eathehadalreadyeaten in the last 15 minutes or hedid sport in the last 30 minutes » TSP: MathematicalFoundations
Formalising the reasoningusing the set BOOL ( {TRUE, FALSE}) in Event-B NOTE: The importance of the presciseinterpreation of the naturallanguagetext; in particularwordssuch as: can, should, could, must, may. Intuitively, the reasoning (expressed in theoremaxm9) must be false as nothing obliges Paul to eat (or cook). Wewillseethiswhenwelaunch the Rodin prover on thistheorem … TSP: MathematicalFoundations
Formalising the reasoningusing the set BOOL ( {TRUE, FALSE}) in Event-B The prover shows that the theoremis false when Paul is not eating, he has not eaten, he has not done sport and has not cooked TSP: MathematicalFoundations
Alternatively, wecanalso use the proverdirectly to show that the reasoningiswrong Wenow know underwhat conditions the reasoningfails Theorem: the reasoningiswrong TSP: MathematicalFoundations
Alternatively, wecanalso use the proverdirectly to show that the reasoningiswrong TO DO: Change the specificationsothat Paul isobliged to cook and eatwhenheishungry TSP: MathematicalFoundations
Specifications in Predicate Logic Which of the following formulae are valid (true), and why? 1 2 3 45 6 7 TSP: MathematicalFoundations
Specifications in PredicateLogic: lemma 7 This lemmais, perhaps, the mostobviouslytrue. So lets put itinto RODIN in Event-B, using the BOOL set. TSP: MathematicalFoundations
Specifications in PredicateLogic: lemma 7 Not surprisingly, the Proverdischargesthisautomatically TSP: MathematicalFoundations
Specifications in PredicateLogic: lemmas 1 to 3 The proverdischarges 3 automatically, sowe know itistrue (provided the lemmaisproperlyspecified in Event-B). However, lemma1 and lemma2 are not provenautomatically -doesthismeanthey are false? TO DO: verify and complete the lemmasusing the same style (based on BOOL functions) TSP: MathematicalFoundations
Specifications in PredicateLogic: another more direct specification style Wecouldalsorepresent the lemma in a more direct wayusing a set – PSet, say - to explicitlyrepresent the subset if the universe for which the predicatePistrue: QUESTION: Which of the representationsisbest? TO DO: verify and complete the lemmasusingthis new style of specification (based on set membership) TSP: MathematicalFoundations
Specifications in Predicate Logic TSP: MathematicalFoundations
Specifications in Predicate Logic • Express the followingusingpredicatelogic • Susan introduced Mary to a studentthatnobodyliked. • Only-if John has-talked-to everywitnesswill Mary be-satisfied. • John introducedonly MARY to Kate. • John introduces Mary only to KATE. TSP: MathematicalFoundations
Specifications in PredicateLogic: Susan introduced Mary to a studentthatnobodyliked. TO DO: Complete the contextspecification TSP: MathematicalFoundations
Specifications in PredicateLogic • Express the following using predicate logic • All students in the class can program in Java or C++ • Some of the students can program in Java or C++ • Every student who could not program in Java or C++ was paired with a student who could • Some students program in Java some of the time, others never program in Java TO DO: Write an Event-B context to specifytheseproperties FOLLOW A SPECIFICATION STYLE AS USED IN THE PREVIOUS SAMPLE ANSWERS TSP: MathematicalFoundations