src/Doc/ProgProve/Logic.thy
changeset 54214 6d0688ce4ee2
parent 54212 5f1e2017eeea
child 54217 2fa338fd0a28
equal deleted inserted replaced
54213:cd5ef8bb9d59 54214:6d0688ce4ee2
   139 \end{tabular}
   139 \end{tabular}
   140 \end{center}
   140 \end{center}
   141 See \cite{Nipkow-Main} for the wealth of further predefined functions in theory
   141 See \cite{Nipkow-Main} for the wealth of further predefined functions in theory
   142 @{theory Main}.
   142 @{theory Main}.
   143 
   143 
       
   144 
       
   145 \subsection{Exercises}
       
   146 
       
   147 \exercise
       
   148 Start from the data type of binary trees defined earlier:
       
   149 *}
       
   150 
       
   151 datatype 'a tree = Tip | Node "'a tree" 'a "'a tree"
       
   152 
       
   153 text{*
       
   154 Define a function @{text "set ::"} @{typ "'a tree \<Rightarrow> 'a set"}
       
   155 that returns the elements in a tree and a function
       
   156 @{text "ord ::"} @{typ "int tree \<Rightarrow> bool"}
       
   157 the tests if an @{typ "int tree"} is ordered.
       
   158 
       
   159 Define a function @{text ins} that inserts an element into an ordered @{typ "int tree"}
       
   160 while maintaining the order of the tree. If the element is already in the tree, the
       
   161 same tree should be returned. Prove correctness of @{text ins}:
       
   162 @{prop "set(ins x t) = {x} \<union> set t"} and @{prop "ord t \<Longrightarrow> ord(ins i t)"}.
       
   163 \endexercise
       
   164 
       
   165 
   144 \section{Proof Automation}
   166 \section{Proof Automation}
   145 
   167 
   146 So far we have only seen @{text simp} and @{text auto}: Both perform
   168 So far we have only seen @{text simp} and @{text auto}: Both perform
   147 rewriting, both can also prove linear arithmetic facts (no multiplication),
   169 rewriting, both can also prove linear arithmetic facts (no multiplication),
   148 and @{text auto} is also able to prove simple logical or set-theoretic goals:
   170 and @{text auto} is also able to prove simple logical or set-theoretic goals: