Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type Term s = TermInf s Sym
- data TermInf s a
- = Var a
- | Ann (TermChk s a) (TermInf s a)
- | Pi IrrSym (TermInf s a) (ScopeH IrrSym (TermInf s) (TermInf s) a)
- | App (TermInf s a) (TermChk s a)
- | Sort s
- | Sigma IrrSym (TermInf s a) (ScopeH IrrSym (TermInf s) (TermInf s) a)
- | Equality (TermInf s a) (TermChk s a) (TermChk s a)
- | J (V3 IrrSym) (TermInf s a) (ScopeInf IrrSym3 s a) (TermChk s a) (TermChk s a) (TermChk s a) (TermChk s a)
- | Unit
- | I
- | Empty
- | TermBool
- | TermTrue
- | TermFalse
- | TermBoolElim IrrSym (ScopeInf IrrSym s a) (TermChk s a) (TermChk s a) (TermChk s a)
- | TermAnd (TermChk s a) (TermChk s a)
- | TermNat
- | TermNatZ
- | TermNatS (TermChk s a)
- | TermNatElim IrrSym (ScopeInf IrrSym s a) (TermChk s a) (TermChk s a) (TermChk s a)
- | TermPlus (TermChk s a) (TermChk s a)
- | TermTimes (TermChk s a) (TermChk s a)
- | Hadron (Set Sym)
- | QuarkElim IrrSym (ScopeInf IrrSym s a) (Map Sym (TermChk s a)) (TermChk s a)
- data TermChk s a
- type ScopeInf n s a = ScopeH n (TermInf s) (TermInf s) a
- type ScopeChkInf n s a = ScopeH n (TermChk s) (TermInf s) a
Documentation
Inferable terms, \(\mathit{Term}_\Rightarrow\).
Var a | variable \[ \frac {\Gamma (x) = \tau} {\color{darkblue}\Gamma \vdash \color{darkgreen}x \Rightarrow \color{darkred}\tau} \;\mathrm{V{\scriptstyle AR}} \] |
Ann (TermChk s a) (TermInf s a) | annotated term \[\frac {\color{darkblue}\Gamma \vdash \color{darkgreen}\rho \Leftarrow \color{darkred}{\sigma} \qquad \rho \leadsto \tau} {\color{darkblue}\Gamma \vdash \color{darkgreen}{x : \rho} \Rightarrow \color{darkred}\tau } \;\mathrm{A{\scriptstyle NN}} \] |
Pi IrrSym (TermInf s a) (ScopeH IrrSym (TermInf s) (TermInf s) a) | dependent function space \[\frac {\color{darkblue}\Gamma \vdash \color{darkgreen}{\rho} \Rightarrow \color{darkred}s \qquad \rho \leadsto \tau \qquad \color{darkblue}{\Gamma, x : \tau} \vdash \color{darkgreen}{\rho'} \Rightarrow \color{darkred}{s'} \qquad (s,s',s'') \in \mathcal{R} } {\color{darkblue}\Gamma \vdash \color{darkgreen}{\prod (x : \rho) \to \rho'} \Rightarrow \color{darkred}{s''} } \;\mathsf{Pi} \] |
App (TermInf s a) (TermChk s a) | application \[\frac {\color{darkblue}\Gamma \vdash \color{darkgreen}{e} \Rightarrow \color{darkred}{\prod (x : \tau) \to \tau'} \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}{e'} \Leftarrow \color{darkred}\tau \qquad \tau'[x \mapsto e'] \leadsto \tau'' } {\color{darkblue}\Gamma \vdash \color{darkgreen}{e\, e'} \Rightarrow \color{darkred}{\tau''} } \;\mathrm{A{\scriptstyle PP}} \] |
Sort s | sort \[\frac {s : s' \in \mathcal{A}} {\color{darkblue}\Gamma \vdash \color{darkgreen}s \Rightarrow \color{darkred}{s'} } \;\mathrm{A{\scriptstyle XIOM}} \] |
Sigma IrrSym (TermInf s a) (ScopeH IrrSym (TermInf s) (TermInf s) a) | Dependent pair \[\frac {\color{darkblue}\Gamma \vdash \color{darkgreen}{\rho} \Rightarrow \color{darkred}s \qquad \rho \leadsto \tau \qquad \color{darkblue}{\Gamma, x : \tau} \vdash \color{darkgreen}{\rho'} \Rightarrow \color{darkred}{s'} \qquad (s,s',s'') \in \mathcal{R} } {\color{darkblue}\Gamma \vdash \color{darkgreen}{\sum (x : \rho) \to \rho'} \Rightarrow \color{darkred}{s''} } \;\mathsf{Sigma} \] |
Equality (TermInf s a) (TermChk s a) (TermChk s a) | Propositional equality \[\frac {\color{darkblue}\Gamma \vdash \color{darkgreen}{\rho} \Rightarrow \color{darkred}{s} \qquad \rho \leadsto \tau \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}{x} \Leftarrow \color{darkred}{\tau} \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}{y} \Leftarrow \color{darkred}{\tau} } {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathsf{Eq}\;\rho\;x\;y} \Rightarrow \color{darkred}{s} } \;\mathsf{Eq} \] |
J (V3 IrrSym) (TermInf s a) (ScopeInf IrrSym3 s a) (TermChk s a) (TermChk s a) (TermChk s a) (TermChk s a) | J-rule. Propositional equality elimination. \[\frac {\array{ \color{darkblue}\Gamma \vdash \color{darkgreen}{a} \Rightarrow \color{darkred}{s} \qquad s \in \mathcal{S} \cr \color{darkblue}{\Gamma, x : A, y : A, z : \mathsf{Eq}\,a\,x\,y} \vdash \color{darkgreen}{P} \Rightarrow \color{darkred}{s'} \qquad s' \in \mathcal{S} \cr \color{darkblue}{\Gamma, q : A} \vdash \color{darkgreen}{r} \Leftarrow \color{darkred}{P [ x \mapsto q; y \mapsto q; z \mapsto \mathsf{refl}]} \cr \color{darkblue}{\Gamma} \vdash \color{darkgreen}{u} \Leftarrow \color{darkred}{a} \qquad \color{darkblue}{\Gamma} \vdash \color{darkgreen}{v} \Leftarrow \color{darkred}{a} \qquad \color{darkblue}{\Gamma} \vdash \color{darkgreen}{w} \Leftarrow \color{darkred}{\mathsf{Eq}\,A\,u\,v} }} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathsf{J}\;a\;(\lambda\,x\,y\,z \to c)\;(\lambda\,q \to r)\;u\,v\,w} \Rightarrow \color{darkred}{P [ x \mapsto u; y \mapsto v; z \mapsto w]} } \;\mathsf{J} \] |
Unit | Tautology. \[\frac {} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\top} \Rightarrow \color{darkred}\star} \] |
I | Tautology witness. \[\frac {} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathsf{I}} \Rightarrow \color{darkred}\top} \] |
Empty | Contradiction. \[\frac {} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\bot} \Rightarrow \color{darkred}\star} \] |
TermBool | Booleans \[\frac {} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathbb{B}} \Rightarrow \color{darkred}\star } \] |
TermTrue | True. \[\frac {} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathsf{True}} \Rightarrow \color{darkred}{\mathbb{B}} } \] |
TermFalse | False. \[\frac {} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathsf{False}} \Rightarrow \color{darkred}{\mathbb{B}} } \] |
TermBoolElim IrrSym (ScopeInf IrrSym s a) (TermChk s a) (TermChk s a) (TermChk s a) | Boolean elimination. Note: \(\mathbb{B}\mathsf{-elim}\) is universe-polymorphic. \[ \frac {\array{ \color{darkblue}{\Gamma, x : \mathbb{B}} \vdash \color{darkgreen}P \Rightarrow \color{darkred}{s} \qquad (\star, s, s') \in \mathcal{R} \cr P[x \mapsto \mathsf{True}] \leadsto \tau \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}t \Leftarrow \color{darkred}{\tau} \cr P[x \mapsto \mathsf{False}] \leadsto \tau' \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}f \Leftarrow \color{darkred}{\tau'} \cr \color{darkblue}\Gamma \vdash \color{darkgreen}b \Leftarrow \color{darkred}{\mathbb{B}} \qquad P[x \mapsto b] \leadsto \sigma }} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathbb{B}\mathsf{-elim}\,(\lambda\, x \to P) \,t\,f\,b} \Rightarrow \color{darkred}{\sigma} } \] |
TermAnd (TermChk s a) (TermChk s a) | Boolean conjunction, \[ \frac {\array{ \color{darkblue}\Gamma \vdash \color{darkgreen}x \Leftarrow \color{darkred}{\mathbb{B}} \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}y \Leftarrow \color{darkred}{\mathbb{B}} }} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathbb{B}\mathsf{-and}\,x\,y} \Rightarrow \color{darkred}{\mathbb{B}} } \] |
TermNat | Natural numbers. \[\frac {\star \in \mathcal{S}} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathbb{N}} \Rightarrow \color{darkred}\star } \] |
TermNatZ | Zero. \[\frac {} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathsf{Zero}} \Rightarrow \color{darkred}{\mathbb{N}} } \] |
TermNatS (TermChk s a) | Successor \[\frac {\color{darkbluw}\Gamma \vdash \color{darkgreen}{n} \Leftarrow \color{darkred}{\mathbb{N}} } {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathsf{Succ}\,n} \Rightarrow \color{darkred}{\mathbb{N}} } \] |
TermNatElim IrrSym (ScopeInf IrrSym s a) (TermChk s a) (TermChk s a) (TermChk s a) | Natural numbers elimination. Here we have to assume the target sort (or parametrise further!). \[ \frac {\array{ \color{darkblue}{\Gamma, x : \mathbb{N}} \vdash \color{darkgreen}P \Leftarrow \color{darkred}{s} \qquad (\star, s, s') \in \mathcal{R} \cr P[x \mapsto \mathsf{Zero}] \leadsto \tau \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}z \Leftarrow \color{darkred}{\tau} \cr \prod (l : \mathbb{N}) \to P[x \mapsto l] \to P[x \mapsto \mathsf{Succ}\,l] \leadsto \tau' \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}s \Leftarrow \color{darkred}{\tau'} \cr \color{darkblue}\Gamma \vdash \color{darkgreen}n \Leftarrow \color{darkred}{\mathbb{N}} \qquad P[x \mapsto n] \leadsto \sigma }} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathbb{N}\mathsf{-elim}\,(\lambda\, x \to p)\,z\,s\,n} \Rightarrow \color{darkred}{\sigma} } \] |
TermPlus (TermChk s a) (TermChk s a) | Natural number addition, \[ \frac {\array{ \color{darkblue}\Gamma \vdash \color{darkgreen}x \Leftarrow \color{darkred}{\mathbb{N}} \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}y \Leftarrow \color{darkred}{\mathbb{N}} }} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathbb{N}\mathsf{-plus}\,x\,y} \Rightarrow \color{darkred}{\mathbb{N}} } \] |
TermTimes (TermChk s a) (TermChk s a) | Natural number addition, \[ \frac {\array{ \color{darkblue}\Gamma \vdash \color{darkgreen}x \Leftarrow \color{darkred}{\mathbb{N}} \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}y \Leftarrow \color{darkred}{\mathbb{N}} }} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathbb{N}\mathsf{-times}\,x\,y} \Rightarrow \color{darkred}{\mathbb{N}} } \] |
Hadron (Set Sym) | Hadron type. In physics, quarks combine to form composite particles called hadrons. In our type system(s) quark combine to form types. Hadrons are finite sets (enumerations). We call single quark hadrons atoms. This is not true in physics, but we do get lisp-like atoms this way; i.e. things which are equal to itself only. But we agree with modern physics: atoms are not indivisible. \[\frac {\star \in \mathcal{S}} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\{\overline{:\!\!q}\}} \Rightarrow \color{darkred}\star } \] |
QuarkElim IrrSym (ScopeInf IrrSym s a) (Map Sym (TermChk s a)) (TermChk s a) | Quark elimination. The rule is not the same as in PiSigma label (which influenced quark design). There the rule is checkable, but we have to provide a motive. Note: here we infer the type of hadron from the match clauses. That way we get exhautivity check. The real reason for the quark name is because \(\mathbb{Q}\) is better supported in fonts, than e.g. \(\mathbb{L}\). \[ \frac {\array{ \color{darkblue}{\Gamma, x : \{\overline{:\!\!q}\}} \vdash \color{darkgreen}P \Rightarrow \color{darkred}{s} \qquad (\star, s, s') \in \mathcal{R} \cr P[x \mapsto :\!\!q_i] \leadsto \tau_i \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}{u_i} \Leftarrow \color{darkred}{\tau_i} \cr \color{darkblue}\Gamma \vdash \color{darkgreen}t \Leftarrow \color{darkred}{\{\overline{:\!\!q}\}} \qquad P[x \mapsto t] \leadsto \sigma }} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathbb{Q}\mathsf{-elim}\,(\lambda\, x \to P)\;\{\overline{:\!\!q \longrightarrow u}\}\;t} \Rightarrow \color{darkred}{\sigma} } \] |
Instances
Checkable terms, \(\mathit{Term}_\Leftarrow\).
A type of the same kind as TermInf
to allow abstracting over them.
Inf (TermInf s a) | Inferrable terms \[\frac {\color{darkblue}\Gamma \vdash \color{darkgreen}x \Rightarrow \color{darkred}{\tau'} \qquad \tau \equiv \tau' } {\color{darkblue}\Gamma \vdash \color{darkgreen}x \Leftarrow \color{darkred}\tau } \;\mathrm{C{\scriptstyle HK}} \] |
Lam IrrSym (ScopeChkInf IrrSym s a) | Lambda abstraction \[\frac {\color{darkblue}{\Gamma, x : \tau} \vdash \color{darkgreen}{e} \Leftarrow \color{darkred}{\tau'}} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\lambda\, x \to e} \Leftarrow \color{darkred}{\prod (x : \tau) \to \tau'}} \;\mathrm{L{\scriptstyle AM}} \] |
Pair (TermChk s a) (TermChk s a) | Dependent pair \[\frac {\color{darkblue}\Gamma \vdash \color{darkgreen}{x} \Leftarrow \color{darkred}{\tau} \qquad \color{darkblue}\Gamma \vdash \color{darkgreen}{y} \Leftarrow \color{darkred}{\tau' [ x \mapsto \tau} ] } {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathsf{pair}\;x\;y} \Leftarrow \color{darkred}{\sum (x : \tau) \to \tau'}} \] |
Match (TermInf s a) IrrSym IrrSym (ScopeChkInf IrrSym2 s a) | Dependent pattern match match p (x y -> b) ~ (x y -> b) (fst p) (snd p) \[\frac { \color{darkblue}\Gamma \vdash \color{darkgreen}p \Rightarrow \color{darkred}{\sum (z : \tau) \to \tau'} \qquad \color{darkblue}{\Gamma, x : \tau, y : \tau' [z \mapsto x]} \vdash b \Leftarrow \color{darkred}{\tau''} } {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathsf{match}\;p\;(\lambda\, x\, y \to b)} \Leftarrow \color{darkred}{\tau''}} \] |
Refl | Witness or propositional equality \[\frac {x \equiv y} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathsf{refl}} \Leftarrow \color{darkred}{\mathsf{Eq}\;\tau\;x\;y}} \] |
Absurd (TermChk s a) | Ex falso quodlibet. \[\frac {\color{darkblue}\Gamma \vdash \color{darkgreen}{x} \Leftarrow \color{darkred}\bot} {\color{darkblue}\Gamma \vdash \color{darkgreen}{\mathsf{absurd}\;x} \Leftarrow \color{darkred}{\tau}} \] |
Quark Sym | Single quark. Compare to Booleans: Quarks are prefixed with a colon, to syntatically distinguish them. \[\frac {:\!\!x \in \overline{:\!\!q}} {\color{darkblue}\Gamma \vdash \color{darkgreen}{:\!\!x} \Leftarrow \color{darkred}{\{\overline{:\!\!q}\}} } \] |