src/Doc/ProgProve/Logic.thy
changeset 56116 bdc03e91684a
parent 55361 d459a63ca42f
equal deleted inserted replaced
56115:9bf84c452463 56116:bdc03e91684a
   809 inductive star' :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" for r where
   809 inductive star' :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" for r where
   810 refl': "star' r x x" |
   810 refl': "star' r x x" |
   811 step': "star' r x y \<Longrightarrow> r y z \<Longrightarrow> star' r x z"
   811 step': "star' r x y \<Longrightarrow> r y z \<Longrightarrow> star' r x z"
   812 
   812 
   813 text{*
   813 text{*
   814 The single @{text r} step is performer after rather than before the @{text star'}
   814 The single @{text r} step is performed after rather than before the @{text star'}
   815 steps. Prove @{prop "star' r x y \<Longrightarrow> star r x y"} and
   815 steps. Prove @{prop "star' r x y \<Longrightarrow> star r x y"} and
   816 @{prop "star r x y \<Longrightarrow> star r' x y"}. You may need lemmas.
   816 @{prop "star r x y \<Longrightarrow> star r' x y"}. You may need lemmas.
   817 Note that rule induction fails
   817 Note that rule induction fails
   818 if the assumption about the inductive predicate is not the first assumption.
   818 if the assumption about the inductive predicate is not the first assumption.
   819 \endexercise
   819 \endexercise
   827 \end{exercise}
   827 \end{exercise}
   828 
   828 
   829 \begin{exercise}
   829 \begin{exercise}
   830 A context-free grammar can be seen as an inductive definition where each
   830 A context-free grammar can be seen as an inductive definition where each
   831 nonterminal $A$ is an inductively defined predicate on lists of terminal
   831 nonterminal $A$ is an inductively defined predicate on lists of terminal
   832 symbols: $A(w)$ mans that $w$ is in the language generated by $A$.
   832 symbols: $A(w)$ means that $w$ is in the language generated by $A$.
   833 For example, the production $S \to a S b$ can be viewed as the implication
   833 For example, the production $S \to a S b$ can be viewed as the implication
   834 @{prop"S w \<Longrightarrow> S (a # w @ [b])"} where @{text a} and @{text b} are terminal symbols,
   834 @{prop"S w \<Longrightarrow> S (a # w @ [b])"} where @{text a} and @{text b} are terminal symbols,
   835 i.e., elements of some alphabet. The alphabet can be defined like this:
   835 i.e., elements of some alphabet. The alphabet can be defined like this:
   836 \isacom{datatype} @{text"alpha = a | b | \<dots>"}
   836 \isacom{datatype} @{text"alpha = a | b | \<dots>"}
   837 
   837