{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Language.PTS.Examples.Hurkens (
hurkensScript,
defineU,
) where
import Data.String (IsString)
import Language.PTS
hurkensScript :: forall s m. Script s m => m ()
hurkensScript = do
let bot, neg, delta, omega, theta :: IsString a => a
bot = "⊥"
neg = "¬"
delta = "Δ"
omega = "Ω"
theta = "Θ"
let tstar, tbox :: CanSort u => u s a
tstar = sort_ typeSort
tbox = sort_ typeSortSort
section_ "Falsehood and negation"
define_ bot
$$ tstar
$$ forall_ "x" "x"
define_ neg
$$ tstar ~> tstar
$$ lam_ "P" ("P" ~> bot)
example_ bot
example_ neg
section_ "Power set and paradoxial universe"
comment_ "we need (△,△,△) to define ℘ S = S → ⋆"
comment_ "luckily we have Haskell as the meta-language"
let power :: TermInf s a -> TermInf s a
power s = s ~> tstar
define_ "U"
$$ tbox
$$ pi_ "X" tbox ((power (power "X") ~> "X") ~> power (power "X"))
example_ "U"
example_ $ power "U"
example_ $ power (power "U")
section_ "Pseudo-terms"
comment_ "τ : ℘℘U → U"
let tau :: TermInf s Sym -> TermInf s Sym
tau t =
lams_ ["X", "f", "p"] (t @@ lam_ "x" (Inf $ "p" @@ ("f" @@ ("x" @@ "X" @@ "f"))))
-:- "U"
comment_ "σ : U → ℘℘U"
let sigma :: TermInf s Sym -> TermInf s Sym
sigma s =
(Inf $ s @@ "U" @@ lam_ "t" (Inf (tau "t")))
-:- power (power "U")
let tauSigma = tau . sigma
section_ "Normal terms"
define_ delta
$$ power "U"
$$ lam_ "y" (neg @@ pi_ "p" (power "U") (sigma "y" @@ "p" ~> "p" @@@ tauSigma "y"))
define_ omega
$$ "U"
$$ Inf (tau (lam_ "p" (pi_ "x" "U" (sigma "x" @@ "p" ~> "p" @@ "x")) -:- power (power "U")))
define_ theta
$$ tstar
$$ Inf (pi_ "p" (power "U") (pi_ "x" "U" (sigma "x" @@ "p" ~> "p" @@ "x") ~> "p" @@ omega))
define_ "D"
$$ tstar
$$ Inf (pi_ "p" (power "U") (sigma omega @@ "p" ~> "p" @@@ tauSigma omega))
example_ delta
example_ omega
example_ theta
example_ "D"
section_ "Lemmas"
define_ "lemma"
$$ theta
$$ lams_ ["p", "t1"] ("t1" @@ omega @@ lam_ "x" (Inf ("t1" @@@ tauSigma "x")))
define_ "H"
$$ "D"
$$ lam_ "p" ("lemma" @@ lam_ "y" ("p" @@@ tauSigma "y"))
define_ "negH"
$$ neg @@ "D"
$$ "lemma" @@ delta @@ lams_ ["x", "H2", "H3"]
("H3" @@ delta @@ "H2" @@ lam_ "pp" ("H3" @@ lam_ "y" ("pp" @@@ tauSigma "y")))
section_ "Falsehood evidence"
define_ "¡Ay, caramba!" $$ bot $$ "negH" @@ "H"
defineU :: forall s m. Script s m => m ()
defineU = do
let tstar, tbox :: CanSort u => u s a
tstar = sort_ typeSort
tbox = sort_ typeSortSort
section_ "Power set and paradoxial universe"
comment_ "we need (△,△,△) to define ℘ S = S → ⋆"
comment_ "luckily we have Haskell as the meta-language"
let power :: TermInf s a -> TermInf s a
power s = s ~> tstar
define_ "U"
$$ tbox
$$ pi_ "X" tbox ((power (power "X") ~> "X") ~> power (power "X"))