Open ice1000 opened 3 years ago
Stumbled upon a similar issue while rewriting PLFA on Arend.
The "Transitivity" section in Relactions chapter demonstrates the following proof:
≤-trans : ∀ {m n p : ℕ} → m ≤ n → n ≤ p → m ≤ p
≤-trans z≤n _ = z≤n
≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p)
And the text stresses that this way of pattern matching is "immensely valuable":
The technique of induction on evidence that a property holds (e.g., inducting on evidence that
m ≤ n
)—rather than induction on values of which the property holds (e.g., inducting onm
)—will turn out to be immensely valuable, and one that we use often.
In Arend I need to also pattern match on implicit variables:
\func <=-trans {m n p : Nat} (m<=n : m <= n) (n<=p : n <= p) : m <= p
| {0}, _, _ => z<=n
| {suc m}, {suc n}, {suc p}, s<=s m<=n, s<=s n<=p => s<=s (<=-trans m<=n n<=p)
Arend asks me to split on
n
as well. In Agda or Coq, they are translated into the so-called 'dotted pattern' which are not actually needed to be split.The above Agda code checks (note that the binding second pattern is not even linear,
a
was bound twice! But internally it is translated to the code below). Before Jesper's work, you need to writeummm
as follows, but the computational behavior is the same.