module Realisability.Data.Pair {β} (πΈ : PCA β) whereopen Realisability.PCA.Sugar πΈ
open Realisability.Data.Bool πΈ
private variable
a b : β― β πΈ β
β' : Level
V A B : Type β'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 : β―βΊ πΈ
`pair = val β¨ a β© β¨ b β© β¨ i β© `if i then a else b_`,_
: β¦ _ : To-term V A β¦ β¦ _ : To-term V B β¦
β A β B β TermΚ° V
a `, b = `pair `Β· a `Β· b
infixr 24 _`,_The projection functions simply apply a pair to either `true or `false depending.
`fst : β―βΊ πΈ
`fst = val β¨ p β© p `Β· `true
`snd : β―βΊ πΈ
`snd = val β¨ p β© p `Β· `falseOur standard battery of lemmas follows: `pair is defined when applied to two
arguments, and the first and second projections compute as expected.
abstract
`pairββ : β a β β β b β β β `pair β a β b β
`pairββ {a} {b} ah bh = subst β_β (sym (abs-Ξ²β [] ((b , bh) β· (a , ah) β· []))) (absβ _ _)
`fst-Ξ² : β a β β β b β β `fst β (`pair β a β b) β‘ a
`fst-Ξ² {a} {b} ah bh =
`fst β (`pair β a β b) β‘β¨ abs-Ξ² _ [] (_ , `pairββ ah bh) β©
`pair β a β b β `true β‘β¨ abs-Ξ²β [] (`true β· (b , bh) β· (a , ah) β· []) β©
`true β a β b β‘β¨ `true-Ξ² ah bh β©
a β
`snd-Ξ² : β a β β β b β β `snd β (`pair β a β b) β‘ b
`snd-Ξ² {a} {b} ah bh =
`snd β (`pair β a β b) β‘β¨ abs-Ξ² _ [] (_ , `pairββ ah bh) β©
`pair β a β b β `false β‘β¨ abs-Ξ²β [] (`false β· (b , bh) β· (a , ah) β· []) β©
`false β a β b β‘β¨ `false-Ξ² ah bh β©
b β