chapter \Exercise Sheet -- Week 7\ theory Exercise07 imports Main begin section \Exercise 1 -- 4 points\ text \Task 1 (1 point)\ text \Complete the following definition to represent the transitive closure of a binary relation $R$, i.e., $R^+$.\ inductive_set transcl :: "('a \ 'a)set \ ('a \ 'a)set" for R where "everything \ transcl R" text \Task 2 (1 point): Prove that the transitive closure of R contains R.\ lemma transcl_R: "R \ transcl R" proof (intro subrelI) oops text \Task 3 (1 point): Prove that the transitive closure of R is transitive.\ text \Note: @{term "A O B"} is relation composition of two binary relations A and B.\ lemma transcl_trans: "transcl R O transcl R \ transcl R" proof (intro subrelI) oops text \Task 4 (1 point): Prove that the transitive closure of R is the least transitive relation that contains R.\ lemma transcl_least: assumes "R \ S" and "S O S \ S" shows "transcl R \ S" proof (intro subrelI) oops section \Exercise 2 -- 3 points\ text \Consider the big-step semantics of simple while programs from Demo07\ type_synonym var = string type_synonym val = nat type_synonym state = "var \ val" datatype prog = Skip | Update "state \ state" | Sequence prog prog | While "state \ bool" prog inductive eval :: "prog \ state \ state \ bool" where skip: "eval Skip s s" | update: "eval (Update f) s (f s)" | sequence: "eval p s t \ eval q t u \ eval (Sequence p q) s u" | while_false: "\ c s \ eval (While c p) s s" | while_true: "c s \ eval p s t \ eval (While c p) t u \ eval (While c p) s u" text \Prove that the evaluation relation is deterministic.\ text \Hint: you need one rule induction and several rule inversions.\ lemma eval_det: "eval p s t \ eval p s u \ t = u" oops section \Exercise 3 -- 3 points\ text \Prove the well-known fact about the cardinality of the powerset of a finite set.\ text \Comment: with this exercise you will become more familiar with sets in Isabelle.\ text \Hint: use @{command find_theorems} to find existing facts, if sledgehammer is not successful.\ lemma "finite X \ card { A . A \ X} = 2^card X" proof (induct X rule: finite_induct) case (insert x X) have "{A. A \ insert x X} = (insert x ` {A . A \ X}) \ {A . A \ X}" (is "?L = ?R1 \ ?R2") proof show "?L \ ?R1 \ ?R2" sorry qed auto show ?case sorry qed auto end