Lean4
/-- Preprocesses facts for preorders. Replaces `x < y` with two equivalent facts: `x ≤ y` and
`¬ (y ≤ x)`. Replaces `x = y` with `x ≤ y`, `y ≤ x` and removes `x ≠ y`. -/
def preprocessFactsPreorder (facts : Array AtomicFact) : MetaM <| Array AtomicFact := do
let mut res : Array AtomicFact := #[]
for fact in facts do
match fact with
| .lt lhs rhs proof =>
res := res.push <| .le lhs rhs (← mkAppM ``le_of_lt #[proof])
res := res.push <| .nle rhs lhs (← mkAppM ``not_le_of_gt #[proof])
| .eq lhs rhs proof =>
res := res.push <| .le lhs rhs (← mkAppM ``le_of_eq #[proof])
res := res.push <| .le rhs lhs (← mkAppM ``ge_of_eq #[proof])
| .ne _ _ _ =>
continue
| _ =>
res := res.push fact
return res