merged
authorChristian Urban <urbanc@in.tum.de>
Tue, 21 Jul 2009 12:51:14 +0200
changeset 277 cc862fd5e0cb
parent 266 cc81adc1034b (diff)
parent 276 682d4711f91e (current diff)
child 278 c6b64fa9f301
merged
ProgTutorial/FirstSteps.thy
progtutorial.pdf
--- a/ProgTutorial/FirstSteps.thy	Tue Jul 21 13:31:23 2009 +0200
+++ b/ProgTutorial/FirstSteps.thy	Tue Jul 21 12:51:14 2009 +0200
@@ -347,14 +347,19 @@
       |> curry list_comb f *}
 
 text {*
-  This code extracts the argument types of a given function @{text "f"} and then generates 
-  for each argument type a distinct variable; finally it applies the generated 
-  variables to the function. For example:
+  This function takes a term and a context as argument. If the term is of function
+  type, then @{ML "apply_fresh_args"} returns the term with distinct variables 
+  applied to it. For example:
 
   @{ML_response_fake [display,gray]
-"apply_fresh_args @{term \"P::nat \<Rightarrow> int \<Rightarrow> unit \<Rightarrow> bool\"} @{context} 
- |> Syntax.string_of_term @{context}
- |> writeln"
+"let
+  val t = @{term \"P::nat \<Rightarrow> int \<Rightarrow> unit \<Rightarrow> bool\"}
+  val ctxt = @{context}
+in 
+  apply_fresh_args t ctxt
+   |> Syntax.string_of_term ctxt
+   |> writeln
+end" 
   "P z za zb"}
 
   You can read off this behaviour from how @{ML apply_fresh_args} is
@@ -372,11 +377,18 @@
   any name clashes. Consider for example: 
 
    @{ML_response_fake [display,gray]
-"apply_fresh_args @{term \"za::'a \<Rightarrow> 'b \<Rightarrow> 'c\"} @{context} 
- |> Syntax.string_of_term @{context}
- |> writeln"
+"let
+  val t = @{term \"za::'a \<Rightarrow> 'b \<Rightarrow> 'c\"}
+  val ctxt = @{context}
+in
+  apply_fresh_args t ctxt 
+   |> Syntax.string_of_term ctxt
+   |> writeln
+end"
   "za z zb"}
   
+  where the @{text "za"} is correctly avoided.
+
   The combinator @{ML [index] "#>"} is the reverse function composition. It can be
   used to define the following function
 *}
Binary file progtutorial.pdf has changed