2023-05-21 14:09:34 -04:00
|
|
|
module Quox.Displace
|
|
|
|
|
|
|
|
import Quox.Syntax
|
|
|
|
|
2023-08-28 13:57:02 -04:00
|
|
|
%default total
|
|
|
|
|
2023-05-21 14:09:34 -04:00
|
|
|
|
|
|
|
parameters (k : Universe)
|
|
|
|
namespace Term
|
2024-05-27 15:28:22 -04:00
|
|
|
export doDisplace : Term q d n -> Term q d n
|
|
|
|
export doDisplaceS : ScopeTermN s q d n -> ScopeTermN s q d n
|
|
|
|
export doDisplaceDS : DScopeTermN s q d n -> DScopeTermN s q d n
|
2023-05-21 14:09:34 -04:00
|
|
|
|
|
|
|
namespace Elim
|
2024-05-27 15:28:22 -04:00
|
|
|
export doDisplace : Elim q d n -> Elim q d n
|
2023-05-21 14:09:34 -04:00
|
|
|
|
|
|
|
namespace Term
|
|
|
|
doDisplace (TYPE l loc) = TYPE (k + l) loc
|
2023-11-01 10:17:15 -04:00
|
|
|
doDisplace (IOState loc) = IOState loc
|
2023-05-21 14:09:34 -04:00
|
|
|
doDisplace (Pi qty arg res loc) =
|
|
|
|
Pi qty (doDisplace arg) (doDisplaceS res) loc
|
|
|
|
doDisplace (Lam body loc) = Lam (doDisplaceS body) loc
|
|
|
|
doDisplace (Sig fst snd loc) = Sig (doDisplace fst) (doDisplaceS snd) loc
|
|
|
|
doDisplace (Pair fst snd loc) = Pair (doDisplace fst) (doDisplace snd) loc
|
|
|
|
doDisplace (Enum cases loc) = Enum cases loc
|
|
|
|
doDisplace (Tag tag loc) = Tag tag loc
|
|
|
|
doDisplace (Eq ty l r loc) =
|
|
|
|
Eq (doDisplaceDS ty) (doDisplace l) (doDisplace r) loc
|
|
|
|
doDisplace (DLam body loc) = DLam (doDisplaceDS body) loc
|
2023-11-02 13:14:22 -04:00
|
|
|
doDisplace (NAT loc) = NAT loc
|
2023-11-02 15:01:34 -04:00
|
|
|
doDisplace (Nat n loc) = Nat n loc
|
2023-05-21 14:09:34 -04:00
|
|
|
doDisplace (Succ p loc) = Succ (doDisplace p) loc
|
2023-11-01 10:17:15 -04:00
|
|
|
doDisplace (STRING loc) = STRING loc
|
|
|
|
doDisplace (Str s loc) = Str s loc
|
2023-05-21 14:09:34 -04:00
|
|
|
doDisplace (BOX qty ty loc) = BOX qty (doDisplace ty) loc
|
|
|
|
doDisplace (Box val loc) = Box (doDisplace val) loc
|
2023-12-04 16:47:52 -05:00
|
|
|
doDisplace (Let qty rhs body loc) =
|
|
|
|
Let qty (doDisplace rhs) (doDisplaceS body) loc
|
2023-05-21 14:09:34 -04:00
|
|
|
doDisplace (E e) = E (doDisplace e)
|
|
|
|
doDisplace (CloT (Sub t th)) =
|
2023-08-28 13:57:02 -04:00
|
|
|
CloT (Sub (doDisplace t) (assert_total $ map doDisplace th))
|
2023-05-21 14:09:34 -04:00
|
|
|
doDisplace (DCloT (Sub t th)) =
|
|
|
|
DCloT (Sub (doDisplace t) th)
|
2024-05-27 15:28:22 -04:00
|
|
|
doDisplace (QCloT (SubR t th)) =
|
|
|
|
QCloT (SubR (doDisplace t) th)
|
2023-05-21 14:09:34 -04:00
|
|
|
|
|
|
|
doDisplaceS (S names (Y body)) = S names $ Y $ doDisplace body
|
|
|
|
doDisplaceS (S names (N body)) = S names $ N $ doDisplace body
|
|
|
|
|
|
|
|
doDisplaceDS (S names (Y body)) = S names $ Y $ doDisplace body
|
|
|
|
doDisplaceDS (S names (N body)) = S names $ N $ doDisplace body
|
|
|
|
|
|
|
|
namespace Elim
|
|
|
|
doDisplace (F x u loc) = F x (k + u) loc
|
|
|
|
doDisplace (B i loc) = B i loc
|
|
|
|
doDisplace (App fun arg loc) = App (doDisplace fun) (doDisplace arg) loc
|
|
|
|
doDisplace (CasePair qty pair ret body loc) =
|
|
|
|
CasePair qty (doDisplace pair) (doDisplaceS ret) (doDisplaceS body) loc
|
2023-09-18 15:52:51 -04:00
|
|
|
doDisplace (Fst pair loc) = Fst (doDisplace pair) loc
|
|
|
|
doDisplace (Snd pair loc) = Snd (doDisplace pair) loc
|
2023-05-21 14:09:34 -04:00
|
|
|
doDisplace (CaseEnum qty tag ret arms loc) =
|
2023-08-28 13:57:02 -04:00
|
|
|
CaseEnum qty (doDisplace tag) (doDisplaceS ret)
|
|
|
|
(assert_total $ map doDisplace arms) loc
|
2023-05-21 14:09:34 -04:00
|
|
|
doDisplace (CaseNat qty qtyIH nat ret zero succ loc) =
|
|
|
|
CaseNat qty qtyIH (doDisplace nat) (doDisplaceS ret)
|
|
|
|
(doDisplace zero) (doDisplaceS succ) loc
|
|
|
|
doDisplace (CaseBox qty box ret body loc) =
|
|
|
|
CaseBox qty (doDisplace box) (doDisplaceS ret) (doDisplaceS body) loc
|
|
|
|
doDisplace (DApp fun arg loc) =
|
|
|
|
DApp (doDisplace fun) arg loc
|
|
|
|
doDisplace (Ann tm ty loc) =
|
|
|
|
Ann (doDisplace tm) (doDisplace ty) loc
|
|
|
|
doDisplace (Coe ty p q val loc) =
|
|
|
|
Coe (doDisplaceDS ty) p q (doDisplace val) loc
|
|
|
|
doDisplace (Comp ty p q val r zero one loc) =
|
|
|
|
Comp (doDisplace ty) p q (doDisplace val) r
|
|
|
|
(doDisplaceDS zero) (doDisplaceDS one) loc
|
|
|
|
doDisplace (TypeCase ty ret arms def loc) =
|
|
|
|
TypeCase (doDisplace ty) (doDisplace ret)
|
2023-08-28 13:57:02 -04:00
|
|
|
(assert_total $ map doDisplaceS arms) (doDisplace def) loc
|
2023-05-21 14:09:34 -04:00
|
|
|
doDisplace (CloE (Sub e th)) =
|
2023-08-28 13:57:02 -04:00
|
|
|
CloE (Sub (doDisplace e) (assert_total $ map doDisplace th))
|
2023-05-21 14:09:34 -04:00
|
|
|
doDisplace (DCloE (Sub e th)) =
|
|
|
|
DCloE (Sub (doDisplace e) th)
|
2024-05-27 15:28:22 -04:00
|
|
|
doDisplace (QCloE (SubR e th)) =
|
|
|
|
QCloE (SubR (doDisplace e) th)
|
2023-05-21 14:09:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
namespace Term
|
|
|
|
export
|
2024-05-27 15:28:22 -04:00
|
|
|
displace : Universe -> Term q d n -> Term q d n
|
2023-05-21 14:09:34 -04:00
|
|
|
displace 0 t = t
|
|
|
|
displace u t = doDisplace u t
|
|
|
|
|
|
|
|
namespace Elim
|
|
|
|
export
|
2024-05-27 15:28:22 -04:00
|
|
|
displace : Universe -> Elim q d n -> Elim q d n
|
2023-05-21 14:09:34 -04:00
|
|
|
displace 0 t = t
|
|
|
|
displace u t = doDisplace u t
|