module Realisability.Data.Pair {β} (πΈ : PCA β) where
open Realisability.PCA.Sugar πΈ
open Realisability.Data.Bool πΈ
private variable
: β― β πΈ β
a b : Level
β' : Type β' V A B
Pairs in a PCAπ
We define an encoding for pairs in a partial combinatory algebra in terms of the encoding of booleans in a PCA. The pairing of and is the function and the pairing function is this abstracted over and
: β―βΊ πΈ
`pair = val β¨ a β© β¨ b β© β¨ i β© `if i then a else b `pair
_`,_
: β¦ _ : To-term V A β¦ β¦ _ : To-term V B β¦
β A β B β TermΚ° V
= `pair `Β· a `Β· b
a `, b
infixr 24 _`,_
The projection functions simply apply a pair to either `true
or `false
depending.
: β―βΊ πΈ
`fst = val β¨ p β© p `Β· `true
`fst
: β―βΊ πΈ
`snd = val β¨ p β© p `Β· `false `snd
Our standard battery of lemmas follows: `pair
is defined when applied to two
arguments, and the first and second projections compute as expected.
abstract
: β a β β β b β β β `pair β a β b β
`pairββ {a} {b} ah bh = subst β_β (sym (abs-Ξ²β [] ((b , bh) β· (a , ah) β· []))) (absβ _ _)
`pairββ
: β a β β β b β β `fst β (`pair β a β b) β‘ a
`fst-Ξ² {a} {b} ah bh =
`fst-Ξ² (`pair β a β b) β‘β¨ abs-Ξ² _ [] (_ , `pairββ ah bh) β©
`fst β (`true β· (b , bh) β· (a , ah) β· []) β©
`pair β a β b β `true β‘β¨ abs-Ξ²β []
`true β a β b β‘β¨ `true-Ξ² ah bh β©
a β
: β a β β β b β β `snd β (`pair β a β b) β‘ b
`snd-Ξ² {a} {b} ah bh =
`snd-Ξ² (`pair β a β b) β‘β¨ abs-Ξ² _ [] (_ , `pairββ ah bh) β©
`snd β (`false β· (b , bh) β· (a , ah) β· []) β©
`pair β a β b β `false β‘β¨ abs-Ξ²β []
`false β a β b β‘β¨ `false-Ξ² ah bh β© b β