Commit d8515360 authored by Frontull Samuel's avatar Frontull Samuel
Browse files

type alias

parent 6b0a183e
......@@ -160,37 +160,39 @@ append :: LCList a -> LCList a -> LCList a
append = \x y -> LCList $ \c n -> unList x c (unList y c n)
-- PCP Algorithm
type StrPair = LCPair LCStr
type ListStrPairs = LCList StrPair
simp :: LCPair LCStr -> LCPair LCStr
simp :: StrPair -> StrPair
simp = \p -> ycomb (\f x y -> ite (lor (isempty x) (isempty y)) (pair x y) (f (tl x) (tl y))) (first p) (second p)
pvalid :: LCPair LCStr -> LCBool
pvalid :: StrPair -> LCBool
pvalid = \p -> lor (prefix (first p) (second p)) (prefix (second p) (first p))
find_eq :: LCList (LCPair LCStr) -> LCBool
find_eq :: ListStrPairs -> LCBool
find_eq = ycomb (\f x -> ite (is_nil x) false (lor (eq (first (hd_l x)) (second (hd_l x))) (f (tl_l x))))
cmb :: LCPair LCStr -> LCPair LCStr -> LCPair LCStr
cmb :: StrPair -> StrPair -> StrPair
cmb = \p s -> pair (conc (first p) (first s)) (conc (second p) (second s))
map_cmb :: LCPair LCStr -> LCList (LCPair LCStr) -> LCList (LCPair LCStr)
map_cmb :: StrPair -> ListStrPairs -> ListStrPairs
map_cmb = ycomb (\f x y -> ite (is_nil y) nil (ite (pvalid (cmb x (hd_l y))) (cons (simp (cmb x (hd_l y))) (f x (tl_l y))) (f x (tl_l y))))
cross_cmb :: LCList (LCPair LCStr) -> LCList (LCPair LCStr) -> LCList (LCPair LCStr)
cross_cmb :: ListStrPairs -> ListStrPairs -> ListStrPairs
cross_cmb = ycomb (\f x y -> ite (is_nil x) nil (append (map_cmb (hd_l x) y) (f (tl_l x) y)))
pcp :: LCList (LCPair LCStr) -> LCBool
pcp :: ListStrPairs -> LCBool
pcp = \x -> ycomb (\f x y -> ite (is_nil x) false (ite (find_eq x) true (f (cross_cmb x y) y))) x x
-- PCP Problems
problem_1 :: LCList (LCPair LCStr)
problem_1 :: ListStrPairs
problem_1 = cons (pair a ab) (cons (pair bb b) nil)
problem_2 :: LCList (LCPair LCStr)
problem_2 :: ListStrPairs
problem_2 = cons (pair a abbb) (cons (pair bb b) nil)
problem_3 :: LCList (LCPair LCStr) -- undecidable
problem_3 :: ListStrPairs -- undecidable
problem_3 = cons (pair bba b) (cons (pair b ab) (cons (pair a bba) nil))
-- Output functions
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