# HG changeset patch # User Christian Urban # Date 1248173117 -7200 # Node ID cc81adc1034bbec2d58ee67974a0be9ae39449e6 # Parent c354e45d80d2b97382198d7bedc5b320331bc013 tuned diff -r c354e45d80d2 -r cc81adc1034b ProgTutorial/FirstSteps.thy --- a/ProgTutorial/FirstSteps.thy Mon Jul 20 16:52:59 2009 +0200 +++ b/ProgTutorial/FirstSteps.thy Tue Jul 21 12:45:17 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 \ int \ unit \ bool\"} @{context} - |> Syntax.string_of_term @{context} - |> writeln" +"let + val t = @{term \"P::nat \ int \ unit \ 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 \ 'b \ 'c\"} @{context} - |> Syntax.string_of_term @{context} - |> writeln" +"let + val t = @{term \"za::'a \ 'b \ '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 *} diff -r c354e45d80d2 -r cc81adc1034b progtutorial.pdf Binary file progtutorial.pdf has changed