congruence.ml 507 B

12345678910111213141516171819
  1. open Types
  2. let rec unfold_repeat = function
  3. | Repeat (_, 0) as i :: _ ->
  4. raise (Ins_error (i, "cannot repeat 0 times"))
  5. | Repeat (i, 1) :: tl ->
  6. i :: unfold_repeat tl
  7. | Repeat (i, n) :: tl ->
  8. i :: unfold_repeat (Repeat (i, n - 1) :: tl)
  9. | hd :: tl ->
  10. hd :: unfold_repeat tl
  11. | [] -> []
  12. let rec norm = function
  13. | [] -> N 0
  14. | Repeat (i, t) :: tl -> norm [i] ** (N t) ++ norm tl
  15. | Loop _ :: tl -> Infinity
  16. | Concat l :: tl -> norm l ++ norm tl
  17. | hd :: tl -> N 1 ++ norm tl