Write a list circularity test

Write a list circularity test

a) Implement implication_string that tests if a string is an implication of the form "P=>Q" where P and Q are letters in the 'A'..'Z' range:

let implication_string s = ... ;;
val implication_string : string -> bool = <fun>

b) Consider the following fonction:

let transitive_implication s1 s2 =
  assert (implication_string s1);
  assert (implication_string s2);

This function tests if two ordered implications are transitive, for exemple:

transitive_implication "P=>Q" "Q=>R";;
- : bool = true

c) Let pred be a binary predicate like transitive_implication is. Implement the circular_chain function:

let circular_chain pred l = ... ;;
val circular_chain : ('a -> 'a -> bool) -> 'a list -> bool = <fun>

As a use-case, given three well ordered implications, the circular_chain function is used to prove the equivalence "P<=>Q<=>R" by just typing:

circular_chain transitive_implication ["P=>Q";"Q=>R";"R=>P"];;
- : bool = true