proof - Prove So (0 < m) -> (n ** m = S n) -
i'm trying make idris function of type (j : nat) -> {auto p : (j < n)} -> fin n convert nat fin n. z case work (and output fz), i'm trying prove proof of 0 < n sufficient able make fz : fin n. can't work out how this.
i'm open making different function, long can convert nat values fin n values (where exist). goal have other function can convert nat mod n value, that, example, 15 : nat mapped 3 : mod 4. mod type has single constructor, mkmod : fin n -> mod n.
after learning lt : nat -> nat -> type, took different approach. started declaration:
nattofin : (j : nat) -> {auto p : j `lt` n} -> fin n nattofin {n} j {p} = ?nattofin_rhs_1 . case-splitting on n, on p in n = z case resulted in:
nattofin : (j : nat) -> {auto p : j `lt` n} -> fin n nattofin {n = (s k)} j {p = p} = ?nattofin_rhs_2 , proof asking for. there, case-split on j , filled 0 case, leaving:
nattofin : (j : nat) -> {auto p : j `lt` n} -> fin n nattofin {n = (s k)} z = fz nattofin {n = (s k)} (s j) {p = p} = ?nattofin_rhs_3 . wanted fill ?nattofin_rhs_3 fs (nattofin j), type checker wasn't letting me. however, after case split on p, fine:
nattofin : (j : nat) -> {auto p : j `lt` n} -> fin n nattofin {n = (s k)} z = fz nattofin {n = (s k)} (s j) {p = (ltesucc x)} = fs (nattofin j) finally, added total, , checked out.
the problem idris can't seem find lt proofs automatically. happens:
λΠ> (fin 6) (nattofin 2) when elaborating argument p function mod2.nattofin: can't solve goal lt (frominteger 2) (frominteger 6) is there way fix that?
Comments
Post a Comment