We attempt to decide identity for natural numbers.
import $ivy.`io.github.siddhartha-gadgil::provingground-core-jvm:0.1.1-SNAPSHOT`
import provingground._, induction._, scalahott._
import NatRing._
val n = "n" :: NatTyp
val m = "m" :: NatTyp
val k = "k" :: NatTyp
import spire.implicits._
import HoTT._
val recNatType = rec(Type)
repl.pprinter.bind(translation.FansiShow.fansiPrint)
recNatType.typ
val recNatNatType = rec(NatTyp ->: Type)
recNatNatType.typ
val A = Type.sym
recNatType(One).typ
val step01 = n :-> (A :-> (Zero: Typ[Term]))
step01.typ
val base0 = recNatType(One)(step01)
recNatNatType(base0).typ
base0(0: Nat)
base0(1: Nat)
base0(n + 1)
val Q = (NatTyp ->: Type).sym
recNatType(Zero).typ
(n :-> A :-> Q(n)).typ
val step1arg = recNatType(Zero)(k :-> (A :-> Q(k)))
step1arg.typ
val step0 = n :-> (Q :-> step1arg)
step0.typ
val AreEqual = recNatNatType(base0)(step0)
AreEqual.typ
AreEqual(0: Nat)(0: Nat)
AreEqual(0: Nat)(1: Nat)
AreEqual(0)(n)
AreEqual(n + 1)(0)
AreEqual(n + 1)(n + 1)
AreEqual(m + 1)(m + 1) == AreEqual(m)(m)
val diagInd = induc(m :-> AreEqual(m)(m))
diagInd.typ
AreEqual(2)(3)
diagInd(Star).dom
diagInd(Star).dom == m ~>: (AreEqual(m)(m) ->: AreEqual(m)(m))
val p = AreEqual(m)(m).sym
val diag = diagInd(Star)(m :~> (p :-> p))
diag.typ == n ~>: (AreEqual(n)(n))
val target = n :~> (m :~> (("_" :: (n =:= m)) :-> AreEqual(n)(m)))
val indEq = IdentityTyp.induc(NatTyp, target)
indEq.typ
indEq.dom == m ~>: AreEqual(m)(m)
indEq.dom == diag.typ
indEq(diag).typ
indEq(diag)(m)(n)
indEq(diag)(m)(n).typ == (m =:= n) ->: AreEqual(m)(n)
indEq(diag).typ == m ~>: (n ~>: ((m =:= n) ->: AreEqual(m)(n)))
indEq(diag)(0: Nat)(1: Nat).typ