Commit 0a661bd3 authored by Frontull Samuel's avatar Frontull Samuel
Browse files

pcp with filter

parent 408a4e34
......@@ -23,10 +23,10 @@ let t_second = tree_of_string s_second
let s_empty = "(/x a b.x)"
let t_empty = tree_of_string s_empty
let s_at = "(/x./x y.x)"
let s_at = "(/z./x y.x)"
let t_af = tree_of_string s_at
let s_af = "(/x./x y.y)"
let s_af = "(/z./x y.y)"
(* let t_af = tree_of_string s_af *)
let s_concat = "(/y z x a b.y (z x a b) a b)"
......@@ -64,15 +64,16 @@ let t_hd_eq = tree_of_string s_hd_eq
let s_ycomb = "(/f.(/x.f (x x)) (/x.f (x x)))"
let t_ycomb = tree_of_string s_ycomb
let s_zcomb = "(/f.(/x.f (/y.x x y)) (/x.f (/y.x x y)))"
let t_zcomb = tree_of_string s_zcomb
let _eq_str = "(/rec x y."^s_ite^" ("^s_or^" ("^s_isempty^" x) ("^s_isempty^" y)) ("^s_and^" ("^s_isempty^" x) ("^s_isempty^" y)) ("^s_and^" ("^s_hd_eq^" x y) (rec ("^s_tl^" x) ("^s_tl^" y))))";;
let s_eq_str = ("(/a b.(/f.(/x.f (x x)) (/x.f (x x))) " ^_eq_str ^ " a b)");;
let eq_str = tree_of_string s_eq_str;;
let _eq_str = "(/r x y."^s_ite^" ("^s_or^" ("^s_isempty^" x) ("^s_isempty^" y)) ("^s_and^" ("^s_isempty^" x) ("^s_isempty^" y)) ("^s_and^" ("^s_hd_eq^" x y) (r ("^s_tl^" x) ("^s_tl^" y))))"
let s_eq_str = ("(/a b."^s_ycomb^" " ^_eq_str ^ " a b)")
let eq_str = tree_of_string s_eq_str
(* let tmp = tree_of_string (s_eq_str ^ " ((/x a b.a x)) ((/x a b.a x))") *)
let _isprefix = "(/r x y."^s_ite^" ("^s_isempty^" x) ("^s_true^") ("^s_and^" ("^s_hd_eq^" x y) (r ("^s_tl^" x) ("^s_tl^" y))))"
let s_isprefix = ("(/a b."^s_ycomb^" " ^_isprefix ^ " a b)")
let t_isprefix = tree_of_string s_isprefix
(* let tmp = tree_of_string (s_isprefix ^ " ((/x a b.x)) ((/x a b.x))") *)
(* LISTS *)
let s_cons = "(/x y.(/a b c.c a b) (/x y.y) ((/a b c.c a b) x y))"
let t_cons = tree_of_string s_cons
......@@ -85,6 +86,12 @@ let t_nil = tree_of_string s_nil
let s_isnil = "(/p.p (/x y.x))"
let t_isnil = tree_of_string s_isnil
let s_pcppair = "(/p."^s_or^" ("^s_isprefix^" ("^s_first^" p) ("^s_second^" p)) ("^s_isprefix^" ("^s_second^" p) ("^s_first^" p)))"
let t_pcppair = tree_of_string s_pcppair
let _filter = "(/r f xs."^s_ite^" ("^s_isnil^" xs) ("^s_nil^") ("^s_ite^" (f ("^s_lhd^" xs)) ("^s_cons^" ("^s_lhd^" xs) (r f ("^s_ltl^" xs))) (r f ("^s_ltl^" xs))))"
let s_filter = "(/f xs."^s_ycomb^" " ^_filter ^ " f xs)"
let t_filter = tree_of_string s_filter
(* STRINGS *)
let s_e = "(/x a b.x)"
......@@ -102,26 +109,37 @@ let s_mkpair = "(/x y." ^ s_pair ^ " x y)"
let t_mkpair = tree_of_string s_mkpair
(* LIST OF TILES *)
(* let s_tile1 = "(" ^ s_mkpair ^ " (/x a b.a x) (/x a b.a (b (b x))))"
let s_tile1 = "(" ^ s_mkpair ^ " (/x a b.a x) (/x a b.b x))"
let t_tile1 = tree_of_string s_tile1
let s_tile2 = "(" ^ s_mkpair ^ " (/x a b.b x) (/x a b.x))"
let s_tile2 = "(" ^ s_mkpair ^ " (/x a b.a x) (/x a b.b x))"
let t_tile2 = tree_of_string s_tile2
let s_tiles = "(" ^ s_cons ^ " " ^ s_tile2 ^ " (" ^ s_cons ^ " " ^ s_tile1 ^ " " ^ s_nil ^ "))" *)
let s_tiles = "(" ^ s_cons ^ " " ^ s_tile2 ^ " (" ^ s_cons ^ " " ^ s_tile1 ^ " " ^ s_nil ^ "))"
let s_tile1 = "(" ^ s_mkpair ^ " (/x a b.b (b (a x))) (/x a b.b x))"
(* let s_tile1 = "(" ^ s_mkpair ^ " (/x a b.b (b (a x))) (/x a b.b x))"
let t_tile1 = tree_of_string s_tile1
let s_tile2 = "(" ^ s_mkpair ^ " (/x a b.a x) (/x a b.b (b (b x))))"
let t_tile2 = tree_of_string s_tile2
let s_tile3 = "(" ^ s_mkpair ^ " (/x a b.b x) (/x a b.a (b x)))"
let t_tile3 = tree_of_string s_tile3 *)
(* let s_tile1 = "(" ^ s_mkpair ^ " (/x a b.b x) (/x a b.b (b (b x))))"
let t_tile1 = tree_of_string s_tile1
let s_tile2 = "(" ^ s_mkpair ^ " (/x a b.b (a (b (b (b x))))) (/x a b.b (a x)))"
let t_tile2 = tree_of_string s_tile2
let s_tile3 = "(" ^ s_mkpair ^ " (/x a b.b (a x)) (/x a b.a x))"
let t_tile3 = tree_of_string s_tile3
let s_tiles = "(" ^ s_cons ^ " " ^ s_tile3 ^ " (" ^ s_cons ^ " " ^ s_tile2 ^ " (" ^ s_cons ^ " " ^ s_tile1 ^ " " ^ s_nil ^ ")))"
let s_tiles = "(" ^ s_cons ^ " " ^ s_tile3 ^ " (" ^ s_cons ^ " " ^ s_tile2 ^ " (" ^ s_cons ^ " " ^ s_tile1 ^ " " ^ s_nil ^ ")))" *)
let t_tiles = tree_of_string s_tiles
(* let tmp = Core.AApp(Core.AApp(t_filter,t_pcppair,UnT),t_tiles,UnT) *)
(* find if for (t1,t2), t1 = t2 in list of tuples *)
(* "/r x.ite (isnil x) (false) (or (eq_str (fst (lhd x)) (snd (lhd x))) (r (tl x)))" *)
let s__find_eq = "(/r xs."^s_ite^" ("^s_isnil^" xs) "^s_false^" ("^s_or^" ("^s_eq_str^" ("^s_first^" ("^s_lhd^" xs)) ("^s_second^" ("^s_lhd^" xs))) (r ("^s_ltl^" xs))))"
......@@ -145,7 +163,7 @@ let s_append = "(/xs ys."^s_ycomb^" "^s__append^" xs ys)"
(* let tmp = Core.AApp(Core.AApp(t_combine, t_tile1, UnT), t_listtuple_ee, UnT) *)
let s__cross_append = "(/r xs ys."^s_ite^" ("^s_isnil^" xs) ("^s_nil^") ("^s_append^" ("^s_combine^" ("^s_lhd^" xs) ys) (r ("^s_ltl^" xs) ys)))"
let s_cross_append = "(/xs ys."^s_ycomb^" "^s__cross_append^" xs ys)"
let s_cross_append = "(/xs ys."^s_filter^" "^s_pcppair^" ("^s_ycomb^" "^s__cross_append^" xs ys))"
let t_cross_append = tree_of_string s_cross_append
(* let tmp = Core.AApp(Core.AApp(t_cross_append, t_tiles, UnT), t_listtuple_ee, UnT) *)
......@@ -162,51 +180,15 @@ let t_cross_append = tree_of_string s_cross_append
(* let tmp = Core.AApp(Core.AApp(t_mkpair,t_a,UnT),(Core.AApp(Core.AApp(t_concat,t_a,UnT),t_a,UnT)),UnT) *)
(* let tmp = Core.AApp(t_lhd, Core.AApp(Core.AApp(t_cross_append, t_tiles, UnT), t_listtuple_ee, UnT), UnT) *)
(* let s__pcp = "(/r xs tiles."^s_ite^" ("^s_find_eq^" ("^s__cross_append^" xs tiles)) "^s_true^" (r ("^s__cross_append^" xs tiles) tiles))" *)
let s__pcp = "(/r xs tiles."^s_ite^" ("^s_find_eq^" xs) ("^s_true^") (r ("^s_cross_append^" xs tiles) tiles))"
let s_pcp = "(/tiles."^s_ycomb^" "^s__pcp^" tiles tiles)"
(* let s__pcp = "(/r xs ts."^s_ite^" ("^s_find_eq^" xs) ("^s_true^") (r ("^s_cross_append^" xs ts) ts))" *)
let s__pcp = "(/r xs ts."^s_ite^" ("^s_isnil^" xs) ("^s_false^") ("^s_ite^" ("^s_find_eq^" xs) ("^s_true^") (r ("^s_cross_append^" xs ts) ts)))"
let s_pcp = "(/ts."^s_ycomb^" "^s__pcp^" ts ts)"
let t_pcp = tree_of_string s_pcp
let tmp = Core.AApp(t_pcp, t_tiles, UnT)
(* let tmp = Core.AApp(t_find_eq, Core.AApp(Core.AApp(t_cross_append, Core.AApp(Core.AApp(t_cross_append, t_tiles, UnT), t_tiles, UnT), UnT), t_tiles, UnT), UnT) *)
(* let tmp = Core.AApp(Core.AApp(t_cross_append, Core.AApp(Core.AApp(t_cross_append, Core.AApp(Core.AApp(t_cross_append, t_listtuple_ee, UnT), t_tiles, UnT), UnT), t_tiles, UnT), UnT), t_tiles, UnT) *)
(* PCP2 *)
(* let s_t1_2 = "(/x a b.a x)"
let s_b1_2 = "(/x a b.a (b (b x)))"
let s_t2_2 = "(/x a b.b x)"
let s_b2_2 = "(/x a b.x)" *)
(* let s_t1_2 = "(/x a b.a x)"
let s_b1_2 = "(/x a b.a (b x))"
let s_t2_2 = "(/x a b.b x)"
let s_b2_2 = "(/x a b.x)"
let _pcp2 = "(/f a b." ^ s_ite ^ " (" ^ s_or ^ " (" ^ s_eq_str ^ " (" ^ s_concat ^ " a " ^ s_t1_2 ^ ") (" ^ s_concat ^ " b " ^ s_b1_2 ^ ")) (" ^ s_eq_str ^ " (" ^ s_concat ^ " a " ^ s_t2_2 ^ ") (" ^ s_concat ^ " b " ^ s_b2_2 ^ "))) " ^ s_true ^ " (" ^ s_or ^ " (f (" ^ s_concat ^ " a " ^ s_t1_2 ^ ") (" ^ s_concat ^ " b " ^ s_b1_2 ^ ")) (f (" ^ s_concat ^ " a " ^ s_t2_2 ^ ") (" ^ s_concat ^ " b " ^ s_b2_2 ^ "))))"
let s_pcp2 = s_ycomb ^ " " ^ _pcp2 ^ " " ^ s_empty ^ " " ^ s_empty
let pcp2 = tree_of_string s_pcp2
let res_pcp2 = Core.nf (Core.casubst) pcp2 *)
(* PCP3 *)
(* let s_t1 = "(/x a b.b x)"
let s_b1 = "(/x a b.b (b (b x)))"
let s_t2 = "(/x a b.b (a (b (b (b x)))))"
let s_b2 = "(/x a b.b (a x))"
let s_t3 = "(/x a b.b (a x))"
let s_b3 = "(/x a b.a x)"
let _pcp3 = "/f a b." ^ s_ite ^ " (" ^ s_or ^ " (" ^ s_or ^ " (" ^ s_eq_str ^ " (" ^ s_concat ^ " a " ^ s_t1 ^ ") (" ^ s_concat ^ " b " ^ s_b1 ^ ")) (" ^ s_eq_str ^ " (" ^ s_concat ^ " a " ^ s_t2 ^ ") (" ^ s_concat ^ " b " ^ s_b2 ^ ")))) (" ^ s_eq_str ^ " (" ^ s_concat ^ " a " ^ s_t3 ^ ") (" ^ s_concat ^ " b " ^ s_b3 ^ ")) " ^ s_true ^ " (" ^ s_or ^ " (" ^ s_or ^ " (f (" ^ s_concat ^ " a " ^ s_t1 ^ ") (" ^ s_concat ^ " b " ^ s_b1 ^ ")) (f (" ^ s_concat ^ " a " ^ s_t2 ^ ") (" ^ s_concat ^ " b " ^ s_b2 ^ "))) (f (" ^ s_concat ^ " a " ^ s_t3 ^ ") (" ^ s_concat ^ " b " ^ s_b3 ^ ")))"
let s_pcp3 = s_ycomb ^ " " ^ _pcp3 ^ " " ^ s_empty ^ " " ^ s_empty
let pcp3 = tree_of_string s_pcp3
let res_pcp3 = Core.nf (Core.casubst) pcp3 *)
let () =
Printf.printf "PCP file.\n";
(* Printf.printf "%s\n\n" (Core.a_term_to_string tmp); *)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment