src/HOL/Decision_Procs/Parametric_Ferrante_Rackoff.thy
changeset 35267 8dfd816713c6
parent 35092 cfe605c54e50
child 35416 d8d7d1b785af
equal deleted inserted replaced
35266:07a56610c00b 35267:8dfd816713c6
  2945 val bT = HOLogic.boolT;
  2945 val bT = HOLogic.boolT;
  2946 fun num rT x = HOLogic.mk_number rT x;
  2946 fun num rT x = HOLogic.mk_number rT x;
  2947 fun rrelT rT = [rT,rT] ---> rT;
  2947 fun rrelT rT = [rT,rT] ---> rT;
  2948 fun rrT rT = [rT, rT] ---> bT;
  2948 fun rrT rT = [rT, rT] ---> bT;
  2949 fun divt rT = Const(@{const_name Rings.divide},rrelT rT);
  2949 fun divt rT = Const(@{const_name Rings.divide},rrelT rT);
  2950 fun timest rT = Const(@{const_name Algebras.times},rrelT rT);
  2950 fun timest rT = Const(@{const_name Groups.times},rrelT rT);
  2951 fun plust rT = Const(@{const_name Algebras.plus},rrelT rT);
  2951 fun plust rT = Const(@{const_name Groups.plus},rrelT rT);
  2952 fun minust rT = Const(@{const_name Algebras.minus},rrelT rT);
  2952 fun minust rT = Const(@{const_name Groups.minus},rrelT rT);
  2953 fun uminust rT = Const(@{const_name Algebras.uminus}, rT --> rT);
  2953 fun uminust rT = Const(@{const_name Groups.uminus}, rT --> rT);
  2954 fun powt rT = Const(@{const_name "power"}, [rT,@{typ "nat"}] ---> rT);
  2954 fun powt rT = Const(@{const_name "power"}, [rT,@{typ "nat"}] ---> rT);
  2955 val brT = [bT, bT] ---> bT;
  2955 val brT = [bT, bT] ---> bT;
  2956 val nott = @{term "Not"};
  2956 val nott = @{term "Not"};
  2957 val conjt = @{term "op &"};
  2957 val conjt = @{term "op &"};
  2958 val disjt = @{term "op |"};
  2958 val disjt = @{term "op |"};
  2959 val impt = @{term "op -->"};
  2959 val impt = @{term "op -->"};
  2960 val ifft = @{term "op = :: bool => _"}
  2960 val ifft = @{term "op = :: bool => _"}
  2961 fun llt rT = Const(@{const_name Orderings.less},rrT rT);
  2961 fun llt rT = Const(@{const_name Orderings.less},rrT rT);
  2962 fun lle rT = Const(@{const_name Orderings.less},rrT rT);
  2962 fun lle rT = Const(@{const_name Orderings.less},rrT rT);
  2963 fun eqt rT = Const("op =",rrT rT);
  2963 fun eqt rT = Const("op =",rrT rT);
  2964 fun rz rT = Const(@{const_name Algebras.zero},rT);
  2964 fun rz rT = Const(@{const_name Groups.zero},rT);
  2965 
  2965 
  2966 fun dest_nat t = case t of
  2966 fun dest_nat t = case t of
  2967   Const ("Suc",_)$t' => 1 + dest_nat t'
  2967   Const ("Suc",_)$t' => 1 + dest_nat t'
  2968 | _ => (snd o HOLogic.dest_number) t;
  2968 | _ => (snd o HOLogic.dest_number) t;
  2969 
  2969 
  2970 fun num_of_term m t = 
  2970 fun num_of_term m t = 
  2971  case t of
  2971  case t of
  2972    Const(@{const_name Algebras.uminus},_)$t => @{code poly.Neg} (num_of_term m t)
  2972    Const(@{const_name Groups.uminus},_)$t => @{code poly.Neg} (num_of_term m t)
  2973  | Const(@{const_name Algebras.plus},_)$a$b => @{code poly.Add} (num_of_term m a, num_of_term m b)
  2973  | Const(@{const_name Groups.plus},_)$a$b => @{code poly.Add} (num_of_term m a, num_of_term m b)
  2974  | Const(@{const_name Algebras.minus},_)$a$b => @{code poly.Sub} (num_of_term m a, num_of_term m b)
  2974  | Const(@{const_name Groups.minus},_)$a$b => @{code poly.Sub} (num_of_term m a, num_of_term m b)
  2975  | Const(@{const_name Algebras.times},_)$a$b => @{code poly.Mul} (num_of_term m a, num_of_term m b)
  2975  | Const(@{const_name Groups.times},_)$a$b => @{code poly.Mul} (num_of_term m a, num_of_term m b)
  2976  | Const(@{const_name Power.power},_)$a$n => @{code poly.Pw} (num_of_term m a, dest_nat n)
  2976  | Const(@{const_name Power.power},_)$a$n => @{code poly.Pw} (num_of_term m a, dest_nat n)
  2977  | Const(@{const_name Rings.divide},_)$a$b => @{code poly.C} (HOLogic.dest_number a |> snd, HOLogic.dest_number b |> snd)
  2977  | Const(@{const_name Rings.divide},_)$a$b => @{code poly.C} (HOLogic.dest_number a |> snd, HOLogic.dest_number b |> snd)
  2978  | _ => (@{code poly.C} (HOLogic.dest_number t |> snd,1) 
  2978  | _ => (@{code poly.C} (HOLogic.dest_number t |> snd,1) 
  2979          handle TERM _ => @{code poly.Bound} (AList.lookup (op aconv) m t |> the));
  2979          handle TERM _ => @{code poly.Bound} (AList.lookup (op aconv) m t |> the));
  2980 
  2980 
  2981 fun tm_of_term m m' t = 
  2981 fun tm_of_term m m' t = 
  2982  case t of
  2982  case t of
  2983    Const(@{const_name Algebras.uminus},_)$t => @{code Neg} (tm_of_term m m' t)
  2983    Const(@{const_name Groups.uminus},_)$t => @{code Neg} (tm_of_term m m' t)
  2984  | Const(@{const_name Algebras.plus},_)$a$b => @{code Add} (tm_of_term m m' a, tm_of_term m m' b)
  2984  | Const(@{const_name Groups.plus},_)$a$b => @{code Add} (tm_of_term m m' a, tm_of_term m m' b)
  2985  | Const(@{const_name Algebras.minus},_)$a$b => @{code Sub} (tm_of_term m m' a, tm_of_term m m' b)
  2985  | Const(@{const_name Groups.minus},_)$a$b => @{code Sub} (tm_of_term m m' a, tm_of_term m m' b)
  2986  | Const(@{const_name Algebras.times},_)$a$b => @{code Mul} (num_of_term m' a, tm_of_term m m' b)
  2986  | Const(@{const_name Groups.times},_)$a$b => @{code Mul} (num_of_term m' a, tm_of_term m m' b)
  2987  | _ => (@{code CP} (num_of_term m' t) 
  2987  | _ => (@{code CP} (num_of_term m' t) 
  2988          handle TERM _ => @{code Bound} (AList.lookup (op aconv) m t |> the)
  2988          handle TERM _ => @{code Bound} (AList.lookup (op aconv) m t |> the)
  2989               | Option => @{code Bound} (AList.lookup (op aconv) m t |> the));
  2989               | Option => @{code Bound} (AList.lookup (op aconv) m t |> the));
  2990 
  2990 
  2991 fun term_of_num T m t = 
  2991 fun term_of_num T m t =