src/HOL/Predicate_Compile_Examples/Code_Prolog_Examples.thy
changeset 55447 aa41ecbdc205
parent 41956 c15ef1b85035
child 58249 180f1b3508ed
equal deleted inserted replaced
55446:e77f2858bd59 55447:aa41ecbdc205
    16    limited_types = [],
    16    limited_types = [],
    17    limited_predicates = [],
    17    limited_predicates = [],
    18    replacing = [],
    18    replacing = [],
    19    manual_reorder = []}) *}
    19    manual_reorder = []}) *}
    20 
    20 
    21 values "{(x, y, z). append x y z}"
    21 values_prolog "{(x, y, z). append x y z}"
    22 
    22 
    23 values 4 "{(z, x, y). append x y ((1::nat) # (2 # (3 # z)))}"
    23 values_prolog 4 "{(z, x, y). append x y ((1::nat) # (2 # (3 # z)))}"
    24 
    24 
    25 values 3 "{(x, y, z). append x y z}"
    25 values_prolog 3 "{(x, y, z). append x y z}"
    26 
    26 
    27 setup {* Code_Prolog.map_code_options (K
    27 setup {* Code_Prolog.map_code_options (K
    28   {ensure_groundness = false,
    28   {ensure_groundness = false,
    29    limit_globally = NONE,
    29    limit_globally = NONE,
    30    limited_types = [],
    30    limited_types = [],
    31    limited_predicates = [],
    31    limited_predicates = [],
    32    replacing = [],
    32    replacing = [],
    33    manual_reorder = []}) *}
    33    manual_reorder = []}) *}
    34 
    34 
    35 values "{(x, y, z). append x y z}"
    35 values_prolog "{(x, y, z). append x y z}"
    36 
    36 
    37 setup {* Code_Prolog.map_code_options (K
    37 setup {* Code_Prolog.map_code_options (K
    38   {ensure_groundness = false,
    38   {ensure_groundness = false,
    39    limit_globally = NONE,
    39    limit_globally = NONE,
    40    limited_types = [],
    40    limited_types = [],
    98 
    98 
    99 inductive queen_9
    99 inductive queen_9
   100 where
   100 where
   101   "queen [1,2,3,4,5,6,7,8,9] ys ==> queen_9 ys"
   101   "queen [1,2,3,4,5,6,7,8,9] ys ==> queen_9 ys"
   102 
   102 
   103 values 10 "{ys. queen_9 ys}"
   103 values_prolog 10 "{ys. queen_9 ys}"
   104 
   104 
   105 
   105 
   106 section {* Example symbolic derivation *}
   106 section {* Example symbolic derivation *}
   107 
   107 
   108 hide_const Pow
   108 hide_const Pow
   188 
   188 
   189 inductive times10
   189 inductive times10
   190 where
   190 where
   191   "d (Mult (Mult (Mult (Mult (Mult (Mult (Mult (Mult (Mult x x) x) x) x) x) x) x) x) x) x e ==> times10 e"
   191   "d (Mult (Mult (Mult (Mult (Mult (Mult (Mult (Mult (Mult x x) x) x) x) x) x) x) x) x) x e ==> times10 e"
   192 
   192 
   193 values "{e. ops8 e}"
   193 values_prolog "{e. ops8 e}"
   194 values "{e. divide10 e}"
   194 values_prolog "{e. divide10 e}"
   195 values "{e. log10 e}"
   195 values_prolog "{e. log10 e}"
   196 values "{e. times10 e}"
   196 values_prolog "{e. times10 e}"
   197 
   197 
   198 section {* Example negation *}
   198 section {* Example negation *}
   199 
   199 
   200 datatype abc = A | B | C
   200 datatype abc = A | B | C
   201 
   201 
   209    limited_types = [],
   209    limited_types = [],
   210    limited_predicates = [],
   210    limited_predicates = [],
   211    replacing = [],
   211    replacing = [],
   212    manual_reorder = []}) *}
   212    manual_reorder = []}) *}
   213 
   213 
   214 values 2 "{y. notB y}"
   214 values_prolog 2 "{y. notB y}"
   215 
   215 
   216 inductive notAB :: "abc * abc \<Rightarrow> bool"
   216 inductive notAB :: "abc * abc \<Rightarrow> bool"
   217 where
   217 where
   218   "y \<noteq> A \<Longrightarrow> z \<noteq> B \<Longrightarrow> notAB (y, z)"
   218   "y \<noteq> A \<Longrightarrow> z \<noteq> B \<Longrightarrow> notAB (y, z)"
   219 
   219 
   220 values 5 "{y. notAB y}"
   220 values_prolog 5 "{y. notAB y}"
   221 
   221 
   222 section {* Example prolog conform variable names *}
   222 section {* Example prolog conform variable names *}
   223 
   223 
   224 inductive equals :: "abc => abc => bool"
   224 inductive equals :: "abc => abc => bool"
   225 where
   225 where
   226   "equals y' y'"
   226   "equals y' y'"
   227 
   227 
   228 values 1 "{(y, z). equals y z}"
   228 values_prolog 1 "{(y, z). equals y z}"
   229 
   229 
   230 end
   230 end