Advertisement
tinyevil

Untitled

Mar 1st, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. Fixpoint has_non_trivial_constr ls :=
  2. match ls with
  3. | nil => false
  4. | cons x xs =>
  5. if x == Constructor []
  6. then has_non_trivial_constr xs
  7. else true
  8. end
  9.  
  10. Defintion IsEnumeration type :=
  11. match Reflect(type) with
  12. | InductiveType ls => not (has_non_trivial_constr ls)
  13. end.
  14.  
  15. Fixpoint compare_constr type1 type2 ls1 ls2 :=
  16. match ls1, ls2 with
  17. | nil, _ => false
  18. | _, nil => true
  19. | x::xs, y::ys =>
  20. if x <> y && (x <> type1 || y <> type2)
  21. then false
  22. else compare_constr type1 type2 xs ys
  23.  
  24. Fixpoint compare_constrs type1 type2 ls1 ls2 :=
  25. match ls1, ls2 with
  26. | nil, _ => true
  27. | _, nil => false
  28. | (Constructor x)::xs, (Constructor y)::ys => (compare_constr type1 type2 x y) && (compare_constrs type1 type2 xs ys)
  29. end.
  30.  
  31. Definition BinaryCompatible type1 type2 :=
  32. match Reflect(type1) Reflect(type2) with
  33. | InductiveType ls1, InductiveType ls2 => compare_constrs type1 type2 ls1 ls2
  34. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement