doc-src/IsarImplementation/Thy/Proof.thy
changeset 39846 cb6634eb8926
parent 39841 c7f3efe59e4e
child 39851 7219a771ab63
equal deleted inserted replaced
39845:50f42116ebdb 39846:cb6634eb8926
   157   "\<And>"} prefix of proposition @{text "B"}.
   157   "\<And>"} prefix of proposition @{text "B"}.
   158 
   158 
   159   \end{description}
   159   \end{description}
   160 *}
   160 *}
   161 
   161 
   162 text %mlex {* The following example (in theory @{theory Pure}) shows
   162 text %mlex {* The following example shows how to work with fixed term
   163   how to work with fixed term and type parameters and with
   163   and type parameters and with type-inference.  *}
   164   type-inference.
       
   165 *}
       
   166 
       
   167 typedecl foo  -- {* some basic type for testing purposes *}
       
   168 
   164 
   169 ML {*
   165 ML {*
   170   (*static compile-time context -- for testing only*)
   166   (*static compile-time context -- for testing only*)
   171   val ctxt0 = @{context};
   167   val ctxt0 = @{context};
   172 
   168 
   176   (*t1: most general fixed type; t1': most general arbitrary type*)
   172   (*t1: most general fixed type; t1': most general arbitrary type*)
   177   val t1 = Syntax.read_term ctxt1 "x";
   173   val t1 = Syntax.read_term ctxt1 "x";
   178   val t1' = singleton (Variable.polymorphic ctxt1) t1;
   174   val t1' = singleton (Variable.polymorphic ctxt1) t1;
   179 
   175 
   180   (*term u enforces specific type assignment*)
   176   (*term u enforces specific type assignment*)
   181   val u = Syntax.read_term ctxt1 "(x::foo) \<equiv> y";
   177   val u = Syntax.read_term ctxt1 "(x::nat) \<equiv> y";
   182 
   178 
   183   (*official declaration of u -- propagates constraints etc.*)
   179   (*official declaration of u -- propagates constraints etc.*)
   184   val ctxt2 = ctxt1 |> Variable.declare_term u;
   180   val ctxt2 = ctxt1 |> Variable.declare_term u;
   185   val t2 = Syntax.read_term ctxt2 "x";  (*x::foo is enforced*)
   181   val t2 = Syntax.read_term ctxt2 "x";  (*x::nat is enforced*)
   186 *}
   182 *}
   187 
   183 
   188 text {* In the above example, the starting context had been derived
   184 text {* In the above example, the starting context had been derived
   189   from the toplevel theory, which means that fixed variables are
   185   from the toplevel theory, which means that fixed variables are
   190   internalized literally: @{verbatim "x"} is mapped again to
   186   internalized literally: @{verbatim "x"} is mapped again to