diff -r 5fbeeac2901b -r e7519207c2b7 CookBook/FirstSteps.thy --- a/CookBook/FirstSteps.thy Mon Jan 12 16:49:15 2009 +0000 +++ b/CookBook/FirstSteps.thy Wed Jan 14 16:46:07 2009 +0000 @@ -226,17 +226,17 @@ The antiquotation @{text "@{prop \}"} constructs terms of propositional type, inserting the invisible @{text "Trueprop"}-coercions whenever necessary. - Consider for example + Consider for example the pairs @{ML_response [display] "(@{term \"P x\"}, @{prop \"P x\"})" "(Free (\"P\", \) $ Free (\"x\", \), Const (\"Trueprop\", \) $ (Free (\"P\", \) $ Free (\"x\", \)))"} - which inserts the coercion in the second component and + where an coercion is inserted in the second component and @{ML_response [display] "(@{term \"P x \ Q x\"}, @{prop \"P x \ Q x\"})" "(Const (\"==>\", \) $ \ $ \, Const (\"==>\", \) $ \ $ \)"} - which does not (since it is already constructed using the meta-implication). + where it is not (since it is already constructed using the meta-implication). Types can be constructed using the antiquotation @{text "@{typ \}"}. For example @@ -281,36 +281,39 @@ text {* To see this apply @{text "@{term S}"}, @{text "@{term T}"} and @{text "@{typ nat}"} - to both functions: + to both functions. With @{ML make_imp} we obtain the correct term involving + @{term "S"}, @{text "T"} and @{text "@{typ nat}"} @{ML_response [display] "make_imp @{term S} @{term T} @{typ nat}" "Const \ $ Abs (\"x\", Type (\"nat\",[]), Const \ $ (Free (\"S\",\) $ \) $ (Free (\"T\",\) $ \))"} + + With @{ML make_wrong_imp} we obtain an incorrect term involving the @{term "P"} + and @{text "Q"} from the antiquotation. + @{ML_response [display] "make_wrong_imp @{term S} @{term T} @{typ nat}" "Const \ $ Abs (\"x\", \, Const \ $ (Const \ $ (Free (\"P\",\) $ \)) $ (Const \ $ (Free (\"Q\",\) $ \)))"} - As can be seen, in the first case the arguments are correctly used, while the - second generates a term involving the @{term "P"} and @{text "Q"} from the - antiquotation. + One tricky point in constructing terms by hand is to obtain the fully + qualified name for constants. For example the names for @{text "zero"} and + @{text "+"} are more complex than one first expects, namely - One tricky point in constructing terms by hand is to obtain the - fully qualified name for constants. For example the names for @{text "zero"} and - @{text "+"} are more complex than one first expects, namely \begin{center} @{text "HOL.zero_class.zero"} and @{text "HOL.plus_class.plus"}. \end{center} - The extra prefixes @{text zero_class} and @{text plus_class} are present because - these constants are defined within type classes; the prefix @{text "HOL"} indicates in - which theory they are defined. Guessing such internal names can sometimes be quite hard. - Therefore Isabelle provides the antiquotation @{text "@{const_name \}"} which does the - expansion automatically, for example: + The extra prefixes @{text zero_class} and @{text plus_class} are present + because these constants are defined within type classes; the prefix @{text + "HOL"} indicates in which theory they are defined. Guessing such internal + names can sometimes be quite hard. Therefore Isabelle provides the + antiquotation @{text "@{const_name \}"} which does the expansion + automatically, for example: @{ML_response_fake [display] "@{const_name \"Nil\"}" "List.list.Nil"} @@ -575,6 +578,11 @@ section {* Theorem Attributes *} +section {* Combinators *} +text {* + @{text I}, @{text K} + +*} end \ No newline at end of file