(*<*) theory Exercise imports Main begin (*>*) section {* Two Grammars *} text{* The most natural definition of valid sequences of parentheses is this: \[ S \quad\to\quad \epsilon \quad\mid\quad '('~S~')' \quad\mid\quad S~S \] where $\epsilon$ is the empty word. A second, somewhat unusual grammar is the following one: \[ T \quad\to\quad \epsilon \quad\mid\quad T~'('~T~')' \] *} text {* $\rhd$ Make the definitions of sets @{term S} and @{term T} in Isabelle and give structured Isar proofs leading to the theorem @{term "S = T"}. Hint: use lists over a specific type to repesent words. *} text {* The alphabet: *} datatype alpha = A | B section {* Polynomial sums *} text {* $\rhd$ Produce structured proofs of the following theorems, using induction and calculational reasoning in Isar. Note that the given tactic scripts are of limited use in reconstructing structured proofs; nevertheless the hints of automated steps below can be re-used to finish sub-problems. The @{text "\"} symbol can be entered as ``\verb,\,''; note that numerals in Isabelle/HOL are polymorphic. *} theorem -- {* problem *} fixes n :: nat shows "2 * (\i=0..n. i) = n * (n + 1)" by (induct n) simp_all theorem -- {* problem *} fixes n :: nat shows "(\i=0.." by (induct n) (simp_all add: power_eq_if nat_distrib) theorem -- {* problem *} fixes n :: nat shows "(\i=0..i=0..i=0..*)