statespace syntax: strip positions -- type constraints are unexpected here;
authorwenzelm
Tue Mar 22 15:32:47 2011 +0100 (2011-03-22)
changeset 4205234f1d2d81284
parent 42051 dbdd4790da34
child 42053 006095137a81
statespace syntax: strip positions -- type constraints are unexpected here;
src/HOL/Statespace/state_space.ML
src/Pure/Syntax/type_ext.ML
     1.1 --- a/src/HOL/Statespace/state_space.ML	Tue Mar 22 14:45:48 2011 +0100
     1.2 +++ b/src/HOL/Statespace/state_space.ML	Tue Mar 22 15:32:47 2011 +0100
     1.3 @@ -623,7 +623,11 @@
     1.4             then Syntax.const "StateFun.lookup" $ Syntax.const "undefined" $ Syntax.free n $ s
     1.5             else raise TERM ("StateSpace.gen_lookup_tr: component " ^ n ^ " not defined",[]));
     1.6  
     1.7 -fun lookup_tr ctxt [s,Free (n,_)] = gen_lookup_tr ctxt s n;
     1.8 +fun lookup_tr ctxt [s, x] =
     1.9 +  (case Syntax.strip_positions x of
    1.10 +    Free (n,_) => gen_lookup_tr ctxt s n
    1.11 +  | _ => raise Match);
    1.12 +
    1.13  fun lookup_swap_tr ctxt [Free (n,_),s] = gen_lookup_tr ctxt s n;
    1.14  
    1.15  fun lookup_tr' ctxt [_$Free (prj,_),n as (_$Free (name,_)),s] =
    1.16 @@ -651,7 +655,10 @@
    1.17           else raise TERM ("StateSpace.gen_update_tr: component " ^ n ^ " not defined",[]))
    1.18     end;
    1.19  
    1.20 -fun update_tr ctxt [s,Free (n,_),v] = gen_update_tr false ctxt n v s;
    1.21 +fun update_tr ctxt [s, x, v] =
    1.22 +  (case Syntax.strip_positions x of
    1.23 +    Free (n, _) => gen_update_tr false ctxt n v s
    1.24 +  | _ => raise Match);
    1.25  
    1.26  fun update_tr' ctxt [_$Free (prj,_),_$Free (inj,_),n as (_$Free (name,_)),(Const (k,_)$v),s] =
    1.27       if Long_Name.base_name k = Long_Name.base_name KN then
     2.1 --- a/src/Pure/Syntax/type_ext.ML	Tue Mar 22 14:45:48 2011 +0100
     2.2 +++ b/src/Pure/Syntax/type_ext.ML	Tue Mar 22 15:32:47 2011 +0100
     2.3 @@ -10,6 +10,7 @@
     2.4    val term_sorts: term -> (indexname * sort) list
     2.5    val typ_of_term: (indexname -> sort) -> term -> typ
     2.6    val strip_positions: term -> term
     2.7 +  val strip_positions_ast: Ast.ast -> Ast.ast
     2.8    val decode_term: (((string * int) * sort) list -> string * int -> sort) ->
     2.9      (string -> bool * string) -> (string -> string option) -> term -> term
    2.10    val term_of_typ: bool -> typ -> term
    2.11 @@ -115,6 +116,13 @@
    2.12    | strip_positions (Abs (x, T, t)) = Abs (x, T, strip_positions t)
    2.13    | strip_positions t = t;
    2.14  
    2.15 +fun strip_positions_ast (Ast.Appl ((t as Ast.Constant c) :: u :: (v as Ast.Variable x) :: asts)) =
    2.16 +      if (c = "_constrain" orelse c = "_constrainAbs") andalso is_some (Lexicon.decode_position x)
    2.17 +      then Ast.mk_appl (strip_positions_ast u) (map strip_positions_ast asts)
    2.18 +      else Ast.Appl (map strip_positions_ast (t :: u :: v :: asts))
    2.19 +  | strip_positions_ast (Ast.Appl asts) = Ast.Appl (map strip_positions_ast asts)
    2.20 +  | strip_positions_ast ast = ast;
    2.21 +
    2.22  
    2.23  (* decode_term -- transform parse tree into raw term *)
    2.24