Search is not available for this dataset
text
string
meta
dict
{- NEW INTERP WITH RREC -} {-# OPTIONS --no-termination-check #-} open import Preliminaries open import Preorder open import Pilot-WithFlatrec module Interp-WithFlatrec where -- interpret complexity types as preorders [_]t : CTp → PREORDER [ unit ]t = unit-p [ nat ]t = Nat , ♭nat-p [ τ ->c τ₁ ]t = [ τ ]t ->p [ τ₁ ]t [ τ ×c τ₁ ]t = [ τ ]t ×p [ τ₁ ]t [ list τ ]t = (List (fst [ τ ]t)) , list-p (snd [ τ ]t) [ bool ]t = Bool , bool-p [ C ]t = Nat , nat-p [ rnat ]t = Nat , nat-p [_]tm : ∀ {A} → CTpM A → Preorder-max-str (snd [ A ]t) [ runit ]tm = unit-pM [ rn ]tm = nat-pM [ e ×cm e₁ ]tm = axb-pM [ e ]tm [ e₁ ]tm [ _->cm_ {τ1} e ]tm = mono-pM [ e ]tm -- interpret contexts as preorders [_]c : Ctx → PREORDER [ [] ]c = unit-p [ τ :: Γ ]c = [ Γ ]c ×p [ τ ]t lookup : ∀{Γ τ} → τ ∈ Γ → el ([ Γ ]c ->p [ τ ]t) lookup (i0 {Γ} {τ}) = snd' id lookup (iS {Γ} {τ} {τ1} x) = comp (fst' id) (lookup x) interpE : ∀{Γ τ} → Γ |- τ → el ([ Γ ]c ->p [ τ ]t) sound : ∀ {Γ τ} (e e' : Γ |- τ) → e ≤s e' → PREORDER≤ ([ Γ ]c ->p [ τ ]t) (interpE e) (interpE e') interpE unit = monotone (λ x → <>) (λ x y x₁ → <>) interpE 0C = monotone (λ x → Z) (λ x y x₁ → <>) interpE 1C = monotone (λ x → S Z) (λ x y x₁ → <>) interpE (plusC e e₁) = monotone (λ x → Monotone.f (interpE e) x + Monotone.f (interpE e₁) x) (λ x y x₁ → plus-lem (Monotone.f (interpE e) x) (Monotone.f (interpE e₁) x) (Monotone.f (interpE e) y) (Monotone.f (interpE e₁) y) (Monotone.is-monotone (interpE e) x y x₁) (Monotone.is-monotone (interpE e₁) x y x₁)) interpE (var x) = lookup x interpE z = monotone (λ x → Z) (λ x y x₁ → <>) interpE (s e) = monotone (λ x → S (Monotone.f (interpE e) x)) (λ x y x₁ → Monotone.is-monotone (interpE e) x y x₁) interpE {Γ} {τ} (rec e e₁ e₂) = comp (pair' id (interpE e)) (♭rec' (interpE e₁) (interpE e₂)) interpE (lam e) = lam' (interpE e) interpE (app e e₁) = app' (interpE e) (interpE e₁) interpE rz = z' interpE (rsuc e) = suc' (interpE e) interpE (rrec e e₁ e₂ P) = comp (pair' id (interpE e)) (rec' (interpE e₁) (unlam' (unlam' (interpE e₂))) (λ x → sound e₁ (app (app e₂ rz) e₁) P x)) interpE (prod e e₁) = pair' (interpE e) (interpE e₁) interpE (l-proj e) = fst' (interpE e) interpE (r-proj e) = snd' (interpE e) interpE nil = nil' interpE (e ::c e₁) = cons' (interpE e) (interpE e₁) interpE (listrec e e₁ e₂) = comp (pair' id (interpE e)) (lrec' (interpE e₁) (interpE e₂)) interpE true = monotone (λ x → True) (λ x y x₁ → <>) interpE false = monotone (λ x → False) (λ x y x₁ → <>) interpE {Γ} {τ'} (max τ e1 e2) = monotone (λ x → Preorder-max-str.max [ τ ]tm (Monotone.f (interpE e1) x) (Monotone.f (interpE e2) x)) (λ x y x₁ → Preorder-max-str.max-lub [ τ ]tm (Preorder-max-str.max [ τ ]tm (Monotone.f (interpE e1) y) (Monotone.f (interpE e2) y)) (Monotone.f (interpE e1) x) (Monotone.f (interpE e2) x) (Preorder-str.trans (snd [ τ' ]t) (Monotone.f (interpE e1) x) (Monotone.f (interpE e1) y) (Preorder-max-str.max [ τ ]tm (Monotone.f (interpE e1) y) (Monotone.f (interpE e2) y)) (Monotone.is-monotone (interpE e1) x y x₁) (Preorder-max-str.max-l [ τ ]tm (Monotone.f (interpE e1) y) (Monotone.f (interpE e2) y))) (Preorder-str.trans (snd [ τ' ]t) (Monotone.f (interpE e2) x) (Monotone.f (interpE e2) y) (Preorder-max-str.max [ τ ]tm (Monotone.f (interpE e1) y) (Monotone.f (interpE e2) y)) (Monotone.is-monotone (interpE e2) x y x₁) (Preorder-max-str.max-r [ τ ]tm (Monotone.f (interpE e1) y) (Monotone.f (interpE e2) y)))) throw-r : ∀ {Γ Γ' τ} → rctx Γ (τ :: Γ') → rctx Γ Γ' throw-r d = λ x → d (iS x) interpR : ∀ {Γ Γ'} → rctx Γ Γ' → MONOTONE [ Γ ]c [ Γ' ]c interpR {Γ' = []} ρ = monotone (λ _ → <>) (λ x y x₁ → <>) interpR {Γ' = τ :: Γ'} ρ = monotone (λ x → (Monotone.f (interpR (throw-r ρ)) x) , (Monotone.f (lookup (ρ i0)) x)) (λ x y x₁ → (Monotone.is-monotone (interpR (throw-r ρ)) x y x₁) , (Monotone.is-monotone (lookup (ρ i0)) x y x₁)) throw-s : ∀ {Γ Γ' τ} → sctx Γ (τ :: Γ') → sctx Γ Γ' throw-s d = λ x → d (iS x) interpS : ∀ {Γ Γ'} → sctx Γ Γ' → el ([ Γ ]c ->p [ Γ' ]c) interpS {Γ' = []} Θ = monotone (λ _ → <>) (λ x y x₁ → <>) interpS {Γ' = τ :: Γ'} Θ = monotone (λ x → Monotone.f (interpS (throw-s Θ)) x , Monotone.f (interpE (Θ i0)) x) (λ x y x₁ → Monotone.is-monotone (interpS (throw-s Θ)) x y x₁ , (Monotone.is-monotone (interpE (Θ i0)) x y x₁)) ren-eq-l-lam : ∀ {Γ Γ' τ1} (ρ : rctx Γ Γ') (k : fst [ Γ ]c) (x : fst [ τ1 ]t) → Preorder-str.≤ (snd [ Γ' ]c) (Monotone.f (interpR (throw-r (r-extend {_} {_} {τ1} ρ))) (k , x)) (Monotone.f (interpR ρ) k) ren-eq-l-lam {Γ' = []} ρ k x = <> ren-eq-l-lam {Γ' = x :: Γ'} ρ k x₁ = (ren-eq-l-lam (throw-r ρ) k x₁) , (Preorder-str.refl (snd [ x ]t) (Monotone.f (lookup (ρ i0)) k)) ren-eq-l : ∀ {Γ Γ' τ} → (ρ : rctx Γ Γ') → (e : Γ' |- τ) → (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ τ ]t) (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) ren-eq-l ρ unit k = <> ren-eq-l ρ 0C k = <> ren-eq-l ρ 1C k = <> ren-eq-l ρ (plusC e e₁) k = plus-lem (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE (ren e₁ ρ)) k) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)) (ren-eq-l ρ e k) (ren-eq-l ρ e₁ k) ren-eq-l {τ = τ} ρ (var i0) k = Preorder-str.refl (snd [ τ ]t) (Monotone.f (lookup (ρ i0)) k) ren-eq-l {τ = τ} ρ (var (iS x)) k = ren-eq-l (throw-r ρ) (var x) k ren-eq-l ρ z k = <> ren-eq-l ρ (s e) k = ren-eq-l ρ e k ren-eq-l {Γ} {Γ'} {τ = τ} ρ (rec e e₁ e₂) k = Preorder-str.trans (snd [ τ ]t) (natrec (Monotone.f (interpE (ren e₁ ρ)) k) (λ n x₂ → Monotone.f (interpE (ren e₂ (r-extend (r-extend ρ)))) ((k , x₂) , n)) (Monotone.f (interpE (ren e ρ)) k)) (natrec (Monotone.f (interpE (ren e₁ ρ)) k) (λ n x₂ → Monotone.f (interpE (ren e₂ (r-extend (r-extend ρ)))) ((k , x₂) , n)) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) (natrec (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)) (λ n x₂ → Monotone.f (interpE e₂) ((Monotone.f (interpR ρ) k , x₂) , n)) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) (♭h-fix-args (interpE (ren e₁ ρ)) (interpE (ren e₂ (r-extend (r-extend ρ)))) (k , (Monotone.f (interpE (ren e ρ)) k)) (k , (Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) (ren-eq-l ρ e k)) (♭h-cong (interpE (ren e₁ ρ)) (monotone (λ v → Monotone.f (interpE e₁) (Monotone.f (interpR ρ) v)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpR ρ) x) (Monotone.f (interpR ρ) y) (Monotone.is-monotone (interpR ρ) x y x₁))) (interpE (ren e₂ (r-extend (r-extend ρ)))) (monotone (λ v → Monotone.f (interpE e₂) ((Monotone.f (interpR ρ) (fst (fst v)) , snd (fst v)) , snd v)) (λ x y x₁ → Monotone.is-monotone (interpE e₂) ((Monotone.f (interpR ρ) (fst (fst x)) , snd (fst x)) , snd x) ((Monotone.f (interpR ρ) (fst (fst y)) , snd (fst y)) , snd y) (((Monotone.is-monotone (interpR ρ) (fst (fst x)) (fst (fst y)) (fst (fst x₁))) , (snd (fst x₁))) , (snd x₁)))) (k , (Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) (λ x → ren-eq-l ρ e₁ x) (λ x → Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren e₂ (r-extend (r-extend ρ)))) x) (Monotone.f (interpE e₂) (Monotone.f (interpR {nat :: τ :: Γ} {_ :: _ :: Γ'} (r-extend (r-extend ρ))) x)) (Monotone.f (interpE e₂) ((Monotone.f (interpR ρ) (fst (fst x)) , snd (fst x)) , snd x)) (ren-eq-l (r-extend (r-extend ρ)) e₂ x) (Monotone.is-monotone (interpE e₂) (Monotone.f (interpR {nat :: τ :: Γ} {_ :: _ :: Γ'} (r-extend (r-extend ρ))) x) ((Monotone.f (interpR ρ) (fst (fst x)) , snd (fst x)) , snd x) ((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpR (λ x₁ → iS (iS (ρ x₁)))) x) (Monotone.f (interpR {τ :: Γ} {Γ'} (throw-r (r-extend ρ))) (fst (fst x) , snd (fst x))) (Monotone.f (interpR ρ) (fst (fst x))) (ren-eq-l-lam {τ :: Γ} {Γ'} (throw-r (r-extend ρ)) (fst x) (snd x)) (ren-eq-l-lam ρ (fst (fst x)) (snd (fst x))) , (Preorder-str.refl (snd [ τ ]t) (snd (fst x)))) , (♭nat-refl (snd x)))))) ren-eq-l {Γ} {τ = τ1 ->c τ2} ρ (lam e) k x = Preorder-str.trans (snd [ τ2 ]t) (Monotone.f (Monotone.f (interpE (ren (lam e) ρ)) k) x) (Monotone.f (interpE e) (Monotone.f (interpR (r-extend {_} {_} {τ1} ρ)) (k , x))) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k , x)) (ren-eq-l (r-extend ρ) e (k , x)) (Monotone.is-monotone (interpE e) (Monotone.f (interpR (r-extend {_} {_} {τ1} ρ)) (k , x)) (Monotone.f (interpR ρ) k , x) (ren-eq-l-lam ρ k x , (Preorder-str.refl (snd [ τ1 ]t) x))) ren-eq-l {Γ} {τ = τ} ρ (app e e₁) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE (ren e₁ ρ)) k)) (Monotone.f (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k))) (Monotone.f (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k))) (Monotone.is-monotone (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE (ren e₁ ρ)) k) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)) (ren-eq-l ρ e₁ k)) (ren-eq-l ρ e k (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k))) ren-eq-l ρ rz k = <> ren-eq-l ρ (rsuc e) k = ren-eq-l ρ e k ren-eq-l {Γ} {Γ'} {τ} ρ (rrec e e₁ e₂ P) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (comp (pair' id (interpE (ren e ρ))) (rec' (interpE (ren e₁ ρ)) (unlam' (unlam' (interpE (ren e₂ ρ)))) (sound (ren e₁ ρ) (app (app (ren e₂ ρ) rz) (ren e₁ ρ)) (ren-cong P)))) k) (Monotone.f (rec' (interpE (ren e₁ ρ)) (unlam' (unlam' (interpE (ren e₂ ρ)))) (λ x₁ → sound (ren e₁ ρ) (app (app (ren e₂ ρ) rz) (ren e₁ ρ)) (ren-cong P) x₁)) (k , Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) (Monotone.f (comp (pair' id (interpE e)) (rec' (interpE e₁) (unlam' (unlam' (interpE e₂))) (sound e₁ (app (app e₂ rz) e₁) P))) (Monotone.f (interpR ρ) k)) (h-lem2 (interpE (ren e₁ ρ)) (unlam' (unlam' (interpE (ren e₂ ρ)))) (k , Monotone.f (interpE (ren e ρ)) k) (k , Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (λ x → sound (ren e₁ ρ) (app (app (ren e₂ ρ) rz) (ren e₁ ρ)) (ren-cong P) x) (ren-eq-l ρ e k)) (h-cong2 (interpE (ren e₁ ρ)) (monotone (λ z₁ → Monotone.f (interpE e₁) (Monotone.f (interpR ρ) z₁)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpR ρ) x) (Monotone.f (interpR ρ) y) (Monotone.is-monotone (interpR ρ) x y x₁))) (unlam' (unlam' (interpE (ren e₂ ρ)))) (monotone (λ v → Monotone.f (Monotone.f (Monotone.f (interpE e₂) (Monotone.f (interpR ρ) (fst (fst v)))) (snd (fst v))) (snd v)) (λ x y x₁ → Monotone.is-monotone (unlam' (unlam' (interpE e₂))) ((Monotone.f (interpR ρ) (fst (fst x)) , snd (fst x)) , snd x) ((Monotone.f (interpR ρ) (fst (fst y)) , snd (fst y)) , snd y) ((Monotone.is-monotone (interpR ρ) (fst (fst x)) (fst (fst y)) (fst (fst x₁)) , snd (fst x₁)) , snd x₁))) (λ x → ren-eq-l ρ e₁ x) (λ x → ren-eq-l ρ e₂ (fst (fst x)) (snd (fst x)) (snd x)) (λ x₁ → sound (ren e₁ ρ) (app (app (ren e₂ ρ) rz) (ren e₁ ρ)) (ren-cong P) x₁) (λ x₁ → sound e₁ (app (app e₂ rz) e₁) P (Monotone.f (interpR ρ) x₁)) (k , Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) ren-eq-l ρ (prod e e₁) k = (ren-eq-l ρ e k) , (ren-eq-l ρ e₁ k) ren-eq-l ρ (l-proj e) k = fst (ren-eq-l ρ e k) ren-eq-l ρ (r-proj e) k = snd (ren-eq-l ρ e k) ren-eq-l ρ nil k = <> ren-eq-l ρ (e ::c e₁) k = (ren-eq-l ρ e k) , (ren-eq-l ρ e₁ k) ren-eq-l {Γ} {Γ'} {τ = τ} ρ (listrec {.Γ'} {τ'} e e₁ e₂) k = Preorder-str.trans (snd [ τ ]t) (lrec (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE (ren e₁ ρ)) k) (λ x₁ x₂ x₃ → Monotone.f (interpE (ren e₂ (r-extend (r-extend (r-extend ρ))))) (((k , x₃) , x₂) , x₁))) (lrec (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (ren e₁ ρ)) k) (λ x₁ x₂ x₃ → Monotone.f (interpE (ren e₂ (r-extend (r-extend (r-extend ρ))))) (((k , x₃) , x₂) , x₁))) (lrec (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)) (λ x₁ x₂ x₃ → Monotone.f (interpE e₂) (((Monotone.f (interpR ρ) k , x₃) , x₂) , x₁))) (listrec-fix-args (interpE (ren e₁ ρ)) (interpE (ren e₂ (r-extend (r-extend (r-extend ρ))))) (k , (Monotone.f (interpE (ren e ρ)) k)) (k , (Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) ((Preorder-str.refl (snd [ Γ ]c) k) , (ren-eq-l ρ e k))) (lrec-cong (interpE (ren e₁ ρ)) (monotone (λ k₁ → Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k₁)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpR ρ) x) (Monotone.f (interpR ρ) y) (Monotone.is-monotone (interpR ρ) x y x₁))) (interpE (ren e₂ (r-extend (r-extend (r-extend ρ))))) (monotone (λ x → Monotone.f (interpE e₂) ((((Monotone.f (interpR ρ) (fst (fst (fst x)))) , (snd (fst (fst x)))) , (snd (fst x))) , (snd x))) (λ x y x₁ → Monotone.is-monotone (interpE e₂) (((Monotone.f (interpR ρ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x) (((Monotone.f (interpR ρ) (fst (fst (fst y))) , snd (fst (fst y))) , snd (fst y)) , snd y) ((((Monotone.is-monotone (interpR ρ) (fst (fst (fst x))) (fst (fst (fst y))) (fst (fst (fst x₁)))) , (snd (fst (fst x₁)))) , (snd (fst x₁))) , (snd x₁)))) (k , (Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) (λ x → ren-eq-l ρ e₁ x) (λ x → Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren e₂ (r-extend (r-extend (r-extend ρ))))) x) (Monotone.f (interpE e₂) (Monotone.f (interpR {τ' :: list τ' :: τ :: Γ} {_ :: _ :: _ :: Γ'} (r-extend (r-extend (r-extend ρ)))) x)) (Monotone.f (interpE e₂) (((Monotone.f (interpR ρ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x)) (ren-eq-l (r-extend (r-extend (r-extend ρ))) e₂ x) (Monotone.is-monotone (interpE e₂) (Monotone.f (interpR {τ' :: list τ' :: τ :: Γ} {_ :: _ :: _ :: Γ'} (r-extend (r-extend (r-extend ρ)))) x) (((Monotone.f (interpR ρ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x) (((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpR (λ x₁ → iS (iS (iS (ρ x₁))))) x) (Monotone.f (interpR {τ :: Γ} {Γ'} (throw-r (r-extend ρ))) (fst (fst (fst x)) , snd (fst (fst x)))) (Monotone.f (interpR ρ) (fst (fst (fst x)))) (Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpR (λ x₁ → iS (iS (iS (ρ x₁))))) x) (Monotone.f (interpR (λ x₁ → iS (iS (ρ x₁)))) (fst x)) (Monotone.f (interpR {τ :: Γ} {Γ'} (throw-r (r-extend ρ))) (fst (fst (fst x)) , snd (fst (fst x)))) (ren-eq-l-lam (λ x₁ → iS (iS (ρ x₁))) (fst x) (snd x)) (ren-eq-l-lam (λ x₁ → iS (ρ x₁)) (fst (fst x)) (snd (fst x)))) (ren-eq-l-lam ρ (fst (fst (fst x))) (snd (fst (fst x)))) , Preorder-str.refl (snd [ τ ]t) (snd (fst (fst x)))) , l-refl (snd [ τ' ]t) (snd (fst x))) , Preorder-str.refl (snd [ τ' ]t) (snd x))))) ren-eq-l ρ true k = <> ren-eq-l ρ false k = <> ren-eq-l {τ = τ} ρ (max x e e₁) k = Preorder-max-str.max-lub [ x ]tm (Monotone.f (interpE (max x e e₁)) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE (ren e₁ ρ)) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (max x e e₁)) (Monotone.f (interpR ρ) k)) (ren-eq-l ρ e k) (Preorder-max-str.max-l [ x ]tm (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)))) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren e₁ ρ)) k) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (max x e e₁)) (Monotone.f (interpR ρ) k)) (ren-eq-l ρ e₁ k) (Preorder-max-str.max-r [ x ]tm (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)))) ren-eq-r-lam : ∀ {Γ Γ' τ1} (ρ : rctx Γ Γ') (k : fst [ Γ ]c) (x : fst [ τ1 ]t) → Preorder-str.≤ (snd [ Γ' ]c) (Monotone.f (interpR ρ) k) (Monotone.f (interpR (throw-r (r-extend {_} {_} {τ1} ρ))) (k , x)) ren-eq-r-lam {Γ' = []} ρ k x = <> ren-eq-r-lam {Γ' = x :: Γ'} ρ k x₁ = (ren-eq-r-lam (throw-r ρ) k x₁) , (Preorder-str.refl (snd [ x ]t) (Monotone.f (lookup (ρ i0)) k)) ren-eq-r : ∀ {Γ Γ' τ} → (ρ : rctx Γ Γ') → (e : Γ' |- τ) → (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (ren e ρ)) k) ren-eq-r ρ unit k = <> ren-eq-r ρ 0C k = <> ren-eq-r ρ 1C k = <> ren-eq-r ρ (plusC e e₁) k = plus-lem (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE (ren e₁ ρ)) k) (ren-eq-r ρ e k) (ren-eq-r ρ e₁ k) ren-eq-r {τ = τ} ρ (var i0) k = Preorder-str.refl (snd [ τ ]t) (Monotone.f (lookup (ρ i0)) k) ren-eq-r {τ = τ} ρ (var (iS x)) k = ren-eq-r (throw-r ρ) (var x) k ren-eq-r ρ z k = <> ren-eq-r ρ (s e) k = ren-eq-r ρ e k ren-eq-r {Γ} {Γ'} {τ} ρ (rec e e₁ e₂) k = Preorder-str.trans (snd [ τ ]t) (natrec (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)) (λ n x₂ → Monotone.f (interpE e₂) ((Monotone.f (interpR ρ) k , x₂) , n)) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) (natrec (Monotone.f (interpE (ren e₁ ρ)) k) (λ n x₂ → Monotone.f (interpE (ren e₂ (r-extend (r-extend ρ)))) ((k , x₂) , n)) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) (natrec (Monotone.f (interpE (ren e₁ ρ)) k) (λ n x₂ → Monotone.f (interpE (ren e₂ (r-extend (r-extend ρ)))) ((k , x₂) , n)) (Monotone.f (interpE (ren e ρ)) k)) (♭h-cong (monotone (λ v → Monotone.f (interpE e₁) (Monotone.f (interpR ρ) v)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpR ρ) x) (Monotone.f (interpR ρ) y) (Monotone.is-monotone (interpR ρ) x y x₁))) (interpE (ren e₁ ρ)) (monotone (λ v → Monotone.f (interpE e₂) ((Monotone.f (interpR ρ) (fst (fst v)) , snd (fst v)) , snd v)) (λ x y x₁ → Monotone.is-monotone (interpE e₂) ((Monotone.f (interpR ρ) (fst (fst x)) , snd (fst x)) , snd x) ((Monotone.f (interpR ρ) (fst (fst y)) , snd (fst y)) , snd y) ((Monotone.is-monotone (interpR ρ) (fst (fst x)) (fst (fst y)) (fst (fst x₁)) , snd (fst x₁)) , snd x₁))) (interpE (ren e₂ (r-extend (r-extend ρ)))) (k , Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (λ x → ren-eq-r ρ e₁ x) (λ x → Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e₂) ((Monotone.f (interpR ρ) (fst (fst x)) , snd (fst x)) , snd x)) (Monotone.f (interpE e₂) (Monotone.f (interpR {nat :: τ :: Γ} {_ :: _ :: Γ'} (r-extend (r-extend ρ))) x)) (Monotone.f (interpE (ren e₂ (r-extend (r-extend ρ)))) x) (Monotone.is-monotone (interpE e₂) ((Monotone.f (interpR ρ) (fst (fst x)) , snd (fst x)) , snd x) (Monotone.f (interpR {nat :: τ :: Γ} {_ :: _ :: Γ'} (r-extend (r-extend ρ))) x) (((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpR ρ) (fst (fst x))) (Monotone.f (interpR {τ :: Γ} {Γ'} (throw-r (r-extend ρ))) (fst (fst x) , snd (fst x))) (Monotone.f (interpR (λ x₁ → iS (iS (ρ x₁)))) x) (ren-eq-r-lam ρ (fst (fst x)) (snd (fst x))) (ren-eq-r-lam {τ :: Γ} {Γ'} (throw-r (r-extend ρ)) (fst x) (snd x))) , (Preorder-str.refl (snd [ τ ]t) (snd (fst x)))) , (♭nat-refl (snd x)))) (ren-eq-r (r-extend (r-extend ρ)) e₂ x))) (♭h-fix-args (interpE (ren e₁ ρ)) (interpE (ren e₂ (r-extend (r-extend ρ)))) (k , Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (k , Monotone.f (interpE (ren e ρ)) k) (ren-eq-r ρ e k)) ren-eq-r {Γ} {τ = τ1 ->c τ2} ρ (lam e) k x = Preorder-str.trans (snd [ τ2 ]t) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k , x)) (Monotone.f (interpE e) (Monotone.f (interpR (r-extend {_} {_} {τ1} ρ)) (k , x))) (Monotone.f (Monotone.f (interpE (ren (lam e) ρ)) k) x) ((Monotone.is-monotone (interpE e) (Monotone.f (interpR ρ) k , x) (Monotone.f (interpR (r-extend {_} {_} {τ1} ρ)) (k , x)) (ren-eq-r-lam ρ k x , (Preorder-str.refl (snd [ τ1 ]t) x)))) (ren-eq-r (r-extend ρ) e (k , x)) ren-eq-r {Γ} {τ = τ} ρ (app e e₁) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k))) (Monotone.f (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k))) (Monotone.f (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE (ren e₁ ρ)) k)) (ren-eq-r ρ e k (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k))) (Monotone.is-monotone (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (ren e₁ ρ)) k) (ren-eq-r ρ e₁ k)) ren-eq-r ρ rz k = <> ren-eq-r ρ (rsuc e) k = ren-eq-r ρ e k ren-eq-r {Γ} {Γ'} {τ} ρ (rrec e e₁ e₂ P) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (comp (pair' id (interpE e)) (rec' (interpE e₁) (unlam' (unlam' (interpE e₂))) (sound e₁ (app (app e₂ rz) e₁) P))) (Monotone.f (interpR ρ) k)) (Monotone.f (rec' (interpE (ren e₁ ρ)) (unlam' (unlam' (interpE (ren e₂ ρ)))) (λ x₁ → sound (ren e₁ ρ) (app (app (ren e₂ ρ) rz) (ren e₁ ρ)) (ren-cong P) x₁)) (k , Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) (Monotone.f (comp (pair' id (interpE (ren e ρ))) (rec' (interpE (ren e₁ ρ)) (unlam' (unlam' (interpE (ren e₂ ρ)))) (sound (ren e₁ ρ) (app (app (ren e₂ ρ) rz) (ren e₁ ρ)) (ren-cong P)))) k) (h-cong2 (monotone (λ z₁ → Monotone.f (interpE e₁) (Monotone.f (interpR ρ) z₁)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpR ρ) x) (Monotone.f (interpR ρ) y) (Monotone.is-monotone (interpR ρ) x y x₁))) (interpE (ren e₁ ρ)) (monotone (λ v → Monotone.f (Monotone.f (Monotone.f (interpE e₂) (Monotone.f (interpR ρ) (fst (fst v)))) (snd (fst v))) (snd v)) (λ x y x₁ → Monotone.is-monotone (unlam' (unlam' (interpE e₂))) ((Monotone.f (interpR ρ) (fst (fst x)) , snd (fst x)) , snd x) ((Monotone.f (interpR ρ) (fst (fst y)) , snd (fst y)) , snd y) ((Monotone.is-monotone (interpR ρ) (fst (fst x)) (fst (fst y)) (fst (fst x₁)) , snd (fst x₁)) , snd x₁))) (unlam' (unlam' (interpE (ren e₂ ρ)))) (λ x → ren-eq-r ρ e₁ x) (λ x → ren-eq-r ρ e₂ (fst (fst x)) (snd (fst x)) (snd x)) (λ x₁ → sound e₁ (app (app e₂ rz) e₁) P (Monotone.f (interpR ρ) x₁)) (λ x₁ → sound (ren e₁ ρ) (app (app (ren e₂ ρ) rz) (ren e₁ ρ)) (ren-cong P) x₁) (k , (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)))) (h-lem2 (interpE (ren e₁ ρ)) (unlam' (unlam' (interpE (ren e₂ ρ)))) (k , Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (k , Monotone.f (interpE (ren e ρ)) k) (λ x → sound (ren e₁ ρ) (app (app (ren e₂ ρ) rz) (ren e₁ ρ)) (ren-cong P) x) (ren-eq-r ρ e k)) ren-eq-r ρ (prod e e₁) k = (ren-eq-r ρ e k) , (ren-eq-r ρ e₁ k) ren-eq-r ρ (l-proj e) k = fst (ren-eq-r ρ e k) ren-eq-r ρ (r-proj e) k = snd (ren-eq-r ρ e k) ren-eq-r ρ nil k = <> ren-eq-r ρ (e ::c e₁) k = (ren-eq-r ρ e k) , (ren-eq-r ρ e₁ k) ren-eq-r {Γ} {Γ'} {τ} ρ (listrec {.Γ'} {τ'} e e₁ e₂) k = Preorder-str.trans (snd [ τ ]t) (lrec (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)) (λ x₁ x₂ x₃ → Monotone.f (interpE e₂) (((Monotone.f (interpR ρ) k , x₃) , x₂) , x₁))) (lrec (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (ren e₁ ρ)) k) (λ x₁ x₂ x₃ → Monotone.f (interpE (ren e₂ (r-extend (r-extend (r-extend ρ))))) (((k , x₃) , x₂) , x₁))) (lrec (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE (ren e₁ ρ)) k) (λ x₁ x₂ x₃ → Monotone.f (interpE (ren e₂ (r-extend (r-extend (r-extend ρ))))) (((k , x₃) , x₂) , x₁))) (lrec-cong (monotone (λ k₁ → Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k₁)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpR ρ) x) (Monotone.f (interpR ρ) y) (Monotone.is-monotone (interpR ρ) x y x₁))) (interpE (ren e₁ ρ)) (monotone (λ x → Monotone.f (interpE e₂) (((Monotone.f (interpR ρ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x)) (λ x y x₁ → Monotone.is-monotone (interpE e₂) (((Monotone.f (interpR ρ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x) (((Monotone.f (interpR ρ) (fst (fst (fst y))) , snd (fst (fst y))) , snd (fst y)) , snd y) (((Monotone.is-monotone (interpR ρ) (fst (fst (fst x))) (fst (fst (fst y))) (fst (fst (fst x₁))) , snd (fst (fst x₁))) , snd (fst x₁)) , snd x₁))) (interpE (ren e₂ (r-extend (r-extend (r-extend ρ))))) (k , (Monotone.f (interpE e) (Monotone.f (interpR ρ) k))) (λ x → ren-eq-r ρ e₁ x) (λ x → Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e₂) (((Monotone.f (interpR ρ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x)) (Monotone.f (interpE e₂) (Monotone.f (interpR {τ' :: list τ' :: τ :: Γ} {_ :: _ :: _ :: Γ'} (r-extend (r-extend (r-extend ρ)))) x)) (Monotone.f (interpE (ren e₂ (r-extend (r-extend (r-extend ρ))))) x) (Monotone.is-monotone (interpE e₂) (((Monotone.f (interpR ρ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x) (Monotone.f (interpR {τ' :: list τ' :: τ :: Γ} {_ :: _ :: _ :: Γ'} (r-extend (r-extend (r-extend ρ)))) x) ((((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpR ρ) (fst (fst (fst x)))) (Monotone.f (interpR {τ :: Γ} {Γ'} (throw-r (r-extend ρ))) (fst (fst (fst x)) , snd (fst (fst x)))) (Monotone.f (interpR (λ x₁ → iS (iS (iS (ρ x₁))))) x) (ren-eq-r-lam ρ (fst (fst (fst x))) (snd (fst (fst x)))) (Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpR {τ :: Γ} {Γ'} (throw-r (r-extend ρ))) (fst (fst (fst x)) , snd (fst (fst x)))) (Monotone.f (interpR (λ x₁ → iS (iS (ρ x₁)))) (fst x)) (Monotone.f (interpR (λ x₁ → iS (iS (iS (ρ x₁))))) x) (ren-eq-r-lam (λ x₁ → iS (ρ x₁)) (fst (fst x)) (snd (fst x))) (ren-eq-r-lam (λ x₁ → iS (iS (ρ x₁))) (fst x) (snd x)))) , (Preorder-str.refl (snd [ τ ]t) (snd (fst (fst x))))) , (l-refl (snd [ τ' ]t) (snd (fst x)))) , (Preorder-str.refl (snd [ τ' ]t) (snd x)))) (ren-eq-r (r-extend (r-extend (r-extend ρ))) e₂ x))) (listrec-fix-args (interpE (ren e₁ ρ)) (interpE (ren e₂ (r-extend (r-extend (r-extend ρ))))) (k , Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (k , Monotone.f (interpE (ren e ρ)) k) (Preorder-str.refl (snd [ Γ ]c) k , ren-eq-r ρ e k)) ren-eq-r ρ true k = <> ren-eq-r ρ false k = <> ren-eq-r {τ = τ} ρ (max x e e₁) k = Preorder-max-str.max-lub [ x ]tm (Monotone.f (interpE (ren (max x e e₁) ρ)) k) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE (ren (max x e e₁) ρ)) k) (ren-eq-r ρ e k) (Preorder-max-str.max-l [ x ]tm (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE (ren e₁ ρ)) k))) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e₁) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (ren e₁ ρ)) k) (Monotone.f (interpE (ren (max x e e₁) ρ)) k) (ren-eq-r ρ e₁ k) (Preorder-max-str.max-r [ x ]tm (Monotone.f (interpE (ren e ρ)) k) (Monotone.f (interpE (ren e₁ ρ)) k))) ids-lem-l : ∀ {Γ} (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ ]c) (Monotone.f (interpR {Γ} {Γ} (λ x₂ → x₂)) k) k ids-lem-l {[]} k = <> ids-lem-l {x :: Γ} (k1 , k2) = (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {x :: Γ} {Γ} (throw-r (λ x₂ → x₂))) (k1 , k2)) (Monotone.f (interpR {Γ} {Γ} (λ x₂ → x₂)) k1) k1 (ren-eq-l-lam {Γ} {Γ} (λ x₂ → x₂) k1 k2) (ids-lem-l {Γ} k1)) , (Preorder-str.refl (snd [ x ]t) k2) subst-eq-l-lam : ∀ {Γ Γ' τ1} (Θ : sctx Γ Γ') (k : fst [ Γ ]c) (x : fst [ τ1 ]t) → Preorder-str.≤ (snd [ Γ' ]c) (Monotone.f (interpS (throw-s (s-extend {_} {_} {τ1} Θ))) (k , x)) (Monotone.f (interpS Θ) k) subst-eq-l-lam {Γ' = []} Θ k x = <> subst-eq-l-lam {Γ} {Γ' = x :: Γ'} {τ1} Θ k x₁ = (subst-eq-l-lam (throw-s Θ) k x₁) , Preorder-str.trans (snd [ x ]t) (Monotone.f (interpE (ren (Θ i0) iS)) (k , x₁)) (Monotone.f (interpE (Θ i0)) (Monotone.f (interpR {τ1 :: Γ} {Γ} iS) (k , x₁))) (snd (Monotone.f (interpS Θ) k)) (ren-eq-l iS (Θ i0) (k , x₁)) (Monotone.is-monotone (interpE (Θ i0)) (Monotone.f (interpR {τ1 :: Γ} {Γ} iS) (k , x₁)) k (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {τ1 :: Γ} {Γ} iS) (k , x₁)) (Monotone.f (interpR {Γ} {Γ} (λ x₂ → x₂)) k) k (ren-eq-l-lam {Γ} {Γ} (λ x₂ → x₂) k x₁) (ids-lem-l {Γ} k))) subst-eq-l : ∀ {Γ Γ' τ} → (Θ : sctx Γ Γ') → (e : Γ' |- τ) → (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ τ ]t) (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) subst-eq-l Θ unit k = <> subst-eq-l Θ 0C k = <> subst-eq-l Θ 1C k = <> subst-eq-l Θ (plusC e e₁) k = plus-lem (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE (subst e₁ Θ)) k) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)) (subst-eq-l Θ e k) (subst-eq-l Θ e₁ k) subst-eq-l {τ = τ} Θ (var i0) k = Preorder-str.refl (snd [ τ ]t) (Monotone.f (interpE (Θ i0)) k) subst-eq-l {τ = τ} Θ (var (iS x)) k = subst-eq-l (throw-s Θ) (var x) k subst-eq-l Θ z k = <> subst-eq-l Θ (s e) k = subst-eq-l Θ e k subst-eq-l {Γ} {Γ'} {τ} Θ (rec e e₁ e₂) k = Preorder-str.trans (snd [ τ ]t) (natrec (Monotone.f (interpE (subst e₁ Θ)) k) (λ n x₂ → Monotone.f (interpE (subst e₂ (s-extend (s-extend Θ)))) ((k , x₂) , n)) (Monotone.f (interpE (subst e Θ)) k)) (natrec (Monotone.f (interpE (subst e₁ Θ)) k) (λ n x₂ → Monotone.f (interpE (subst e₂ (s-extend (s-extend Θ)))) ((k , x₂) , n)) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k))) (natrec (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)) (λ n x₂ → Monotone.f (interpE e₂) ((Monotone.f (interpS Θ) k , x₂) , n)) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k))) (♭h-fix-args (interpE (subst e₁ Θ)) (interpE (subst e₂ (s-extend (s-extend Θ)))) (k , Monotone.f (interpE (subst e Θ)) k) (k , Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (subst-eq-l Θ e k)) (♭h-cong (interpE (subst e₁ Θ)) (monotone (λ v → Monotone.f (interpE e₁) (Monotone.f (interpS Θ) v)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpS Θ) x) (Monotone.f (interpS Θ) y) (Monotone.is-monotone (interpS Θ) x y x₁))) (interpE (subst e₂ (s-extend (s-extend Θ)))) (monotone (λ v → Monotone.f (interpE e₂) ((Monotone.f (interpS Θ) (fst (fst v)) , snd (fst v)) , snd v)) (λ x y x₁ → Monotone.is-monotone (interpE e₂) ((Monotone.f (interpS Θ) (fst (fst x)) , snd (fst x)) , snd x) ((Monotone.f (interpS Θ) (fst (fst y)) , snd (fst y)) , snd y) ((Monotone.is-monotone (interpS Θ) (fst (fst x)) (fst (fst y)) (fst (fst x₁)) , snd (fst x₁)) , snd x₁))) (k , Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (λ x → subst-eq-l Θ e₁ x) (λ x → Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e₂ (s-extend (s-extend Θ)))) x) (Monotone.f (interpE e₂) (Monotone.f (interpS {nat :: τ :: Γ} {_ :: _ :: Γ'} (s-extend (s-extend Θ))) x)) (Monotone.f (interpE e₂) ((Monotone.f (interpS Θ) (fst (fst x)) , snd (fst x)) , snd x)) (subst-eq-l (s-extend (s-extend Θ)) e₂ x) (Monotone.is-monotone (interpE e₂) (Monotone.f (interpS {nat :: τ :: Γ} {_ :: _ :: Γ'} (s-extend (s-extend Θ))) x) ((Monotone.f (interpS Θ) (fst (fst x)) , snd (fst x)) , snd x) (((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS (λ x₁ → ren (ren (Θ x₁) iS) iS)) x) (Monotone.f (interpS (λ x₁ → ren (Θ x₁) iS)) (fst x)) (Monotone.f (interpS Θ) (fst (fst x))) (subst-eq-l-lam {τ :: Γ} {Γ'} (λ x₁ → ren (Θ x₁) iS) (fst x) (snd x)) (subst-eq-l-lam Θ (fst (fst x)) (snd (fst x)))) , (Preorder-str.refl (snd [ τ ]t) (snd (fst x)))) , (♭nat-refl (snd x)))))) subst-eq-l {Γ} {τ = τ1 ->c τ2} Θ (lam e) k x = Preorder-str.trans (snd [ τ2 ]t) (Monotone.f (Monotone.f (interpE (subst (lam e) Θ)) k) x) (Monotone.f (interpE e) (Monotone.f (interpS (s-extend {_} {_} {τ1} Θ)) (k , x))) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k , x)) (subst-eq-l (s-extend Θ) e (k , x)) (Monotone.is-monotone (interpE e) (Monotone.f (interpS (s-extend {_} {_} {τ1} Θ)) (k , x)) (Monotone.f (interpS Θ) k , x) (subst-eq-l-lam Θ k x , (Preorder-str.refl (snd [ τ1 ]t) x))) subst-eq-l {Γ} {τ = τ} Θ (app e e₁) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE (subst e₁ Θ)) k)) (Monotone.f (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k))) (Monotone.f (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k))) (Monotone.is-monotone (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE (subst e₁ Θ)) k) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)) (subst-eq-l Θ e₁ k)) (subst-eq-l Θ e k (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k))) subst-eq-l Θ rz k = <> subst-eq-l Θ (rsuc e) k = subst-eq-l Θ e k subst-eq-l {Γ} {Γ'} {τ} Θ (rrec e e₁ e₂ P) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (comp (pair' id (interpE (subst e Θ))) (rec' (interpE (subst e₁ Θ)) (unlam' (unlam' (interpE (subst e₂ Θ)))) (sound (subst e₁ Θ) (app (app (subst e₂ Θ) rz) (subst e₁ Θ)) (subst-cong P)))) k) (Monotone.f (rec' (interpE (subst e₁ Θ)) (unlam' (unlam' (interpE (subst e₂ Θ)))) (λ x₁ → sound (subst e₁ Θ) (app (app (subst e₂ Θ) rz) (subst e₁ Θ)) (subst-cong P) x₁)) (k , Monotone.f (interpE e) (Monotone.f (interpS Θ) k))) (Monotone.f (comp (pair' id (interpE e)) (rec' (interpE e₁) (unlam' (unlam' (interpE e₂))) (sound e₁ (app (app e₂ rz) e₁) P))) (Monotone.f (interpS Θ) k)) (h-lem2 (interpE (subst e₁ Θ)) (unlam' (unlam' (interpE (subst e₂ Θ)))) (k , Monotone.f (interpE (subst e Θ)) k) (k , Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (λ x → sound (subst e₁ Θ) (app (app (subst e₂ Θ) rz) (subst e₁ Θ)) (subst-cong P) x) (subst-eq-l Θ e k)) (h-cong2 (interpE (subst e₁ Θ)) (monotone (λ x → Monotone.f (interpE e₁) (Monotone.f (interpS Θ) x)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpS Θ) x) (Monotone.f (interpS Θ) y) (Monotone.is-monotone (interpS Θ) x y x₁))) (unlam' (unlam' (interpE (subst e₂ Θ)))) (monotone (λ x → Monotone.f (Monotone.f (Monotone.f (interpE e₂) (Monotone.f (interpS Θ) (fst (fst x)))) (snd (fst x))) (snd x)) (λ x y x₁ → Monotone.is-monotone (unlam' (unlam' (interpE e₂))) ((Monotone.f (interpS Θ) (fst (fst x)) , snd (fst x)) , snd x) ((Monotone.f (interpS Θ) (fst (fst y)) , snd (fst y)) , snd y) ((Monotone.is-monotone (interpS Θ) (fst (fst x)) (fst (fst y)) (fst (fst x₁)) , snd (fst x₁)) , snd x₁))) (λ x → subst-eq-l Θ e₁ x) (λ x → subst-eq-l Θ e₂ (fst (fst x)) (snd (fst x)) (snd x)) (λ x₁ → sound (subst e₁ Θ) (app (app (subst e₂ Θ) rz) (subst e₁ Θ)) (subst-cong P) x₁) (λ x₁ → sound e₁ (app (app e₂ rz) e₁) P (Monotone.f (interpS Θ) x₁)) (k , Monotone.f (interpE e) (Monotone.f (interpS Θ) k))) subst-eq-l Θ (prod e e₁) k = (subst-eq-l Θ e k) , (subst-eq-l Θ e₁ k) subst-eq-l Θ (l-proj e) k = fst (subst-eq-l Θ e k) subst-eq-l Θ (r-proj e) k = snd (subst-eq-l Θ e k) subst-eq-l Θ nil k = <> subst-eq-l Θ (e ::c e₁) k = (subst-eq-l Θ e k) , (subst-eq-l Θ e₁ k) subst-eq-l {Γ} {Γ'} {τ} Θ (listrec {.Γ'} {τ'} e e₁ e₂) k = Preorder-str.trans (snd [ τ ]t) (lrec (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE (subst e₁ Θ)) k) (λ x₁ x₂ x₃ → Monotone.f (interpE (subst e₂ (s-extend (s-extend (s-extend Θ))))) (((k , x₃) , x₂) , x₁))) (lrec (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e₁ Θ)) k) (λ x₁ x₂ x₃ → Monotone.f (interpE (subst e₂ (s-extend (s-extend (s-extend Θ))))) (((k , x₃) , x₂) , x₁))) (lrec (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)) (λ x₁ x₂ x₃ → Monotone.f (interpE e₂) (((Monotone.f (interpS Θ) k , x₃) , x₂) , x₁))) (listrec-fix-args (interpE (subst e₁ Θ)) (interpE (subst e₂ (s-extend (s-extend (s-extend Θ))))) (k , Monotone.f (interpE (subst e Θ)) k) (k , Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Preorder-str.refl (snd [ Γ ]c) k , subst-eq-l Θ e k)) (lrec-cong (interpE (subst e₁ Θ)) (monotone (λ k₁ → Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k₁)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpS Θ) x) (Monotone.f (interpS Θ) y) (Monotone.is-monotone (interpS Θ) x y x₁))) (interpE (subst e₂ (s-extend (s-extend (s-extend Θ))))) (monotone (λ x → Monotone.f (interpE e₂) (((Monotone.f (interpS Θ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x)) (λ x y x₁ → Monotone.is-monotone (interpE e₂) (((Monotone.f (interpS Θ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x) (((Monotone.f (interpS Θ) (fst (fst (fst y))) , snd (fst (fst y))) , snd (fst y)) , snd y) (((Monotone.is-monotone (interpS Θ) (fst (fst (fst x))) (fst (fst (fst y))) (fst (fst (fst x₁))) , snd (fst (fst x₁))) , snd (fst x₁)) , snd x₁))) (k , Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (λ x → subst-eq-l Θ e₁ x) (λ x → Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e₂ (s-extend (s-extend (s-extend Θ))))) x) (Monotone.f (interpE e₂) (Monotone.f (interpS {τ' :: list τ' :: τ :: Γ} {_ :: _ :: _ :: Γ'} (s-extend (s-extend (s-extend Θ)))) x)) (Monotone.f (interpE e₂) (((Monotone.f (interpS Θ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x)) (subst-eq-l (s-extend (s-extend (s-extend Θ))) e₂ x) (Monotone.is-monotone (interpE e₂) (Monotone.f (interpS {τ' :: list τ' :: τ :: Γ} {_ :: _ :: _ :: Γ'} (s-extend (s-extend (s-extend Θ)))) x) (((Monotone.f (interpS Θ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x) ((((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS (λ x₁ → ren (ren (ren (Θ x₁) iS) iS) iS)) x) (Monotone.f (interpS {τ :: Γ} {Γ'} (throw-s (s-extend Θ))) (fst (fst x))) (Monotone.f (interpS Θ) (fst (fst (fst x)))) (Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS (λ x₁ → ren (ren (ren (Θ x₁) iS) iS) iS)) x) (Monotone.f (interpS (λ x₁ → ren (ren (Θ x₁) iS) iS)) (fst x)) (Monotone.f (interpS {τ :: Γ} {Γ'} (throw-s (s-extend Θ))) (fst (fst x))) (subst-eq-l-lam (λ x₁ → ren (ren (Θ x₁) iS) iS) (fst x) (snd x)) (subst-eq-l-lam (λ x₁ → ren (Θ x₁) iS) (fst (fst x)) (snd (fst x)))) (subst-eq-l-lam {Γ} {Γ'} Θ (fst (fst (fst x))) (snd (fst (fst x))))) , (Preorder-str.refl (snd [ τ ]t) (snd (fst (fst x))))) , (l-refl (snd [ τ' ]t) (snd (fst x)))) , (Preorder-str.refl (snd [ τ' ]t) (snd x)))))) subst-eq-l Θ true k = <> subst-eq-l Θ false k = <> subst-eq-l {τ = τ} Θ (max x e e₁) k = Preorder-max-str.max-lub [ x ]tm (Monotone.f (interpE (max x e e₁)) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE (subst e₁ Θ)) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (max x e e₁)) (Monotone.f (interpS Θ) k)) (subst-eq-l Θ e k) (Preorder-max-str.max-l [ x ]tm (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)))) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e₁ Θ)) k) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (max x e e₁)) (Monotone.f (interpS Θ) k)) (subst-eq-l Θ e₁ k) (Preorder-max-str.max-r [ x ]tm (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)))) ids-lem-r : ∀ {Γ} (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ ]c) k (Monotone.f (interpR {Γ} {Γ} (λ x₂ → x₂)) k) ids-lem-r {[]} k = <> ids-lem-r {x :: Γ} (k1 , k2) = (Preorder-str.trans (snd [ Γ ]c) k1 (Monotone.f (interpR {Γ} {Γ} (λ x₂ → x₂)) k1) (Monotone.f (interpR {x :: Γ} {Γ} (throw-r (λ x₂ → x₂))) (k1 , k2)) (ids-lem-r {Γ} k1) (ren-eq-r-lam {Γ} {Γ} (λ x₂ → x₂) k1 k2)) , (Preorder-str.refl (snd [ x ]t) k2) subst-eq-r-lam : ∀ {Γ Γ' τ1} (Θ : sctx Γ Γ') (k : fst [ Γ ]c) (x : fst [ τ1 ]t) → Preorder-str.≤ (snd [ Γ' ]c) (Monotone.f (interpS Θ) k) (Monotone.f (interpS (throw-s (s-extend {_} {_} {τ1} Θ))) (k , x)) subst-eq-r-lam {Γ' = []} Θ k x = <> subst-eq-r-lam {Γ} {Γ' = x :: Γ'} {τ1} Θ k x₁ = (subst-eq-r-lam (throw-s Θ) k x₁) , Preorder-str.trans (snd [ x ]t) (snd (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (Θ i0)) (Monotone.f (interpR {τ1 :: Γ} {Γ} iS) (k , x₁))) (Monotone.f (interpE (ren (Θ i0) iS)) (k , x₁)) (Monotone.is-monotone (interpE (Θ i0)) k (Monotone.f (interpR {τ1 :: Γ} {Γ} iS) (k , x₁)) (Preorder-str.trans (snd [ Γ ]c) k (Monotone.f (interpR {Γ} {Γ} (λ x₂ → x₂)) k) (Monotone.f (interpR {τ1 :: Γ} {Γ} iS) (k , x₁)) (ids-lem-r {Γ} k) (ren-eq-r-lam {Γ} {Γ} (λ x₂ → x₂) k x₁))) (ren-eq-r iS (Θ i0) (k , x₁)) subst-eq-r : ∀ {Γ Γ' τ} → (Θ : sctx Γ Γ') → (e : Γ' |- τ) → (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e Θ)) k) subst-eq-r Θ unit k = <> subst-eq-r Θ 0C k = <> subst-eq-r Θ 1C k = <> subst-eq-r Θ (plusC e e₁) k = plus-lem (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE (subst e₁ Θ)) k) (subst-eq-r Θ e k) (subst-eq-r Θ e₁ k) subst-eq-r {τ = τ} Θ (var i0) k = Preorder-str.refl (snd [ τ ]t) (Monotone.f (interpE (Θ i0)) k) subst-eq-r {τ = τ} Θ (var (iS x)) k = subst-eq-r (throw-s Θ) (var x) k subst-eq-r Θ z k = <> subst-eq-r Θ (s e) k = subst-eq-r Θ e k subst-eq-r {Γ} {Γ'} {τ} Θ (rec e e₁ e₂) k = Preorder-str.trans (snd [ τ ]t) (natrec (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)) (λ n x₂ → Monotone.f (interpE e₂) ((Monotone.f (interpS Θ) k , x₂) , n)) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k))) (natrec (Monotone.f (interpE (subst e₁ Θ)) k) (λ n x₂ → Monotone.f (interpE (subst e₂ (s-extend (s-extend Θ)))) ((k , x₂) , n)) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k))) (natrec (Monotone.f (interpE (subst e₁ Θ)) k) (λ n x₂ → Monotone.f (interpE (subst e₂ (s-extend (s-extend Θ)))) ((k , x₂) , n)) (Monotone.f (interpE (subst e Θ)) k)) (♭h-cong (monotone (λ v → Monotone.f (interpE e₁) (Monotone.f (interpS Θ) v)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpS Θ) x) (Monotone.f (interpS Θ) y) (Monotone.is-monotone (interpS Θ) x y x₁))) (interpE (subst e₁ Θ)) (monotone (λ v → Monotone.f (interpE e₂) ((Monotone.f (interpS Θ) (fst (fst v)) , snd (fst v)) , snd v)) (λ x y x₁ → Monotone.is-monotone (interpE e₂) ((Monotone.f (interpS Θ) (fst (fst x)) , snd (fst x)) , snd x) ((Monotone.f (interpS Θ) (fst (fst y)) , snd (fst y)) , snd y) ((Monotone.is-monotone (interpS Θ) (fst (fst x)) (fst (fst y)) (fst (fst x₁)) , snd (fst x₁)) , snd x₁))) (interpE (subst e₂ (s-extend (s-extend Θ)))) (k , (Monotone.f (interpE e) (Monotone.f (interpS Θ) k))) (λ x → subst-eq-r Θ e₁ x) (λ x → Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e₂) ((Monotone.f (interpS Θ) (fst (fst x)) , snd (fst x)) , snd x)) (Monotone.f (interpE e₂) (Monotone.f (interpS {nat :: τ :: Γ} {_ :: _ :: Γ'} (s-extend (s-extend Θ))) x)) (Monotone.f (interpE (subst e₂ (s-extend (s-extend Θ)))) x) (Monotone.is-monotone (interpE e₂) ((Monotone.f (interpS Θ) (fst (fst x)) , snd (fst x)) , snd x) (Monotone.f (interpS {nat :: τ :: Γ} {_ :: _ :: Γ'} (s-extend (s-extend Θ))) x) (((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS Θ) (fst (fst x))) (Monotone.f (interpS (λ x₁ → ren (Θ x₁) iS)) (fst x)) (Monotone.f (interpS (λ x₁ → ren (ren (Θ x₁) iS) iS)) x) (subst-eq-r-lam Θ (fst (fst x)) (snd (fst x))) (subst-eq-r-lam {τ :: Γ} {Γ'} (λ x₁ → ren (Θ x₁) iS) (fst x) (snd x))) , (Preorder-str.refl (snd [ τ ]t) (snd (fst x)))) , (♭nat-refl (snd x)))) (subst-eq-r (s-extend (s-extend Θ)) e₂ x))) (♭h-fix-args (interpE (subst e₁ Θ)) (interpE (subst e₂ (s-extend (s-extend Θ)))) (k , Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (k , Monotone.f (interpE (subst e Θ)) k) (subst-eq-r Θ e k)) subst-eq-r {Γ} {τ = τ1 ->c τ2} Θ (lam e) k x = Preorder-str.trans (snd [ τ2 ]t) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k , x)) (Monotone.f (interpE e) (Monotone.f (interpS (s-extend {_} {_} {τ1} Θ)) (k , x))) (Monotone.f (Monotone.f (interpE (subst (lam e) Θ)) k) x) ((Monotone.is-monotone (interpE e) (Monotone.f (interpS Θ) k , x) (Monotone.f (interpS (s-extend {_} {_} {τ1} Θ)) (k , x)) (subst-eq-r-lam Θ k x , (Preorder-str.refl (snd [ τ1 ]t) x)))) (subst-eq-r (s-extend Θ) e (k , x)) subst-eq-r {Γ} {τ = τ} Θ (app e e₁) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k))) (Monotone.f (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k))) (Monotone.f (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE (subst e₁ Θ)) k)) (subst-eq-r Θ e k (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k))) (Monotone.is-monotone (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e₁ Θ)) k) (subst-eq-r Θ e₁ k)) subst-eq-r Θ rz k = <> subst-eq-r Θ (rsuc e) k = subst-eq-r Θ e k subst-eq-r {Γ} {Γ'} {τ} Θ (rrec e e₁ e₂ P) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (comp (pair' id (interpE e)) (rec' (interpE e₁) (unlam' (unlam' (interpE e₂))) (sound e₁ (app (app e₂ rz) e₁) P))) (Monotone.f (interpS Θ) k)) (Monotone.f (rec' (interpE (subst e₁ Θ)) (unlam' (unlam' (interpE (subst e₂ Θ)))) (λ x₁ → sound (subst e₁ Θ) (app (app (subst e₂ Θ) rz) (subst e₁ Θ)) (subst-cong P) x₁)) (k , Monotone.f (interpE e) (Monotone.f (interpS Θ) k))) (Monotone.f (comp (pair' id (interpE (subst e Θ))) (rec' (interpE (subst e₁ Θ)) (unlam' (unlam' (interpE (subst e₂ Θ)))) (sound (subst e₁ Θ) (app (app (subst e₂ Θ) rz) (subst e₁ Θ)) (subst-cong P)))) k) (h-cong2 (monotone (λ z₁ → Monotone.f (interpE e₁) (Monotone.f (interpS Θ) z₁)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpS Θ) x) (Monotone.f (interpS Θ) y) (Monotone.is-monotone (interpS Θ) x y x₁))) (interpE (subst e₁ Θ)) (monotone (λ v → Monotone.f (Monotone.f (Monotone.f (interpE e₂) (Monotone.f (interpS Θ) (fst (fst v)))) (snd (fst v))) (snd v)) (λ x y x₁ → Monotone.is-monotone (unlam' (unlam' (interpE e₂))) ((Monotone.f (interpS Θ) (fst (fst x)) , snd (fst x)) , snd x) ((Monotone.f (interpS Θ) (fst (fst y)) , snd (fst y)) , snd y) ((Monotone.is-monotone (interpS Θ) (fst (fst x)) (fst (fst y)) (fst (fst x₁)) , snd (fst x₁)) , snd x₁))) (unlam' (unlam' (interpE (subst e₂ Θ)))) (λ x → subst-eq-r Θ e₁ x) (λ x → subst-eq-r Θ e₂ (fst (fst x)) (snd (fst x)) (snd x)) (λ x₁ → sound e₁ (app (app e₂ rz) e₁) P (Monotone.f (interpS Θ) x₁)) (λ x₁ → sound (subst e₁ Θ) (app (app (subst e₂ Θ) rz) (subst e₁ Θ)) (subst-cong P) x₁) (k , (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)))) (h-lem2 (interpE (subst e₁ Θ)) (unlam' (unlam' (interpE (subst e₂ Θ)))) (k , Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (k , Monotone.f (interpE (subst e Θ)) k) (λ x → sound (subst e₁ Θ) (app (app (subst e₂ Θ) rz) (subst e₁ Θ)) (subst-cong P) x) (subst-eq-r Θ e k)) subst-eq-r Θ (prod e e₁) k = (subst-eq-r Θ e k) , (subst-eq-r Θ e₁ k) subst-eq-r Θ (l-proj e) k = fst (subst-eq-r Θ e k) subst-eq-r Θ (r-proj e) k = snd (subst-eq-r Θ e k) subst-eq-r Θ nil k = <> subst-eq-r Θ (e ::c e₁) k = (subst-eq-r Θ e k) , (subst-eq-r Θ e₁ k) subst-eq-r {Γ} {Γ'} {τ} Θ (listrec {.Γ'} {τ'} e e₁ e₂) k = Preorder-str.trans (snd [ τ ]t) (lrec (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)) (λ x₁ x₂ x₃ → Monotone.f (interpE e₂) (((Monotone.f (interpS Θ) k , x₃) , x₂) , x₁))) (lrec (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e₁ Θ)) k) (λ x₁ x₂ x₃ → Monotone.f (interpE (subst e₂ (s-extend (s-extend (s-extend Θ))))) (((k , x₃) , x₂) , x₁))) (lrec (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE (subst e₁ Θ)) k) (λ x₁ x₂ x₃ → Monotone.f (interpE (subst e₂ (s-extend (s-extend (s-extend Θ))))) (((k , x₃) , x₂) , x₁))) (lrec-cong (monotone (λ k₁ → Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k₁)) (λ x y x₁ → Monotone.is-monotone (interpE e₁) (Monotone.f (interpS Θ) x) (Monotone.f (interpS Θ) y) (Monotone.is-monotone (interpS Θ) x y x₁))) (interpE (subst e₁ Θ)) (monotone (λ x → Monotone.f (interpE e₂) (((Monotone.f (interpS Θ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x)) (λ x y x₁ → Monotone.is-monotone (interpE e₂) (((Monotone.f (interpS Θ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x) (((Monotone.f (interpS Θ) (fst (fst (fst y))) , snd (fst (fst y))) , snd (fst y)) , snd y) (((Monotone.is-monotone (interpS Θ) (fst (fst (fst x))) (fst (fst (fst y))) (fst (fst (fst x₁))) , snd (fst (fst x₁))) , snd (fst x₁)) , snd x₁))) (interpE (subst e₂ (s-extend (s-extend (s-extend Θ))))) (k , (Monotone.f (interpE e) (Monotone.f (interpS Θ) k))) (λ x → subst-eq-r Θ e₁ x) (λ x → Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e₂) (((Monotone.f (interpS Θ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x)) (Monotone.f (interpE e₂) (Monotone.f (interpS {τ' :: list τ' :: τ :: Γ} {_ :: _ :: _ :: Γ'} (s-extend (s-extend (s-extend Θ)))) x)) (Monotone.f (interpE (subst e₂ (s-extend (s-extend (s-extend Θ))))) x) (Monotone.is-monotone (interpE e₂) (((Monotone.f (interpS Θ) (fst (fst (fst x))) , snd (fst (fst x))) , snd (fst x)) , snd x) (Monotone.f (interpS {τ' :: list τ' :: τ :: Γ} {_ :: _ :: _ :: Γ'} (s-extend (s-extend (s-extend Θ)))) x) ((((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS Θ) (fst (fst (fst x)))) (Monotone.f (interpS {τ :: Γ} {Γ'} (throw-s (s-extend Θ))) (fst (fst x))) (Monotone.f (interpS (λ x₁ → ren (ren (ren (Θ x₁) iS) iS) iS)) x) (subst-eq-r-lam {Γ} {Γ'} Θ (fst (fst (fst x))) (snd (fst (fst x)))) (Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS {τ :: Γ} {Γ'} (throw-s (s-extend Θ))) (fst (fst x))) (Monotone.f (interpS (λ x₁ → ren (ren (Θ x₁) iS) iS)) (fst x)) (Monotone.f (interpS (λ x₁ → ren (ren (ren (Θ x₁) iS) iS) iS)) x) (subst-eq-r-lam (λ x₁ → ren (Θ x₁) iS) (fst (fst x)) (snd (fst x))) (subst-eq-r-lam (λ x₁ → ren (ren (Θ x₁) iS) iS) (fst x) (snd x)))) , (Preorder-str.refl (snd [ τ ]t) (snd (fst (fst x))))) , (l-refl (snd [ τ' ]t) (snd (fst x)))) , (Preorder-str.refl (snd [ τ' ]t) (snd x)))) (subst-eq-r (s-extend (s-extend (s-extend Θ))) e₂ x))) (listrec-fix-args (interpE (subst e₁ Θ)) (interpE (subst e₂ (s-extend (s-extend (s-extend Θ))))) (k , Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (k , Monotone.f (interpE (subst e Θ)) k) (Preorder-str.refl (snd [ Γ ]c) k , subst-eq-r Θ e k)) subst-eq-r Θ true k = <> subst-eq-r Θ false k = <> subst-eq-r {τ = τ} Θ (max x e e₁) k = Preorder-max-str.max-lub [ x ]tm (Monotone.f (interpE (subst (max x e e₁) Θ)) k) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE (subst (max x e e₁) Θ)) k) (subst-eq-r Θ e k) (Preorder-max-str.max-l [ x ]tm (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE (subst e₁ Θ)) k))) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e₁) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e₁ Θ)) k) (Monotone.f (interpE (subst (max x e e₁) Θ)) k) (subst-eq-r Θ e₁ k) (Preorder-max-str.max-r [ x ]tm (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE (subst e₁ Θ)) k))) interp-rr-l : ∀ {Γ Γ' Γ''} (ρ1 : rctx Γ Γ') (ρ2 : rctx Γ' Γ'') (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ'' ]c) (Monotone.f (interpR ρ2) (Monotone.f (interpR ρ1) k)) (Monotone.f (interpR (λ x → ρ1 (ρ2 x))) k) interp-rr-l {Γ'' = []} ρ1 ρ2 k = <> interp-rr-l {Γ'' = x :: Γ''} ρ1 ρ2 k = (interp-rr-l ρ1 (throw-r ρ2) k) , (ren-eq-r ρ1 (var (ρ2 i0)) k) interp-rr-r : ∀ {Γ Γ' Γ''} (ρ1 : rctx Γ Γ') (ρ2 : rctx Γ' Γ'') (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ'' ]c) (Monotone.f (interpR (λ x → ρ1 (ρ2 x))) k) (Monotone.f (interpR ρ2) (Monotone.f (interpR ρ1) k)) interp-rr-r {Γ'' = []} ρ1 ρ2 k = <> interp-rr-r {Γ'' = x :: Γ''} ρ1 ρ2 k = (interp-rr-r ρ1 (throw-r ρ2) k) , (ren-eq-l ρ1 (var (ρ2 i0)) k) interp-rs-l : ∀ {Γ Γ' Γ''} (ρ : rctx Γ Γ') (Θ : sctx Γ' Γ'') (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ'' ]c) (Monotone.f (interpS Θ) (Monotone.f (interpR ρ) k)) (Monotone.f (interpS (λ x → ren (Θ x) ρ)) k) interp-rs-l {Γ'' = []} ρ Θ k = <> interp-rs-l {Γ'' = x :: Γ''} ρ Θ k = (interp-rs-l ρ (throw-s Θ) k) , (ren-eq-r ρ (Θ i0) k) interp-rs-r : ∀ {Γ Γ' Γ''} (ρ : rctx Γ Γ') (Θ : sctx Γ' Γ'') (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ'' ]c) (Monotone.f (interpS (λ x → ren (Θ x) ρ)) k) (Monotone.f (interpS Θ) (Monotone.f (interpR ρ) k)) interp-rs-r {Γ'' = []} ρ Θ k = <> interp-rs-r {Γ'' = x :: Γ''} ρ Θ k = (interp-rs-r ρ (throw-s Θ) k) , (ren-eq-l ρ (Θ i0) k) interp-sr-l : ∀ {Γ Γ' Γ''} (Θ : sctx Γ Γ') (ρ : rctx Γ' Γ'') (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ'' ]c) (Monotone.f (interpR ρ) (Monotone.f (interpS Θ) k)) (Monotone.f (interpS (λ x → Θ (ρ x))) k) interp-sr-l {Γ'' = []} Θ ρ k = <> interp-sr-l {Γ'' = x :: Γ''} Θ ρ k = (interp-sr-l Θ (throw-r ρ) k) , (subst-eq-r Θ (var (ρ i0)) k) interp-sr-r : ∀ {Γ Γ' Γ''} (Θ : sctx Γ Γ') (ρ : rctx Γ' Γ'') (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ'' ]c) (Monotone.f (interpS (λ x → Θ (ρ x))) k) (Monotone.f (interpR ρ) (Monotone.f (interpS Θ) k)) interp-sr-r {Γ'' = []} Θ ρ k = <> interp-sr-r {Γ'' = x :: Γ''} Θ ρ k = (interp-sr-r Θ (throw-r ρ) k) , (subst-eq-l Θ (var (ρ i0)) k) interp-ss-l : ∀ {Γ Γ' Γ''} (Θ1 : sctx Γ Γ') (Θ2 : sctx Γ' Γ'') (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ'' ]c) (Monotone.f (interpS (λ x → subst (Θ2 x) Θ1)) k) (Monotone.f (interpS Θ2) (Monotone.f (interpS Θ1) k)) interp-ss-l {Γ'' = []} Θ1 Θ2 k = <> interp-ss-l {Γ'' = x :: Γ''} Θ1 Θ2 k = (interp-ss-l Θ1 (throw-s Θ2) k) , (subst-eq-l Θ1 (Θ2 i0) k) interp-ss-r : ∀ {Γ Γ' Γ''} (Θ1 : sctx Γ Γ') (Θ2 : sctx Γ' Γ'') (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ'' ]c) (Monotone.f (interpS Θ2) (Monotone.f (interpS Θ1) k)) (Monotone.f (interpS (λ x → subst (Θ2 x) Θ1)) k) interp-ss-r {Γ'' = []} Θ1 Θ2 k = <> interp-ss-r {Γ'' = x :: Γ''} Θ1 Θ2 k = (interp-ss-r Θ1 (throw-s Θ2) k) , (subst-eq-r Θ1 (Θ2 i0) k) lam-s-lem : ∀ {Γ} (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ ]c) (Monotone.f (interpS {Γ} {Γ} ids) k) k lam-s-lem {[]} k = <> lam-s-lem {x :: Γ} (k1 , k2) = (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpS {x :: Γ} {Γ} (throw-s ids)) (k1 , k2)) (Monotone.f (interpS {Γ} {Γ} ids) k1) k1 (subst-eq-l-lam {Γ} {Γ} ids k1 (Monotone.f (interpE {x :: Γ} {x} (ids i0)) (k1 , k2))) (lam-s-lem {Γ} k1)) , (Preorder-str.refl (snd [ x ]t) k2) lam-s-lem-r : ∀ {Γ} (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ ]c) k (Monotone.f (interpS {Γ} {Γ} ids) k) lam-s-lem-r {[]} k = <> lam-s-lem-r {x :: Γ} (k1 , k2) = (Preorder-str.trans (snd [ Γ ]c) k1 (Monotone.f (interpS {Γ} {Γ} ids) k1) (Monotone.f (interpS {x :: Γ} {Γ} (throw-s ids)) (k1 , k2)) (lam-s-lem-r {Γ} k1) (subst-eq-r-lam {Γ} {Γ} ids k1 (Monotone.f (interpE {x :: Γ} {x} (ids i0)) (k1 , k2)))) , (Preorder-str.refl (snd [ x ]t) k2) interp-subst-comp-l : ∀ {Γ Γ' τ'} (Θ : sctx Γ Γ') (v : Γ |- τ') (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ' ]c) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v))) k) (Monotone.f (interpS (λ x → Θ x)) k) interp-subst-comp-l {Γ' = []} Θ v k = <> interp-subst-comp-l {Γ} {Γ' = x :: Γ'} {τ'} Θ v k = (interp-subst-comp-l (throw-s Θ) v k) , (Preorder-str.trans (snd [ x ]t) (Monotone.f (interpE (subst (ren (Θ i0) iS) (lem3' ids v))) k) (Monotone.f (interpE (ren (Θ i0) iS)) (Monotone.f (interpS (lem3' ids v)) k)) (Monotone.f (interpE (Θ i0)) k) (subst-eq-l (lem3' ids v) (ren (Θ i0) iS) k) (Preorder-str.trans (snd [ x ]t) (Monotone.f (interpE (ren (Θ i0) iS)) (Monotone.f (interpS (lem3' ids v)) k)) (Monotone.f (interpE (Θ i0)) (Monotone.f (interpR {τ' :: Γ} {Γ} iS) (Monotone.f (interpS {Γ} {τ' :: Γ} (lem3' ids v)) k))) (Monotone.f (interpE (Θ i0)) k) (ren-eq-l iS (Θ i0) (Monotone.f (interpS (lem3' ids v)) k)) (Monotone.is-monotone (interpE (Θ i0)) (Monotone.f (interpR {τ' :: Γ} {Γ} iS) (Monotone.f (interpS {Γ} {τ' :: Γ} (lem3' ids v)) k)) k (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {τ' :: Γ} {Γ} iS) (Monotone.f (interpS {Γ} {τ' :: Γ} (lem3' ids v)) k)) (Monotone.f (interpR {Γ} {Γ} (λ x₂ → x₂)) k) k (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {τ' :: Γ} {Γ} iS) (Monotone.f (interpS {Γ} {τ' :: Γ} (lem3' ids v)) k)) (Monotone.f (interpR {τ' :: Γ} {Γ} iS) (k , Monotone.f (interpE v) k)) (Monotone.f (interpR {Γ} {Γ} (λ x₂ → x₂)) k) (Monotone.is-monotone (interpR {τ' :: Γ} {Γ} iS) (Monotone.f (interpS {Γ} {τ' :: Γ} (lem3' ids v)) k) (k , Monotone.f (interpE v) k) (lam-s-lem {Γ} k , (Preorder-str.refl (snd [ τ' ]t) (Monotone.f (interpE v) k)))) (ren-eq-l-lam {Γ} {Γ} {τ'} (λ x₂ → x₂) k (Monotone.f (interpE v) k))) (ids-lem-l {Γ} k))))) interp-subst-comp-r : ∀ {Γ Γ' τ'} (Θ : sctx Γ Γ') (v : Γ |- τ') (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ' ]c) (Monotone.f (interpS (λ x → Θ x)) k) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v))) k) interp-subst-comp-r {Γ' = []} Θ v k = <> interp-subst-comp-r {Γ} {Γ' = x :: Γ'} {τ'} Θ v k = (interp-subst-comp-r (throw-s Θ) v k) , Preorder-str.trans (snd [ x ]t) (Monotone.f (interpE (Θ i0)) k) (Monotone.f (interpE (ren (Θ i0) iS)) (Monotone.f (interpS (lem3' ids v)) k)) (Monotone.f (interpE (subst (ren (Θ i0) iS) (lem3' ids v))) k) (Preorder-str.trans (snd [ x ]t) (Monotone.f (interpE (Θ i0)) k) (Monotone.f (interpE (Θ i0)) (Monotone.f (interpR {τ' :: Γ} {Γ} iS) (Monotone.f (interpS {Γ} {τ' :: Γ} (lem3' ids v)) k))) (Monotone.f (interpE (ren (Θ i0) iS)) (Monotone.f (interpS (lem3' ids v)) k)) (Monotone.is-monotone (interpE (Θ i0)) k (Monotone.f (interpR {τ' :: Γ} {Γ} iS) (Monotone.f (interpS {Γ} {τ' :: Γ} (lem3' ids v)) k)) (Preorder-str.trans (snd [ Γ ]c) k (Monotone.f (interpR {Γ} {Γ} (λ x₂ → x₂)) k) (Monotone.f (interpR {τ' :: Γ} {Γ} iS) (Monotone.f (interpS {Γ} {τ' :: Γ} (lem3' ids v)) k)) (ids-lem-r {Γ} k) (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {Γ} {Γ} (λ x₂ → x₂)) k) (Monotone.f (interpR {τ' :: Γ} {Γ} iS) (k , Monotone.f (interpE v) k)) (Monotone.f (interpR {τ' :: Γ} {Γ} iS) (Monotone.f (interpS {Γ} {τ' :: Γ} (lem3' ids v)) k)) (ren-eq-r-lam {Γ} {Γ} {τ'} (λ x₂ → x₂) k (Monotone.f (interpE v) k)) (Monotone.is-monotone (interpR {τ' :: Γ} {Γ} iS) (k , Monotone.f (interpE v) k) (Monotone.f (interpS {Γ} {τ' :: Γ} (lem3' ids v)) k) (lam-s-lem-r {Γ} k , Preorder-str.refl (snd [ τ' ]t) (Monotone.f (interpE v) k)))))) (ren-eq-r iS (Θ i0) (Monotone.f (interpS (lem3' ids v)) k))) (subst-eq-r (lem3' ids v) (ren (Θ i0) iS) k) interp-subst-comp2-l : ∀ {Γ Γ' τ' τ''} (Θ : sctx Γ Γ') (k : fst [ Γ ]c) (v1 : Γ |- τ') (v2 : Γ |- τ'') → Preorder-str.≤ (snd [ Γ' ]c) (Monotone.f (interpS {τ' :: τ'' :: Γ} {Γ'} (λ x → ren (ren (Θ x) iS) iS)) ((Monotone.f (interpS {Γ} {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v2))) k) interp-subst-comp2-l {Γ' = []} Θ k v1 v2 = <> interp-subst-comp2-l {Γ} {Γ' = x :: Γ'} {τ'} {τ''} Θ k v1 v2 = (interp-subst-comp2-l (throw-s Θ) k v1 v2) , Preorder-str.trans (snd [ x ]t) (Monotone.f (interpE (ren (ren (Θ i0) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpE (ren (Θ i0) iS)) (Monotone.f (interpR {τ' :: τ'' :: Γ} iS) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k))) (Monotone.f (interpE (subst (ren (Θ i0) iS) (lem3' ids v2))) k) (ren-eq-l iS (ren (Θ i0) iS) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Preorder-str.trans (snd [ x ]t) (Monotone.f (interpE (ren (Θ i0) iS)) (Monotone.f (interpR {τ' :: τ'' :: Γ} iS) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k))) (Monotone.f (interpE (ren (Θ i0) iS)) (Monotone.f (interpS (lem3' ids v2)) k)) (Monotone.f (interpE (subst (ren (Θ i0) iS) (lem3' ids v2))) k) (Monotone.is-monotone (interpE (ren (Θ i0) iS)) (Monotone.f (interpR {τ' :: τ'' :: Γ} iS) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpS (lem3' ids v2)) k) (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {τ' :: τ'' :: Γ} (λ x₁ → iS (iS x₁))) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpR {Γ} {Γ} (λ x₁ → x₁)) (Monotone.f (interpS {Γ} ids) k)) (Monotone.f (interpS {Γ} ids) k) (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {τ' :: τ'' :: Γ} (λ x₁ → iS (iS x₁))) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpR {τ'' :: Γ} (throw-r (r-extend (λ x₁ → x₁)))) (Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k)) (Monotone.f (interpR {Γ} {Γ} (λ x₁ → x₁)) (Monotone.f (interpS {Γ} ids) k)) (ren-eq-l-lam {τ'' :: Γ} (λ x₁ → iS x₁) (Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) (Monotone.f (interpE v1) k)) (ren-eq-l-lam {Γ} {Γ} {τ''} (λ x₁ → x₁) (Monotone.f (interpS {Γ} ids) k) (Monotone.f (interpE v2) k))) (interp-sr-l {Γ} ids (λ x₁ → x₁) k) , Preorder-str.refl (snd [ τ'' ]t) (Monotone.f (interpE v2) k))) (subst-eq-r (lem3' ids v2) (ren (Θ i0) iS) k)) interp-subst-comp2-r : ∀ {Γ Γ' τ' τ''} (Θ : sctx Γ Γ') (k : fst [ Γ ]c) (v1 : Γ |- τ') (v2 : Γ |- τ'') → Preorder-str.≤ (snd [ Γ' ]c) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v2))) k) (Monotone.f (interpS {τ' :: τ'' :: Γ} {Γ'} (λ x → ren (ren (Θ x) iS) iS)) ((Monotone.f (interpS {Γ} {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) interp-subst-comp2-r {Γ' = []} Θ k v1 v2 = <> interp-subst-comp2-r {Γ} {Γ' = x :: Γ'} {τ'} {τ''} Θ k v1 v2 = (interp-subst-comp2-r (throw-s Θ) k v1 v2) , (Preorder-str.trans (snd [ x ]t) (Monotone.f (interpE (subst (ren (Θ i0) iS) (lem3' ids v2))) k) (Monotone.f (interpE (ren (Θ i0) iS)) (Monotone.f (interpR {τ' :: τ'' :: Γ} iS) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k))) (Monotone.f (interpE (ren (ren (Θ i0) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Preorder-str.trans (snd [ x ]t) (Monotone.f (interpE (subst (ren (Θ i0) iS) (lem3' ids v2))) k) (Monotone.f (interpE (ren (Θ i0) iS)) (Monotone.f (interpS (lem3' ids v2)) k)) (Monotone.f (interpE (ren (Θ i0) iS)) (Monotone.f (interpR {τ' :: τ'' :: Γ} iS) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k))) (subst-eq-l (lem3' ids v2) (ren (Θ i0) iS) k) (Monotone.is-monotone (interpE (ren (Θ i0) iS)) (Monotone.f (interpS (lem3' ids v2)) k) (Monotone.f (interpR {τ' :: τ'' :: Γ} iS) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) ((Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpS {Γ} ids) k) (Monotone.f (interpR {Γ} {Γ} (λ x₁ → x₁)) (Monotone.f (interpS {Γ} ids) k)) (Monotone.f (interpR {τ' :: τ'' :: Γ} (λ x₁ → iS (iS x₁))) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (interp-sr-r {Γ} ids (λ x₁ → x₁) k) (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {Γ} {Γ} (λ x₁ → x₁)) (Monotone.f (interpS {Γ} ids) k)) (Monotone.f (interpR {τ'' :: Γ} (throw-r (r-extend (λ x₁ → x₁)))) (Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k)) (Monotone.f (interpR {τ' :: τ'' :: Γ} (λ x₁ → iS (iS x₁))) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (ren-eq-r-lam {Γ} {Γ} {τ''} (λ x₁ → x₁) (Monotone.f (interpS {Γ} ids) k) (Monotone.f (interpE v2) k)) (ren-eq-r-lam {τ'' :: Γ} (λ x₁ → iS x₁) (Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) (Monotone.f (interpE v1) k)))) , (Preorder-str.refl (snd [ τ'' ]t) (Monotone.f (interpE v2) k))))) (ren-eq-r iS (ren (Θ i0) iS) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k))) interp-subst-comp3-l : ∀ {Γ Γ' τ1 τ2 τ3} (Θ : sctx Γ Γ') (k : fst [ Γ ]c) (v3 : Γ |- τ3) (v2 : Γ |- τ2) (v1 : Γ |- τ1) → Preorder-str.≤ (snd [ Γ' ]c) (Monotone.f (interpS {τ1 :: τ2 :: τ3 :: Γ} {Γ'} (λ x → ren (ren (ren (Θ x) iS) iS) iS)) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpS {τ2 :: τ3 :: Γ} {Γ'} (λ x → ren (ren (Θ x) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k)) interp-subst-comp3-l {Γ' = []} Θ k v3 v2 v1 = <> interp-subst-comp3-l {Γ} {Γ' = x :: Γ'} {τ1} {τ2} {τ3} Θ k v3 v2 v1 = (interp-subst-comp3-l (throw-s Θ) k v3 v2 v1) , (Preorder-str.trans (snd [ x ]t) (Monotone.f (interpE (ren (ren (ren (Θ i0) iS) iS) iS)) (((Monotone.f (interpS {Γ} {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpE (ren (ren (Θ i0) iS) iS)) (Monotone.f (interpR {τ1 :: τ2 :: τ3 :: Γ} {τ2 :: τ3 :: Γ} iS) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k))) (Monotone.f (interpE (ren (ren (Θ i0) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k)) (ren-eq-l iS (ren (ren (Θ i0) iS) iS) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.is-monotone (interpE (ren (ren (Θ i0) iS) iS)) (Monotone.f (interpR {τ1 :: τ2 :: τ3 :: Γ} {τ2 :: τ3 :: Γ} iS) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) ((Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {τ1 :: τ2 :: τ3 :: Γ} {Γ} (λ x₁ → iS (iS (iS x₁)))) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpR {Γ} (λ x₁ → x₁)) (Monotone.f (interpS {Γ} ids) k)) (Monotone.f (interpS {Γ} ids) k) (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {τ1 :: τ2 :: τ3 :: Γ} {Γ} (λ x₁ → iS (iS (iS x₁)))) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpR {τ3 :: Γ} {Γ} (throw-r (r-extend (λ x₁ → x₁)))) (Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k)) (Monotone.f (interpR {Γ} (λ x₁ → x₁)) (Monotone.f (interpS {Γ} ids) k)) (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {τ1 :: τ2 :: τ3 :: Γ} {Γ} (λ x₁ → iS (iS (iS x₁)))) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpR {τ2 :: τ3 :: Γ} (throw-r (r-extend iS))) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k)) (Monotone.f (interpR {τ3 :: Γ} {Γ} (throw-r (r-extend (λ x₁ → x₁)))) (Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k)) (fst (ren-eq-l-lam {τ2 :: τ3 :: Γ} {τ3 :: Γ} {τ1} (λ x₁ → iS x₁) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) (Monotone.f (interpE v1) k))) (ren-eq-l-lam {τ3 :: Γ} {Γ} {τ2} (λ x₁ → iS x₁) (Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) (Monotone.f (interpE v2) k))) (ren-eq-l-lam {Γ} {Γ} {τ3} (λ x₁ → x₁) (Monotone.f (interpS {Γ} ids) k) (Monotone.f (interpE v3) k))) (interp-sr-l {Γ} ids (λ x₁ → x₁) k) , Preorder-str.refl (snd [ τ3 ]t) (Monotone.f (interpE v3) k)) , Preorder-str.refl (snd [ τ2 ]t) (Monotone.f (interpE v2) k)))) interp-subst-comp3-r : ∀ {Γ Γ' τ1 τ2 τ3} (Θ : sctx Γ Γ') (k : fst [ Γ ]c) (v3 : Γ |- τ3) (v2 : Γ |- τ2) (v1 : Γ |- τ1) → Preorder-str.≤ (snd [ Γ' ]c) (Monotone.f (interpS {τ2 :: τ3 :: Γ} {Γ'} (λ x → ren (ren (Θ x) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k)) (Monotone.f (interpS {τ1 :: τ2 :: τ3 :: Γ} {Γ'} (λ x → ren (ren (ren (Θ x) iS) iS) iS)) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) interp-subst-comp3-r {Γ' = []} Θ k v3 v2 v1 = <> interp-subst-comp3-r {Γ} {Γ' = x :: Γ'} {τ1} {τ2} {τ3} Θ k v3 v2 v1 = (interp-subst-comp3-r (throw-s Θ) k v3 v2 v1) , Preorder-str.trans (snd [ x ]t) (Monotone.f (interpE (ren (ren (Θ i0) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k)) (Monotone.f (interpE (ren (ren (Θ i0) iS) iS)) (Monotone.f (interpR {τ1 :: τ2 :: τ3 :: Γ} {τ2 :: τ3 :: Γ} iS) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k))) (Monotone.f (interpE (ren (ren (ren (Θ i0) iS) iS) iS)) (((Monotone.f (interpS {Γ} {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.is-monotone (interpE (ren (ren (Θ i0) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) (Monotone.f (interpR {τ1 :: τ2 :: τ3 :: Γ} {τ2 :: τ3 :: Γ} iS) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (((Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpS {Γ} ids) k) (Monotone.f (interpR {Γ} (λ x₁ → x₁)) (Monotone.f (interpS {Γ} ids) k)) (Monotone.f (interpR {τ1 :: τ2 :: τ3 :: Γ} {Γ} (λ x₁ → iS (iS (iS x₁)))) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (interp-sr-r {Γ} ids (λ x₁ → x₁) k) (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {Γ} (λ x₁ → x₁)) (Monotone.f (interpS {Γ} ids) k)) (Monotone.f (interpR {τ3 :: Γ} {Γ} (throw-r (r-extend (λ x₁ → x₁)))) (Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k)) (Monotone.f (interpR {τ1 :: τ2 :: τ3 :: Γ} {Γ} (λ x₁ → iS (iS (iS x₁)))) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (ren-eq-r-lam {Γ} {Γ} {τ3} (λ x₁ → x₁) (Monotone.f (interpS {Γ} ids) k) (Monotone.f (interpE v3) k)) (Preorder-str.trans (snd [ Γ ]c) (Monotone.f (interpR {τ3 :: Γ} {Γ} (throw-r (r-extend (λ x₁ → x₁)))) (Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k)) (Monotone.f (interpR {τ2 :: τ3 :: Γ} (throw-r (r-extend iS))) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k)) (Monotone.f (interpR {τ1 :: τ2 :: τ3 :: Γ} {Γ} (λ x₁ → iS (iS (iS x₁)))) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (ren-eq-r-lam {τ3 :: Γ} {Γ} {τ2} (λ x₁ → iS x₁) (Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) (Monotone.f (interpE v2) k)) (fst (ren-eq-r-lam {τ2 :: τ3 :: Γ} {τ3 :: Γ} {τ1} (λ x₁ → iS x₁) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) (Monotone.f (interpE v1) k)))))) , (Preorder-str.refl (snd [ τ3 ]t) (Monotone.f (interpE v3) k))) , (Preorder-str.refl (snd [ τ2 ]t) (Monotone.f (interpE v2) k)))) (ren-eq-r iS (ren (ren (Θ i0) iS) iS) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) s-cong2-lem : ∀ {Γ Γ'} (Θ Θ' : sctx Γ Γ') (x : (τ₁ : CTp) (x₁ : τ₁ ∈ Γ') → Θ x₁ ≤s Θ' x₁) (k : fst [ Γ ]c) → Preorder-str.≤ (snd [ Γ' ]c) (Monotone.f (interpS Θ) k) (Monotone.f (interpS Θ') k) s-cong2-lem {Γ' = []} Θ Θ' x k = <> s-cong2-lem {Γ' = x :: Γ'} Θ Θ' x₁ k = s-cong2-lem (throw-s Θ) (throw-s Θ') (λ τ₁ x₂ → x₁ τ₁ (iS x₂)) k , sound (Θ i0) (Θ' i0) (x₁ x i0) k sound {_} {τ} e .e refl-s k = Preorder-str.refl (snd [ τ ]t) (Monotone.f (interpE e) k) sound {Γ} {τ} e e' (trans-s {.Γ} {.τ} {.e} {e''} {.e'} d d₁) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) k) (Monotone.f (interpE e'') k) (Monotone.f (interpE e') k) (sound e e'' d k) (sound e'' e' d₁ k) sound {_} {τ} e .e (cong-refl Refl) k = Preorder-str.refl (snd [ τ ]t) (Monotone.f (interpE e) k) sound .(plusC 0C e') e' +-unit-l k = Preorder-str.refl (snd [ rnat ]t) (Monotone.f (interpE e') k) sound e .(plusC 0C e) +-unit-l' k = Preorder-str.refl (snd [ rnat ]t) (Monotone.f (interpE e) k) sound {_} {.C} .(plusC e' 0C) e' +-unit-r k = +-unit (Monotone.f (interpE e') k) sound e .(plusC e 0C) +-unit-r' k = plus-lem' (Monotone.f (interpE e) k) (Monotone.f (interpE e) k) Z (nat-refl (Monotone.f (interpE e) k)) sound {Γ} {.C} ._ ._ (+-assoc {.Γ} {e1} {e2} {e3}) k = plus-assoc (Monotone.f (interpE e1) k) (Monotone.f (interpE e2) k) (Monotone.f (interpE e3) k) sound {Γ} {.C} ._ ._ (+-assoc' {.Γ} {e1} {e2} {e3}) k = plus-assoc' (Monotone.f (interpE e1) k) (Monotone.f (interpE e2) k) (Monotone.f (interpE e3) k) sound {Γ} {.C} ._ ._ (refl-+ {.Γ} {e0} {e1}) k = +-comm (Monotone.f (interpE e0) k) (Monotone.f (interpE e1) k) sound {Γ} {C} ._ ._ (cong-+ {.Γ} {e0} {e1} {e0'} {e1'} d d₁) k = --also called plus-s. should really delete this rule so we don't have duplicates plus-lem (Monotone.f (interpE e0) k) (Monotone.f (interpE e1) k) (Monotone.f (interpE e0') k) (Monotone.f (interpE e1') k) (sound e0 e0' d k) (sound e1 e1' d₁ k) sound {Γ} {τ} ._ ._ (cong-lproj {.Γ} {.τ} {_} {e} {e'} d) k = fst (sound e e' d k) sound {Γ} {τ} ._ ._ (cong-rproj {.Γ} {_} {.τ} {e} {e'} d) k = snd (sound e e' d k) sound {Γ} {τ} ._ ._ (cong-app {.Γ} {τ'} {.τ} {e} {e'} {e1} d) k = sound e e' d k (Monotone.f (interpE e1) k) sound {Γ} {τ} ._ ._ (ren-cong {.Γ} {Γ'} {.τ} {e1} {e2} {ρ} d) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren e1 ρ)) k) (Monotone.f (interpE e1) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (ren e2 ρ)) k) (ren-eq-l ρ e1 k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e1) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE e2) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (ren e2 ρ)) k) (sound e1 e2 d (Monotone.f (interpR ρ) k)) (ren-eq-r ρ e2 k)) sound {Γ} {τ} ._ ._ (subst-cong {.Γ} {Γ'} {.τ} {e1} {e2} {Θ} d) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 Θ)) k) (Monotone.f (interpE e1) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e2 Θ)) k) (subst-eq-l Θ e1 k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e1) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e2) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e2 Θ)) k) (sound e1 e2 d (Monotone.f (interpS Θ) k)) (subst-eq-r Θ e2 k)) sound {Γ} {τ} ._ ._ (subst-cong2 {.Γ} {Γ'} {.τ} {Θ} {Θ'} {e} x) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e Θ)) k) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e Θ')) k) (subst-eq-l Θ e k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e) (Monotone.f (interpS Θ') k)) (Monotone.f (interpE (subst e Θ')) k) (Monotone.is-monotone (interpE e) (Monotone.f (interpS Θ) k) (Monotone.f (interpS Θ') k) (s-cong2-lem Θ Θ' x k)) (subst-eq-r Θ' e k)) sound {Γ} {τ} ._ ._ (cong-rec {.Γ} {.τ} {e} {e'} {e0} {e1} d) k = ♭h-fix-args (interpE e0) (interpE e1) (k , Monotone.f (interpE e) k) (k , Monotone.f (interpE e') k) (sound e e' d k) sound {Γ} {τ} ._ ._ (cong-listrec {.Γ} {τ'} {.τ} {e} {e'} {e0} {e1} d) k = listrec-fix-args (interpE e0) (interpE e1) (k , (Monotone.f (interpE e) k)) (k , Monotone.f (interpE e') k) ((Preorder-str.refl (snd [ Γ ]c) k) , (sound e e' d k)) sound {Γ} {τ} ._ ._ (lam-s {.Γ} {τ'} {.τ} {e} {e2}) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (q e2))) k) (Monotone.f (interpE e) (Monotone.f (interpS (q e2)) k)) (Monotone.f (interpE e) (k , Monotone.f (interpE e2) k)) (subst-eq-l (q e2) e k) (Monotone.is-monotone (interpE e) (Monotone.f (interpS (q e2)) k) (k , Monotone.f (interpE e2) k) (lam-s-lem {Γ} k , (Preorder-str.refl (snd [ τ' ]t) (Monotone.f (interpE e2) k)))) sound {Γ} {τ} e ._ (l-proj-s {.Γ}) k = Preorder-str.refl (snd [ τ ]t) (Monotone.f (interpE e) k) sound {Γ} {τ} e ._ (r-proj-s {.Γ}) k = Preorder-str.refl (snd [ τ ]t) (Monotone.f (interpE e) k) sound {_} {τ} e ._ rec-steps-z k = Preorder-str.refl (snd [ τ ]t) (Monotone.f (interpE e) k) sound {Γ} {τ} ._ ._ (rec-steps-s {.Γ} {.τ} {e} {e0} {e1}) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (lem3' (lem3' ids (rec e e0 e1)) e))) k) (Monotone.f (interpE e1) (Monotone.f (interpS (lem3' (lem3' ids (rec e e0 e1)) e)) k)) (Monotone.f (interpE e1) ((k , natrec (Monotone.f (interpE e0) k) (λ n x₂ → Monotone.f (interpE e1) ((k , x₂) , n)) (Monotone.f (interpE e) k)) , Monotone.f (interpE e) k)) (subst-eq-l (lem3' (lem3' ids (rec e e0 e1)) e) e1 k) (Monotone.is-monotone (interpE e1) (Monotone.f (interpS (lem3' (lem3' ids (rec e e0 e1)) e)) k) ((k , natrec (Monotone.f (interpE e0) k) (λ n x₂ → Monotone.f (interpE e1) ((k , x₂) , n)) (Monotone.f (interpE e) k)) , Monotone.f (interpE e) k) ((lam-s-lem {Γ} k , (Preorder-str.refl (snd [ τ ]t) (natrec (Monotone.f (interpE e0) k) (λ n x₂ → Monotone.f (interpE e1) ((k , x₂) , n)) (Monotone.f (interpE e) k)))) , (♭nat-refl (Monotone.f (interpE e) k)))) sound {Γ} {τ} e ._ listrec-steps-nil k = Preorder-str.refl (snd [ τ ]t) (Monotone.f (interpE e) k) sound {Γ} {τ} ._ ._ (listrec-steps-cons {.Γ} {τ'} {.τ} {h} {t} {e0} {e1}) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (lem3' (lem3' (lem3' ids (listrec t e0 e1)) t) h))) k) (Monotone.f (interpE e1) (Monotone.f (interpS (lem3' (lem3' (lem3' ids (listrec t e0 e1)) t) h)) k)) (Monotone.f (interpE e1) (((k , lrec (Monotone.f (interpE t) k) (Monotone.f (interpE e0) k) (λ x₁ x₂ x₃ → Monotone.f (interpE e1) (((k , x₃) , x₂) , x₁))) , Monotone.f (interpE t) k) , Monotone.f (interpE h) k)) (subst-eq-l (lem3' (lem3' (lem3' ids (listrec t e0 e1)) t) h) e1 k) (Monotone.is-monotone (interpE e1) (Monotone.f (interpS (lem3' (lem3' (lem3' ids (listrec t e0 e1)) t) h)) k) (((k , lrec (Monotone.f (interpE t) k) (Monotone.f (interpE e0) k) (λ x₁ x₂ x₃ → Monotone.f (interpE e1) (((k , x₃) , x₂) , x₁))) , Monotone.f (interpE t) k) , Monotone.f (interpE h) k) (((lam-s-lem {Γ} k , (Preorder-str.refl (snd [ τ ]t) (lrec (Monotone.f (interpE t) k) (Monotone.f (interpE e0) k) (λ x₁ x₂ x₃ → Monotone.f (interpE e1) (((k , x₃) , x₂) , x₁))))) , (l-refl (snd [ τ' ]t) (Monotone.f (interpE t) k))) , (Preorder-str.refl (snd [ τ' ]t) (Monotone.f (interpE h) k)))) sound {Γ} {τ} .(ren (ren e ρ2) ρ1) ._ (ren-comp-l ρ1 ρ2 e) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren (ren e ρ2) ρ1)) k) (Monotone.f (interpE (ren e ρ2)) (Monotone.f (interpR ρ1) k)) (Monotone.f (interpE (ren e (ρ1 ∙rr ρ2))) k) (ren-eq-l ρ1 (ren e ρ2) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren e ρ2)) (Monotone.f (interpR ρ1) k)) (Monotone.f (interpE e) (Monotone.f (interpR (ρ1 ∙rr ρ2)) k)) (Monotone.f (interpE (ren e (ρ1 ∙rr ρ2))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren e ρ2)) (Monotone.f (interpR ρ1) k)) (Monotone.f (interpE e) (Monotone.f (interpR ρ2) (Monotone.f (interpR ρ1) k))) (Monotone.f (interpE e) (Monotone.f (interpR (ρ1 ∙rr ρ2)) k)) (ren-eq-l ρ2 e (Monotone.f (interpR ρ1) k)) (Monotone.is-monotone (interpE e) (Monotone.f (interpR ρ2) (Monotone.f (interpR ρ1) k)) (Monotone.f (interpR (ρ1 ∙rr ρ2)) k) (interp-rr-l ρ1 ρ2 k))) (ren-eq-r (ρ1 ∙rr ρ2) e k)) sound {Γ} {τ} ._ .(ren (ren e ρ2) ρ1) (ren-comp-r ρ1 ρ2 e) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren e (ρ1 ∙rr ρ2))) k) (Monotone.f (interpE (ren e ρ2)) (Monotone.f (interpR ρ1) k)) (Monotone.f (interpE (ren (ren e ρ2) ρ1)) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren e (ρ1 ∙rr ρ2))) k) (Monotone.f (interpE e) (Monotone.f (interpR (ρ1 ∙rr ρ2)) k)) (Monotone.f (interpE (ren e ρ2)) (Monotone.f (interpR ρ1) k)) (ren-eq-l (ρ1 ∙rr ρ2) e k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpR (ρ1 ∙rr ρ2)) k)) (Monotone.f (interpE e) (Monotone.f (interpR ρ2) (Monotone.f (interpR ρ1) k))) (Monotone.f (interpE (ren e ρ2)) (Monotone.f (interpR ρ1) k)) (Monotone.is-monotone (interpE e) (Monotone.f (interpR (ρ1 ∙rr ρ2)) k) (Monotone.f (interpR ρ2) (Monotone.f (interpR ρ1) k)) (interp-rr-r ρ1 ρ2 k)) (ren-eq-r ρ2 e (Monotone.f (interpR ρ1) k)))) (ren-eq-r ρ1 (ren e ρ2) k) sound {Γ} {τ} e ._ (subst-id-l .e) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) k) (Monotone.f (interpE e) (Monotone.f (interpS {Γ} {Γ} ids) k)) (Monotone.f (interpE (subst e ids)) k) (Monotone.is-monotone (interpE e) k (Monotone.f (interpS {Γ} {Γ} ids) k) (lam-s-lem-r {Γ} k)) (subst-eq-r ids e k) sound {Γ} {τ} ._ e' (subst-id-r .e') k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e' ids)) k) (Monotone.f (interpE e') (Monotone.f (interpS {Γ} {Γ} ids) k)) (Monotone.f (interpE e') k) (subst-eq-l ids e' k) (Monotone.is-monotone (interpE e') (Monotone.f (interpS {Γ} {Γ} ids) k) k (lam-s-lem {Γ} k)) sound {Γ} {τ} .(ren (subst e Θ) ρ) ._ (subst-rs-l ρ Θ e) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren (subst e Θ) ρ)) k) (Monotone.f (interpE (subst e Θ)) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (subst e (ρ rs Θ))) k) (ren-eq-l ρ (subst e Θ) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e Θ)) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE e) (Monotone.f (interpS Θ) (Monotone.f (interpR ρ) k))) (Monotone.f (interpE (subst e (ρ rs Θ))) k) (subst-eq-l Θ e (Monotone.f (interpR ρ) k)) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpS Θ) (Monotone.f (interpR ρ) k))) (Monotone.f (interpE e) (Monotone.f (interpS (ρ rs Θ)) k)) (Monotone.f (interpE (subst e (ρ rs Θ))) k) (Monotone.is-monotone (interpE e) (Monotone.f (interpS Θ) (Monotone.f (interpR ρ) k)) (Monotone.f (interpS (ρ rs Θ)) k) (interp-rs-l ρ Θ k)) (subst-eq-r (ρ rs Θ) e k))) sound {Γ} {τ} ._ .(ren (subst e Θ) ρ) (subst-rs-r ρ Θ e) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (ρ rs Θ))) k) (Monotone.f (interpE (subst e Θ)) (Monotone.f (interpR ρ) k)) (Monotone.f (interpE (ren (subst e Θ) ρ)) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (ρ rs Θ))) k) (Monotone.f (interpE e) (Monotone.f (interpS Θ) (Monotone.f (interpR ρ) k))) (Monotone.f (interpE (subst e Θ)) (Monotone.f (interpR ρ) k)) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (ρ rs Θ))) k) (Monotone.f (interpE e) (Monotone.f (interpS (ρ rs Θ)) k)) (Monotone.f (interpE e) (Monotone.f (interpS Θ) (Monotone.f (interpR ρ) k))) (subst-eq-l (ρ rs Θ) e k) (Monotone.is-monotone (interpE e) (Monotone.f (interpS (ρ rs Θ)) k) (Monotone.f (interpS Θ) (Monotone.f (interpR ρ) k)) (interp-rs-r ρ Θ k))) (subst-eq-r Θ e (Monotone.f (interpR ρ) k))) (ren-eq-r ρ (subst e Θ) k) sound {Γ} {τ} .(subst (ren e ρ) Θ) ._ (subst-sr-l Θ ρ e) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst (ren e ρ) Θ)) k) (Monotone.f (interpE (ren e ρ)) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e (Θ sr ρ))) k) (subst-eq-l Θ (ren e ρ) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren e ρ)) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e) (Monotone.f (interpS (Θ sr ρ)) k)) (Monotone.f (interpE (subst e (Θ sr ρ))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (ren e ρ)) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e) (Monotone.f (interpR ρ) (Monotone.f (interpS Θ) k))) (Monotone.f (interpE e) (Monotone.f (interpS (Θ sr ρ)) k)) (ren-eq-l ρ e (Monotone.f (interpS Θ) k)) (Monotone.is-monotone (interpE e) (Monotone.f (interpR ρ) (Monotone.f (interpS Θ) k)) (Monotone.f (interpS (Θ sr ρ)) k) (interp-sr-l Θ ρ k))) (subst-eq-r (Θ sr ρ) e k)) sound {Γ} {τ} ._ .(subst (ren e ρ) Θ) (subst-sr-r Θ ρ e) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (Θ sr ρ))) k) (Monotone.f (interpE (ren e ρ)) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst (ren e ρ) Θ)) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (Θ sr ρ))) k) (Monotone.f (interpE e) (Monotone.f (interpS (Θ sr ρ)) k)) (Monotone.f (interpE (ren e ρ)) (Monotone.f (interpS Θ) k)) (subst-eq-l (Θ sr ρ) e k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpS (Θ sr ρ)) k)) (Monotone.f (interpE e) (Monotone.f (interpR ρ) (Monotone.f (interpS Θ) k))) (Monotone.f (interpE (ren e ρ)) (Monotone.f (interpS Θ) k)) (Monotone.is-monotone (interpE e) (Monotone.f (interpS (Θ sr ρ)) k) (Monotone.f (interpR ρ) (Monotone.f (interpS Θ) k)) (interp-sr-r Θ ρ k)) (ren-eq-r ρ e (Monotone.f (interpS Θ) k)))) (subst-eq-r Θ (ren e ρ) k) sound {Γ} {τ} ._ .(subst (subst e Θ2) Θ1) (subst-ss-l Θ1 Θ2 e) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (Θ1 ss Θ2))) k) (Monotone.f (interpE e) (Monotone.f (interpS (Θ1 ss Θ2)) k)) (Monotone.f (interpE (subst (subst e Θ2) Θ1)) k) (subst-eq-l (Θ1 ss Θ2) e k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpS (Θ1 ss Θ2)) k)) (Monotone.f (interpE (subst e Θ2)) (Monotone.f (interpS Θ1) k)) (Monotone.f (interpE (subst (subst e Θ2) Θ1)) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpS (Θ1 ss Θ2)) k)) (Monotone.f (interpE e) (Monotone.f (interpS Θ2) (Monotone.f (interpS Θ1) k))) (Monotone.f (interpE (subst e Θ2)) (Monotone.f (interpS Θ1) k)) (Monotone.is-monotone (interpE e) (Monotone.f (interpS (Θ1 ss Θ2)) k) (Monotone.f (interpS Θ2) (Monotone.f (interpS Θ1) k)) (interp-ss-l Θ1 Θ2 k)) (subst-eq-r Θ2 e (Monotone.f (interpS Θ1) k))) (subst-eq-r Θ1 (subst e Θ2) k)) sound {Γ} {τ} .(subst (subst e Θ2) Θ1) ._ (subst-ss-r Θ1 Θ2 e) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst (subst e Θ2) Θ1)) k) (Monotone.f (interpE e) (Monotone.f (interpS (Θ1 ss Θ2)) k)) (Monotone.f (interpE (subst e (Θ1 ss Θ2))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst (subst e Θ2) Θ1)) k) (Monotone.f (interpE (subst e Θ2)) (Monotone.f (interpS Θ1) k)) (Monotone.f (interpE e) (Monotone.f (interpS (Θ1 ss Θ2)) k)) (subst-eq-l Θ1 (subst e Θ2) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e Θ2)) (Monotone.f (interpS Θ1) k)) (Monotone.f (interpE e) (Monotone.f (interpS Θ2) (Monotone.f (interpS Θ1) k))) (Monotone.f (interpE e) (Monotone.f (interpS (Θ1 ss Θ2)) k)) (subst-eq-l Θ2 e (Monotone.f (interpS Θ1) k)) (Monotone.is-monotone (interpE e) (Monotone.f (interpS Θ2) (Monotone.f (interpS Θ1) k)) (Monotone.f (interpS (Θ1 ss Θ2)) k) (interp-ss-r Θ1 Θ2 k)))) (subst-eq-r (Θ1 ss Θ2) e k) sound {Γ} {τ} ._ .(subst e (lem3' Θ v)) (subst-compose-l {.Γ} {Γ'} {τ'} Θ v e) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst (subst e (s-extend Θ)) (q v))) k) (Monotone.f (interpE (subst e (s-extend Θ))) (Monotone.f (interpS (q v)) k)) (Monotone.f (interpE (subst e (lem3' Θ v))) k) (subst-eq-l (q v) (subst e (s-extend Θ)) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (s-extend Θ))) (Monotone.f (interpS (q v)) k)) (Monotone.f (interpE e) (Monotone.f (interpS (lem3' Θ v)) k)) (Monotone.f (interpE (subst e (lem3' Θ v))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (s-extend Θ))) (Monotone.f (interpS (q v)) k)) (Monotone.f (interpE e) (Monotone.f (interpS {τ' :: Γ} {τ' :: Γ'} (s-extend {Γ} {Γ'} Θ)) (Monotone.f (interpS {Γ} {τ' :: Γ} (q v)) k))) (Monotone.f (interpE e) (Monotone.f (interpS (lem3' Θ v)) k)) (subst-eq-l (s-extend Θ) e (Monotone.f (interpS (q v)) k)) (Monotone.is-monotone (interpE e) (Monotone.f (interpS {τ' :: Γ} {τ' :: Γ'} (s-extend {Γ} {Γ'} Θ)) (Monotone.f (interpS {Γ} {τ' :: Γ} (q v)) k)) (Monotone.f (interpS (lem3' Θ v)) k) (Preorder-str.trans (snd [ Γ' ]c) (fst (Monotone.f (interpS (s-extend Θ)) (Monotone.f (interpS (q v)) k))) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v))) k) (Monotone.f (interpS Θ) k) (fst (interp-ss-r (q v) (s-extend Θ) k)) (interp-subst-comp-l Θ v k) , Preorder-str.refl (snd [ τ' ]t) (Monotone.f (interpE v) k)))) (subst-eq-r (lem3' Θ v) e k)) sound {Γ} {τ} .(subst e (lem3' Θ v)) ._ (subst-compose-r {.Γ} {Γ'} {τ'} Θ v e) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (lem3' Θ v))) k) (Monotone.f (interpE (subst e (s-extend Θ))) (Monotone.f (interpS (q v)) k)) (Monotone.f (interpE (subst (subst e (s-extend Θ)) (q v))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (lem3' Θ v))) k) (Monotone.f (interpE e) (Monotone.f (interpS (lem3' Θ v)) k)) (Monotone.f (interpE (subst e (s-extend Θ))) (Monotone.f (interpS (q v)) k)) (subst-eq-l (lem3' Θ v) e k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpS (lem3' Θ v)) k)) (Monotone.f (interpE e) (Monotone.f (interpS {τ' :: Γ} {τ' :: Γ'} (s-extend {Γ} {Γ'} Θ)) (Monotone.f (interpS {Γ} {τ' :: Γ} (q v)) k))) (Monotone.f (interpE (subst e (s-extend Θ))) (Monotone.f (interpS (q v)) k)) (Monotone.is-monotone (interpE e) (Monotone.f (interpS (lem3' Θ v)) k) (Monotone.f (interpS {τ' :: Γ} {τ' :: Γ'} (s-extend {Γ} {Γ'} Θ)) (Monotone.f (interpS {Γ} {τ' :: Γ} (q v)) k)) ((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS Θ) k) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v))) k) (fst (Monotone.f (interpS (s-extend Θ)) (Monotone.f (interpS (q v)) k))) (interp-subst-comp-r Θ v k) (fst (interp-ss-l (q v) (s-extend Θ) k))) , (Preorder-str.refl (snd [ τ' ]t) (Monotone.f (interpE v) k)))) (subst-eq-r (s-extend Θ) e (Monotone.f (interpS (q v)) k)))) (subst-eq-r (q v) (subst e (s-extend Θ)) k) sound {Γ} {τ} ._ .(subst e1 (lem3' (lem3' Θ v2) v1)) (subst-compose2-l {.Γ} {Γ'} {.τ} {τ'} {τ''} Θ e1 v1 v2) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst (subst e1 (s-extend (s-extend Θ))) (lem4 v1 v2))) k) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.f (interpE (subst e1 (lem4' Θ v1 v2))) k) (subst-eq-l (lem4 v1 v2) (subst e1 (s-extend (s-extend Θ))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.f (interpE e1) (Monotone.f (interpS (lem4' Θ v1 v2)) k)) (Monotone.f (interpE (subst e1 (lem4' Θ v1 v2))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.f (interpE e1) (Monotone.f (interpS {τ' :: τ'' :: Γ} {τ' :: τ'' :: Γ'} (s-extend (s-extend Θ))) (Monotone.f (interpS (lem4 v1 v2)) k))) (Monotone.f (interpE e1) (Monotone.f (interpS (lem4' Θ v1 v2)) k)) (subst-eq-l (s-extend (s-extend Θ)) e1 (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.is-monotone (interpE e1) (Monotone.f (interpS {τ' :: τ'' :: Γ} {τ' :: τ'' :: Γ'} (s-extend (s-extend Θ))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.f (interpS (lem4' Θ v1 v2)) k) ((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS (λ x → ren (ren (Θ x) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v2))) k) (Monotone.f (interpS Θ) k) (interp-subst-comp2-l Θ k v1 v2) (interp-subst-comp-l Θ v2 k) , Preorder-str.refl (snd [ τ'' ]t) (Monotone.f (interpE v2) k)) , Preorder-str.refl (snd [ τ' ]t) (Monotone.f (interpE v1) k)))) (subst-eq-r (lem4' Θ v1 v2) e1 k)) sound {Γ} {τ} .(subst e1 (lem3' (lem3' Θ v2) v1)) ._ (subst-compose2-r {.Γ} {Γ'} {.τ} {τ'} {τ''} Θ e1 v1 v2) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (lem4' Θ v1 v2))) k) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.f (interpE (subst (subst e1 (s-extend (s-extend Θ))) (lem4 v1 v2))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (lem4' Θ v1 v2))) k) (Monotone.f (interpE e1) (Monotone.f (interpS (lem4' Θ v1 v2)) k)) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (subst-eq-l (lem4' Θ v1 v2) e1 k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e1) (Monotone.f (interpS (lem4' Θ v1 v2)) k)) (Monotone.f (interpE e1) (Monotone.f (interpS {τ' :: τ'' :: Γ} {τ' :: τ'' :: Γ'} (s-extend (s-extend Θ))) (Monotone.f (interpS (lem4 v1 v2)) k))) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.is-monotone (interpE e1) (Monotone.f (interpS (lem4' Θ v1 v2)) k) (Monotone.f (interpS {τ' :: τ'' :: Γ} {τ' :: τ'' :: Γ'} (s-extend (s-extend Θ))) (Monotone.f (interpS (lem4 v1 v2)) k)) (((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS Θ) k) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v2))) k) (Monotone.f (interpS (λ x → ren (ren (Θ x) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (interp-subst-comp-r Θ v2 k) (interp-subst-comp2-r Θ k v1 v2)) , (Preorder-str.refl (snd [ τ'' ]t) (Monotone.f (interpE v2) k))) , (Preorder-str.refl (snd [ τ' ]t) (Monotone.f (interpE v1) k)))) (subst-eq-r (s-extend (s-extend Θ)) e1 (Monotone.f (interpS (lem4 v1 v2)) k)))) (subst-eq-r (lem4 v1 v2) (subst e1 (s-extend (s-extend Θ))) k) sound {Γ} {τ} ._ .(subst e1 (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ))) (subst-compose3-l {.Γ} {Γ'} {.τ} {τ'} {τ''} Θ e1 v1 v2) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst (subst e1 (lem3' (lem3' ids v2) v1)) Θ)) k) (Monotone.f (interpE (subst e1 (lem3' (lem3' ids v2) v1))) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst e1 (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ)))) k) (subst-eq-l Θ (subst e1 (lem3' (lem3' ids v2) v1)) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (lem3' (lem3' ids v2) v1))) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e1) (Monotone.f (interpS (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ))) k)) (Monotone.f (interpE (subst e1 (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ)))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (lem3' (lem3' ids v2) v1))) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE e1) (Monotone.f (interpS (lem3' (lem3' ids v2) v1)) (Monotone.f (interpS Θ) k))) (Monotone.f (interpE e1) (Monotone.f (interpS (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ))) k)) (subst-eq-l (lem3' (lem3' ids v2) v1) e1 (Monotone.f (interpS Θ) k)) (Monotone.is-monotone (interpE e1) (Monotone.f (interpS (lem3' (lem3' ids v2) v1)) (Monotone.f (interpS Θ) k)) (Monotone.f (interpS (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ))) k) (((interp-ss-r Θ ids k) , (subst-eq-r Θ v2 k)) , (subst-eq-r Θ v1 k)))) (subst-eq-r (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ)) e1 k)) sound {Γ} {τ} .(subst e1 (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ))) ._ (subst-compose3-r {.Γ} {Γ'} {.τ} {τ'} {τ''} Θ e1 v1 v2) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ)))) k) (Monotone.f (interpE (subst e1 (lem3' (lem3' ids v2) v1))) (Monotone.f (interpS Θ) k)) (Monotone.f (interpE (subst (subst e1 (lem3' (lem3' ids v2) v1)) Θ)) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ)))) k) (Monotone.f (interpE e1) (Monotone.f (interpS (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ))) k)) (Monotone.f (interpE (subst e1 (lem3' (lem3' ids v2) v1))) (Monotone.f (interpS Θ) k)) (subst-eq-l (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ)) e1 k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e1) (Monotone.f (interpS (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ))) k)) (Monotone.f (interpE e1) (Monotone.f (interpS (lem3' (lem3' ids v2) v1)) (Monotone.f (interpS Θ) k))) (Monotone.f (interpE (subst e1 (lem3' (lem3' ids v2) v1))) (Monotone.f (interpS Θ) k)) (Monotone.is-monotone (interpE e1) (Monotone.f (interpS (lem3' (lem3' Θ (subst v2 Θ)) (subst v1 Θ))) k) (Monotone.f (interpS (lem3' (lem3' ids v2) v1)) (Monotone.f (interpS Θ) k)) (((interp-ss-l Θ ids k) , (subst-eq-l Θ v2 k)) , (subst-eq-l Θ v1 k))) (subst-eq-r (lem3' (lem3' ids v2) v1) e1 (Monotone.f (interpS Θ) k)))) (subst-eq-r Θ (subst e1 (lem3' (lem3' ids v2) v1)) k) sound {Γ} {τ} ._ .(subst e1 (lem3' (lem3' Θ v2) v1)) (subst-compose4-l {.Γ} {Γ'} Θ v1 v2 e1) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst (subst e1 (s-extend (s-extend Θ))) (lem4 v1 v2))) k) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.f (interpE (subst e1 (lem4' Θ v1 v2))) k) (subst-eq-l (lem4 v1 v2) (subst e1 (s-extend (s-extend Θ))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.f (interpE e1) (Monotone.f (interpS (lem4' Θ v1 v2)) k)) (Monotone.f (interpE (subst e1 (lem4' Θ v1 v2))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.f (interpE e1) (Monotone.f (interpS {nat :: τ :: Γ} {nat :: τ :: Γ'} (s-extend (s-extend Θ))) (Monotone.f (interpS (lem4 v1 v2)) k))) (Monotone.f (interpE e1) (Monotone.f (interpS (lem4' Θ v1 v2)) k)) (subst-eq-l (s-extend (s-extend Θ)) e1 (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.is-monotone (interpE e1) (Monotone.f (interpS {nat :: τ :: Γ} {nat :: τ :: Γ'} (s-extend (s-extend Θ))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.f (interpS (lem4' Θ v1 v2)) k) ((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS (λ x → ren (ren (Θ x) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v2))) k) (Monotone.f (interpS Θ) k) (interp-subst-comp2-l Θ k v1 v2) (interp-subst-comp-l Θ v2 k) , Preorder-str.refl (snd [ τ ]t) (Monotone.f (interpE v2) k)) , Preorder-str.refl (snd [ nat ]t) (Monotone.f (interpE v1) k)))) (subst-eq-r (lem4' Θ v1 v2) e1 k)) sound {Γ} {τ} .(subst e1 (lem3' (lem3' Θ v2) v1)) ._ (subst-compose4-r {.Γ} {Γ'} Θ v1 v2 e1) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (lem4' Θ v1 v2))) k) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.f (interpE (subst (subst e1 (s-extend (s-extend Θ))) (lem4 v1 v2))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e1 (lem4' Θ v1 v2))) k) (Monotone.f (interpE e1) (Monotone.f (interpS (lem4' Θ v1 v2)) k)) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (subst-eq-l (lem4' Θ v1 v2) e1 k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e1) (Monotone.f (interpS (lem4' Θ v1 v2)) k)) (Monotone.f (interpE e1) (Monotone.f (interpS {nat :: τ :: Γ} {nat :: τ :: Γ'} (s-extend (s-extend Θ))) (Monotone.f (interpS (lem4 v1 v2)) k))) (Monotone.f (interpE (subst e1 (s-extend (s-extend Θ)))) (Monotone.f (interpS (lem4 v1 v2)) k)) (Monotone.is-monotone (interpE e1) (Monotone.f (interpS (lem4' Θ v1 v2)) k) (Monotone.f (interpS {nat :: τ :: Γ} {nat :: τ :: Γ'} (s-extend (s-extend Θ))) (Monotone.f (interpS (lem4 v1 v2)) k)) (((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS Θ) k) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v2))) k) (Monotone.f (interpS (λ x → ren (ren (Θ x) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (interp-subst-comp-r Θ v2 k) (interp-subst-comp2-r Θ k v1 v2)) , (Preorder-str.refl (snd [ τ ]t) (Monotone.f (interpE v2) k))) , (Preorder-str.refl (snd [ nat ]t) (Monotone.f (interpE v1) k)))) (subst-eq-r (s-extend (s-extend Θ)) e1 (Monotone.f (interpS (lem4 v1 v2)) k)))) (subst-eq-r (lem4 v1 v2) (subst e1 (s-extend (s-extend Θ))) k) sound {Γ} {τ} ._ .(subst e (lem3' (lem3' (lem3' Θ v3) v2) v1)) (subst-compose5-l {.Γ} {Γ'} {.τ} {τ1} {τ2} {τ3} Θ e v1 v2 v3) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst (subst e (s-extend (s-extend (s-extend Θ)))) (lem3' (lem3' (lem3' ids v3) v2) v1))) k) (Monotone.f (interpE (subst e (s-extend (s-extend (s-extend Θ))))) (Monotone.f (interpS (lem3' (lem3' (lem3' ids v3) v2) v1)) k)) (Monotone.f (interpE (subst e (lem3' (lem3' (lem3' Θ v3) v2) v1))) k) (subst-eq-l (lem3' (lem3' (lem3' ids v3) v2) v1) (subst e (s-extend (s-extend (s-extend Θ)))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (s-extend (s-extend (s-extend Θ))))) (Monotone.f (interpS (lem3' (lem3' (lem3' ids v3) v2) v1)) k)) (Monotone.f (interpE e) (Monotone.f (interpS (lem3' (lem3' (lem3' Θ v3) v2) v1)) k)) (Monotone.f (interpE (subst e (lem3' (lem3' (lem3' Θ v3) v2) v1))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (s-extend (s-extend (s-extend Θ))))) (Monotone.f (interpS (lem3' (lem3' (lem3' ids v3) v2) v1)) k)) (Monotone.f (interpE e) (Monotone.f (interpS {τ1 :: τ2 :: τ3 :: Γ} {τ1 :: τ2 :: τ3 :: Γ'} (s-extend (s-extend (s-extend Θ)))) (Monotone.f (interpS {Γ} {τ1 :: τ2 :: τ3 :: Γ} (lem3' (lem3' (lem3' ids v3) v2) v1)) k))) (Monotone.f (interpE e) (Monotone.f (interpS (lem3' (lem3' (lem3' Θ v3) v2) v1)) k)) (subst-eq-l (s-extend (s-extend (s-extend Θ))) e (Monotone.f (interpS (lem3' (lem3' (lem3' ids v3) v2) v1)) k)) (Monotone.is-monotone (interpE e) (Monotone.f (interpS {τ1 :: τ2 :: τ3 :: Γ} {τ1 :: τ2 :: τ3 :: Γ'} (s-extend (s-extend (s-extend Θ)))) (Monotone.f (interpS {Γ} {τ1 :: τ2 :: τ3 :: Γ} (lem3' (lem3' (lem3' ids v3) v2) v1)) k)) (Monotone.f (interpS (lem3' (lem3' (lem3' Θ v3) v2) v1)) k) ((((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS (λ x → ren (ren (ren (Θ x) iS) iS) iS)) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v3))) k) (Monotone.f (interpS Θ) k) (Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS (λ x → ren (ren (ren (Θ x) iS) iS) iS)) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (Monotone.f (interpS (λ x → ren (ren (Θ x) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k)) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v3))) k) (interp-subst-comp3-l Θ k v3 v2 v1) (interp-subst-comp2-l Θ k v2 v3)) (interp-subst-comp-l Θ v3 k)) , (Preorder-str.refl (snd [ τ3 ]t) (Monotone.f (interpE v3) k))) , (Preorder-str.refl (snd [ τ2 ]t) (Monotone.f (interpE v2) k))) , (Preorder-str.refl (snd [ τ1 ]t) (Monotone.f (interpE v1) k))))) (subst-eq-r (lem3' (lem3' (lem3' Θ v3) v2) v1) e k)) sound {Γ} {τ} .(subst e (lem3' (lem3' (lem3' Θ v3) v2) v1)) ._ (subst-compose5-r {.Γ} {Γ'} {.τ} {τ1} {τ2} {τ3} Θ e v1 v2 v3) k = Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (lem3' (lem3' (lem3' Θ v3) v2) v1))) k) (Monotone.f (interpE (subst e (s-extend (s-extend (s-extend Θ))))) (Monotone.f (interpS (lem3' (lem3' (lem3' ids v3) v2) v1)) k)) (Monotone.f (interpE (subst (subst e (s-extend (s-extend (s-extend Θ)))) (lem3' (lem3' (lem3' ids v3) v2) v1))) k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE (subst e (lem3' (lem3' (lem3' Θ v3) v2) v1))) k) (Monotone.f (interpE e) (Monotone.f (interpS (lem3' (lem3' (lem3' Θ v3) v2) v1)) k)) (Monotone.f (interpE (subst e (s-extend (s-extend (s-extend Θ))))) (Monotone.f (interpS (lem3' (lem3' (lem3' ids v3) v2) v1)) k)) (subst-eq-l (lem3' (lem3' (lem3' Θ v3) v2) v1) e k) (Preorder-str.trans (snd [ τ ]t) (Monotone.f (interpE e) (Monotone.f (interpS (lem3' (lem3' (lem3' Θ v3) v2) v1)) k)) (Monotone.f (interpE e) (Monotone.f (interpS {τ1 :: τ2 :: τ3 :: Γ} {τ1 :: τ2 :: τ3 :: Γ'} (s-extend (s-extend (s-extend Θ)))) (Monotone.f (interpS {Γ} {τ1 :: τ2 :: τ3 :: Γ} (lem3' (lem3' (lem3' ids v3) v2) v1)) k))) (Monotone.f (interpE (subst e (s-extend (s-extend (s-extend Θ))))) (Monotone.f (interpS (lem3' (lem3' (lem3' ids v3) v2) v1)) k)) (Monotone.is-monotone (interpE e) (Monotone.f (interpS (lem3' (lem3' (lem3' Θ v3) v2) v1)) k) (Monotone.f (interpS {τ1 :: τ2 :: τ3 :: Γ} {τ1 :: τ2 :: τ3 :: Γ'} (s-extend (s-extend (s-extend Θ)))) (Monotone.f (interpS {Γ} {τ1 :: τ2 :: τ3 :: Γ} (lem3' (lem3' (lem3' ids v3) v2) v1)) k)) ((((Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS Θ) k) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v3))) k) (Monotone.f (interpS (λ x → ren (ren (ren (Θ x) iS) iS) iS)) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (interp-subst-comp-r Θ v3 k) (Preorder-str.trans (snd [ Γ' ]c) (Monotone.f (interpS (λ x → subst (ren (Θ x) iS) (lem3' ids v3))) k) (Monotone.f (interpS (λ x → ren (ren (Θ x) iS) iS)) ((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k)) (Monotone.f (interpS (λ x → ren (ren (ren (Θ x) iS) iS) iS)) (((Monotone.f (interpS {Γ} ids) k , Monotone.f (interpE v3) k) , Monotone.f (interpE v2) k) , Monotone.f (interpE v1) k)) (interp-subst-comp2-r Θ k v2 v3) (interp-subst-comp3-r Θ k v3 v2 v1))) , (Preorder-str.refl (snd [ τ3 ]t) (Monotone.f (interpE v3) k))) , (Preorder-str.refl (snd [ τ2 ]t) (Monotone.f (interpE v2) k))) , (Preorder-str.refl (snd [ τ1 ]t) (Monotone.f (interpE v1) k)))) (subst-eq-r (s-extend (s-extend (s-extend Θ))) e (Monotone.f (interpS (lem3' (lem3' (lem3' ids v3) v2) v1)) k)))) (subst-eq-r (lem3' (lem3' (lem3' ids v3) v2) v1) (subst e (s-extend (s-extend (s-extend Θ)))) k)
{ "alphanum_fraction": 0.5097528075, "avg_line_length": 65.8153594771, "ext": "agda", "hexsha": "1ce72a68545ea0951345a24e1b8bd4db7661416b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "benhuds/Agda", "max_forks_repo_path": "complexity/complexity-final/Interp-WithFlatrec.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_issues_repo_issues_event_max_datetime": "2020-05-12T00:32:45.000Z", "max_issues_repo_issues_event_min_datetime": "2020-03-23T08:39:04.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "benhuds/Agda", "max_issues_repo_path": "complexity/complexity-final/Interp-WithFlatrec.agda", "max_line_length": 172, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2404a6ef2688f879bda89860bb22f77664ad813e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "benhuds/Agda", "max_stars_repo_path": "complexity/complexity-final/Interp-WithFlatrec.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:27:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-04-26T20:22:22.000Z", "num_tokens": 50202, "size": 120837 }
------------------------------------------------------------------------ -- The Agda standard library -- -- AVL trees ------------------------------------------------------------------------ -- AVL trees are balanced binary search trees. -- The search tree invariant is specified using the technique -- described by Conor McBride in his talk "Pivotal pragmatism". open import Relation.Binary open import Relation.Binary.PropositionalEquality as P using (_≡_) module Data.AVL {k v ℓ} {Key : Set k} (Value : Key → Set v) {_<_ : Rel Key ℓ} (isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_) where open import Data.Bool import Data.DifferenceList as DiffList open import Data.Empty open import Data.List as List using (List) open import Data.Maybe hiding (map) open import Data.Nat hiding (_<_; compare; _⊔_) open import Data.Product hiding (map) open import Data.Unit open import Function open import Level using (_⊔_; Lift; lift) open IsStrictTotalOrder isStrictTotalOrder ------------------------------------------------------------------------ -- Extended keys module Extended-key where -- The key type extended with a new minimum and maximum. data Key⁺ : Set k where ⊥⁺ ⊤⁺ : Key⁺ [_] : (k : Key) → Key⁺ -- An extended strict ordering relation. infix 4 _<⁺_ _<⁺_ : Key⁺ → Key⁺ → Set ℓ ⊥⁺ <⁺ [ _ ] = Lift ⊤ ⊥⁺ <⁺ ⊤⁺ = Lift ⊤ [ x ] <⁺ [ y ] = x < y [ _ ] <⁺ ⊤⁺ = Lift ⊤ _ <⁺ _ = Lift ⊥ -- A pair of ordering constraints. infix 4 _<_<_ _<_<_ : Key⁺ → Key → Key⁺ → Set ℓ l < x < u = l <⁺ [ x ] × [ x ] <⁺ u -- _<⁺_ is transitive. trans⁺ : ∀ l {m u} → l <⁺ m → m <⁺ u → l <⁺ u trans⁺ [ l ] {m = [ m ]} {u = [ u ]} l<m m<u = trans l<m m<u trans⁺ ⊥⁺ {u = [ _ ]} _ _ = _ trans⁺ ⊥⁺ {u = ⊤⁺} _ _ = _ trans⁺ [ _ ] {u = ⊤⁺} _ _ = _ trans⁺ _ {m = ⊥⁺} {u = ⊥⁺} _ (lift ()) trans⁺ _ {m = [ _ ]} {u = ⊥⁺} _ (lift ()) trans⁺ _ {m = ⊤⁺} {u = ⊥⁺} _ (lift ()) trans⁺ [ _ ] {m = ⊥⁺} {u = [ _ ]} (lift ()) _ trans⁺ [ _ ] {m = ⊤⁺} {u = [ _ ]} _ (lift ()) trans⁺ ⊤⁺ {m = ⊥⁺} (lift ()) _ trans⁺ ⊤⁺ {m = [ _ ]} (lift ()) _ trans⁺ ⊤⁺ {m = ⊤⁺} (lift ()) _ ------------------------------------------------------------------------ -- Types and functions which are used to keep track of height -- invariants module Height-invariants where -- Bits. (I would use Fin 2 instead if Agda had "defined patterns", -- so that I could pattern match on 1# instead of suc zero; the text -- "suc zero" takes up a lot more space.) data ℕ₂ : Set where 0# : ℕ₂ 1# : ℕ₂ -- Addition. infixl 6 _⊕_ _⊕_ : ℕ₂ → ℕ → ℕ 0# ⊕ n = n 1# ⊕ n = 1 + n -- i ⊕ n -1 = pred (i ⊕ n). _⊕_-1 : ℕ₂ → ℕ → ℕ i ⊕ zero -1 = 0 i ⊕ suc n -1 = i ⊕ n infix 4 _∼_ -- If m ∼ n, then the difference between m and n is at most 1. _∼_ -- is used to record the balance factor of the AVL trees, and also -- to ensure that the absolute value of the balance factor is never -- more than 1. data _∼_ : ℕ → ℕ → Set where ∼+ : ∀ {n} → n ∼ 1 + n ∼0 : ∀ {n} → n ∼ n ∼- : ∀ {n} → 1 + n ∼ n -- The maximum of m and n. max : ∀ {m n} → m ∼ n → ℕ max (∼+ {n}) = 1 + n max (∼0 {n}) = n max (∼- {n}) = 1 + n -- Some lemmas. 1+ : ∀ {m n} → m ∼ n → 1 + m ∼ 1 + n 1+ ∼+ = ∼+ 1+ ∼0 = ∼0 1+ ∼- = ∼- max∼ : ∀ {i j} (bal : i ∼ j) → max bal ∼ i max∼ ∼+ = ∼- max∼ ∼0 = ∼0 max∼ ∼- = ∼0 ∼max : ∀ {i j} (bal : i ∼ j) → j ∼ max bal ∼max ∼+ = ∼0 ∼max ∼0 = ∼0 ∼max ∼- = ∼+ max∼max : ∀ {i j} (bal : i ∼ j) → max (max∼ bal) ∼ max (∼max bal) max∼max ∼+ = ∼0 max∼max ∼0 = ∼0 max∼max ∼- = ∼0 max-lemma : ∀ {m n} (bal : m ∼ n) → 1 + max (1+ (max∼max bal)) ≡ 2 + max bal max-lemma ∼+ = P.refl max-lemma ∼0 = P.refl max-lemma ∼- = P.refl ------------------------------------------------------------------------ -- AVL trees -- Key/value pairs. KV : Set (k ⊔ v) KV = Σ Key Value module Indexed where open Extended-key open Height-invariants -- The trees have three parameters/indices: a lower bound on the -- keys, an upper bound, and a height. -- -- (The bal argument is the balance factor.) data Tree (l u : Key⁺) : ℕ → Set (k ⊔ v ⊔ ℓ) where leaf : (l<u : l <⁺ u) → Tree l u 0 node : ∀ {hˡ hʳ} (k : KV) (lk : Tree l [ proj₁ k ] hˡ) (ku : Tree [ proj₁ k ] u hʳ) (bal : hˡ ∼ hʳ) → Tree l u (1 + max bal) -- Cast operations. Logarithmic in the size of the tree, if we don't -- count the time needed to construct the new proofs in the leaf -- cases. (The same kind of caveat applies to other operations -- below.) -- -- Perhaps it would be worthwhile changing the data structure so -- that the casts could be implemented in constant time (excluding -- proof manipulation). However, note that this would not change the -- worst-case time complexity of the operations below (up to Θ). castˡ : ∀ {l m u h} → l <⁺ m → Tree m u h → Tree l u h castˡ {l} l<m (leaf m<u) = leaf (trans⁺ l l<m m<u) castˡ l<m (node k mk ku bal) = node k (castˡ l<m mk) ku bal castʳ : ∀ {l m u h} → Tree l m h → m <⁺ u → Tree l u h castʳ {l} (leaf l<m) m<u = leaf (trans⁺ l l<m m<u) castʳ (node k lk km bal) m<u = node k lk (castʳ km m<u) bal -- Various constant-time functions which construct trees out of -- smaller pieces, sometimes using rotation. joinˡ⁺ : ∀ {l u hˡ hʳ} → (k : KV) → (∃ λ i → Tree l [ proj₁ k ] (i ⊕ hˡ)) → Tree [ proj₁ k ] u hʳ → (bal : hˡ ∼ hʳ) → ∃ λ i → Tree l u (i ⊕ (1 + max bal)) joinˡ⁺ k₆ (1# , node k₂ t₁ (node k₄ t₃ t₅ bal) ∼+) t₇ ∼- = (0# , P.subst (Tree _ _) (max-lemma bal) (node k₄ (node k₂ t₁ t₃ (max∼ bal)) (node k₆ t₅ t₇ (∼max bal)) (1+ (max∼max bal)))) joinˡ⁺ k₄ (1# , node k₂ t₁ t₃ ∼-) t₅ ∼- = (0# , node k₂ t₁ (node k₄ t₃ t₅ ∼0) ∼0) joinˡ⁺ k₄ (1# , node k₂ t₁ t₃ ∼0) t₅ ∼- = (1# , node k₂ t₁ (node k₄ t₃ t₅ ∼-) ∼+) joinˡ⁺ k₂ (1# , t₁) t₃ ∼0 = (1# , node k₂ t₁ t₃ ∼-) joinˡ⁺ k₂ (1# , t₁) t₃ ∼+ = (0# , node k₂ t₁ t₃ ∼0) joinˡ⁺ k₂ (0# , t₁) t₃ bal = (0# , node k₂ t₁ t₃ bal) joinʳ⁺ : ∀ {l u hˡ hʳ} → (k : KV) → Tree l [ proj₁ k ] hˡ → (∃ λ i → Tree [ proj₁ k ] u (i ⊕ hʳ)) → (bal : hˡ ∼ hʳ) → ∃ λ i → Tree l u (i ⊕ (1 + max bal)) joinʳ⁺ k₂ t₁ (1# , node k₆ (node k₄ t₃ t₅ bal) t₇ ∼-) ∼+ = (0# , P.subst (Tree _ _) (max-lemma bal) (node k₄ (node k₂ t₁ t₃ (max∼ bal)) (node k₆ t₅ t₇ (∼max bal)) (1+ (max∼max bal)))) joinʳ⁺ k₂ t₁ (1# , node k₄ t₃ t₅ ∼+) ∼+ = (0# , node k₄ (node k₂ t₁ t₃ ∼0) t₅ ∼0) joinʳ⁺ k₂ t₁ (1# , node k₄ t₃ t₅ ∼0) ∼+ = (1# , node k₄ (node k₂ t₁ t₃ ∼+) t₅ ∼-) joinʳ⁺ k₂ t₁ (1# , t₃) ∼0 = (1# , node k₂ t₁ t₃ ∼+) joinʳ⁺ k₂ t₁ (1# , t₃) ∼- = (0# , node k₂ t₁ t₃ ∼0) joinʳ⁺ k₂ t₁ (0# , t₃) bal = (0# , node k₂ t₁ t₃ bal) joinˡ⁻ : ∀ {l u} hˡ {hʳ} → (k : KV) → (∃ λ i → Tree l [ proj₁ k ] (i ⊕ hˡ -1)) → Tree [ proj₁ k ] u hʳ → (bal : hˡ ∼ hʳ) → ∃ λ i → Tree l u (i ⊕ max bal) joinˡ⁻ zero k₂ (0# , t₁) t₃ bal = (1# , node k₂ t₁ t₃ bal) joinˡ⁻ zero k₂ (1# , t₁) t₃ bal = (1# , node k₂ t₁ t₃ bal) joinˡ⁻ (suc _) k₂ (0# , t₁) t₃ ∼+ = joinʳ⁺ k₂ t₁ (1# , t₃) ∼+ joinˡ⁻ (suc _) k₂ (0# , t₁) t₃ ∼0 = (1# , node k₂ t₁ t₃ ∼+) joinˡ⁻ (suc _) k₂ (0# , t₁) t₃ ∼- = (0# , node k₂ t₁ t₃ ∼0) joinˡ⁻ (suc _) k₂ (1# , t₁) t₃ bal = (1# , node k₂ t₁ t₃ bal) joinʳ⁻ : ∀ {l u hˡ} hʳ → (k : KV) → Tree l [ proj₁ k ] hˡ → (∃ λ i → Tree [ proj₁ k ] u (i ⊕ hʳ -1)) → (bal : hˡ ∼ hʳ) → ∃ λ i → Tree l u (i ⊕ max bal) joinʳ⁻ zero k₂ t₁ (0# , t₃) bal = (1# , node k₂ t₁ t₃ bal) joinʳ⁻ zero k₂ t₁ (1# , t₃) bal = (1# , node k₂ t₁ t₃ bal) joinʳ⁻ (suc _) k₂ t₁ (0# , t₃) ∼- = joinˡ⁺ k₂ (1# , t₁) t₃ ∼- joinʳ⁻ (suc _) k₂ t₁ (0# , t₃) ∼0 = (1# , node k₂ t₁ t₃ ∼-) joinʳ⁻ (suc _) k₂ t₁ (0# , t₃) ∼+ = (0# , node k₂ t₁ t₃ ∼0) joinʳ⁻ (suc _) k₂ t₁ (1# , t₃) bal = (1# , node k₂ t₁ t₃ bal) -- Extracts the smallest element from the tree, plus the rest. -- Logarithmic in the size of the tree. headTail : ∀ {l u h} → Tree l u (1 + h) → ∃ λ (k : KV) → l <⁺ [ proj₁ k ] × ∃ λ i → Tree [ proj₁ k ] u (i ⊕ h) headTail (node k₁ (leaf l<k₁) t₂ ∼+) = (k₁ , l<k₁ , 0# , t₂) headTail (node k₁ (leaf l<k₁) t₂ ∼0) = (k₁ , l<k₁ , 0# , t₂) headTail (node {hˡ = suc _} k₃ t₁₂ t₄ bal) with headTail t₁₂ ... | (k₁ , l<k₁ , t₂) = (k₁ , l<k₁ , joinˡ⁻ _ k₃ t₂ t₄ bal) -- Extracts the largest element from the tree, plus the rest. -- Logarithmic in the size of the tree. initLast : ∀ {l u h} → Tree l u (1 + h) → ∃ λ (k : KV) → [ proj₁ k ] <⁺ u × ∃ λ i → Tree l [ proj₁ k ] (i ⊕ h) initLast (node k₂ t₁ (leaf k₂<u) ∼-) = (k₂ , k₂<u , (0# , t₁)) initLast (node k₂ t₁ (leaf k₂<u) ∼0) = (k₂ , k₂<u , (0# , t₁)) initLast (node {hʳ = suc _} k₂ t₁ t₃₄ bal) with initLast t₃₄ ... | (k₄ , k₄<u , t₃) = (k₄ , k₄<u , joinʳ⁻ _ k₂ t₁ t₃ bal) -- Another joining function. Logarithmic in the size of either of -- the input trees (which need to have almost equal heights). join : ∀ {l m u hˡ hʳ} → Tree l m hˡ → Tree m u hʳ → (bal : hˡ ∼ hʳ) → ∃ λ i → Tree l u (i ⊕ max bal) join t₁ (leaf m<u) ∼0 = (0# , castʳ t₁ m<u) join t₁ (leaf m<u) ∼- = (0# , castʳ t₁ m<u) join {hʳ = suc _} t₁ t₂₃ bal with headTail t₂₃ ... | (k₂ , m<k₂ , t₃) = joinʳ⁻ _ k₂ (castʳ t₁ m<k₂) t₃ bal -- An empty tree. empty : ∀ {l u} → l <⁺ u → Tree l u 0 empty = leaf -- A singleton tree. singleton : ∀ {l u} (k : Key) → Value k → l < k < u → Tree l u 1 singleton k v (l<k , k<u) = node (k , v) (leaf l<k) (leaf k<u) ∼0 -- Inserts a key into the tree, using a function to combine any -- existing value with the new value. Logarithmic in the size of the -- tree (assuming constant-time comparisons and a constant-time -- combining function). insertWith : ∀ {l u h} → (k : Key) → Value k → (Value k → Value k → Value k) → -- New → old → result. Tree l u h → l < k < u → ∃ λ i → Tree l u (i ⊕ h) insertWith k v f (leaf l<u) l<k<u = (1# , singleton k v l<k<u) insertWith k v f (node (k′ , v′) lp pu bal) (l<k , k<u) with compare k k′ ... | tri< k<k′ _ _ = joinˡ⁺ (k′ , v′) (insertWith k v f lp (l<k , k<k′)) pu bal ... | tri> _ _ k′<k = joinʳ⁺ (k′ , v′) lp (insertWith k v f pu (k′<k , k<u)) bal ... | tri≈ _ k≡k′ _ rewrite P.sym k≡k′ = (0# , node (k , f v v′) lp pu bal) -- Inserts a key into the tree. If the key already exists, then it -- is replaced. Logarithmic in the size of the tree (assuming -- constant-time comparisons). insert : ∀ {l u h} → (k : Key) → Value k → Tree l u h → l < k < u → ∃ λ i → Tree l u (i ⊕ h) insert k v = insertWith k v const -- Deletes the key/value pair containing the given key, if any. -- Logarithmic in the size of the tree (assuming constant-time -- comparisons). delete : ∀ {l u h} → Key → Tree l u h → ∃ λ i → Tree l u (i ⊕ h -1) delete k (leaf l<u) = (0# , leaf l<u) delete k (node p lp pu bal) with compare k (proj₁ p) ... | tri< _ _ _ = joinˡ⁻ _ p (delete k lp) pu bal ... | tri> _ _ _ = joinʳ⁻ _ p lp (delete k pu) bal ... | tri≈ _ _ _ = join lp pu bal -- Looks up a key. Logarithmic in the size of the tree (assuming -- constant-time comparisons). lookup : ∀ {l u h} → (k : Key) → Tree l u h → Maybe (Value k) lookup k (leaf _) = nothing lookup k (node (k′ , v) lk′ k′u _) with compare k k′ ... | tri< _ _ _ = lookup k lk′ ... | tri> _ _ _ = lookup k k′u ... | tri≈ _ eq _ rewrite eq = just v -- Maps a function over all values in the tree. map : (∀ {k} → Value k → Value k) → ∀ {l u h} → Tree l u h → Tree l u h map f (leaf l<u) = leaf l<u map f (node (k , v) l r bal) = node (k , f v) (map f l) (map f r) bal -- Converts the tree to an ordered list. Linear in the size of the -- tree. open DiffList toDiffList : ∀ {l u h} → Tree l u h → DiffList KV toDiffList (leaf _) = [] toDiffList (node k l r _) = toDiffList l ++ k ∷ toDiffList r ------------------------------------------------------------------------ -- Types and functions with hidden indices data Tree : Set (k ⊔ v ⊔ ℓ) where tree : let open Extended-key in ∀ {h} → Indexed.Tree ⊥⁺ ⊤⁺ h → Tree empty : Tree empty = tree (Indexed.empty _) singleton : (k : Key) → Value k → Tree singleton k v = tree (Indexed.singleton k v _) insert : (k : Key) → Value k → Tree → Tree insert k v (tree t) = tree $ proj₂ $ Indexed.insert k v t _ insertWith : (k : Key) → Value k → (Value k → Value k → Value k) → Tree → Tree insertWith k v f (tree t) = tree $ proj₂ $ Indexed.insertWith k v f t _ delete : Key → Tree → Tree delete k (tree t) = tree $ proj₂ $ Indexed.delete k t lookup : (k : Key) → Tree → Maybe (Value k) lookup k (tree t) = Indexed.lookup k t map : ({k : Key} → Value k → Value k) → Tree → Tree map f (tree t) = tree $ Indexed.map f t _∈?_ : Key → Tree → Bool k ∈? t = is-just (lookup k t) headTail : Tree → Maybe (KV × Tree) headTail (tree (Indexed.leaf _)) = nothing headTail (tree {h = suc _} t) with Indexed.headTail t ... | (k , _ , _ , t′) = just (k , tree (Indexed.castˡ _ t′)) initLast : Tree → Maybe (Tree × KV) initLast (tree (Indexed.leaf _)) = nothing initLast (tree {h = suc _} t) with Indexed.initLast t ... | (k , _ , _ , t′) = just (tree (Indexed.castʳ t′ _) , k) -- The input does not need to be ordered. fromList : List KV → Tree fromList = List.foldr (uncurry insert) empty -- Returns an ordered list. toList : Tree → List KV toList (tree t) = DiffList.toList (Indexed.toDiffList t) -- Naive implementations of union. unionWith : (∀ {k} → Value k → Value k → Value k) → -- Left → right → result. Tree → Tree → Tree unionWith f t₁ t₂ = List.foldr (λ { (k , v) → insertWith k v f }) t₂ (toList t₁) -- Left-biased. union : Tree → Tree → Tree union = unionWith const unionsWith : (∀ {k} → Value k → Value k → Value k) → List Tree → Tree unionsWith f ts = List.foldr (unionWith f) empty ts -- Left-biased. unions : List Tree → Tree unions = unionsWith const
{ "alphanum_fraction": 0.4863217858, "avg_line_length": 33.9258426966, "ext": "agda", "hexsha": "937e2bc5a73a7a30755418e6b5bd6292ecf3ac11", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/AVL.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/AVL.agda", "max_line_length": 85, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/AVL.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 5920, "size": 15097 }
module Issue4260.M where postulate F : Set → Set syntax F X = G X
{ "alphanum_fraction": 0.6714285714, "avg_line_length": 10, "ext": "agda", "hexsha": "ae3f1a57a6e88267cddfb657b57e21ebffe13d88", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue4260/M.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue4260/M.agda", "max_line_length": 24, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue4260/M.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 24, "size": 70 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} open import Light.Library.Data.Integer as ℤ using (ℤ ; zero ; successor) open import Light.Package using (Package) module Light.Literals.Integer ⦃ package : Package record { ℤ } ⦄ where open import Light.Literals.Definition.Natural using (FromNatural) open import Light.Literals.Definition.Negative using (FromNegative) open FromNatural using (convert) open import Light.Library.Relation.Decidable using (if_then_else_) open import Light.Library.Relation.Binary.Equality using (_≈_) import Light.Library.Data.Natural as ℕ import Light.Library.Relation.Binary.Equality.Decidable instance from‐natural : FromNatural ℤ convert from‐natural n = if n ≈ ℕ.zero then zero else successor (convert from‐natural (ℕ.predecessor n))
{ "alphanum_fraction": 0.7752126367, "avg_line_length": 39.1904761905, "ext": "agda", "hexsha": "7471e952f7cfdb71ccb7b5e1f0c769c47c883918", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "Light/Literals/Integer.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "Light/Literals/Integer.agda", "max_line_length": 79, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "Light/Literals/Integer.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 192, "size": 823 }
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Int.Base where open import Cubical.Core.Everything open import Cubical.Data.Nat data Int : Type₀ where pos : (n : ℕ) → Int negsuc : (n : ℕ) → Int sucInt : Int → Int sucInt (pos n) = pos (suc n) sucInt (negsuc zero) = pos zero sucInt (negsuc (suc n)) = negsuc n predInt : Int → Int predInt (pos zero) = negsuc zero predInt (pos (suc n)) = pos n predInt (negsuc n) = negsuc (suc n)
{ "alphanum_fraction": 0.6306695464, "avg_line_length": 22.0476190476, "ext": "agda", "hexsha": "fa561630da1e4be7136ee6801275bcdf163c51f8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "limemloh/cubical", "max_forks_repo_path": "Cubical/Data/Int/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "limemloh/cubical", "max_issues_repo_path": "Cubical/Data/Int/Base.agda", "max_line_length": 38, "max_stars_count": null, "max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "limemloh/cubical", "max_stars_repo_path": "Cubical/Data/Int/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 172, "size": 463 }
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; sym ; trans ; subst ; subst₂ ; cong ; cong₂ ) open import AssocFree.Util using ( δsubst₂ ) import AssocFree.STLambdaC.Typ import AssocFree.STLambdaC.Exp import AssocFree.STLambdaC.NF import AssocFree.STLambdaC.Redn module AssocFree.STLambdaC.Eval (TConst : Set) (Const : AssocFree.STLambdaC.Typ.Typ TConst → Set) where open Relation.Binary.PropositionalEquality.≡-Reasoning using ( begin_ ; _≡⟨_⟩_ ; _∎ ) open module Typ = AssocFree.STLambdaC.Typ TConst using ( Typ ; Ctxt ; const ; _⇝_ ; [_] ; [] ; _∷_ ; _++_ ; _∈_ ; uniq ; Case ; case ; inj₁ ; inj₂ ; case-≫ ; _≪_ ; _≫_ ) open module Exp = AssocFree.STLambdaC.Exp TConst Const using ( Exp ; exp ; const ; abs ; app ; var ; var₀ ; Substn ; substn+ ; substn* ; xsubstn+ ; weaken+ ; weaken* ; weakens* ; ⟨_⟩ ; choose ; _◁_ ; id ; weaken*-[] ; weaken*-++ ; substn*-◁ ; substn*-id ) open module NF = AssocFree.STLambdaC.NF TConst Const using ( Atom ; NF ; var ; const ; app ; abs ; atom ; atom₀ ; aweaken* ) open module Redn = AssocFree.STLambdaC.Redn TConst Const using ( _⇒_ ; _⇓ ; _⇓′ ; eta ; beta ; lhs ; atom ; nf ; redn ; tgt ; ⇓abs ; ⇓app ; rweaken* ) -- Values data cVal {Γ C} : Exp Γ (const C) → Set where atom : ∀ {M} → Atom M → cVal M redn : ∀ {M N} → (M ⇒ N) → cVal N → cVal M data fVal {Γ T U} (F : ∀ {Γ} → Exp Γ T → Set) (G : ∀ {Γ} → Exp Γ U → Set) : Exp Γ (T ⇝ U) → Set where fun : ∀ {M} → (∀ Δ → {N : Exp (Δ ++ Γ) T} → F N → G (app (weaken* Δ {Γ} M) N)) → fVal F G M redn : ∀ {M N} → (M ⇒ N) → fVal F G N → fVal F G M Val : ∀ {Γ T} → Exp Γ T → Set Val {Γ} {const C} M = cVal M Val {Γ} {T ⇝ U} M = fVal Val Val M -- Values are closed under reduction and application vredn : ∀ {Γ T} {M N : Exp Γ T} → (M ⇒ N) → Val N → Val M vredn {Γ} {const C} = redn vredn {Γ} {T ⇝ U} = redn vapp : ∀ {Γ T U} {M : Exp Γ (T ⇝ U)} {N : Exp Γ T} → Val M → Val N → Val (app M N) vapp {Γ} {T} {U} {M} {N} (fun f) W = subst (λ X → Val (app X N)) (weaken*-[] M) (f [] W) vapp (redn M⇒N V) W = vredn (lhs M⇒N) (vapp V W) -- Reification and reflection mutual reify : ∀ {Γ T} {M : Exp Γ T} → Val M → (M ⇓) reify {Γ} {const C} (atom N) = nf (atom N) reify {Γ} {const C} (redn M⇒N V) = redn M⇒N (reify V) reify {Γ} {T ⇝ U} {M} (fun f) = redn (eta M) (⇓abs {Γ} T (reify (f [ T ] (reflect (atom (atom₀ {Γ})))))) reify {Γ} {T ⇝ U} (redn M⇒N V) = redn M⇒N (reify V) reflect : ∀ {Γ T} {M : Exp Γ T} → (M ⇓′) → Val M reflect {Γ} {const C} (atom M) = atom M reflect {Γ} {T ⇝ U} (atom M) = fun (λ Δ V → reflect (⇓app (atom (aweaken* Δ M)) (reify V))) reflect (redn M⇒N N⇓) = vredn M⇒N (reflect N⇓) -- Value substitutions Vals : ∀ {Γ Δ} → Substn (exp var) Γ Δ → Set Vals {Γ} {Δ} σ = ∀ {T} (x : T ∈ Δ) → Val (σ x) ⟪_⟫ : ∀ {Γ T} {N : Exp Γ T} → Val N → Vals ⟨ N ⟩ ⟪ V ⟫ x = δsubst₂ (λ X Y → Val {T = X} Y) (uniq x) refl V vchoose : ∀ {Γ Δ E} {σ : Substn (exp var) Γ Δ} {τ : Substn (exp var) Γ E} → Vals σ → Vals τ → ∀ {T} (x : Case T Δ E) → Val (choose σ τ x) vchoose Vs Ws (inj₁ x) = Vs x vchoose Vs Ws (inj₂ x) = Ws x _◂_ : ∀ {Γ Δ T} {N : Exp Γ T} {σ : Substn (exp var) Γ Δ} → Val N → Vals σ → Vals (N ◁ σ) _◂_ {Γ} {Δ} {T} V Vs x = vchoose ⟪ V ⟫ Vs (case [ T ] Δ x) -- Weakening vweaken* : ∀ {Γ} Δ {U} {M : Exp Γ U} → Val M → Val (weaken* Δ M) vweaken* Δ {const C} (atom N) = atom (aweaken* Δ N) vweaken* Δ {const C} (redn M⇒N V) = redn (rweaken* Δ M⇒N) (vweaken* Δ V) vweaken* Δ {T ⇝ U} {M} (fun f) = fun (λ Φ {N} V → subst (λ X → Val (app X N)) (sym (weaken*-++ Φ Δ _ M)) (f (Φ ++ Δ) V)) vweaken* Δ {T ⇝ U} (redn M⇒N V) = redn (rweaken* Δ M⇒N) (vweaken* Δ V) vweakens* : ∀ {Γ Δ} E {σ : Substn (exp var) Γ Δ} → Vals σ → Vals (weakens* E σ) vweakens* E {σ} Vs x = vweaken* E (Vs x) -- Evaluation eval : ∀ {Γ Δ T} (M : Exp Γ T) → {σ : Substn (exp var) Δ Γ} → Vals σ → Val (substn* σ M) eval (const {T} c) Vs = reflect (atom (const c)) eval {Γ} {Δ} (var x) {σ} Vs = subst Val (begin σ x ≡⟨ sym (weaken*-[] (σ x)) ⟩ weaken* [] (σ x) ≡⟨ cong (xsubstn+ [] Δ Γ σ) (sym (case-≫ [] x)) ⟩ substn* σ (var x) ∎) (Vs x) eval {Γ} {Δ} (abs T M) {σ} Vs = fun (λ E {N} V → vredn (beta {E ++ Δ} (weaken+ [ T ] E Δ (substn+ [ T ] Δ Γ σ M)) N) (subst Val (substn*-◁ Γ Δ E M N σ) (eval M (V ◂ vweakens* E {σ} Vs)))) eval (app M N) Vs = vapp (eval M Vs) (eval N Vs) vid : ∀ Γ → Vals (id Γ) vid Γ x = reflect (atom (var x)) normalize : ∀ {Γ T} → (M : Exp Γ T) → (M ⇓) normalize {Γ} M = reify (subst Val (substn*-id M) (eval M (vid Γ))) normal : ∀ {Γ T} → Exp Γ T → Exp Γ T normal M = tgt (normalize M)
{ "alphanum_fraction": 0.5299765308, "avg_line_length": 36.6171875, "ext": "agda", "hexsha": "4350e0f776976a3839e95218c6fb4b6494b08d6e", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:38:44.000Z", "max_forks_repo_forks_event_min_datetime": "2018-03-03T04:39:31.000Z", "max_forks_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-assoc-free", "max_forks_repo_path": "src/AssocFree/STLambdaC/Eval.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-assoc-free", "max_issues_repo_path": "src/AssocFree/STLambdaC/Eval.agda", "max_line_length": 125, "max_stars_count": 3, "max_stars_repo_head_hexsha": "08337fdb8375137a52cc9b3ade766305191b2394", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-assoc-free", "max_stars_repo_path": "src/AssocFree/STLambdaC/Eval.agda", "max_stars_repo_stars_event_max_datetime": "2020-08-27T20:56:20.000Z", "max_stars_repo_stars_event_min_datetime": "2016-11-22T11:48:31.000Z", "num_tokens": 2119, "size": 4687 }
module Duploid.Functor where open import Preduploid open import Duploid import Preduploid.Functor as PF open import Level record Functor {o₁ ℓ₁ o₂ ℓ₂} (𝒞 : Duploid o₁ ℓ₁) (𝒟 : Duploid o₂ ℓ₂) : Set (levelOfTerm 𝒞 ⊔ levelOfTerm 𝒟) where private module 𝒞 = Duploid.Duploid 𝒞 module 𝒟 = Duploid.Duploid 𝒟 open 𝒟 field F : PF.Functor 𝒞.𝒟 𝒟.𝒟 open PF.Functor F field F-wrap-Thunkable : forall {N : 𝒞.Ob ⊝} -> Thunkable (F₁ (𝒞.wrap {N = N})) F-force-Linear : forall {P : 𝒞.Ob +} -> Linear (F₁ (𝒞.force {P = P}))
{ "alphanum_fraction": 0.6525735294, "avg_line_length": 21.76, "ext": "agda", "hexsha": "9243e08320575e2186b7d0ae58cd657bb38eb75e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "16def03e15bb8d71680bea60ae758ab37f4b2df9", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "elpinal/duploids", "max_forks_repo_path": "Duploid/Functor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "16def03e15bb8d71680bea60ae758ab37f4b2df9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "elpinal/duploids", "max_issues_repo_path": "Duploid/Functor.agda", "max_line_length": 77, "max_stars_count": 5, "max_stars_repo_head_hexsha": "16def03e15bb8d71680bea60ae758ab37f4b2df9", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "elpinal/duploids", "max_stars_repo_path": "Duploid/Functor.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-13T22:35:15.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-09T01:39:36.000Z", "num_tokens": 237, "size": 544 }
{-# OPTIONS --cubical --safe #-} module Cubical.Structures.Ring where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Foundations.SIP renaming (SNS-PathP to SNS) open import Cubical.Structures.NAryOp open import Cubical.Structures.Monoid hiding (⟨_⟩) open import Cubical.Structures.AbGroup hiding (⟨_⟩) open import Cubical.Structures.Pointed private variable ℓ ℓ' : Level raw-ring-structure : Type ℓ → Type ℓ raw-ring-structure X = (X → X → X) × X × (X → X → X) -- Maybe this is not the best way? (Suggestions welcome, maybe having raw-monoid-iso defined?) raw-ring-is-SNS : SNS {ℓ} raw-ring-structure _ raw-ring-is-SNS = join-SNS (nAryFunIso 2) (nAryFunSNS 2) (join-iso pointed-iso (nAryFunIso 2)) (join-SNS pointed-iso pointed-is-SNS (nAryFunIso 2) (nAryFunSNS 2)) ring-axioms : (X : Type ℓ) (s : raw-ring-structure X) → Type ℓ ring-axioms X (_+_ , ₁ , _·_) = abelian-group-axioms X _+_ × monoid-axioms X (₁ , _·_) × ((x y z : X) → x · (y + z) ≡ (x · y) + (x · z)) × ((x y z : X) → (x + y) · z ≡ (x · z) + (y · z)) ring-structure : Type ℓ → Type ℓ ring-structure = add-to-structure raw-ring-structure ring-axioms Ring : Type (ℓ-suc ℓ) Ring {ℓ} = TypeWithStr ℓ ring-structure ring-iso : StrIso ring-structure ℓ ring-iso = add-to-iso (join-iso (nAryFunIso 2) (join-iso pointed-iso (nAryFunIso 2))) ring-axioms ring-axioms-isProp : (X : Type ℓ) (s : raw-ring-structure X) → isProp (ring-axioms X s) ring-axioms-isProp X (_+_ , ₁ , _·_) = isPropΣ (abelian-group-axioms-isProp X _+_) λ _ → isPropΣ (monoid-axioms-are-Props X (₁ , _·_)) λ { (isSetX , _) → isPropΣ (isPropΠ3 (λ _ _ _ → isSetX _ _)) λ _ → isPropΠ3 (λ _ _ _ → isSetX _ _)} ring-is-SNS : SNS {ℓ} ring-structure ring-iso ring-is-SNS = add-axioms-SNS _ ring-axioms-isProp raw-ring-is-SNS RingPath : (M N : Ring {ℓ}) → (M ≃[ ring-iso ] N) ≃ (M ≡ N) RingPath = SIP ring-is-SNS -- Rings have an abelian group Ring→AbGroup : Ring {ℓ} → AbGroup {ℓ} Ring→AbGroup (R , (_+_ , _) , +AbGroup , _) = R , _+_ , +AbGroup -- Rings have a monoid Ring→Monoid : Ring {ℓ} → Monoid {ℓ} Ring→Monoid (R , (_ , ₁ , _·_) , _ , ·Monoid , _) = R , (₁ , _·_) , ·Monoid -- Ring extractors ⟨_⟩ : Ring {ℓ} → Type ℓ ⟨ R , _ ⟩ = R module _ (R : Ring {ℓ}) where ring+-operation = abgroup-operation (Ring→AbGroup R) ring-is-set = abgroup-is-set (Ring→AbGroup R) ring+-assoc = abgroup-assoc (Ring→AbGroup R) ring+-id = abgroup-id (Ring→AbGroup R) ring+-rid = abgroup-rid (Ring→AbGroup R) ring+-lid = abgroup-lid (Ring→AbGroup R) ring+-inv = abgroup-inv (Ring→AbGroup R) ring+-rinv = abgroup-rinv (Ring→AbGroup R) ring+-linv = abgroup-linv (Ring→AbGroup R) ring+-comm = abgroup-comm (Ring→AbGroup R) ring·-operation = monoid-operation (Ring→Monoid R) ring·-assoc = monoid-assoc (Ring→Monoid R) ring·-id = monoid-id (Ring→Monoid R) ring·-rid = monoid-rid (Ring→Monoid R) ring·-lid = monoid-lid (Ring→Monoid R) module ring-syntax where ring+-operation-syntax : (R : Ring {ℓ}) → ⟨ R ⟩ → ⟨ R ⟩ → ⟨ R ⟩ ring+-operation-syntax R = ring+-operation R infixr 14 ring+-operation-syntax syntax ring+-operation-syntax R x y = x +⟨ R ⟩ y ring·-operation-syntax : (R : Ring {ℓ}) → ⟨ R ⟩ → ⟨ R ⟩ → ⟨ R ⟩ ring·-operation-syntax R = ring·-operation R infixr 18 ring·-operation-syntax syntax ring·-operation-syntax R x y = x ·⟨ R ⟩ y open ring-syntax ring-rdist : (R : Ring {ℓ}) (x y z : ⟨ R ⟩) → x ·⟨ R ⟩ (y +⟨ R ⟩ z) ≡ (x ·⟨ R ⟩ y) +⟨ R ⟩ (x ·⟨ R ⟩ z) ring-rdist (_ , _ , _ , _ , P , _) = P ring-ldist : (R : Ring {ℓ}) (x y z : ⟨ R ⟩) → (x +⟨ R ⟩ y) ·⟨ R ⟩ z ≡ (x ·⟨ R ⟩ z) +⟨ R ⟩ (y ·⟨ R ⟩ z) ring-ldist (_ , _ , _ , _ , _ , P) = P -- Ring ·syntax module ring-·syntax (R : Ring {ℓ}) where infixr 14 _+_ infixr 18 _·_ infix 15 -_ _+_ = ring+-operation R _·_ = ring·-operation R ₀ = ring+-id R ₁ = ring·-id R -_ = ring+-inv R
{ "alphanum_fraction": 0.5877772534, "avg_line_length": 29.6363636364, "ext": "agda", "hexsha": "bd8d07297ecb8e47ee5d8fcb375dc6755e72c5d6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmester0/cubical", "max_forks_repo_path": "Cubical/Structures/Ring.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cmester0/cubical", "max_issues_repo_path": "Cubical/Structures/Ring.agda", "max_line_length": 102, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c67854d2e11aafa5677e25a09087e176fafd3e43", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmester0/cubical", "max_stars_repo_path": "Cubical/Structures/Ring.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-23T23:52:11.000Z", "max_stars_repo_stars_event_min_datetime": "2020-03-23T23:52:11.000Z", "num_tokens": 1573, "size": 4238 }
open import Common.Prelude hiding (_>>=_) open import Common.Reflection open import Common.Equality open import Agda.Builtin.Sigma record Functor (F : Set → Set) : Set₁ where field fmap : ∀ {A B} → (A → B) → F A → F B IdF : Functor (λ A → A) unquoteDef IdF = defineFun IdF (clause (("x" , vArg unknown) ∷ ("f" , vArg unknown) ∷ []) (vArg (projP (quote Functor.fmap)) ∷ vArg (var 1) ∷ vArg (var 0) ∷ []) (var 1 (vArg (var 0 []) ∷ [])) ∷ []) check : ∀ {A B} (f : A → B) (x : A) → Functor.fmap IdF f x ≡ f x check f x = refl open Functor {{...}} instance InstF : Functor (λ A → A) unquoteDef InstF = defineFun InstF (clause (("x" , vArg unknown) ∷ ("f" , vArg unknown) ∷ []) (iArg (projP (quote fmap)) ∷ vArg (var 1) ∷ vArg (var 0) ∷ []) (var 1 (vArg (var 0 []) ∷ [])) ∷ []) check₁ : ∀ {A B} (f : A → B) (x : A) → fmap f x ≡ f x check₁ f x = refl
{ "alphanum_fraction": 0.5010288066, "avg_line_length": 30.375, "ext": "agda", "hexsha": "6c90cdc2e66f9d6d03177b5fa5af65806755cc87", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/ReflectionCopatterns.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/ReflectionCopatterns.agda", "max_line_length": 94, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/ReflectionCopatterns.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 346, "size": 972 }
open import Agda.Builtin.Reflection open import Agda.Builtin.Unit open import Agda.Builtin.String infixr 4 _>>=_ _>>=_ = bindTC login : String → String login "secret" = "access granted" login _ = "access denied" macro getDef : Name → Term → TC ⊤ getDef f hole = getDefinition f >>= λ def → quoteTC def >>= unify hole test : Definition test = getDef login
{ "alphanum_fraction": 0.6853333333, "avg_line_length": 18.75, "ext": "agda", "hexsha": "24951948995d273589b982a4f3c8f4def916d914", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue2072.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue2072.agda", "max_line_length": 58, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2072.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 109, "size": 375 }
module Everything where import Prelude import Category -------------------------------------------------------------------------------- -- The syntax of STLC. import STLC.Syntax -- A simplification of Coquand 2002, -- with de Bruijn indices and implicit substitutions. import STLC.Coquand.Renaming import STLC.Coquand.Substitution import STLC.Coquand.Normalisation -- TODO: Fill postulates import STLC.Coquand.Convertibility -- TODO: Simplify β-reduction rule import STLC.Coquand.Completeness -- TODO: Fill postulates import STLC.Coquand.Soundness -- TODO: Fill postulates -- A restyling of Kovacs 2017. import STLC.Kovacs.Embedding import STLC.Kovacs.Substitution import STLC.Kovacs.NormalForm import STLC.Kovacs.Normalisation import STLC.Kovacs.Convertibility import STLC.Kovacs.Completeness import STLC.Kovacs.PresheafRefinement import STLC.Kovacs.Soundness -------------------------------------------------------------------------------- -- The syntax of STLC, with simple products. import STLC1.Syntax -- An extension of Kovacs 2017. import STLC1.Kovacs.Embedding import STLC1.Kovacs.Substitution import STLC1.Kovacs.NormalForm import STLC1.Kovacs.Normalisation import STLC1.Kovacs.Convertibility import STLC1.Kovacs.Completeness import STLC1.Kovacs.PresheafRefinement import STLC1.Kovacs.Soundness -------------------------------------------------------------------------------- -- The syntax of STLC, with simple products and coproducts. import STLC2.Syntax -- An extension of Kovacs 2017. import STLC2.Kovacs.Embedding import STLC2.Kovacs.Substitution import STLC2.Kovacs.NormalForm import STLC2.Kovacs.Normalisation.SoundNotComplete import STLC2.Kovacs.Normalisation.Experimental import STLC2.Kovacs.Normalisation import STLC2.Kovacs.Convertibility import STLC2.Kovacs.Completeness -- TODO: Finish this -- import STLC2.Kovacs.PresheafRefinement -- TODO: Start this -- import STLC2.Kovacs.Soundness -- TODO: Start this --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.6796116505, "avg_line_length": 29.4285714286, "ext": "agda", "hexsha": "cbda07a7a1a1adbea809d63e2973cedcd930af0a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/coquand-kovacs", "max_forks_repo_path": "src/Everything.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/coquand-kovacs", "max_issues_repo_path": "src/Everything.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "bd626509948fbf8503ec2e31c1852e1ac6edcc79", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/coquand-kovacs", "max_stars_repo_path": "src/Everything.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 501, "size": 2060 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Implementation.Standard.Relation.Sets where open import Light.Level using (_⊔_) open import Light.Variable.Levels open import Light.Variable.Sets open import Light.Library.Relation using (Base ; Kind ; Style) open import Light.Library.Data.Unit as Unit using (Unit ; unit) open import Light.Library.Data.Empty as Empty using (Empty) open import Light.Library.Data.Both as Both using (Both) import Light.Library.Data.Product as Product open import Light.Library.Data.These as These using (These) import Light.Implementation.Standard.Data.Unit import Light.Implementation.Standard.Data.Empty import Light.Implementation.Standard.Data.Product import Light.Implementation.Standard.Data.These instance kind : Kind kind = record { Proposition = λ ℓ → Set ℓ } instance style : Style kind style = record { Implementation } where module Implementation where true = Unit false = Empty ¬_ : Set ℓ → Set ℓ ¬ 𝕒 = 𝕒 → Empty _∧_ = Both _∨_ = These _⇢_ : Set aℓ → Set bℓ → Set (aℓ ⊔ bℓ) 𝕒 ⇢ 𝕓 = 𝕒 → 𝕓 True : Set ℓ → Set ℓ True 𝕒 = 𝕒 False = ¬_ true‐is‐true = unit false‐is‐false : _ false‐is‐false () instance base : Base base = record { kind = kind ; style = style }
{ "alphanum_fraction": 0.6234113712, "avg_line_length": 31.1458333333, "ext": "agda", "hexsha": "16a5458ce44bd7703bb4d1f5c096efd488a6a84d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "bindings/stdlib/Light/Implementation/Standard/Relation/Sets.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "bindings/stdlib/Light/Implementation/Standard/Relation/Sets.agda", "max_line_length": 79, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "bindings/stdlib/Light/Implementation/Standard/Relation/Sets.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 363, "size": 1495 }
-- Agda program using the Iowa Agda library open import bool module PROOF-permlength (Choice : Set) (choose : Choice → 𝔹) (lchoice : Choice → Choice) (rchoice : Choice → Choice) where open import eq open import bool open import nat open import list open import maybe --------------------------------------------------------------------------- -- Translated Curry operations: insert : {a : Set} → Choice → a → 𝕃 a → 𝕃 a insert c1 x [] = x :: [] insert c1 y (z :: u) = if choose c1 then y :: (z :: u) else z :: (insert (lchoice c1) y u) perm : {a : Set} → Choice → 𝕃 a → 𝕃 a perm c1 [] = [] perm c1 (x :: y) = insert c1 x (perm (lchoice c1) y) --------------------------------------------------------------------------- insert-inc-length : ∀ {a : Set} → (ch : Choice) (x : a) (xs : 𝕃 a) → length (insert ch x xs) ≡ suc (length xs) insert-inc-length ch x [] = refl insert-inc-length ch x (y :: ys) with choose ch ... | tt = refl ... | ff rewrite insert-inc-length (lchoice ch) x ys = refl permlength : {a : Set} → (c1 : Choice) → (x : 𝕃 a) → (length x) ≡ (length (perm c1 x)) permlength c1 [] = refl permlength c1 (x :: xs) rewrite insert-inc-length c1 x (perm (lchoice c1) xs) | permlength (lchoice c1) xs = refl ---------------------------------------------------------------------------
{ "alphanum_fraction": 0.4981301421, "avg_line_length": 28.4468085106, "ext": "agda", "hexsha": "333a43c190ccd362bf171ca4f4c346751feeb4b0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "phlummox/curry-tools", "max_forks_repo_path": "currypp/.cpm/packages/verify/examples/PROOF-permlength.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "phlummox/curry-tools", "max_issues_repo_path": "currypp/.cpm/packages/verify/examples/PROOF-permlength.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "7905bc4f625a94a725f9f6d8a2de1140bea5e471", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "phlummox/curry-tools", "max_stars_repo_path": "currypp/.cpm/packages/verify/examples/PROOF-permlength.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 391, "size": 1337 }
module SHE-Prelude where record Functor (T : Set -> Set) : Set1 where field -- OPERATIONS ---------------------------------------------- map : forall {X Y} -> (X -> Y) -> T X -> T Y record Applicative (T : Set -> Set) : Set1 where field -- OPERATIONS ---------------------------------------------- pure : forall {X} -> X -> T X _<*>_ : forall {X Y} -> T (X -> Y) -> T X -> T Y data Zero : Set where magic : forall {l}{A : Set l} -> Zero -> A magic () record One : Set where constructor <> open One public {-# COMPILED_DATA One () () #-}
{ "alphanum_fraction": 0.4446337308, "avg_line_length": 25.5217391304, "ext": "agda", "hexsha": "a54596c54e4c45c4362240576de48c786a9725a9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3d0514c72c804acc10851b90a7ef82a5b4cbc1ff", "max_forks_repo_licenses": [ "MIT-0" ], "max_forks_repo_name": "iain-logan/she", "max_forks_repo_path": "comparisons/agda/SHE-Prelude.agda", "max_issues_count": 11, "max_issues_repo_head_hexsha": "3d0514c72c804acc10851b90a7ef82a5b4cbc1ff", "max_issues_repo_issues_event_max_datetime": "2016-03-20T10:18:21.000Z", "max_issues_repo_issues_event_min_datetime": "2016-01-28T17:02:48.000Z", "max_issues_repo_licenses": [ "MIT-0" ], "max_issues_repo_name": "iain-logan/she", "max_issues_repo_path": "comparisons/agda/SHE-Prelude.agda", "max_line_length": 64, "max_stars_count": 1, "max_stars_repo_head_hexsha": "3d0514c72c804acc10851b90a7ef82a5b4cbc1ff", "max_stars_repo_licenses": [ "MIT-0" ], "max_stars_repo_name": "iain-logan/she", "max_stars_repo_path": "comparisons/agda/SHE-Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2016-08-04T00:06:06.000Z", "max_stars_repo_stars_event_min_datetime": "2016-08-04T00:06:06.000Z", "num_tokens": 161, "size": 587 }
-- Note that this module assumes function extensionality module guarded-recursion.prelude where open import Level public using (_⊔_) renaming (zero to ₀ ;suc to ₛ) open import Function public using (id; _∘_; _∘′_) open import Data.Nat public using (ℕ; _+_) renaming (zero to O ;suc to S) open import Data.Bool public renaming (Bool to 𝟚 ;false to 0₂ ;true to 1₂) open import Data.Sum public using (_⊎_; [_,_]) renaming (inj₁ to inl ;inj₂ to inr) open import Data.Maybe public using (Maybe; nothing; just) open import Data.Empty public renaming (⊥ to 𝟘 ;⊥-elim to 𝟘-elim) open import Data.Unit public using () -- using (Hidden; Unit; hide; reveal) renaming (⊤ to 𝟙) open import Data.Unit.NonEta public using (Hidden; Unit; hide; reveal) import Data.Product open Data.Product public using (Σ; _×_; _,_; curry; <_,_>) renaming (proj₁ to fst ;proj₂ to snd) open import Relation.Binary public using (Reflexive) import Relation.Binary.PropositionalEquality open Relation.Binary.PropositionalEquality public using (_≡_) renaming (subst to transport ;refl to idp ;sym to ! ;cong to ap) import Relation.Binary.PropositionalEquality.TrustMe module ThisIsUnsafeButPlease = Relation.Binary.PropositionalEquality.TrustMe -- using stdlib only infixr 8 _∙_ _∙_ = Relation.Binary.PropositionalEquality.trans ℕ² = ℕ × ℕ -- Let's rename "Set₀" as "Type" to avoid confusion with set-theory Type = Set -- Let's rename "Set ℓ" as "Type_ ℓ" to avoid confusion with set-theory Type_ : ∀ ℓ → Set (ₛ ℓ) Type_ ℓ = Set ℓ -→- : ∀ {a b} → Type_ a → Type_ b → Type_ (a ⊔ b) -→- A B = A → B Endo : ∀ {a} → Type_ a → Type_ a Endo A = A → A Fix : ∀ {a} → Type_ a → Type_ a Fix X = (X → X) → X postulate funext : ∀ {a b} {A : Type_ a} {B : A → Type_ b} {f g : (x : A) → B x} → (∀ x → f x ≡ g x) → f ≡ g 𝟘-elim-uniq! : ∀ {a} {A : Type_ a} {f : 𝟘 → A} → 𝟘-elim ≡ f 𝟘-elim-uniq! = funext (λ()) [,]-uniq! : ∀ {a b c} {A : Type_ a} {B : Type_ b} {C : Type_ c} {f : (A ⊎ B) → C} → [ f ∘ inl , f ∘ inr ] ≡ f [,]-uniq! = funext p where p : (_ : _ ⊎ _) → _ p (inl _) = idp p (inr _) = idp module Coe {ℓ} where coe : {A B : Type_ ℓ} → A ≡ B → A → B coe = transport id coe! : {A B : Type_ ℓ} → A ≡ B → B → A coe! = transport id ∘ ! module _ {a} {A : Type_ a} {P Q : A → Type_ ℓ} (p : P ≡ Q) {x} where coe₁ : P x → Q x coe₁ = transport (λ P → P x) p coe₁! : Q x → P x coe₁! = transport (λ P → P x) (! p) module _ {a b} {A : Type_ a} {B : Type_ b} {R S : A → B → Type_ ℓ} (p : R ≡ S) {x y} where coe₂ : R x y → S x y coe₂ = transport (λ R → R x y) p coe₂! : S x y → R x y coe₂! = transport (λ R → R x y) (! p) [0:_1:_] : ∀ {a} {A : Type_ a} (a₀ a₁ : A) → 𝟚 → A [0: a₀ 1: a₁ ] 0₂ = a₀ [0: a₀ 1: a₁ ] 1₂ = a₁
{ "alphanum_fraction": 0.4670793472, "avg_line_length": 27.9842519685, "ext": "agda", "hexsha": "de84d6bc527c8d60d284620afd6b784411f9f60c", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-11-16T16:21:54.000Z", "max_forks_repo_forks_event_min_datetime": "2015-08-19T12:37:53.000Z", "max_forks_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "np/guarded-recursion", "max_forks_repo_path": "guarded-recursion/prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "np/guarded-recursion", "max_issues_repo_path": "guarded-recursion/prelude.agda", "max_line_length": 94, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9fba7d89d8b27e9bb08c27df802608b5fff769e0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "np/guarded-recursion", "max_stars_repo_path": "guarded-recursion/prelude.agda", "max_stars_repo_stars_event_max_datetime": "2016-12-06T23:04:56.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-06T23:04:56.000Z", "num_tokens": 1192, "size": 3554 }
module Categories.Terminal where open import Library open import Categories open import Categories.Sets open Cat record Term {a b} (C : Cat {a}{b})(T : Obj C) : Set (a ⊔ b) where constructor term field t : ∀{X} → Hom C X T law : ∀{X}{f : Hom C X T} → t {X} ≅ f OneSet : Term Sets ⊤ OneSet = record {t = λ _ → _; law = ext (λ _ → refl)}
{ "alphanum_fraction": 0.6096866097, "avg_line_length": 23.4, "ext": "agda", "hexsha": "1c2f39bd02752ad5115c4e1d41b89aa2bf6c9c0b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z", "max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "jmchapman/Relative-Monads", "max_forks_repo_path": "Categories/Terminal.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "jmchapman/Relative-Monads", "max_issues_repo_path": "Categories/Terminal.agda", "max_line_length": 65, "max_stars_count": 21, "max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "jmchapman/Relative-Monads", "max_stars_repo_path": "Categories/Terminal.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z", "num_tokens": 123, "size": 351 }
import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} {- Addition -} _+_ : ℕ → ℕ → ℕ zero + n = n (suc m) + n = suc (m + n) _ : 3 + 4 ≡ 7 _ = begin 3 + 4 ≡⟨⟩ suc (2 + 4) ≡⟨⟩ suc (suc (1 + 4)) ≡⟨⟩ suc (suc (suc (0 + 4))) ≡⟨⟩ suc (suc (suc 4)) ≡⟨⟩ 7 ∎ _ : 1 + 1 ≡ 2 _ = refl {- Multiplication -} _*_ : ℕ → ℕ → ℕ zero * n = zero (suc m) * n = n + (m * n) _ : 2 * 2 ≡ 4 _ = begin 2 * 2 ≡⟨⟩ 2 + (1 * 2) ≡⟨⟩ 2 + (2 + (0 * 2)) ≡⟨⟩ 2 + 2 ≡⟨⟩ 4 ∎ _ : 1 * 1 ≡ 1 _ = refl {- Exponentiation -} _^_ : ℕ → ℕ → ℕ n ^ 0 = 1 n ^ (suc m) = n * (n ^ m) _ : 2 ^ 3 ≡ 8 _ = begin 2 ^ 3 ≡⟨⟩ 2 * (2 ^ 2) ≡⟨⟩ 2 * (2 * (2 ^ 1)) ≡⟨⟩ 2 * (2 * (2 * (2 ^ 0))) ≡⟨⟩ 2 * (2 * (2 * 1)) ≡⟨⟩ 8 ∎ _ : 42 ^ 0 ≡ 1 _ = refl {- Monus -} _∸_ : ℕ → ℕ → ℕ m ∸ zero = m zero ∸ (suc n) = zero (suc m) ∸ (suc n) = m ∸ n _ : 2 ∸ 1 ≡ 1 _ = begin 2 ∸ 1 ≡⟨⟩ 1 ∸ 0 ≡⟨⟩ 1 ∎ _ : 7 ∸ 4 ≡ 3 _ = refl _ : 4 ∸ 7 ≡ 0 _ = refl
{ "alphanum_fraction": 0.356779661, "avg_line_length": 11.1320754717, "ext": "agda", "hexsha": "0e5c5c77e66b3e256aa745eb27d76e9c4057952e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "anqurvanillapy/fpl", "max_forks_repo_path": "agda/proof-nat.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "anqurvanillapy/fpl", "max_issues_repo_path": "agda/proof-nat.agda", "max_line_length": 50, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9576d5b76e6a868992dbe52930712ac67697bed2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "anqurvanillapy/fpl", "max_stars_repo_path": "agda/proof-nat.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-24T22:47:47.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-24T22:47:47.000Z", "num_tokens": 689, "size": 1180 }
module String where import Lvl open import Data.Boolean open import Data.List open import Numeral.Natural open import Type postulate Char : Type{Lvl.𝟎} {-# BUILTIN CHAR Char #-} postulate String : Type{Lvl.𝟎} {-# BUILTIN STRING String #-} private module Primitives where primitive primStringToList : String → List(Char) primitive primStringFromList : List(Char) → String primitive primStringAppend : String → String → String primitive primStringEquality : String → String → Bool primitive primShowChar : Char → String primitive primShowString : String → String primitive primShowNat : ℕ → String primitive primIsLower : Char → Bool primitive primIsDigit : Char → Bool primitive primIsAlpha : Char → Bool primitive primIsSpace : Char → Bool primitive primIsAscii : Char → Bool primitive primIsLatin1 : Char → Bool primitive primIsPrint : Char → Bool primitive primIsHexDigit : Char → Bool primitive primToUpper : Char → Char primitive primToLower : Char → Char primitive primCharToNat : Char → ℕ primitive primNatToChar : ℕ → Char primitive primCharEquality : Char → Char → Bool module String where open Primitives renaming ( primStringToList to toList ; primStringFromList to fromList ; primStringAppend to _++_ ; primStringEquality to _==_ ; primShowChar to fromChar ; primShowNat to fromℕ ) public {- open import Relator.Equals open import Relator.Equals.Proofs open import Syntax.Transitivity primitive primEraseEquality : ∀{ℓ}{A : Type{ℓ}}{x y : A} → (x ≡ y) → (x ≡ y) unsafeDefinitionalEquality : ∀{ℓ}{A : Type{ℓ}}{x y : A} → (x ≡ y) unsafeDefinitionalEquality {x = x}{y = y} = primEraseEquality xy where postulate xy : x ≡ y toList-fromList-of-[⊰] : ∀{x}{l} → (toList(fromList(x ⊰ l)) ≡ x ⊰ toList(fromList(l))) toList-fromList-of-[⊰] = unsafeDefinitionalEquality fromList-toList-inverse : ∀{s} → (fromList(toList(s)) ≡ s) fromList-toList-inverse = unsafeDefinitionalEquality toList-fromList-inverse : ∀{l} → (toList(fromList(l)) ≡ l) toList-fromList-inverse {∅} = [≡]-intro toList-fromList-inverse {x ⊰ l} = toList-fromList-of-[⊰] 🝖 [≡]-with(x ⊰_) (toList-fromList-inverse {l}) -}
{ "alphanum_fraction": 0.6631130064, "avg_line_length": 33.5, "ext": "agda", "hexsha": "36694c5c733ec9d5a8ec6aa8b8e39c2a2b0d6bfb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "String.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "String.agda", "max_line_length": 105, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "String.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 688, "size": 2345 }
{- This file describes properties of computable relations. -} open import bool open import level open import eq open import product open import product-thms module relations {ℓ ℓ' : level}{A : Set ℓ} (_≥A_ : A → A → Set ℓ') where reflexive : Set (ℓ ⊔ ℓ') reflexive = ∀ {a : A} → a ≥A a transitive : Set (ℓ ⊔ ℓ') transitive = ∀ {a b c : A} → a ≥A b → b ≥A c → a ≥A c preorder : Set (ℓ ⊔ ℓ') preorder = reflexive ∧ transitive _iso_ : A → A → Set ℓ' d iso d' = d ≥A d' ∧ d' ≥A d iso-intro : ∀{x y : A} → x ≥A y → y ≥A x → x iso y iso-intro p1 p2 = p1 , p2
{ "alphanum_fraction": 0.593250444, "avg_line_length": 21.6538461538, "ext": "agda", "hexsha": "965b1a952dedf5b9014d436411dc31f59c146f58", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "relations.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "relations.agda", "max_line_length": 72, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "relations.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 224, "size": 563 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Categories.Type where open import Cubical.Foundations.Prelude open import Cubical.Categories.Category open Precategory module _ ℓ where TYPE : Precategory (ℓ-suc ℓ) ℓ TYPE .ob = Type ℓ TYPE .Hom[_,_] A B = A → B TYPE .id A = λ x → x TYPE ._⋆_ f g = λ x → g (f x) TYPE .⋆IdL f = refl TYPE .⋆IdR f = refl TYPE .⋆Assoc f g h = refl
{ "alphanum_fraction": 0.6466346154, "avg_line_length": 21.8947368421, "ext": "agda", "hexsha": "e73bdbe19a2d728cf10865a78505288428a4e499", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "apabepa10/cubical", "max_forks_repo_path": "Cubical/Categories/Type.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "apabepa10/cubical", "max_issues_repo_path": "Cubical/Categories/Type.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a9bb56260c25a6f2e9c20af8d278de0fe8d9e05", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "apabepa10/cubical", "max_stars_repo_path": "Cubical/Categories/Type.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 154, "size": 416 }
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness --no-subtyping #-} module Agda.Builtin.Reflection.Properties where open import Agda.Builtin.Reflection open import Agda.Builtin.Equality primitive primMetaToNatInjective : ∀ a b → primMetaToNat a ≡ primMetaToNat b → a ≡ b primQNameToWord64sInjective : ∀ a b → primQNameToWord64s a ≡ primQNameToWord64s b → a ≡ b
{ "alphanum_fraction": 0.7279596977, "avg_line_length": 30.5384615385, "ext": "agda", "hexsha": "55d067eea90964e7104da1e140e119d892ef061a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "src/data/lib/prim/Agda/Builtin/Reflection/Properties.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_issues_event_min_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "src/data/lib/prim/Agda/Builtin/Reflection/Properties.agda", "max_line_length": 91, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "src/data/lib/prim/Agda/Builtin/Reflection/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-26T09:35:17.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-26T09:35:17.000Z", "num_tokens": 120, "size": 397 }
------------------------------------------------------------------------ -- Some theory of equivalences with erased "proofs", developed using -- Cubical Agda ------------------------------------------------------------------------ -- This module instantiates and reexports code from -- Equivalence.Erased. {-# OPTIONS --erased-cubical --safe #-} import Equality.Path as P module Equivalence.Erased.Cubical {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq open import Erased.Cubical eq import Equivalence.Erased open Equivalence.Erased equality-with-J public hiding (module []-cong) open Equivalence.Erased.[]-cong equality-with-J instance-of-[]-cong-axiomatisation public
{ "alphanum_fraction": 0.6, "avg_line_length": 28.4615384615, "ext": "agda", "hexsha": "2da3190509d09ca9a3ce33c89d3de62933b4e57a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Equivalence/Erased/Cubical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Equivalence/Erased/Cubical.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Equivalence/Erased/Cubical.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 177, "size": 740 }
{-# OPTIONS --without-K --safe #-} -- Defines Restriction Category -- https://ncatlab.org/nlab/show/restriction+category -- but see also -- https://github.com/jmchapman/restriction-categories -- Notation choice: one of the interpretations is that the -- restriction structure captures the "domain of definedness" -- of a morphism, as a (partial) identity. As this is positive -- information, we will use f ↓ (as a postfix operation) to -- denote this. Note that computability theory uses the same -- notation to mean definedness. -- Note, as we're working in Setoid-Enriched Categories, we need -- to add an explicit axiom, that ↓ preserves ≈ module Categories.Category.Restriction where open import Level using (Level; _⊔_) open import Categories.Category.Core using (Category) private variable o ℓ e : Level record Restriction (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where open Category C using (Obj; _⇒_; _∘_; _≈_; id) field _↓ : {A B : Obj} → A ⇒ B → A ⇒ A -- partial identity on the right pidʳ : {A B : Obj} {f : A ⇒ B} → f ∘ f ↓ ≈ f -- the domain-of-definition arrows commute ↓-comm : {A B C : Obj} {f : A ⇒ B} {g : A ⇒ C} → f ↓ ∘ g ↓ ≈ g ↓ ∘ f ↓ -- domain-of-definition denests (on the right) ↓-denestʳ : {A B C : Obj} {f : A ⇒ B} {g : A ⇒ C} → (g ∘ f ↓) ↓ ≈ g ↓ ∘ f ↓ -- domain-of-definition has a skew-commutative law ↓-skew-comm : {A B C : Obj} {g : A ⇒ B} {f : C ⇒ A} → g ↓ ∘ f ≈ f ∘ (g ∘ f) ↓ -- and the new axiom, ↓ is a congruence ↓-cong : {A B : Obj} {f g : A ⇒ B} → f ≈ g → f ↓ ≈ g ↓ -- it is convenient to define the total predicate in this context total : {A B : Obj} (f : A ⇒ B) → Set e total f = f ↓ ≈ id
{ "alphanum_fraction": 0.6107184923, "avg_line_length": 36.9130434783, "ext": "agda", "hexsha": "523f8c4d533408799ad349e7c226d9306daf144c", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Restriction.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Restriction.agda", "max_line_length": 81, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Restriction.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 570, "size": 1698 }
module Formalization.LambdaCalculus where import Lvl open import Data open import Numeral.Natural open import Numeral.Finite open import Syntax.Number open import Type -- A lambda term (A term in the language of lambda calculus). -- This is encoded with an abstraction depth which ensures that every term is well-formed. -- `Term(𝟎)` is the type of closed terms, terms that have no unbound variables. -- In this representation, it means that there are no occurrences of `Var(_)` in a term. -- `Term(𝐒(n))` for some `n` is the types of open terms with possibly `n` number of different variables, terms that have unbound variables. -- In this representation, it means that there can be `Var(i)` for `i < n` in a term. data Term : ℕ → Type{0} where -- The term which represents applying the second term on the first term. -- Representation in function notation: -- (Apply f(x)) is f(x) Apply : ∀{d} → Term(d) → Term(d) → Term(d) -- The term which represents bounding a new variable (introducing a variable). -- Representation in function notation: -- (Abstract{n} term) is (xₙ ↦ term) Abstract : ∀{d} → Term(𝐒(d)) → Term(d) -- The term which represents a specific variable in scope. -- Representation in function notation: -- (Var(n)) is xₙ Var : ∀{d} → 𝕟(d) → Term(d) -- An expression in the language of lambda calculus is a closed term. Expression : Type{0} Expression = Term(0) module VarNumeralSyntax where -- Syntax for writing Var as a numeral. instance Term-from-ℕ : ∀{N} → Numeral(Term(N)) Numeral.restriction-ℓ ( Term-from-ℕ {N} ) = Numeral.restriction-ℓ ( 𝕟-from-ℕ {N} ) Numeral.restriction ( Term-from-ℕ {N} ) = Numeral.restriction ( 𝕟-from-ℕ {N} ) num ⦃ Term-from-ℕ {N} ⦄ (n) ⦃ proof ⦄ = Var(num n) module OperSyntax where open VarNumeralSyntax public infixr 100 _↦_ infixl 101 _←_ pattern _↦_ d expr = Term.Abstract{d} expr pattern _←_ a b = Term.Apply a b module ExplicitLambdaSyntax where open VarNumeralSyntax public infixl 101 _←_ pattern 𝜆 d expr = Term.Abstract{d} expr pattern _←_ a b = Term.Apply a b
{ "alphanum_fraction": 0.6857410882, "avg_line_length": 35.5333333333, "ext": "agda", "hexsha": "8e2cf11e109e0eed8ea0970b6827f3802bc8fb68", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Formalization/LambdaCalculus.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Formalization/LambdaCalculus.agda", "max_line_length": 139, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Formalization/LambdaCalculus.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 631, "size": 2132 }
module ctxt-types where open import lib open import cedille-types open import general-util open import syntax-util location : Set location = string × posinfo -- file path and starting position in the file -- file path and starting / ending position in file span-location = string × posinfo × posinfo -- missing locations missing-location : location missing-location = ("missing" , "missing") missing-span-location : span-location missing-span-location = ("missing" , "missing" , "missing") {- we will generally keep classifiers of variables in hnf in the ctxt, although we will not necessarily unfold recursive type definitions. -} defScope : Set defScope = 𝔹 pattern localScope = tt pattern globalScope = ff pattern concrete-datatype = globalScope pattern abstract-datatype = localScope defParams : Set defParams = maybe params data ctxt-info : Set where -- for defining a datatype -- datatype-def : defParams → (ind reg : kind) → ctrs → ctxt-info -- for defining a datatype constructor ctr-def : params → type → (ctrs-length ctr-index ctr-unerased-arrows : ℕ) → ctxt-info -- for declaring the type that proves a type is a datatype (X/Mu) -- mu-def : defParams → var → kind → ctxt-info -- for declaring a variable to have a given type (with no definition) term-decl : type → ctxt-info -- for defining a variable to equal a term with a given type -- maybe term, because datatype X/Mu and X/mu have params, etc... but no def term-def : defParams → opacity → maybe term → type → ctxt-info -- for untyped term definitions term-udef : defParams → opacity → term → ctxt-info -- for declaring a variable to have a given kind (with no definition) type-decl : kind → ctxt-info -- for defining a variable to equal a type with a given kind type-def : defParams → opacity → maybe type → kind → ctxt-info -- for defining a variable to equal a kind kind-def : params → kind → ctxt-info -- to rename a variable at any level to another rename-def : var → ctxt-info -- representing a declaration of a variable with no other information about it var-decl : ctxt-info sym-info : Set sym-info = ctxt-info × location -- module filename, name, parameters, and qualifying substitution mod-info : Set mod-info = string × string × params × qualif is-term-level : ctxt-info → 𝔹 is-term-level (term-decl _) = tt is-term-level (term-def _ _ _ _) = tt is-term-level (term-udef _ _ _) = tt is-term-level (ctr-def _ _ _ _ _ ) = tt is-term-level _ = ff data ctxt : Set where mk-ctxt : (mod : mod-info) → -- current module (syms : trie (string × 𝕃 string) × trie string × trie params × trie ℕ × Σ ℕ (𝕍 string)) → -- map each filename to its module name and the symbols declared in that file, map each module name to its filename and params, and file ID's for use in to-string.agda (i : trie sym-info) → -- map symbols (from Cedille files) to their ctxt-info and location (sym-occurrences : trie (𝕃 (var × posinfo × string))) → -- map symbols to a list of definitions they occur in (and relevant file info) (Δ : trie (params × kind × kind × ctrs) × trie (var × var × args) × trie var) → -- datatype info: (concrete/global datatypes × abstract/local datatypes × datatype/Mu map) ctxt ctxt-binds-var : ctxt → var → 𝔹 ctxt-binds-var (mk-ctxt (_ , _ , _ , q) _ i _ _) x = trie-contains q x || trie-contains i x ctxt-var-decl : var → ctxt → ctxt ctxt-var-decl v (mk-ctxt (fn , mn , ps , q) syms i symb-occs Δ) = mk-ctxt (fn , mn , ps , (trie-insert q v (v , []))) syms (trie-insert i v (var-decl , "missing" , "missing")) symb-occs Δ ctxt-var-decl-loc : posinfo → var → ctxt → ctxt ctxt-var-decl-loc pi v (mk-ctxt (fn , mn , ps , q) syms i symb-occs Δ) = mk-ctxt (fn , mn , ps , (trie-insert q v (v , []))) syms (trie-insert i v (var-decl , fn , pi)) symb-occs Δ qualif-var : ctxt → var → var qualif-var (mk-ctxt (_ , _ , _ , q) _ _ _ _) v with trie-lookup q v ...| just (v' , _) = v' ...| nothing = v start-modname : start → string start-modname (File _ _ _ mn _ _ _) = mn ctxt-get-current-filename : ctxt → string ctxt-get-current-filename (mk-ctxt (fn , _) _ _ _ _) = fn ctxt-get-current-mod : ctxt → mod-info ctxt-get-current-mod (mk-ctxt m _ _ _ _) = m ctxt-get-current-modname : ctxt → string ctxt-get-current-modname (mk-ctxt (_ , mn , _ , _) _ _ _ _) = mn ctxt-get-current-params : ctxt → params ctxt-get-current-params (mk-ctxt (_ , _ , ps , _) _ _ _ _) = ps ctxt-get-symbol-occurrences : ctxt → trie (𝕃 (var × posinfo × string)) ctxt-get-symbol-occurrences (mk-ctxt _ _ _ symb-occs _) = symb-occs ctxt-set-symbol-occurrences : ctxt → trie (𝕃 (var × posinfo × string)) → ctxt ctxt-set-symbol-occurrences (mk-ctxt fn syms i symb-occs Δ) new-symb-occs = mk-ctxt fn syms i new-symb-occs Δ
{ "alphanum_fraction": 0.6708599711, "avg_line_length": 37.5891472868, "ext": "agda", "hexsha": "1993c5dab5ff9c3a79fda2529ef442e0c04b4df4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f5ce42258b7d9bc66f75cd679c785d6133b82b58", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CarlOlson/cedille", "max_forks_repo_path": "src/ctxt-types.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f5ce42258b7d9bc66f75cd679c785d6133b82b58", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CarlOlson/cedille", "max_issues_repo_path": "src/ctxt-types.agda", "max_line_length": 272, "max_stars_count": null, "max_stars_repo_head_hexsha": "f5ce42258b7d9bc66f75cd679c785d6133b82b58", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CarlOlson/cedille", "max_stars_repo_path": "src/ctxt-types.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1381, "size": 4849 }
-- {-# OPTIONS -v tc.cover.split.con:100 #-} {-# OPTIONS --show-implicit #-} data D : Set where d : {x : D} → D f : D → Set f y = {!!}
{ "alphanum_fraction": 0.4928571429, "avg_line_length": 14, "ext": "agda", "hexsha": "22c6e4b2c5551cbc62fd28a0815972ab50c77fdb", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue2166.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue2166.agda", "max_line_length": 44, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2166.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 48, "size": 140 }
open import Sec2 data Vec (A : Set) : ℕ → Set where [] : Vec A Z _∷_ : {n : ℕ} → A → Vec A n → Vec A (S n) head : {A : Set} → {n : ℕ} → Vec A (S n) → A head (x ∷ vs) = x tail : {A : Set} → {n : ℕ} → Vec A (S n) → Vec A n tail (x ∷ vs) = vs map : {A B : Set} → {n : ℕ} → (f : A → B) → Vec A n → Vec B n map f [] = [] map f (x ∷ vs) = f x ∷ map f vs zip : {A B : Set} → {n : ℕ} → Vec A n → Vec B n → Vec (A Π B) n zip [] [] = [] zip (x ∷ xs) (x₁ ∷ ys) = < x , x₁ > ∷ zip xs ys
{ "alphanum_fraction": 0.4156378601, "avg_line_length": 22.0909090909, "ext": "agda", "hexsha": "61077a6af3740f509d479ecfed02341afd84ff28", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "amal029/agda-tutorial-dybjer", "max_forks_repo_path": "Sec3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "amal029/agda-tutorial-dybjer", "max_issues_repo_path": "Sec3.agda", "max_line_length": 63, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "amal029/agda-tutorial-dybjer", "max_stars_repo_path": "Sec3.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:52:30.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:52:30.000Z", "num_tokens": 234, "size": 486 }
module x02-842Induction-hc-2 where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; sym) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_) -- PLFA coverage of identity, associativity, commutativity, distributivity. -- + associative _ : (3 + 4) + 5 ≡ 3 + (4 + 5) _ = begin (3 + 4) + 5 ≡⟨⟩ 7 + 5 ≡⟨⟩ 12 ≡⟨⟩ 3 + 9 ≡⟨⟩ 3 + (4 + 5) ∎ +-identityᴸ : ∀ (m : ℕ) → zero + m ≡ m +-identityᴸ m = refl 0+ : ∀ (m : ℕ) → zero + m ≡ m 0+ = +-identityᴸ +-identityʳ : ∀ (m : ℕ) → m + zero ≡ m +-identityʳ zero = refl +-identityʳ (suc m) = cong suc (+-identityʳ m) +0 : ∀ (m : ℕ) → m + zero ≡ m +0 = +-identityʳ +-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p) +-assoc zero n p = refl +-assoc (suc m) n p = cong suc (+-assoc m n p) +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n) +-suc zero n = refl +-suc (suc m) n = cong suc (+-suc m n) +-comm : ∀ (m n : ℕ) → m + n ≡ n + m +-comm zero n -- zero + n ≡ n + zero -- n ≡ n + zero rewrite +-identityʳ n -- n ≡ n = refl +-comm (suc m) n -- suc m + n ≡ n + suc m -- suc (m + n) ≡ n + suc m rewrite +-suc n m -- suc (m + n) ≡ suc (n + m) | cong suc (+-comm m n) -- suc (n + m) ≡ suc (n + m) = refl -- without using induction/recursion +-swap : ∀ (m n p : ℕ) → (m + n) + p ≡ n + (m + p) +-swap zero n p = refl +-swap (suc m) n p -- suc m + n + p ≡ n + (suc m + p) -- suc (m + n + p) ≡ n + suc (m + p) rewrite +-suc n (m + p) -- suc (m + n + p) ≡ suc (n + (m + p)) | sym (+-assoc n m p) -- suc (m + n + p) ≡ suc (n + m + p) | +-comm m n -- suc (n + m + p) ≡ suc (n + m + p) = refl *-+-rdistrib : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p *-+-rdistrib zero n p = refl *-+-rdistrib (suc m) n p -- (suc m + n) * p ≡ suc m * p + n * p -- p + (m + n) * p ≡ p + m * p + n * p rewrite *-+-rdistrib m n p -- p + (m * p + n * p) ≡ p + m * p + n * p | +-assoc p (m * p) (n * p) -- p + (m * p + n * p) ≡ p + (m * p + n * p) = refl *-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p) *-assoc zero n p = refl *-assoc (suc m) n p -- suc m * n * p ≡ suc m * (n * p) -- (n + m * n) * p ≡ n * p + m * (n * p) rewrite *-+-rdistrib n (m * n) p -- n * p + m * n * p ≡ n * p + m * (n * p) | sym (*-assoc m n p) -- n * p + m * n * p ≡ n * p + m * n * p = refl *0 : ∀ (m : ℕ) → m * zero ≡ zero *0 zero = refl *0 (suc m) = *0 m *1 : ∀ (m : ℕ) → m * suc zero ≡ m *1 zero = refl *1 (suc m) = cong suc (*1 m) -- like addition, helper lemmas needed *-comm : ∀ (m n : ℕ) → m * n ≡ n * m *-comm zero n rewrite *0 n = refl *-comm m zero rewrite *0 m = refl *-comm (suc m) (suc n) -- suc m * suc n ≡ suc n * suc m -- suc (n + m * suc n) ≡ suc (m + n * suc m) rewrite *-comm m (suc n) -- suc (n + (m + n * m)) ≡ suc (m + n * suc m) | *-comm n (suc m) -- suc (n + (m + n * m)) ≡ suc (m + (n + m * n)) | sym (+-assoc n m (n * m)) -- suc (n + m + n * m) ≡ suc (m + (n + m * n)) | sym (+-assoc m n (m * n)) -- suc (n + m + n * m) ≡ suc (m + n + m * n) | +-swap n m (n * m) -- suc (m + (n + n * m)) ≡ suc (m + n + m * n) | sym (+-assoc m n (n * m)) -- suc (m + n + n * m) ≡ suc (m + n + m * n) | *-comm m n -- suc (m + n + n * m) ≡ suc (m + n + n * m) = refl 0∸n≡0 : ∀ (m : ℕ) → zero ∸ m ≡ zero 0∸n≡0 zero = refl 0∸n≡0 (suc m) rewrite 0∸n≡0 m = refl m∸0≡m : ∀ (m : ℕ) → m ∸ zero ≡ m m∸0≡m m = refl ∸-+-assoc : ∀ (m n p : ℕ) → m ∸ n ∸ p ≡ m ∸ (n + p) ∸-+-assoc zero n p -- zero ∸ n ∸ p ≡ zero ∸ (n + p) rewrite 0∸n≡0 (n + p) -- 0 ∸ n ∸ p ≡ 0 | 0∸n≡0 n -- 0 ∸ p ≡ 0 | 0∸n≡0 p -- 0 ≡ 0 = refl ∸-+-assoc m zero p = refl ∸-+-assoc m n zero -- m ∸ n ∸ zero ≡ m ∸ (n + zero) rewrite +0 n -- m ∸ n ≡ m ∸ n = refl ∸-+-assoc (suc m) (suc n) (suc p) -- m ∸ n ∸ suc p ≡ m ∸ (n + suc p) rewrite sym (∸-+-assoc m n (suc p)) -- m ∸ n ∸ suc p ≡ m ∸ n ∸ suc p = refl ------------------------------------------------------------------------------ -- Properties of binary representation. ----- -- BEGIN : copied from x01-842Naturals-hc-2.agda data Bin-ℕ : Set where bits : Bin-ℕ _x0 : Bin-ℕ → Bin-ℕ _x1 : Bin-ℕ → Bin-ℕ bin-zero : Bin-ℕ bin-zero = bits bin-one : Bin-ℕ bin-one = bits x1 -- 1 in binary bin-two : Bin-ℕ bin-two = bits x1 x0 -- 10 in binary inc : Bin-ℕ → Bin-ℕ inc bits = bits x1 inc (m x0) = m x1 inc (m x1) = (inc m) x0 dbl : ℕ → ℕ dbl zero = zero dbl (suc m) = suc (suc (dbl m)) tob : ℕ → Bin-ℕ tob zero = bits tob (suc m) = inc (tob m) fromb : Bin-ℕ → ℕ fromb bits = zero fromb (n x0) = dbl (fromb n) fromb (n x1) = suc (dbl (fromb n)) _bin-+_ : Bin-ℕ → Bin-ℕ → Bin-ℕ bits bin-+ n = n m bin-+ bits = m (m x0) bin-+ (n x0) = (m bin-+ n) x0 (m x0) bin-+ (n x1) = inc ((m bin-+ n) x0) (m x1) bin-+ (n x0) = inc ((m bin-+ n) x0) (m x1) bin-+ (n x1) = inc (inc ((m bin-+ n) x0)) -- END : copied from x01-842Naturals-hc-2.agda ----- -- Bin-ℕ version of dbl. Do not use tob/fromb. dblb : Bin-ℕ → Bin-ℕ dblb bits = bits dblb (m x0) = (dblb m) x0 dblb (m x1) = inc (inc ((dblb m) x0)) _ : dblb bits ≡ bits _ = refl _ : dblb (bits x0) ≡ bits x0 _ = refl _ : dblb (bits x1) ≡ bits x1 x0 _ = refl _ : dblb (bits x1 x0) ≡ bits x1 x0 x0 _ = refl _ : dblb (bits x1 x1) ≡ bits x1 x1 x0 _ = refl _ : dblb (bits x1 x0 x0) ≡ bits x1 x0 x0 x0 _ = refl _ : dblb (bits x1 x0 x1) ≡ bits x1 x0 x1 x0 _ = refl from∘inc : ∀ (m : Bin-ℕ) → fromb (inc m) ≡ suc (fromb m) from∘inc bits = refl from∘inc (m x0) = refl from∘inc (m x1) -- fromb (inc (m x1)) ≡ suc (fromb (m x1)) -- dbl (fromb (inc m)) ≡ suc (suc (dbl (fromb m))) rewrite from∘inc m -- dbl (suc (fromb m)) ≡ suc (suc (dbl (fromb m))) -- suc (suc (dbl (fromb m))) ≡ suc (suc (dbl (fromb m))) = refl from∘tob : ∀ (m : ℕ) → fromb (tob m) ≡ m from∘tob zero = refl from∘tob (suc m) -- fromb (tob (suc m)) ≡ suc m -- fromb (inc (tob m)) ≡ suc m rewrite from∘inc (tob m) -- suc (fromb (tob m)) ≡ suc m | from∘tob m -- suc m ≡ suc m = refl -- ∀ (m : Bin-ℕ) → tob (fromb m) ≡ m cannot be proved. -- Because there are multiple representations of ZERO. -- This restriction can be proved. to/from-corr : ∀ (b : Bin-ℕ) (n : ℕ) → b ≡ tob n → fromb b ≡ n to/from-corr .bits zero refl = refl to/from-corr .(inc (tob n)) (suc n) refl -- fromb (tob (suc n)) ≡ suc n -- fromb (inc (tob n)) ≡ suc n rewrite from∘inc (tob n) -- suc (fromb (tob n)) ≡ suc n | to/from-corr (tob n) n refl -- suc n ≡ suc n = refl dblb∘inc : ∀ (b : Bin-ℕ) → dblb (inc b) ≡ inc (inc (dblb b)) dblb∘inc bits = refl dblb∘inc (b x0) = refl dblb∘inc (b x1) -- dblb (inc (b x1)) ≡ inc (inc (dblb (b x1))) -- (dblb (inc b) x0) ≡ (inc (inc (dblb b)) x0) rewrite dblb∘inc b -- (inc (inc (dblb b)) x0) ≡ (inc (inc (dblb b)) x0) = refl to∘dbl : ∀ (m : ℕ) → tob (dbl m) ≡ dblb (tob m) to∘dbl zero = refl to∘dbl (suc m) -- tob (dbl (suc m)) ≡ dblb (tob (suc m)) -- inc (inc (tob (dbl m))) ≡ dblb (inc (tob m)) rewrite to∘dbl m -- inc (inc (dblb (tob m))) ≡ dblb (inc (tob m)) | dblb∘inc (tob m) -- inc (inc (dblb (tob m))) ≡ inc (inc (dblb (tob m))) = refl from∘dblb : ∀ (b : Bin-ℕ) → fromb (dblb b) ≡ dbl (fromb b) from∘dblb bits = refl from∘dblb (b x0) -- fromb (dblb (b x0)) ≡ dbl (fromb (b x0)) -- dbl (fromb (dblb b)) ≡ dbl (dbl (fromb b)) rewrite from∘dblb b -- dbl (dbl (fromb b)) ≡ dbl (dbl (fromb b)) = refl from∘dblb (b x1) -- fromb (dblb (b x1)) ≡ dbl (fromb (b x1)) -- dbl (fromb (inc (dblb b))) ≡ suc (suc (dbl (dbl (fromb b)))) rewrite from∘inc (dblb b) -- dbl (suc (fromb (dblb b))) ≡ suc (suc (dbl (dbl (fromb b)))) | from∘dblb b -- suc (suc (dbl (dbl (fromb b)))) ≡ suc (suc (dbl (dbl (fromb b)))) = refl -- lemma -- second case for unary addition -- suc m + n = suc (m + n) -- into binary setting. -- Induction on both m and n is needed. bin-+-linc : ∀ (m n : Bin-ℕ) → (inc m) bin-+ n ≡ inc (m bin-+ n) bin-+-linc bits bits = refl bin-+-linc bits (n x0) = refl bin-+-linc bits (n x1) = refl bin-+-linc (m x0) bits = refl bin-+-linc (m x0) (n x0) = refl bin-+-linc (m x0) (n x1) = refl bin-+-linc (m x1) bits = refl bin-+-linc (m x1) (n x0) rewrite bin-+-linc m n = refl bin-+-linc (m x1) (n x1) rewrite bin-+-linc m n = refl -- theorem relates unary and binary addition to∘+ : ∀ (m n : ℕ) → tob (m + n) ≡ tob m bin-+ tob n to∘+ zero n = refl to∘+ (suc m) n -- tob (suc m + n) ≡ (tob (suc m) bin-+ tob n) -- inc (tob (m + n)) ≡ (inc (tob m) bin-+ tob n) rewrite bin-+-linc (tob m) (tob n) -- inc (tob (m + n)) ≡ inc (tob m bin-+ tob n) | to∘+ m n -- inc (tob m bin-+ tob n) ≡ inc (tob m bin-+ tob n) = refl
{ "alphanum_fraction": 0.4312001636, "avg_line_length": 33.7310344828, "ext": "agda", "hexsha": "9f9c031472e4f5d5e7e975986bd2a52c59708722", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x02-842Induction-hc-2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x02-842Induction-hc-2.agda", "max_line_length": 90, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x02-842Induction-hc-2.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 4236, "size": 9782 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.Groupoids where -- The category of groupoids. -- -- This category should maybe be called "Ho(Groupoids)" or "Ho(Gpd)" -- instead. The "homsets" are not the "usual" ones consisting of -- functors, but consist instead of equivalence classes of functors up -- to natural isomorphism. This is because homsets here are really -- hom-setoids and we pick natural isomorphism as the equivalence -- relation for these setoids. -- -- See https://ncatlab.org/nlab/show/Ho%28Cat%29 open import Level open import Categories.Category open import Categories.Category.Groupoid open import Categories.Functor as Fctr using (Functor; _∘F_) open import Categories.Functor.Properties using ([_]-resp-Iso) import Categories.Morphism.IsoEquiv as IsoEquiv open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; associator; unitorˡ; unitorʳ; unitor²; isEquivalence; _ⓘₕ_; sym) private variable o ℓ e : Level open Groupoid using (category) -- The category of groupoids. Groupoids : ∀ o ℓ e → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e) Groupoids o ℓ e = record { Obj = Groupoid o ℓ e ; _⇒_ = λ G H → Functor (category G) (category H) ; _≈_ = NaturalIsomorphism ; id = Fctr.id ; _∘_ = _∘F_ ; assoc = λ {_ _ _ _ F G H} → associator F G H ; sym-assoc = λ {_ _ _ _ F G H} → sym (associator F G H) ; identityˡ = unitorˡ ; identityʳ = unitorʳ ; identity² = unitor² ; equiv = isEquivalence ; ∘-resp-≈ = _ⓘₕ_ } module _ {o ℓ e o′ ℓ′ e′} {G : Groupoid o ℓ e} {H : Groupoid o′ ℓ′ e′} (F : Functor (category G) (category H)) where private module G = Groupoid G module H = Groupoid H open Functor F open IsoEquiv (category H) using (to-unique) -- Functors preserve inverses F-resp-⁻¹ : ∀ {A B} (f : A G.⇒ B) → F₁ (f G.⁻¹) H.≈ (F₁ f) H.⁻¹ F-resp-⁻¹ f = to-unique ([ F ]-resp-Iso G.iso) H.iso H.Equiv.refl
{ "alphanum_fraction": 0.6603491272, "avg_line_length": 32.868852459, "ext": "agda", "hexsha": "407bb6167fc6ee65f0fa471b37b776cd3de025b8", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/Groupoids.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/Groupoids.agda", "max_line_length": 93, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/Groupoids.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 683, "size": 2005 }
{-# OPTIONS --safe #-} module Cubical.Algebra.DistLattice where open import Cubical.Algebra.DistLattice.Base public
{ "alphanum_fraction": 0.7863247863, "avg_line_length": 23.4, "ext": "agda", "hexsha": "a0d6e821a5555e72da6c5df8bc93320528a3fcc0", "lang": "Agda", "max_forks_count": 134, "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_path": "Cubical/Algebra/DistLattice.agda", "max_issues_count": 584, "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_path": "Cubical/Algebra/DistLattice.agda", "max_line_length": 51, "max_stars_count": 301, "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_path": "Cubical/Algebra/DistLattice.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "num_tokens": 29, "size": 117 }
-- Andreas, 2016-04-14 Issue 1821 -- pts rule for SizeUniv not implemented properly open import Common.Size open import Common.Equality record Reveal_·_is_ {A : Set} {B : A → Set} (f : (x : A) → B x) (x : A) (y : B x) : Set where constructor [_] field eq : f x ≡ y inspect : ∀ {A : Set} {B : A → Set} (f : (x : A) → B x) (x : A) → Reveal f · x is f x inspect f x = [ refl ] record Co i : Set where coinductive field force : ∀{j : Size< i} → Co j test : ∀ (n : Co ∞) → Set (test n) with inspect Co.force n (test n) | n' = Co ∞ -- Error WAS: -- SizeUniv != Set -- when checking that the type -- ... -- of the generated with function is well-formed
{ "alphanum_fraction": 0.5499296765, "avg_line_length": 23.7, "ext": "agda", "hexsha": "ee38953f32c97e516b187ec3680cfefc118c3b44", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue1821.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue1821.agda", "max_line_length": 59, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue1821.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 242, "size": 711 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import LogicalFormulae open import Functions.Definition open import Numbers.Naturals.Definition open import Sets.FinSet.Definition open import Setoids.Setoids module Setoids.Cardinality.Infinite.Definition where InfiniteSetoid : {a b : _} {A : Set a} (S : Setoid {a} {b} A) → Set (a ⊔ b) InfiniteSetoid {A = A} S = (n : ℕ) → (f : FinSet n → A) → (SetoidBijection (reflSetoid (FinSet n)) S f) → False record DedekindInfiniteSetoid {a b : _} {A : Set a} (S : Setoid {a} {b} A) : Set (a ⊔ b) where field inj : ℕ → A isInjection : SetoidInjection (reflSetoid ℕ) S inj
{ "alphanum_fraction": 0.6868686869, "avg_line_length": 36.4736842105, "ext": "agda", "hexsha": "8e644d8bb6b74f765d30e69c7a161da2c9096483", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Setoids/Cardinality/Infinite/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Setoids/Cardinality/Infinite/Definition.agda", "max_line_length": 111, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Setoids/Cardinality/Infinite/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 238, "size": 693 }
module Properties.Dec where data ⊥ : Set where data Dec(A : Set) : Set where yes : A → Dec A no : (A → ⊥) → Dec A
{ "alphanum_fraction": 0.5785123967, "avg_line_length": 13.4444444444, "ext": "agda", "hexsha": "d89fd754e58cc9fd62c88106a3d8d3e289b19072", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "FreakingBarbarians/luau", "max_forks_repo_path": "prototyping/Properties/Dec.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5187e64f88953f34785ffe58acd0610ee5041f5f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "FreakingBarbarians/luau", "max_issues_repo_path": "prototyping/Properties/Dec.agda", "max_line_length": 29, "max_stars_count": 1, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/Properties/Dec.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-11T21:30:17.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-11T21:30:17.000Z", "num_tokens": 43, "size": 121 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Magma.Morphism where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Functions.Embedding open import Cubical.Algebra private variable m n : Level IsMagmaHom : (M : Magma m) (N : Magma n) → (⟨ M ⟩ → ⟨ N ⟩) → Type (ℓ-max m n) IsMagmaHom M N fun = Homomorphic₂ fun (Magma._•_ M) (Magma._•_ N) record MagmaHom (M : Magma m) (N : Magma n) : Type (ℓ-max m n) where constructor magmahom field fun : ⟨ M ⟩ → ⟨ N ⟩ isHom : IsMagmaHom M N fun record MagmaEquiv (M : Magma m) (N : Magma n) : Type (ℓ-max m n) where constructor magmaequiv field eq : ⟨ M ⟩ ≃ ⟨ N ⟩ isHom : IsMagmaHom M N (equivFun eq) hom : MagmaHom M N hom = record { isHom = isHom } instance MagmaHomOperators : HomOperators (Magma m) (Magma n) (ℓ-max m n) MagmaHomOperators = record { _⟶ᴴ_ = MagmaHom; _≃ᴴ_ = MagmaEquiv }
{ "alphanum_fraction": 0.6617492097, "avg_line_length": 27.1142857143, "ext": "agda", "hexsha": "a3460beff72780b3d5ed2ef07e327a1d42f8ac66", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Magma/Morphism.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Magma/Morphism.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Magma/Morphism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 351, "size": 949 }
{-# OPTIONS --without-K #-} module Piston where open import Data.Fin using (#_) open import Data.List using (List; map; _∷_; []; concatMap; zip; drop; length; replicate; intercalate) open import Data.Maybe using (Maybe; fromMaybe) open import Data.Nat using (ℕ) open import Data.Product using (_×_; proj₁; proj₂) open import Data.Vec using (Vec; fromList; _∷_; []; toList) open import Function using (_∘_) open import Counterpoint open import Harmony open import Note open import Music open import MidiEvent open import Pitch open import Interval open import Util -- 3/4 time melodyAs : List Note melodyAs = tone dhalf (c 6) ∷ tone qtr (d 6) ∷ tone qtr (c 6) ∷ tone qtr (e 6) ∷ tone half (f 6) ∷ tone qtr (f 6) ∷ tone qtr (g 6) ∷ tone qtr (f 6) ∷ tone qtr (d 6) ∷ tone half (c 6) ∷ tone qtr (a 5) ∷ tone qtr (b♭ 5) ∷ tone half (g 5) ∷ tone dhalf (f 5) ∷ [] -- 4/4 time melodyBs : List Note melodyBs = tone half (c 6) ∷ tone qtr (b 5) ∷ tone qtr (c 6) ∷ tone half (d 6) ∷ tone qtr (e 6) ∷ tone qtr (c 6) ∷ tone half (f 6) ∷ tone half (d 6) ∷ tone half (b 5) ∷ tone qtr (c 6) ∷ tone qtr (d 6) ∷ tone half (b 5) ∷ tone half (b 5) ∷ tone half (c 6) ∷ tone half (c 6) ∷ [] -- 4/4 time melodyCs : List Note melodyCs = tone qtr (g♯ 5) ∷ tone qtr (g♯ 5) ∷ tone qtr (a 5) ∷ tone qtr (f♯ 5) ∷ tone half (g♯ 5) ∷ tone qtr (g♯ 5) ∷ tone qtr (c♯ 6) ∷ tone half (b 5) ∷ tone qtr (g♯ 5) ∷ tone qtr (a 5) ∷ tone half (f♯ 5) ∷ tone half (f♯ 5) ∷ tone qtr (g♯ 5) ∷ tone qtr (g♯ 5) ∷ tone qtr (a 5) ∷ tone qtr (b 5) ∷ tone half (c♯ 6) ∷ tone half (b 5) ∷ tone qtr (b 5) ∷ tone qtr (d♯ 5) ∷ tone qtr (e 5) ∷ tone qtr (f♯ 5) ∷ tone whole (e 5) ∷ [] -- This is example 9-1 in the 5th edition of Piston. -- It was example 117 in a previous edition used in the FHARM paper. -- 4/4 time melody117s : List Note melody117s = rest half ∷ tone half (g 5) ∷ tone half (e 5) ∷ tone half (g 5) ∷ tone half (a 5) ∷ tone half (c 6) ∷ tone half (b 5) ∷ tone half (a 5) ∷ tone whole (g 5) ∷ [] melody117a : List Note melody117a = tone whole (b 4) ∷ tone half (c 5) ∷ tone half (e 5) ∷ tone half (f 5) ∷ tone half (e 5) ∷ tone half (g 5) ∷ tone half (f 5) ∷ tone whole (d 5) ∷ [] melody117t : List Note melody117t = tone dwhole (g 4) ∷ tone half (c 5) ∷ tone whole (c 5) ∷ tone half (e 5) ∷ tone half (c 5) ∷ tone whole (b 4) ∷ [] melody117b : List Note melody117b = tone whole (g 3) ∷ tone whole (c 4) ∷ tone half (f 4) ∷ tone half (a 4) ∷ tone half (e 4) ∷ tone half (f 4) ∷ tone whole (g 4) ∷ [] ---- piano marimba : InstrumentNumber-1 piano = # 0 marimba = # 12 channel1 channel2 : Channel-1 channel1 = # 0 channel2 = # 1 tempo : ℕ tempo = 120 mVelocity cVelocity : Velocity mVelocity = # 60 cVelocity = # 60 melodyAsTrack : MidiTrack melodyAsTrack = track "Melody A S" piano channel1 tempo (notes→events mVelocity melodyAs) melodyATracks : List MidiTrack melodyATracks = melodyAsTrack ∷ [] melodyBsTrack : MidiTrack melodyBsTrack = track "Melody B S" piano channel1 tempo (notes→events mVelocity melodyBs) melodyBTracks : List MidiTrack melodyBTracks = melodyBsTrack ∷ [] melodyCsTrack : MidiTrack melodyCsTrack = track "Melody C S" piano channel1 tempo (notes→events mVelocity melodyCs) melodyCTracks : List MidiTrack melodyCTracks = melodyCsTrack ∷ [] melody117sTrack : MidiTrack melody117sTrack = track "Melody 117 S" piano channel1 tempo (notes→events mVelocity melody117s) melody117aTrack : MidiTrack melody117aTrack = track "Melody 117 A" piano channel1 tempo (notes→events mVelocity melody117a) melody117tTrack : MidiTrack melody117tTrack = track "Melody 117 T" piano channel1 tempo (notes→events mVelocity melody117t) melody117bTrack : MidiTrack melody117bTrack = track "Melody 117 B" piano channel1 tempo (notes→events mVelocity melody117b) melody117Tracks : List MidiTrack melody117Tracks = melody117sTrack ∷ melody117aTrack ∷ melody117tTrack ∷ melody117bTrack ∷ [] ----- -- Harmonization of Piston's example 9-1 (117). pitches117s : Vec Pitch 9 pitches117s = g 5 ∷ g 5 ∷ e 5 ∷ g 5 ∷ a 5 ∷ c 6 ∷ b 5 ∷ a 5 ∷ g 5 ∷ [] vhs117 : List (Vec (Vec Pitch 4) 9) vhs117 = voicedHarmonizations pitches117s best : Maybe (List (Vec Pitch 4)) best = Data.Maybe.map toList (listMin (length ∘ motionErrors) vhs117) vh117 : List (Vec Pitch 4) vh117 = fromMaybe [] best chordsPoints117 : List (Vec Point 4) chordsPoints117 = map (Data.Vec.map tone) vh117 harm117 : Harmony 4 (length vh117) harm117 = harmony (fromList (map chord chordsPoints117)) testHTrack : MidiTrack testHTrack = track "Test Harm" piano channel1 tempo (harmony→events mVelocity harm117) testHTracks : List MidiTrack testHTracks = testHTrack ∷ []
{ "alphanum_fraction": 0.6663137836, "avg_line_length": 28.2814371257, "ext": "agda", "hexsha": "7524d7d476bee46b52f14c7024bb10ebc412a191", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z", "max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "halfaya/MusicTools", "max_forks_repo_path": "doc/icfp20/code/Piston.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z", "max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "halfaya/MusicTools", "max_issues_repo_path": "doc/icfp20/code/Piston.agda", "max_line_length": 105, "max_stars_count": 28, "max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "halfaya/MusicTools", "max_stars_repo_path": "doc/icfp20/code/Piston.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z", "num_tokens": 1873, "size": 4723 }
module A where postulate A : Set
{ "alphanum_fraction": 0.7352941176, "avg_line_length": 8.5, "ext": "agda", "hexsha": "33ccb027b9f510bfe3f85848d865255703d8af35", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/relocatable/originals/A.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/relocatable/originals/A.agda", "max_line_length": 17, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/relocatable/originals/A.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 10, "size": 34 }
module Data.Any where import Lvl open import Type -- A type that can hold a value of any type. record Any {ℓ} : Type{Lvl.𝐒(ℓ)} where constructor intro field {type} : Type{ℓ} value : type map : ∀{T : Type{ℓ}} → (type → T) → Any{ℓ} map f = record{value = f(value)} -- A type that can hold a value of any type in any universe. record UniversalAny : Typeω where constructor intro field {level} : Lvl.Level {type} : Type{level} value : type map : ∀{ℓ}{T : Type{ℓ}} → (type → T) → UniversalAny map f = record{value = f(value)}
{ "alphanum_fraction": 0.6151142355, "avg_line_length": 21.8846153846, "ext": "agda", "hexsha": "8d9b8e3013f8d1b68bf27e7d3e6ef7fa86a54519", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Data/Any.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/Any.agda", "max_line_length": 60, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Data/Any.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 195, "size": 569 }
module List.Permutation.Base.Equivalence (A : Set) where open import List.Permutation.Base A open import Data.List open import Data.Product renaming (_×_ to _∧_) refl∼ : {xs : List A} → xs ∼ xs refl∼ {[]} = ∼[] refl∼ {x ∷ xs} = ∼x /head /head refl∼ sym∼ : {xs ys : List A} → xs ∼ ys → ys ∼ xs sym∼ ∼[] = ∼[] sym∼ (∼x xs/x⟶xs' ys/x⟶ys' xs'∼ys') = ∼x ys/x⟶ys' xs/x⟶xs' (sym∼ xs'∼ys') lemma// : {x y : A}{xs ys zs : List A} → xs / x ⟶ ys → ys / y ⟶ zs → ∃ (λ ws → xs / y ⟶ ws ∧ ws / x ⟶ zs) lemma// (/head {x = x}) (/head {xs = xs}) = x ∷ xs , /tail /head , /head lemma// (/head {x = x}) (/tail {x = u} {ys = us'} us/y⟶us') = x ∷ u ∷ us' , /tail (/tail us/y⟶us') , /head lemma// (/tail {xs = us} us/x⟶us') /head = us , /head , us/x⟶us' lemma// (/tail {x = u} us/x⟶us') (/tail us'/y⟶us'') with lemma// us/x⟶us' us'/y⟶us'' ... | ws' , us/y⟶ws' , ws'/x⟶us'' = u ∷ ws' , /tail us/y⟶ws' , /tail ws'/x⟶us'' lemma∼/∷ : {x : A}{xs ys : List A} → (x ∷ xs) ∼ ys → ∃ (λ ys' → ys / x ⟶ ys' ∧ xs ∼ ys') lemma∼/∷ (∼x {ys' = vs'} /head ys/x⟶vs' xs∼vs') = vs' , ys/x⟶vs' , xs∼vs' lemma∼/∷ (∼x (/tail xs/u⟶us') ys/u⟶vs' x∷us'∼vs') with lemma∼/∷ x∷us'∼vs' ... | _ , vs'/x⟶zs , us'∼zs with lemma// ys/u⟶vs' vs'/x⟶zs ... | ws , ys/x⟶ws , ws/u⟶zs = ws , ys/x⟶ws , ∼x xs/u⟶us' ws/u⟶zs us'∼zs lemma∼/ : {x : A}{xs xs' ys : List A} → xs ∼ ys → xs / x ⟶ xs' → ∃ (λ ys' → ys / x ⟶ ys' ∧ xs' ∼ ys') lemma∼/ u∷us∼ys /head = lemma∼/∷ u∷us∼ys lemma∼/ u∷us∼ys (/tail us/x⟶xs') with lemma∼/∷ u∷us∼ys ... | _ , ys/u⟶ys' , us∼ys' with lemma∼/ us∼ys' us/x⟶xs' ... | _ , ys'/x⟶vs , xs'∼vs with lemma// ys/u⟶ys' ys'/x⟶vs ... | ws , ys/x⟶ws , ws/u⟶vs = ws , ys/x⟶ws , ∼x /head ws/u⟶vs xs'∼vs trans∼ : {xs ys zs : List A} → xs ∼ ys → ys ∼ zs → xs ∼ zs trans∼ ∼[] ∼[] = ∼[] trans∼ ∼[] (∼x .{xs = []} () zs/x⟶zs' ys'∼zs') trans∼ {zs = zs} (∼x {ys = ys} xs/x⟶xs' ys/x⟶ys' xs'∼ys') ys∼zs with lemma∼/ {xs = ys} ys∼zs ys/x⟶ys' ... | _ , zs/x⟶us , ys'∼us = ∼x xs/x⟶xs' zs/x⟶us (trans∼ xs'∼ys' ys'∼us)
{ "alphanum_fraction": 0.4689655172, "avg_line_length": 41.4285714286, "ext": "agda", "hexsha": "e0ccccb2b88f2a4e1b80e1aae48de4852ee0bbfd", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/List/Permutation/Base/Equivalence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/List/Permutation/Base/Equivalence.agda", "max_line_length": 106, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/List/Permutation/Base/Equivalence.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 1057, "size": 2030 }
{- This file contains: - the abelianization of groups as a HIT as proposed in https://arxiv.org/abs/2007.05833 The definition of the abelianization is not as a set-quotient, since the relation of abelianization is cumbersome to work with. -} {-# OPTIONS --safe #-} module Cubical.Algebra.Group.Abelianization.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties using (isPropIsGroupHom; compGroupHom; idGroupHom) open import Cubical.Algebra.AbGroup.Base open import Cubical.Algebra.Group.Abelianization.Base private variable ℓ : Level module _ (G : Group ℓ) where open GroupStr {{...}} open GroupTheory G private instance _ = snd G -- Some helpful lemmas, similar to those in Cubical/HITs/SetQuotients/Properties.agda elimProp : {B : Abelianization G → Type ℓ} → (Bprop : (x : Abelianization G) → isProp (B x)) → (f : (g : fst G) → B (η g)) → (x : Abelianization G) → B x elimProp Bprop f (η g) = f g elimProp {B = B} Bprop f (comm a b c i) = isProp→PathP (λ i → Bprop (comm a b c i)) (f (a · (b · c))) (f (a · (c · b))) i elimProp Bprop f (isset x y p q i j) = isOfHLevel→isOfHLevelDep 2 (λ x → isProp→isSet (Bprop x)) (g x) (g y) (cong g p) (cong g q) (isset x y p q) i j where g = elimProp Bprop f elimProp2 : {C : Abelianization G → Abelianization G → Type ℓ} → (Cprop : (x y : Abelianization G) → isProp (C x y)) → (f : (a b : fst G) → C (η a) (η b)) → (x y : Abelianization G) → C x y elimProp2 Cprop f = elimProp (λ x → isPropΠ (λ y → Cprop x y)) (λ x → elimProp (λ y → Cprop (η x) y) (f x)) elimProp3 : {D : Abelianization G → Abelianization G → Abelianization G → Type ℓ} → (Dprop : (x y z : Abelianization G) → isProp (D x y z)) → ((a b c : fst G) → D (η a) (η b) (η c)) → (x y z : Abelianization G) → D x y z elimProp3 Dprop f = elimProp (λ x → isPropΠ2 (λ y z → Dprop x y z)) (λ x → elimProp2 (λ y z → Dprop (η x) y z) (f x)) elimContr : {B : Abelianization G → Type ℓ} → (Bcontr : ∀ (a : fst G) → isContr (B (η a))) → (x : Abelianization G) → B x elimContr Bcontr = elimProp (elimProp (λ _ → isPropIsProp) λ _ → isContr→isProp (Bcontr _)) λ _ → Bcontr _ .fst elimContr2 : {C : Abelianization G → Abelianization G → Type ℓ} → (Ccontr : ∀ (a b : fst G) → isContr (C (η a) (η b))) → (x y : Abelianization G) → C x y elimContr2 Ccontr = elimContr λ _ → isOfHLevelΠ 0 (elimContr λ _ → inhProp→isContr (Ccontr _ _) isPropIsContr) rec : {M : Type ℓ} (Mset : isSet M) (f : fst G → M) (fcomm : (a b c : fst G) → f (a · (b · c)) ≡ f (a · (c · b))) → Abelianization G → M rec Mset f fcomm (η g) = f g rec Mset f fcomm (comm a b c i) = fcomm a b c i rec Mset f fcomm (isset a b p q i j) = Mset (g a) (g b) (cong g p) (cong g q) i j where g = rec Mset f fcomm rec2 : {M : Type ℓ} (Mset : isSet M) (f : fst G → fst G → M) (fcomml : (a b c d : fst G) → f (a · (b · c)) d ≡ f (a · (c · b)) d) (fcommr : (a b c d : fst G) → f a (b · (c · d)) ≡ f a (b · (d · c))) → Abelianization G → Abelianization G → M rec2 Mset f fcomml fcommr = rec (isSetΠ (λ _ → Mset)) (λ g → rec Mset (λ h → f g h) (fcommr g)) (λ a b c → funExt (elimProp (λ _ → Mset _ _) (λ d → fcomml a b c d))) module AbelianizationGroupStructure (G : Group ℓ) where open GroupStr {{...}} open GroupTheory G private instance _ = snd G {- Definition of the group structure on the abelianization. Here the generality of the comm relation is used. -} _·Ab_ : Abelianization G → Abelianization G → Abelianization G _·Ab_ = (rec2 G) isset (λ x y → η (x · y)) (λ a b c d → η ((a · (b · c)) · d) ≡⟨ cong η (cong (λ x → (x · d)) (assoc _ _ _)) ⟩ η (((a · b) · c) · d) ≡⟨ cong η (sym (assoc (a · b) c d)) ⟩ η ((a · b) · (c · d)) ≡⟨ comm (a · b) c d ⟩ η ((a · b) · (d · c)) ≡⟨ cong η (sym (assoc _ _ _)) ⟩ η (a · (b · (d · c))) ≡⟨ cong η (cong (λ x → (a · x)) (assoc _ _ _)) ⟩ η (a · ((b · d) · c)) ≡⟨ comm a (b · d) c ⟩ η (a · (c · (b · d))) ≡⟨ cong η (cong (λ x → (a · x)) (assoc _ _ _)) ⟩ η (a · ((c · b) · d)) ≡⟨ cong η (assoc a (c · b) d) ⟩ η ((a · (c · b)) · d) ∎) (λ a b c d → η (a · (b · (c · d))) ≡⟨ cong η (assoc _ _ _) ⟩ η ((a · b) · (c · d)) ≡⟨ comm (a · b) c d ⟩ η ((a · b) · (d · c)) ≡⟨ cong η (sym (assoc _ _ _)) ⟩ η (a · (b · (d · c))) ∎) 1Ab : Abelianization G 1Ab = η 1g invAb : Abelianization G → Abelianization G invAb = (rec G) isset ((λ x → η (inv x))) (λ a b c → η (inv (a · (b · c))) ≡⟨ cong η (invDistr a (b · c)) ⟩ η ((inv (b · c)) · (inv a)) ≡⟨ cong (λ x → η (x · (inv a))) (invDistr b c) ⟩ η (((inv c) · (inv b)) · (inv a)) ≡⟨ cong η ((sym (lid (((inv c) · (inv b)) · (inv a))))) ⟩ η (1g · (((inv c) · (inv b)) · (inv a))) ≡⟨ comm 1g ((inv c) · (inv b)) (inv a) ⟩ η (1g · ((inv a) · ((inv c) · (inv b)))) ≡⟨ cong η (lid ((inv a) · ((inv c) · (inv b)))) ⟩ η ((inv a) · ((inv c) · (inv b))) ≡⟨ comm (inv a) (inv c) (inv b) ⟩ η ((inv a) · ((inv b) · (inv c))) ≡⟨ cong η ((sym (lid ((inv a) · ((inv b) · (inv c)))))) ⟩ η (1g · ((inv a) · ((inv b) · (inv c)))) ≡⟨ comm 1g (inv a) ((inv b) · (inv c)) ⟩ η (1g · (((inv b) · (inv c)) · (inv a))) ≡⟨ cong η (lid (((inv b) · (inv c)) · (inv a))) ⟩ η (((inv b) · (inv c)) · (inv a)) ≡⟨ cong (λ x → η (x · (inv a))) (sym (invDistr c b)) ⟩ η ((inv (c · b)) · (inv a)) ≡⟨ cong η (sym (invDistr a (c · b))) ⟩ η (inv (a · (c · b))) ∎) assocAb : (x y z : Abelianization G) → x ·Ab (y ·Ab z) ≡ (x ·Ab y) ·Ab z assocAb = (elimProp3 G) (λ x y z → isset (x ·Ab (y ·Ab z)) ((x ·Ab y) ·Ab z)) (λ x y z → cong η (assoc x y z)) ridAb : (x : Abelianization G) → x ·Ab 1Ab ≡ x ridAb = (elimProp G) (λ x → isset (x ·Ab 1Ab) x) (λ x → cong η (rid x)) rinvAb : (x : Abelianization G) → x ·Ab (invAb x) ≡ 1Ab rinvAb = (elimProp G) (λ x → isset (x ·Ab (invAb x)) 1Ab) (λ x → (η x) ·Ab (invAb (η x)) ≡⟨ refl ⟩ (η x) ·Ab (η (inv x)) ≡⟨ refl ⟩ η (x · (inv x)) ≡⟨ cong η (fst (inverse x)) ⟩ η 1g ≡⟨ refl ⟩ 1Ab ∎) commAb : (x y : Abelianization G) → x ·Ab y ≡ y ·Ab x commAb = (elimProp2 G) (λ x y → isset (x ·Ab y) (y ·Ab x)) (λ x y → (η x) ·Ab (η y) ≡⟨ refl ⟩ η (x · y) ≡⟨ cong η (sym (lid (x · y))) ⟩ η (1g · (x · y)) ≡⟨ comm 1g x y ⟩ η (1g · (y · x)) ≡⟨ cong η (lid (y · x)) ⟩ η (y · x) ≡⟨ refl ⟩ (η y) ·Ab (η x) ∎) -- The proof that the abelianization is in fact an abelian group. asAbelianGroup : AbGroup ℓ asAbelianGroup = makeAbGroup 1Ab _·Ab_ invAb isset assocAb ridAb rinvAb commAb -- The proof that η can be seen as a group homomorphism ηAsGroupHom : GroupHom G (AbGroup→Group asAbelianGroup) ηAsGroupHom = f , fIsHom where f = λ x → η x fIsHom : IsGroupHom (snd G) f (snd (AbGroup→Group asAbelianGroup)) IsGroupHom.pres· fIsHom = λ x y → refl IsGroupHom.pres1 fIsHom = refl IsGroupHom.presinv fIsHom = λ x → refl AbelianizationAbGroup : (G : Group ℓ) → AbGroup ℓ AbelianizationAbGroup G = AbelianizationGroupStructure.asAbelianGroup G AbelianizationHom : (G : Group ℓ) → GroupHom G (AbGroup→Group (AbelianizationAbGroup G)) AbelianizationHom G = AbelianizationGroupStructure.ηAsGroupHom G module UniversalProperty (G : Group ℓ) where open GroupStr {{...}} open GroupTheory G open AbelianizationGroupStructure G private instance _ = snd G abstract {- The proof of the universal property of the abelianization. G --η--> abelianization \ . \ . f ∃! inducedHom \ . \ . H commuting diagram -} inducedHom : (H : AbGroup ℓ) → (f : GroupHom G (AbGroup→Group H)) → AbGroupHom asAbelianGroup H inducedHom H f = g , gIsHom where open IsGroupHom instance _ : GroupStr (fst H) _ = snd (AbGroup→Group H) f' : fst G → fst H f' = fst f g : Abelianization G → fst H g = (rec G) (isSetAbGroup H) (λ x → (f') x) (λ a b c → f' (a · b · c) ≡⟨ (snd f).pres· a (b · c) ⟩ (f' a) · (f' (b · c)) ≡⟨ cong (λ x → (f' a) · x) ((snd f).pres· b c) ⟩ (f' a) · (f' b) · (f' c) ≡⟨ cong (λ x → (f' a) · x) ((snd H).AbGroupStr.comm (f' b) (f' c)) ⟩ (f' a) · (f' c) · (f' b) ≡⟨ cong (λ x → (f' a) · x) (sym ((snd f).pres· c b)) ⟩ (f' a) · (f' (c · b)) ≡⟨ sym ((snd f).pres· a (c · b)) ⟩ f' (a · c · b) ∎) gIsHom : IsGroupHom (snd (AbGroup→Group asAbelianGroup)) g (snd (AbGroup→Group H)) pres· gIsHom = (elimProp2 G) (λ x y → isSetAbGroup H _ _) ((snd f).pres·) pres1 gIsHom = (snd f).pres1 presinv gIsHom = (elimProp G) (λ x → isSetAbGroup H _ _) ((snd f).presinv) commutativity : (H : AbGroup ℓ) → (f : GroupHom G (AbGroup→Group H)) → (compGroupHom ηAsGroupHom (inducedHom H f) ≡ f) commutativity H f = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (λ i x → q x i) where q : (x : fst G) → fst (compGroupHom ηAsGroupHom (inducedHom H f)) x ≡ fst f x q = (λ x → refl) uniqueness : (H : AbGroup ℓ) → (f : GroupHom G (AbGroup→Group H)) → (g : AbGroupHom asAbelianGroup H) → (p : compGroupHom ηAsGroupHom g ≡ f) → (g ≡ inducedHom H f) uniqueness H f g p = Σ≡Prop (λ _ → isPropIsGroupHom _ _) (λ i x → q x i) where q : (x : Abelianization G) → fst g x ≡ fst (inducedHom H f) x q = (elimProp G) (λ _ → isSetAbGroup H _ _) (λ x → fst g (η x) ≡⟨ cong (λ f → f x) (cong fst p) ⟩ (fst f) x ≡⟨ refl ⟩ fst (inducedHom H f) (η x)∎)
{ "alphanum_fraction": 0.4489156218, "avg_line_length": 39.3466666667, "ext": "agda", "hexsha": "47262c5ee1a6493e6a597c70c8dba1b4c1784472", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1d9b9691d375659fa8ebd9cbf8b63678955b196b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "gmagaf/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/Abelianization/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1d9b9691d375659fa8ebd9cbf8b63678955b196b", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "gmagaf/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/Abelianization/Properties.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "1d9b9691d375659fa8ebd9cbf8b63678955b196b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "gmagaf/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/Abelianization/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4191, "size": 11804 }
{-# OPTIONS --copatterns #-} module IOExampleGraphicsMovingText where -- -- not yet updated for new SizedIO library -- not yet updated to change with IOInterface Record of Commands / Responses -- {- open import SizedIO.General open import SizedIO.IOGraphicsLib -- TODO open import Data.Bool.Base open import Data.Char.Base open import Data.Nat.Base open import Data.List.Base hiding (_++_) open import Data.Integer.Base hiding (_+_;suc) open import Data.String.Base open import Data.Maybe.Base open import Function open import Size width : ℕ width = 125 height : ℕ height = 20 myBox : Point → Graphic myBox p = withColor black (polygon ( point x y ∷ point (x +IntNat width) y ∷ point (x +IntNat width) (y +IntNat height) ∷ point x (y +IntNat height) ∷ [] ) ) where x = proj1Point p y = proj2Point p record State : Set where constructor state field oldpoint : Maybe Point newpoint : Maybe Point open State module _ (w : Window) where -- If there was a mouse movement since the last invokation of refresh -- overwrite old text and place text at new mouse position. refresh : ∀{i} → State → IOGraphics i State refresh s = case newpoint s of λ{ nothing → return s ; (just lastMousePoint) → {- case there was a new mouse movement. -} (whenJust (oldpoint s) λ p → exec1 (drawInWindow w (myBox p)) >> exec1 (drawInWindow w (withColor white (text lastMousePoint ("1st :some Text"))))) >> return (state (just lastMousePoint) nothing) } processEvent : ∀{i} → State → IOGraphics+ i (Maybe State) processEvent s = exec (getWindowEvent w) λ{ {- key event: check whether this was equal to 'x'; if yes, terminate, otherwise return to loop -} (Key c t) → if (c ==CharBool 'x') then return nothing else return (just s) {- mouse event: if this was the first ever event, ignore it, but record that the next mouse event is no longer the first one. If it was not the first ever event: set newpoint to the position of the mouse p -} ; (MouseMove p) → return (just record s{ newpoint = just p }) {- otherwise just go back to start -} ; _ → return (just s) } loop : ∀{i} → State → IOGraphics i Unit force (loop s) = processEvent s >>=+' -- maybe′ loop (return _) λ{ nothing → return _ ; (just s') → refresh s' >>= loop } myProgram : ∀{i} → IOGraphics i Unit force myProgram = exec (openWindowEx "Hello World" nothing (just (natSize 1000 1000)) nativeDrawGraphic nothing) λ window → loop window (state nothing nothing) main : NativeIO Unit main = nativeRunGraphics (translateIOGraphics myProgram) -}
{ "alphanum_fraction": 0.6113387978, "avg_line_length": 30.8210526316, "ext": "agda", "hexsha": "8de5eda7568e9ff0db639d88f277cf4f2e6b73c3", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/DrawingProgram/IOExampleGraphicsMovingText.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/DrawingProgram/IOExampleGraphicsMovingText.agda", "max_line_length": 109, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/DrawingProgram/IOExampleGraphicsMovingText.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 743, "size": 2928 }
open import Data.Empty open import Data.List renaming (_∷_ to _∷ₗ_ ; [_] to [_]ₗ) open import Data.Maybe open import Data.Product open import Data.Sum open import Data.Unit open import AEff open import AwaitingComputations open import EffectAnnotations open import Preservation open import ProcessPreservation open import Progress open import Renamings open import Substitutions open import Types open import Relation.Binary.PropositionalEquality hiding ([_]) open import Relation.Nullary open import Relation.Nullary.Negation module ProcessProgress where -- PROCESS RESULTS data ParResult⟨_⟩ : {o : O} {PP : PType o} → [] ⊢P⦂ PP → Set where run : {X : VType} {o : O} {i : I} → {M : [] ⊢M⦂ X ! (o , i)} → RunResult⟨ [] ∣ M ⟩ → -------------------------- ParResult⟨ run M ⟩ par : {o o' : O} {PP : PType o} {QQ : PType o'} {P : [] ⊢P⦂ PP} {Q : [] ⊢P⦂ QQ} → ParResult⟨ P ⟩ → ParResult⟨ Q ⟩ → ------------------ ParResult⟨ P ∥ Q ⟩ data ProcResult⟨_⟩ : {o : O} {PP : PType o} → [] ⊢P⦂ PP → Set where proc : {o : O} {PP : PType o} {P : [] ⊢P⦂ PP} → ParResult⟨ P ⟩ → ----------------- ProcResult⟨ P ⟩ signal : {o : O} {PP : PType o} {op : Σₛ} {p : op ∈ₒ o} {V : [] ⊢V⦂ ``(payload op)} {P : [] ⊢P⦂ PP} → ProcResult⟨ P ⟩ → --------------------------- ProcResult⟨ ↑ op p V P ⟩ -- PROGRESS THEOREM FOR PROCESSES {- THEOREM 4.3 -} proc-progress : {o : O} {PP : PType o} → (P : [] ⊢P⦂ PP) → ------------------------------------------------------------------------------- (Σ[ o' ∈ O ] Σ[ QQ ∈ PType o' ] Σ[ r ∈ PP ⇝ QQ ] Σ[ Q ∈ [] ⊢P⦂ QQ ] (P [ r ]↝ Q) ⊎ ProcResult⟨ P ⟩) proc-progress (run {X} {o} {i} M) with progress M ... | inj₁ (M' , r) = inj₁ (_ , _ , _ , _ , run r) ... | inj₂ (comp R) = inj₂ (proc (run R)) ... | inj₂ (signal {_} {_} {_} {_} {p} {V} {Q} R) = inj₁ (_ , _ , _ , _ , ↑ p V Q) proc-progress (P ∥ Q) with proc-progress P ... | inj₁ (o' , PP' , r , P' , r') = inj₁ (_ , _ , _ , _ , context ([-] ∥ₗ Q) r') ... | inj₂ R with proc-progress Q ... | inj₁ (o' , QQ' , r , Q' , r') = inj₁ (_ , _ , _ , _ , context (P ∥ᵣ [-]) r') proc-progress (P ∥ Q) | inj₂ (proc R) | inj₂ (proc R') = inj₂ (proc (par R R')) proc-progress (P ∥ .(↑ _ _ _ _)) | inj₂ R | inj₂ (signal {_} {_} {_} {p} {V} {Q} R') = inj₁ (_ , _ , _ , _ , ↑-∥ᵣ p V P Q) proc-progress (.(↑ _ _ _ _) ∥ Q) | inj₂ (signal {_} {_} {_} {p} {V} {P} R) | inj₂ R' = inj₁ (_ , _ , _ , _ , ↑-∥ₗ p V P Q) proc-progress (↑ op p V P) with proc-progress P ... | inj₁ (o' , PP' , r , P' , r') = inj₁ (_ , _ , _ , _ , context (↑ op p V [-]) r') ... | inj₂ R = inj₂ (signal R) proc-progress (↓ op V P) with proc-progress P ... | inj₁ (o' , OO' , r , P' , r') = inj₁ (_ , _ , _ , _ , context (↓ op V [-]) r') ... | inj₂ (proc (run {_} {_} {_} {M} R)) = inj₁ (_ , _ , _ , _ , ↓-run V M) ... | inj₂ (proc (par {_} {_} {_} {_} {Q} {Q'} R R')) = inj₁ (_ , _ , _ , _ , ↓-∥ V Q Q') ... | inj₂ (signal {_} {_} {_} {p} {W} {Q} R) = inj₁ (_ , _ , _ , _ , ↓-↑ p V W Q)
{ "alphanum_fraction": 0.4304023845, "avg_line_length": 30.2252252252, "ext": "agda", "hexsha": "50a498bd6b2c040c503cfee4bf5f4a5561799bc5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danelahman/aeff-agda", "max_forks_repo_path": "ProcessProgress.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danelahman/aeff-agda", "max_issues_repo_path": "ProcessProgress.agda", "max_line_length": 96, "max_stars_count": 4, "max_stars_repo_head_hexsha": "71ebed9f90a3eb37ae6cd209457bae23a4d122d1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danelahman/aeff-agda", "max_stars_repo_path": "ProcessProgress.agda", "max_stars_repo_stars_event_max_datetime": "2021-03-22T22:48:48.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-17T00:15:00.000Z", "num_tokens": 1231, "size": 3355 }
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRingSolver.Solver where open import Cubical.Foundations.Prelude open import Cubical.Data.FinData open import Cubical.Data.Nat using (ℕ) open import Cubical.Data.Nat.Order using (zero-≤) open import Cubical.Data.Vec.Base open import Cubical.Algebra.CommRing open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRingSolver.RawAlgebra renaming (⟨_⟩ to ⟨_⟩ᵣ) open import Cubical.Algebra.CommRingSolver.AlgebraExpression open import Cubical.Algebra.CommRingSolver.IntAsRawRing open import Cubical.Algebra.CommRingSolver.HornerForms open import Cubical.Algebra.CommRingSolver.EvalHom open import Cubical.Algebra.CommRingSolver.HornerEval private variable ℓ : Level module EqualityToNormalform (R : CommRing ℓ) where νR = CommRing→RawℤAlgebra R open CommRingStr (snd R) open RingTheory (CommRing→Ring R) open Eval ℤAsRawRing νR open IteratedHornerOperations νR open HomomorphismProperties R ℤExpr : (n : ℕ) → Type _ ℤExpr = Expr ℤAsRawRing (fst R) normalize : {n : ℕ} → ℤExpr n → IteratedHornerForms νR n normalize {n = n} (K r) = Constant n νR r normalize {n = n} (∣ k) = Variable n νR k normalize (x +' y) = (normalize x) +ₕ (normalize y) normalize (x ·' y) = (normalize x) ·ₕ (normalize y) normalize (-' x) = -ₕ (normalize x) isEqualToNormalform : {n : ℕ} (e : ℤExpr n) (xs : Vec (fst R) n) → eval (normalize e) xs ≡ ⟦ e ⟧ xs isEqualToNormalform (K r) [] = refl isEqualToNormalform {n = ℕ.suc n} (K r) (x ∷ xs) = eval (Constant (ℕ.suc n) νR r) (x ∷ xs) ≡⟨ refl ⟩ eval (0ₕ ·X+ Constant n νR r) (x ∷ xs) ≡⟨ combineCasesEval R 0ₕ (Constant n νR r) x xs ⟩ eval 0ₕ (x ∷ xs) · x + eval (Constant n νR r) xs ≡⟨ cong (λ u → u · x + eval (Constant n νR r) xs) (Eval0H (x ∷ xs)) ⟩ 0r · x + eval (Constant n νR r) xs ≡⟨ cong (λ u → u + eval (Constant n νR r) xs) (0LeftAnnihilates _) ⟩ 0r + eval (Constant n νR r) xs ≡⟨ +IdL _ ⟩ eval (Constant n νR r) xs ≡⟨ isEqualToNormalform (K r) xs ⟩ _ ∎ isEqualToNormalform (∣ zero) (x ∷ xs) = eval (1ₕ ·X+ 0ₕ) (x ∷ xs) ≡⟨ combineCasesEval R 1ₕ 0ₕ x xs ⟩ eval 1ₕ (x ∷ xs) · x + eval 0ₕ xs ≡⟨ cong (λ u → u · x + eval 0ₕ xs) (Eval1ₕ (x ∷ xs)) ⟩ 1r · x + eval 0ₕ xs ≡⟨ cong (λ u → 1r · x + u ) (Eval0H xs) ⟩ 1r · x + 0r ≡⟨ +IdR _ ⟩ 1r · x ≡⟨ ·IdL _ ⟩ x ∎ isEqualToNormalform {n = ℕ.suc n} (∣ (suc k)) (x ∷ xs) = eval (0ₕ ·X+ Variable n νR k) (x ∷ xs) ≡⟨ combineCasesEval R 0ₕ (Variable n νR k) x xs ⟩ eval 0ₕ (x ∷ xs) · x + eval (Variable n νR k) xs ≡⟨ cong (λ u → u · x + eval (Variable n νR k) xs) (Eval0H (x ∷ xs)) ⟩ 0r · x + eval (Variable n νR k) xs ≡⟨ cong (λ u → u + eval (Variable n νR k) xs) (0LeftAnnihilates _) ⟩ 0r + eval (Variable n νR k) xs ≡⟨ +IdL _ ⟩ eval (Variable n νR k) xs ≡⟨ isEqualToNormalform (∣ k) xs ⟩ ⟦ ∣ (suc k) ⟧ (x ∷ xs) ∎ isEqualToNormalform (-' e) [] = eval (-ₕ (normalize e)) [] ≡⟨ -EvalDist (normalize e) [] ⟩ - eval (normalize e) [] ≡⟨ cong -_ (isEqualToNormalform e [] ) ⟩ - ⟦ e ⟧ [] ∎ isEqualToNormalform (-' e) (x ∷ xs) = eval (-ₕ (normalize e)) (x ∷ xs) ≡⟨ -EvalDist (normalize e) (x ∷ xs) ⟩ - eval (normalize e) (x ∷ xs) ≡⟨ cong -_ (isEqualToNormalform e (x ∷ xs) ) ⟩ - ⟦ e ⟧ (x ∷ xs) ∎ isEqualToNormalform (e +' e₁) [] = eval (normalize e +ₕ normalize e₁) [] ≡⟨ +Homeval (normalize e) _ [] ⟩ eval (normalize e) [] + eval (normalize e₁) [] ≡⟨ cong (λ u → u + eval (normalize e₁) []) (isEqualToNormalform e []) ⟩ ⟦ e ⟧ [] + eval (normalize e₁) [] ≡⟨ cong (λ u → ⟦ e ⟧ [] + u) (isEqualToNormalform e₁ []) ⟩ ⟦ e ⟧ [] + ⟦ e₁ ⟧ [] ∎ isEqualToNormalform (e +' e₁) (x ∷ xs) = eval (normalize e +ₕ normalize e₁) (x ∷ xs) ≡⟨ +Homeval (normalize e) _ (x ∷ xs) ⟩ eval (normalize e) (x ∷ xs) + eval (normalize e₁) (x ∷ xs) ≡⟨ cong (λ u → u + eval (normalize e₁) (x ∷ xs)) (isEqualToNormalform e (x ∷ xs)) ⟩ ⟦ e ⟧ (x ∷ xs) + eval (normalize e₁) (x ∷ xs) ≡⟨ cong (λ u → ⟦ e ⟧ (x ∷ xs) + u) (isEqualToNormalform e₁ (x ∷ xs)) ⟩ ⟦ e ⟧ (x ∷ xs) + ⟦ e₁ ⟧ (x ∷ xs) ∎ isEqualToNormalform (e ·' e₁) [] = eval (normalize e ·ₕ normalize e₁) [] ≡⟨ ·Homeval (normalize e) _ [] ⟩ eval (normalize e) [] · eval (normalize e₁) [] ≡⟨ cong (λ u → u · eval (normalize e₁) []) (isEqualToNormalform e []) ⟩ ⟦ e ⟧ [] · eval (normalize e₁) [] ≡⟨ cong (λ u → ⟦ e ⟧ [] · u) (isEqualToNormalform e₁ []) ⟩ ⟦ e ⟧ [] · ⟦ e₁ ⟧ [] ∎ isEqualToNormalform (e ·' e₁) (x ∷ xs) = eval (normalize e ·ₕ normalize e₁) (x ∷ xs) ≡⟨ ·Homeval (normalize e) _ (x ∷ xs) ⟩ eval (normalize e) (x ∷ xs) · eval (normalize e₁) (x ∷ xs) ≡⟨ cong (λ u → u · eval (normalize e₁) (x ∷ xs)) (isEqualToNormalform e (x ∷ xs)) ⟩ ⟦ e ⟧ (x ∷ xs) · eval (normalize e₁) (x ∷ xs) ≡⟨ cong (λ u → ⟦ e ⟧ (x ∷ xs) · u) (isEqualToNormalform e₁ (x ∷ xs)) ⟩ ⟦ e ⟧ (x ∷ xs) · ⟦ e₁ ⟧ (x ∷ xs) ∎ solve : {n : ℕ} (e₁ e₂ : ℤExpr n) (xs : Vec (fst R) n) (p : eval (normalize e₁) xs ≡ eval (normalize e₂) xs) → ⟦ e₁ ⟧ xs ≡ ⟦ e₂ ⟧ xs solve e₁ e₂ xs p = ⟦ e₁ ⟧ xs ≡⟨ sym (isEqualToNormalform e₁ xs) ⟩ eval (normalize e₁) xs ≡⟨ p ⟩ eval (normalize e₂) xs ≡⟨ isEqualToNormalform e₂ xs ⟩ ⟦ e₂ ⟧ xs ∎ ℤExpr : (R : CommRing ℓ) (n : ℕ) → _ ℤExpr R n = EqualityToNormalform.ℤExpr R n solve : (R : CommRing ℓ) {n : ℕ} (e₁ e₂ : ℤExpr R n) (xs : Vec (fst R) n) (p : eval (EqualityToNormalform.normalize R e₁) xs ≡ eval (EqualityToNormalform.normalize R e₂) xs) → _ solve R = EqualityToNormalform.solve R
{ "alphanum_fraction": 0.5062952471, "avg_line_length": 43.5205479452, "ext": "agda", "hexsha": "8f7d7d5f43494f1ce09b757822143b70de568e96", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thomas-lamiaux/cubical", "max_forks_repo_path": "Cubical/Algebra/CommRingSolver/Solver.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "thomas-lamiaux/cubical", "max_issues_repo_path": "Cubical/Algebra/CommRingSolver/Solver.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/Algebra/CommRingSolver/Solver.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2382, "size": 6354 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Diagram.Pullback {o ℓ e} (C : Category o ℓ e) where open Category C open HomReasoning open import Level open import Data.Product using (_,_; ∃) open import Function using (flip; _$_) renaming (_∘_ to _●_) open import Categories.Morphism C open import Categories.Object.Product C open import Categories.Diagram.Equalizer C open import Categories.Morphism.Reasoning C as Square renaming (glue to glue-square) hiding (id-unique) private variable A B X Y Z : Obj f g h h₁ h₂ i i₁ i₂ j : A ⇒ B -- Pullback of two arrows with a common codomain record Pullback (f : X ⇒ Z) (g : Y ⇒ Z) : Set (o ⊔ ℓ ⊔ e) where field {P} : Obj p₁ : P ⇒ X p₂ : P ⇒ Y field commute : f ∘ p₁ ≈ g ∘ p₂ universal : ∀ {h₁ : A ⇒ X} {h₂ : A ⇒ Y} → f ∘ h₁ ≈ g ∘ h₂ → A ⇒ P unique : ∀ {eq : f ∘ h₁ ≈ g ∘ h₂} → p₁ ∘ i ≈ h₁ → p₂ ∘ i ≈ h₂ → i ≈ universal eq p₁∘universal≈h₁ : ∀ {eq : f ∘ h₁ ≈ g ∘ h₂} → p₁ ∘ universal eq ≈ h₁ p₂∘universal≈h₂ : ∀ {eq : f ∘ h₁ ≈ g ∘ h₂} → p₂ ∘ universal eq ≈ h₂ unique′ : (eq eq′ : f ∘ h₁ ≈ g ∘ h₂) → universal eq ≈ universal eq′ unique′ eq eq′ = unique p₁∘universal≈h₁ p₂∘universal≈h₂ id-unique : id ≈ universal commute id-unique = unique identityʳ identityʳ unique-diagram : p₁ ∘ h ≈ p₁ ∘ i → p₂ ∘ h ≈ p₂ ∘ i → h ≈ i unique-diagram {h = h} {i = i} eq₁ eq₂ = begin h ≈⟨ unique eq₁ eq₂ ⟩ universal eq ≈˘⟨ unique refl refl ⟩ i ∎ where eq = extendʳ commute swap : Pullback f g → Pullback g f swap p = record { p₁ = p₂ ; p₂ = p₁ ; commute = ⟺ commute ; universal = universal ● ⟺ ; unique = flip unique ; p₁∘universal≈h₁ = p₂∘universal≈h₂ ; p₂∘universal≈h₂ = p₁∘universal≈h₁ } where open Pullback p glue : (p : Pullback f g) → Pullback h (Pullback.p₁ p) → Pullback (f ∘ h) g glue {h = h} p q = record { p₁ = q.p₁ ; p₂ = p.p₂ ∘ q.p₂ ; commute = glue-square p.commute q.commute ; universal = λ eq → q.universal (⟺ (p.p₁∘universal≈h₁ {eq = ⟺ assoc ○ eq})) ; unique = λ {_ h₁ h₂ i} eq eq′ → q.unique eq (p.unique (begin p.p₁ ∘ q.p₂ ∘ i ≈˘⟨ extendʳ q.commute ⟩ h ∘ q.p₁ ∘ i ≈⟨ refl⟩∘⟨ eq ⟩ h ∘ h₁ ∎) (⟺ assoc ○ eq′)) ; p₁∘universal≈h₁ = q.p₁∘universal≈h₁ ; p₂∘universal≈h₂ = assoc ○ ∘-resp-≈ʳ q.p₂∘universal≈h₂ ○ p.p₂∘universal≈h₂ } where module p = Pullback p module q = Pullback q unglue : (p : Pullback f g) → Pullback (f ∘ h) g → Pullback h (Pullback.p₁ p) unglue {f = f} {g = g} {h = h} p q = record { p₁ = q.p₁ ; p₂ = p₂′ ; commute = ⟺ p.p₁∘universal≈h₁ ; universal = λ {_ h₁ h₂} eq → q.universal $ begin (f ∘ h) ∘ h₁ ≈⟨ pullʳ eq ⟩ f ∘ p.p₁ ∘ h₂ ≈⟨ extendʳ p.commute ⟩ g ∘ p.p₂ ∘ h₂ ∎ ; unique = λ {_ h₁ h₂ i} eq eq′ → q.unique eq $ begin q.p₂ ∘ i ≈⟨ pushˡ (⟺ p.p₂∘universal≈h₂) ⟩ p.p₂ ∘ p₂′ ∘ i ≈⟨ refl⟩∘⟨ eq′ ⟩ p.p₂ ∘ h₂ ∎ ; p₁∘universal≈h₁ = q.p₁∘universal≈h₁ ; p₂∘universal≈h₂ = λ {_ _ _ eq} → p.unique-diagram ((pullˡ p.p₁∘universal≈h₁) ○ pullʳ q.p₁∘universal≈h₁ ○ eq) (pullˡ p.p₂∘universal≈h₂ ○ q.p₂∘universal≈h₂) } where module p = Pullback p module q = Pullback q p₂′ = p.universal (⟺ assoc ○ q.commute) -- used twice above Product×Equalizer⇒Pullback : (p : Product A B) → Equalizer (f ∘ Product.π₁ p) (g ∘ Product.π₂ p) → Pullback f g Product×Equalizer⇒Pullback {f = f} {g = g} p e = record { p₁ = π₁ ∘ arr ; p₂ = π₂ ∘ arr ; commute = ⟺ assoc ○ equality ○ assoc ; universal = λ {_ h₁ h₂} eq → equalize $ begin (f ∘ π₁) ∘ ⟨ h₁ , h₂ ⟩ ≈⟨ pullʳ project₁ ⟩ f ∘ h₁ ≈⟨ eq ⟩ g ∘ h₂ ≈˘⟨ pullʳ project₂ ⟩ (g ∘ π₂) ∘ ⟨ h₁ , h₂ ⟩ ∎ ; unique = λ eq eq′ → e.unique (p.unique (⟺ assoc ○ eq) (⟺ assoc ○ eq′)) ; p₁∘universal≈h₁ = pullʳ (⟺ e.universal) ○ project₁ ; p₂∘universal≈h₂ = pullʳ (⟺ e.universal) ○ project₂ } where module p = Product p module e = Equalizer e open p open e Product×Pullback⇒Equalizer : (p : Product A B) → Pullback f g → Equalizer (f ∘ Product.π₁ p) (g ∘ Product.π₂ p) Product×Pullback⇒Equalizer {f = f} {g = g} p pu = record { arr = ⟨ p₁ , p₂ ⟩ ; equality = begin (f ∘ π₁) ∘ ⟨ p₁ , p₂ ⟩ ≈⟨ pullʳ project₁ ⟩ f ∘ p₁ ≈⟨ commute ⟩ g ∘ p₂ ≈˘⟨ pullʳ project₂ ⟩ (g ∘ π₂) ∘ ⟨ p₁ , p₂ ⟩ ∎ ; equalize = λ eq → pu.universal (⟺ assoc ○ eq ○ assoc) ; universal = λ {_ h} → begin h ≈˘⟨ p.unique (⟺ p₁∘universal≈h₁) (⟺ p₂∘universal≈h₂) ⟩ ⟨ p₁ ∘ _ , p₂ ∘ _ ⟩ ≈⟨ p.unique (pullˡ project₁) (pullˡ project₂) ⟩ ⟨ p₁ , p₂ ⟩ ∘ _ ∎ ; unique = λ eq → pu.unique (pushˡ (⟺ project₁) ○ ⟺ (∘-resp-≈ʳ eq)) (pushˡ (⟺ project₂) ○ ⟺ (∘-resp-≈ʳ eq)) } where module p = Product p module pu = Pullback pu open p open pu module _ (p : Pullback f g) where open Pullback p Pullback-resp-≈ : h ≈ f → i ≈ g → Pullback h i Pullback-resp-≈ eq eq′ = record { p₁ = p₁ ; p₂ = p₂ ; commute = ∘-resp-≈ˡ eq ○ commute ○ ⟺ (∘-resp-≈ˡ eq′) ; universal = λ eq″ → universal (∘-resp-≈ˡ (⟺ eq) ○ eq″ ○ ∘-resp-≈ˡ eq′) ; unique = unique ; p₁∘universal≈h₁ = p₁∘universal≈h₁ ; p₂∘universal≈h₂ = p₂∘universal≈h₂ } Pullback-resp-Mono : Mono g → Mono p₁ Pullback-resp-Mono mg h i eq = unique-diagram eq (mg _ _ eq′) where eq′ : g ∘ p₂ ∘ h ≈ g ∘ p₂ ∘ i eq′ = begin g ∘ p₂ ∘ h ≈⟨ extendʳ (sym commute) ⟩ f ∘ p₁ ∘ h ≈⟨ refl⟩∘⟨ eq ⟩ f ∘ p₁ ∘ i ≈⟨ extendʳ commute ⟩ g ∘ p₂ ∘ i ∎ Pullback-resp-Iso : Iso g h → ∃ λ i → Iso p₁ i Pullback-resp-Iso {h = h} iso = universal eq , record { isoˡ = unique-diagram eq₁ eq₂ ; isoʳ = p₁∘universal≈h₁ } where open Iso iso eq = begin f ∘ id ≈⟨ introˡ refl ⟩ id ∘ f ∘ id ≈⟨ pushˡ (⟺ isoʳ) ⟩ g ∘ h ∘ f ∘ id ∎ eq₁ = begin p₁ ∘ universal eq ∘ p₁ ≈⟨ cancelˡ p₁∘universal≈h₁ ⟩ p₁ ≈˘⟨ identityʳ ⟩ p₁ ∘ id ∎ eq₂ = begin p₂ ∘ universal eq ∘ p₁ ≈⟨ extendʳ p₂∘universal≈h₂ ⟩ h ∘ (f ∘ id) ∘ p₁ ≈⟨ refl ⟩∘⟨ identityʳ ⟩∘⟨ refl ⟩ h ∘ f ∘ p₁ ≈⟨ refl ⟩∘⟨ commute ⟩ h ∘ g ∘ p₂ ≈⟨ cancelˡ isoˡ ⟩ p₂ ≈˘⟨ identityʳ ⟩ p₂ ∘ id ∎
{ "alphanum_fraction": 0.4765999436, "avg_line_length": 36.0101522843, "ext": "agda", "hexsha": "f96f0f5123e7e1f5181c83189252f6e2f5897e0d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Taneb/agda-categories", "max_forks_repo_path": "Categories/Diagram/Pullback.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Taneb/agda-categories", "max_issues_repo_path": "Categories/Diagram/Pullback.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Taneb/agda-categories", "max_stars_repo_path": "Categories/Diagram/Pullback.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2897, "size": 7094 }
-- Environment model of the STLC module STLC.Model where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Families.Build open import SOAS.ContextMaps.Inductive open import SOAS.Abstract.Monoid open import SOAS.Coalgebraic.Lift open import STLC.Signature open import STLC.Syntax open import SOAS.Metatheory.SecondOrder.Metasubstitution Λ:Syn open import SOAS.Metatheory.SecondOrder.Equality Λ:Syn open import SOAS.Metatheory.FreeMonoid Λ:Syn open import SOAS.Syntax.Arguments open import Data.Nat private variable α β γ τ : ΛT Γ Δ Π : Ctx 𝔛 : Familyₛ Λᴳ : Familyₛ Λᴳ = Λ Ø -- Interpretation of types and contexts ⟦_⟧ : ΛT → Set ⟦ N ⟧ = ℕ ⟦ α ↣ β ⟧ = ⟦ α ⟧ → ⟦ β ⟧ ⟦_⟧ᶜ : Ctx → Set ⟦ Γ ⟧ᶜ = {α : ΛT} → ℐ α Γ → ⟦ α ⟧ _⁺_ : ⟦ α ⟧ → ⟦ Γ ⟧ᶜ → ⟦ α ∙ Γ ⟧ᶜ _⁺_ x γ new = x _⁺_ x γ (old v) = γ v infixr 10 _⁺_ -- Environment model Env : Familyₛ Env α Γ = ⟦ Γ ⟧ᶜ → ⟦ α ⟧ ΣEnvᴹ : ΣMon Env ΣEnvᴹ = record { ᵐ = record { η = λ v γ → γ v ; μ = λ t σ δ → t (λ v → σ v δ) ; lunit = refl ; runit = refl ; assoc = refl } ; 𝑎𝑙𝑔 = λ{ (appₒ ⋮ f , a) γ → f γ (a γ) ; (lamₒ ⋮ b) γ → λ a → b (a ⁺ γ) } ; μ⟨𝑎𝑙𝑔⟩ = λ{ (appₒ ⋮ _) → refl ; (lamₒ ⋮ b) → ext² λ δ a → cong b (dext (λ { new → refl ; (old y) → refl })) } } module Env = FΣM Ø ΣEnvᴹ (λ ()) eval : Λ Ø ⇾̣ Env eval = Env.𝕖𝕩𝕥 evalᶜ : Λ Ø α ∅ → ⟦ α ⟧ evalᶜ t = eval t (λ ()) _ : evalᶜ {N ↣ N ↣ N} (ƛ ƛ x₁) ≡ λ x y → x _ = refl open Theory Ø -- Operational semantics of the STLC data Value : Λᴳ α Γ → Set where lamⱽ : {b : Λᴳ β (α ∙ Γ)} → Value (ƛ b) data _⟿_ : Λᴳ α Γ → Λᴳ α Γ → Set where ζ-$₁ : {f g : Λᴳ (α ↣ β) Γ}{a : Λᴳ α Γ} → f ⟿ g → f $ a ⟿ g $ a ζ-$₂ : {f : Λᴳ (α ↣ β) Γ}{a b : Λᴳ α Γ} → Value f → a ⟿ b → f $ a ⟿ f $ b β-ƛ : {b : Λᴳ β (α ∙ Γ)}{t : Λᴳ α Γ} → Value t → ((ƛ b) $ t) ⟿ [ t /] b infix 2 _⟿_ -- Evaluation preserves the meaning of terms sound : {t s : Λᴳ α Γ} → t ⟿ s → (γ : ⟦ Γ ⟧ᶜ) → eval t γ ≡ eval s γ sound (ζ-$₁ r) γ rewrite sound r γ = refl sound (ζ-$₂ _ r) γ rewrite sound r γ = refl sound (β-ƛ {b = b}{t} x) γ rewrite Env.𝕖𝕩𝕥ᵐ⇒.sub-lemma t b = cong (eval b) (dext λ{ new → refl ; (old v) → refl })
{ "alphanum_fraction": 0.5521796565, "avg_line_length": 24.1595744681, "ext": "agda", "hexsha": "17c98996d682f736589c104fb16b3895a3271cb5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "k4rtik/agda-soas", "max_forks_repo_path": "out/STLC/Model.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "k4rtik/agda-soas", "max_issues_repo_path": "out/STLC/Model.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "k4rtik/agda-soas", "max_stars_repo_path": "out/STLC/Model.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1100, "size": 2271 }
-- Andreas, 2016-12-12, issue #2046, reported by Nad -- Parameter refinement broke the size solver. -- {-# OPTIONS -v tc.size.solve:100 #-} -- {-# OPTIONS -v tc.constr.cast:100 #-} -- -- {-# OPTIONS -v tc.sig.param:60 #-} -- -- {-# OPTIONS -v tc.check.internal:100 #-} -- -- {-# OPTIONS -v interaction.give:100 #-} open import Agda.Builtin.Size using (Size; Size<_) data _×_ (A B : Set) : Set where _,_ : A → B → A × B record Always {A : Set} (P : A → Set) : Set where field always : ∀ x → P x postulate A : Set module M (P : A → Set) where record R₁ (i : Size) (x : A) : Set where coinductive field force : {j : Size< i} → R₁ j x record R₂ (i : Size) (x : A) : Set where inductive constructor ⟨_,_⟩ field f₁ : P x f₂ : P x → R₁ i x data P : A → Set where c : (y : A) → P y → P y postulate p : (x : A) → P x a : (i : Size) → Always (M.R₁ P i) module _ (Unused : Set) where open M P rejected : ∀ i z → R₂ i z rejected i z = ⟨ p z , (λ { (c y q) → Always.always (a _) z }) ⟩ -- Should succeed {- Solving constraints (DontDefaultToInfty) i =< _i_31 Unused i z : Size _i_31 Unused i z =< _i_35 z Unused i q : Size converting size constraint i =< _i_31 Unused i z : Size converting size constraint _i_31 Unused i z =< _i_35 z Unused i q : Size Solving constraint cluster [Unused, i, z] i ≤ _i_31 Unused i z [z, Unused, i, q] _i_31 Unused i z ≤ _i_35 z Unused i q Size hypotheses Canonicalized constraints [z, Unused, i, q] Unused ≤ _i_31 z Unused i [z, Unused, i, q] _i_31 Unused i z ≤ _i_35 z Unused i q solution _i_31 z Unused i := Unused xs = [3,2,1] u = Var 2 [] solution _i_35 z Unused i q := Unused xs = [3,2,1,0] u = Var 2 [] -}
{ "alphanum_fraction": 0.5875933372, "avg_line_length": 22.9078947368, "ext": "agda", "hexsha": "98dfaaa14a2593be4ca7c6cd18435e0a21567168", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue2046.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue2046.agda", "max_line_length": 55, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue2046.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 646, "size": 1741 }
{- Matrix with coefficients in integers -} {-# OPTIONS --safe #-} module Cubical.Algebra.IntegerMatrix.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function hiding (const) open import Cubical.Foundations.Powerset open import Cubical.Data.Nat hiding (_·_) renaming (_+_ to _+ℕ_ ; +-assoc to +Assocℕ) open import Cubical.Data.Nat.Order open import Cubical.Data.Nat.Divisibility using (m∣n→m≤n) renaming (∣-trans to ∣ℕ-trans) open import Cubical.Data.Int hiding (_+_ ; _·_ ; _-_ ; -_ ; addEq) open import Cubical.Data.Int.Divisibility open import Cubical.Data.FinData open import Cubical.Data.Empty as Empty open import Cubical.Data.Unit as Unit open import Cubical.Data.Sum open import Cubical.Data.Sigma open import Cubical.Algebra.Matrix open import Cubical.Algebra.Matrix.CommRingCoefficient open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Instances.Int renaming (ℤ to ℤRing) open import Cubical.Relation.Nullary open import Cubical.Induction.WellFounded private variable m n k : ℕ open CommRingStr (ℤRing .snd) open Coefficient ℤRing open Sum (CommRing→Ring ℤRing) -- Using well-foundedness to do induction Norm : ℤ → Type Norm n = Acc _<_ (abs n) -- Divisibility of matrix elements ∣-sum : (a : ℤ)(V : FinVec ℤ n) → ((i : Fin n) → a ∣ V i) → a ∣ ∑ V ∣-sum {n = 0} _ _ _ = ∣-zeroʳ ∣-sum {n = suc n} _ _ p = ∣-+ (p zero) (∣-sum _ _ (p ∘ suc)) ∣-left⋆ : (a : ℤ)(M : Mat m n)(N : Mat n k) → ((i : Fin m)(j : Fin n) → a ∣ M i j) → (i : Fin m)(j : Fin k) → a ∣ (M ⋆ N) i j ∣-left⋆ a M N div i j = ∣-sum a (λ l → M i l · N l j) (λ l → ∣-left· (div i l)) ∣-right⋆ : (a : ℤ)(M : Mat m n)(N : Mat n k) → ((i : Fin n)(j : Fin k) → a ∣ N i j) → (i : Fin m)(j : Fin k) → a ∣ (M ⋆ N) i j ∣-right⋆ a M N div i j = ∣-sum a (λ l → M i l · N l j) (λ l → ∣-right· {n = M i l} (div l j)) open SimRel open Sim sim∣ : (a : ℤ)(M : Mat m n) → (sim : Sim M) → ((i : Fin m)(j : Fin n) → a ∣ M i j) → (i : Fin m)(j : Fin n) → a ∣ sim .result i j sim∣ a M sim div i j = subst (a ∣_) (λ t → sim .simrel .transEq (~ t) i j) (∣-left⋆ _ _ (sim .simrel .transMatR) (∣-right⋆ _ (sim .simrel .transMatL) _ div) i j) -- Find a pivot to begin reduction data PivotOrNot (a : ℤ)(M : Mat (suc m) (suc n)) : Type where pivot : (i : Fin (suc m))(j : Fin (suc n))(p : ¬ a ∣ M i j) → PivotOrNot a M noPivot : ((i : Fin (suc m))(j : Fin (suc n)) → a ∣ M i j) → PivotOrNot a M findPivot : (a : ℤ)(M : Mat (suc m) (suc n)) → PivotOrNot a M findPivot a M = let pivot? = ∀Dec2 (λ i j → a ∣ M i j) (λ _ _ → dec∣ _ _) in case pivot? return (λ _ → PivotOrNot a M) of λ { (inl p) → noPivot p ; (inr p) → pivot (p .fst) (p .snd .fst) (p . snd .snd) } -- Find an non-zero element data NonZeroOrNot (M : Mat (suc m) (suc n)) : Type where hereIs : (i : Fin (suc m))(j : Fin (suc n))(p : ¬ M i j ≡ 0) → NonZeroOrNot M allZero : M ≡ 𝟘 → NonZeroOrNot M findNonZero : (M : Mat (suc m) (suc n)) → NonZeroOrNot M findNonZero M = let nonZero? = ∀Dec2 (λ i j → M i j ≡ 0) (λ _ _ → discreteℤ _ 0) in case nonZero? return (λ _ → NonZeroOrNot M) of λ { (inl p) → allZero (λ t i j → p i j t) ; (inr p) → hereIs (p .fst) (p .snd .fst) (p . snd .snd) }
{ "alphanum_fraction": 0.5976011994, "avg_line_length": 28.2627118644, "ext": "agda", "hexsha": "77d1441c37f1e5770e0da002dbda019bccfb6f8f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Algebra/IntegerMatrix/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/IntegerMatrix/Base.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Algebra/IntegerMatrix/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1349, "size": 3335 }
{-# OPTIONS --exact-split #-} -- The --exact-split flag causes Agda to raise an error whenever -- a clause in a definition by pattern matching cannot be made to -- hold definitionally (i.e. as a reduction rule). Specific clauses -- can be excluded from this check by means of the {-# CATCHALL #-} -- pragma. module ExactSplit where data Bool : Set where true false : Bool data ℕ : Set where zero : ℕ suc : ℕ → ℕ _+_ : ℕ → ℕ → ℕ zero + n = zero (suc m) + n = suc (m + n) eq : ℕ → ℕ → Bool eq zero zero = true eq (suc m) (suc n) = eq m n {-# CATCHALL #-} eq _ _ = false -- See also fail/ExactSplitMin.agda min : ℕ → ℕ → ℕ min zero y = zero {-# CATCHALL #-} min x zero = zero min (suc x) (suc y) = suc (min x y) -- See also fail/ExactSplitBerry.agda maj : Bool → Bool → Bool → Bool maj true true true = true {-# CATCHALL #-} maj x true false = x {-# CATCHALL #-} maj false y true = y maj true false z = z maj false false false = false -- See also fail/ExactSplitParity.agda parity : ℕ → ℕ → Bool parity zero zero = true parity zero (suc zero) = false parity zero (suc (suc n)) = parity zero n parity (suc zero) zero = false parity (suc (suc m)) zero = parity m zero {-# CATCHALL #-} parity (suc m) (suc n) = parity m n
{ "alphanum_fraction": 0.5815654718, "avg_line_length": 25.3148148148, "ext": "agda", "hexsha": "00a87798c9fdcd2e068a2c5d797066d6cf1f6f97", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/ExactSplit.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/ExactSplit.agda", "max_line_length": 67, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/ExactSplit.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 423, "size": 1367 }
module Numeral.Finite.Conversions where import Lvl open import Data using (Empty ; Unit ; <>) open import Data.Boolean using (Bool ; 𝐹 ; 𝑇) open import Data.Tuple using (_,_) open import Logic.Propositional using (_↔_) open import Numeral.Finite open import Numeral.Natural open import Syntax.Number private variable ℓ : Lvl.Level empty : 𝕟(0) ↔ Empty{ℓ} empty = (\()) , (\()) unit : 𝕟(1) ↔ Unit{ℓ} unit = (\{<> → 0}) , (\{𝟎 → <>}) bool : 𝕟(2) ↔ Bool bool = (\{𝐹 → 0 ; 𝑇 → 1}) , (\{𝟎 → 𝐹 ; (𝐒(𝟎)) → 𝑇})
{ "alphanum_fraction": 0.6159844055, "avg_line_length": 23.3181818182, "ext": "agda", "hexsha": "6723c22d13545676327458619792f61d80cc626a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Finite/Conversions.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Finite/Conversions.agda", "max_line_length": 51, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Finite/Conversions.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 196, "size": 513 }
{-# OPTIONS --without-K #-} open import HoTT.Base open import HoTT.Equivalence module HoTT.Equivalence.Lift where open variables Lift-equiv : Lift {i} A ≃ A Lift-equiv = iso→eqv λ{.f → lower ; .g → lift ; .η _ → refl ; .ε _ → refl} where open Iso
{ "alphanum_fraction": 0.6666666667, "avg_line_length": 21, "ext": "agda", "hexsha": "3eadbb2730efc0ee1af18536416c5af7bddc89c3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "michaelforney/hott", "max_forks_repo_path": "HoTT/Equivalence/Lift.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "michaelforney/hott", "max_issues_repo_path": "HoTT/Equivalence/Lift.agda", "max_line_length": 74, "max_stars_count": null, "max_stars_repo_head_hexsha": "ef4d9fbb9cc0352657f1a6d0d3534d4c8a6fd508", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "michaelforney/hott", "max_stars_repo_path": "HoTT/Equivalence/Lift.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 83, "size": 252 }
module prelude where open import level public open import product public open import product-thms public open import sum public open import empty public open import unit public open import functions renaming (id to id-set) public open import eq public open import list public open import list-thms public open import bool public open import nat public open import nat-thms public -- Extensionality will be used when proving equivalences of morphisms. postulate ext-set : ∀{l1 l2 : level} → extensionality {l1} {l2} -- These are isomorphisms, but Agda has no way to prove these as -- equivalences. They are consistent to adopt as equivalences by -- univalence: postulate ∧-unit : ∀{ℓ}{A : Set ℓ} → A ≡ (⊤ {ℓ} ∧ A) postulate ∧-assoc : ∀{ℓ}{A B C : Set ℓ} → (A ∧ (B ∧ C)) ≡ ((A ∧ B) ∧ C) postulate ∧-twist : ∀{ℓ}{A B : Set ℓ} → (A ∧ B) ≡ (B ∧ A) -- Provable from the above axioms: postulate assoc-twist₁ : {A B C D : Set} → ((A × C) × (B × D)) ≡ ((A × B) × (C × D)) -- The following defines a commutative monoid as lists: _* = 𝕃 postulate *-comm : ∀{A : Set}{l₁ l₂ : A *} → l₁ ++ l₂ ≡ l₂ ++ l₁
{ "alphanum_fraction": 0.6715195632, "avg_line_length": 33.303030303, "ext": "agda", "hexsha": "55e57f432bcc5101d45e0761e1d6651e8ff44238", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "dialectica-cats/prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "dialectica-cats/prelude.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "dialectica-cats/prelude.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 365, "size": 1099 }
open import Oscar.Prelude open import Oscar.Class open import Oscar.Class.Transitivity module Oscar.Class.Transitivity.Function where module _ {a} where instance 𝓣ransitivityFunction : Transitivity.class Function⟦ a ⟧ 𝓣ransitivityFunction .⋆ f g = g ∘ f
{ "alphanum_fraction": 0.7545787546, "avg_line_length": 17.0625, "ext": "agda", "hexsha": "6091fc5c8f0892e4681e9bcd7fed3a359f60c43a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Transitivity/Function.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Transitivity/Function.agda", "max_line_length": 59, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Transitivity/Function.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 76, "size": 273 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Functions.Definition open import LogicalFormulae open import Numbers.Naturals.Definition open import Sets.FinSet.Definition module Sets.Cardinality.Infinite.Definition where InfiniteSet : {a : _} (A : Set a) → Set a InfiniteSet A = (n : ℕ) → (f : FinSet n → A) → (Bijection f) → False record DedekindInfiniteSet {a : _} (A : Set a) : Set a where field inj : ℕ → A isInjection : Injection inj
{ "alphanum_fraction": 0.6993603412, "avg_line_length": 27.5882352941, "ext": "agda", "hexsha": "fb6679891bb9fb2a9b3df0b14fc72c5c0e2d19a1", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Sets/Cardinality/Infinite/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Sets/Cardinality/Infinite/Definition.agda", "max_line_length": 68, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Sets/Cardinality/Infinite/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 141, "size": 469 }
open import Agda.Builtin.Nat open import Agda.Builtin.Equality pathological : (e : 9999999999 ≡ 9999999999) → Set pathological refl = Nat
{ "alphanum_fraction": 0.7714285714, "avg_line_length": 20, "ext": "agda", "hexsha": "30d4d851d756460102b1186c869a44d14a5e6317", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/UnifyLiteral.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/UnifyLiteral.agda", "max_line_length": 50, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/UnifyLiteral.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 47, "size": 140 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Container combinators ------------------------------------------------------------------------ module Data.Container.Combinator where open import Data.Container open import Data.Empty using (⊥; ⊥-elim) open import Data.Product as Prod hiding (Σ) renaming (_×_ to _⟨×⟩_) open import Data.Sum renaming (_⊎_ to _⟨⊎⟩_) open import Data.Unit using (⊤) open import Function as F hiding (id; const) renaming (_∘_ to _⟨∘⟩_) open import Function.Inverse using (_↔_) open import Level open import Relation.Binary.PropositionalEquality as P using (_≗_; refl) ------------------------------------------------------------------------ -- Combinators -- Identity. id : ∀ {c} → Container c id = Lift ⊤ ▷ F.const (Lift ⊤) -- Constant. const : ∀ {c} → Set c → Container c const X = X ▷ F.const (Lift ⊥) -- Composition. infixr 9 _∘_ _∘_ : ∀ {c} → Container c → Container c → Container c C₁ ∘ C₂ = ⟦ C₁ ⟧ (Shape C₂) ▷ ◇ (Position C₂) -- Product. (Note that, up to isomorphism, this is a special case of -- indexed product.) infixr 2 _×_ _×_ : ∀ {c} → Container c → Container c → Container c C₁ × C₂ = (Shape C₁ ⟨×⟩ Shape C₂) ▷ uncurry (λ s₁ s₂ → Position C₁ s₁ ⟨⊎⟩ Position C₂ s₂) -- Indexed product. Π : ∀ {c} {I : Set c} → (I → Container c) → Container c Π C = (∀ i → Shape (C i)) ▷ λ s → ∃ λ i → Position (C i) (s i) -- Sum. (Note that, up to isomorphism, this is a special case of -- indexed sum.) infixr 1 _⊎_ _⊎_ : ∀ {c} → Container c → Container c → Container c C₁ ⊎ C₂ = (Shape C₁ ⟨⊎⟩ Shape C₂) ▷ [ Position C₁ , Position C₂ ] -- Indexed sum. Σ : ∀ {c} {I : Set c} → (I → Container c) → Container c Σ C = (∃ λ i → Shape (C i)) ▷ λ s → Position (C (proj₁ s)) (proj₂ s) -- Constant exponentiation. (Note that this is a special case of -- indexed product.) infix 0 const[_]⟶_ const[_]⟶_ : ∀ {c} → Set c → Container c → Container c const[ X ]⟶ C = Π {I = X} (F.const C) ------------------------------------------------------------------------ -- Correctness proofs -- I have proved some of the correctness statements under the -- assumption of functional extensionality. I could have reformulated -- the statements using suitable setoids, but I could not be bothered. module Identity where correct : ∀ {c} {X : Set c} → ⟦ id ⟧ X ↔ F.id X correct {c} = record { to = P.→-to-⟶ {a = c} λ xs → proj₂ xs _ ; from = P.→-to-⟶ {b₁ = c} λ x → (_ , λ _ → x) ; inverse-of = record { left-inverse-of = λ _ → refl ; right-inverse-of = λ _ → refl } } module Constant (ext : ∀ {ℓ} → P.Extensionality ℓ ℓ) where correct : ∀ {ℓ} (X : Set ℓ) {Y} → ⟦ const X ⟧ Y ↔ F.const X Y correct X {Y} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { right-inverse-of = λ _ → refl ; left-inverse-of = λ xs → P.cong (_,_ (proj₁ xs)) (ext (λ x → ⊥-elim (lower x))) } } where to : ⟦ const X ⟧ Y → X to = proj₁ from : X → ⟦ const X ⟧ Y from = < F.id , F.const (⊥-elim ∘′ lower) > module Composition where correct : ∀ {c} (C₁ C₂ : Container c) {X : Set c} → ⟦ C₁ ∘ C₂ ⟧ X ↔ (⟦ C₁ ⟧ ⟨∘⟩ ⟦ C₂ ⟧) X correct C₁ C₂ {X} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = λ _ → refl ; right-inverse-of = λ _ → refl } } where to : ⟦ C₁ ∘ C₂ ⟧ X → ⟦ C₁ ⟧ (⟦ C₂ ⟧ X) to ((s , f) , g) = (s , < f , curry g >) from : ⟦ C₁ ⟧ (⟦ C₂ ⟧ X) → ⟦ C₁ ∘ C₂ ⟧ X from (s , f) = ((s , proj₁ ⟨∘⟩ f) , uncurry (proj₂ ⟨∘⟩ f)) module Product (ext : ∀ {ℓ} → P.Extensionality ℓ ℓ) where correct : ∀ {c} (C₁ C₂ : Container c) {X : Set c} → ⟦ C₁ × C₂ ⟧ X ↔ (⟦ C₁ ⟧ X ⟨×⟩ ⟦ C₂ ⟧ X) correct {c} C₁ C₂ {X} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = from∘to ; right-inverse-of = λ _ → refl } } where to : ⟦ C₁ × C₂ ⟧ X → ⟦ C₁ ⟧ X ⟨×⟩ ⟦ C₂ ⟧ X to ((s₁ , s₂) , f) = ((s₁ , f ⟨∘⟩ inj₁) , (s₂ , f ⟨∘⟩ inj₂)) from : ⟦ C₁ ⟧ X ⟨×⟩ ⟦ C₂ ⟧ X → ⟦ C₁ × C₂ ⟧ X from ((s₁ , f₁) , (s₂ , f₂)) = ((s₁ , s₂) , [ f₁ , f₂ ]) from∘to : from ⟨∘⟩ to ≗ F.id from∘to (s , f) = P.cong (_,_ s) (ext {ℓ = c} [ (λ _ → refl) , (λ _ → refl) ]) module IndexedProduct where correct : ∀ {c I} (C : I → Container c) {X : Set c} → ⟦ Π C ⟧ X ↔ (∀ i → ⟦ C i ⟧ X) correct {I = I} C {X} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = λ _ → refl ; right-inverse-of = λ _ → refl } } where to : ⟦ Π C ⟧ X → ∀ i → ⟦ C i ⟧ X to (s , f) = λ i → (s i , λ p → f (i , p)) from : (∀ i → ⟦ C i ⟧ X) → ⟦ Π C ⟧ X from f = (proj₁ ⟨∘⟩ f , uncurry (proj₂ ⟨∘⟩ f)) module Sum where correct : ∀ {c} (C₁ C₂ : Container c) {X : Set c} → ⟦ C₁ ⊎ C₂ ⟧ X ↔ (⟦ C₁ ⟧ X ⟨⊎⟩ ⟦ C₂ ⟧ X) correct C₁ C₂ {X} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = from∘to ; right-inverse-of = [ (λ _ → refl) , (λ _ → refl) ] } } where to : ⟦ C₁ ⊎ C₂ ⟧ X → ⟦ C₁ ⟧ X ⟨⊎⟩ ⟦ C₂ ⟧ X to (inj₁ s₁ , f) = inj₁ (s₁ , f) to (inj₂ s₂ , f) = inj₂ (s₂ , f) from : ⟦ C₁ ⟧ X ⟨⊎⟩ ⟦ C₂ ⟧ X → ⟦ C₁ ⊎ C₂ ⟧ X from = [ Prod.map inj₁ F.id , Prod.map inj₂ F.id ] from∘to : from ⟨∘⟩ to ≗ F.id from∘to (inj₁ s₁ , f) = refl from∘to (inj₂ s₂ , f) = refl module IndexedSum where correct : ∀ {c I} (C : I → Container c) {X : Set c} → ⟦ Σ C ⟧ X ↔ (∃ λ i → ⟦ C i ⟧ X) correct {I = I} C {X} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = λ _ → refl ; right-inverse-of = λ _ → refl } } where to : ⟦ Σ C ⟧ X → ∃ λ i → ⟦ C i ⟧ X to ((i , s) , f) = (i , (s , f)) from : (∃ λ i → ⟦ C i ⟧ X) → ⟦ Σ C ⟧ X from (i , (s , f)) = ((i , s) , f) module ConstantExponentiation where correct : ∀ {c X} (C : Container c) {Y : Set c} → ⟦ const[ X ]⟶ C ⟧ Y ↔ (X → ⟦ C ⟧ Y) correct C = IndexedProduct.correct (F.const C)
{ "alphanum_fraction": 0.4706812075, "avg_line_length": 28.3721973094, "ext": "agda", "hexsha": "f3c7bf3abb1b74182706814ea39c5edd4ef96d0b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Container/Combinator.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Container/Combinator.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Container/Combinator.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 2479, "size": 6327 }
test : Set → Set test A with A test | B = B
{ "alphanum_fraction": 0.5909090909, "avg_line_length": 11, "ext": "agda", "hexsha": "60317a31cd2491a40e4aced0bbb9bffb7c7c522e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/WithTooFewPatterns.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/WithTooFewPatterns.agda", "max_line_length": 16, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/WithTooFewPatterns.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 17, "size": 44 }
module Sec4 where -- open import Sec2 Prop : Set₁ Prop = Set Value : Set₁ Value = Set -- XXX: The true type data ⊤ : Prop where ⋆ : ⊤ -- XXX: The false type data ⊥ : Prop where -- XXX: Conjunction of Propositions data _∧_ (A B : Prop) : Prop where and : A → B → (A ∧ B) -- XXX: The disjuction of propositions data _∨_ (A B : Prop) : Prop where ora : A → A ∨ B orb : B → A ∨ B -- XXX: implication data _⇒_ (A B : Prop) : Prop where impl : (f : A → B) → A ⇒ B infixr 2 _⇒_ -- XXX: equivalence data _⇔_ (A B : Prop) : Prop where eq : (f₁ : A ⇒ B) → (f₂ : B ⇒ A) → A ⇔ B -- XXX: Negation as a function data ¬_ (A : Prop) : Prop where neg : A ⇒ ⊥ → (¬ A) -- XXX: Elimination rules as functions -- XXX: Eliminating ≡> elim-⇒ : {A B : Prop} → (f₁ : A ⇒ B) → A → B elim-⇒ (impl f) x = f x elim1-⇔ : {A B : Prop} → (A ⇔ B) → A → B elim1-⇔ (eq (impl f) _) x = f x elim2-⇔ : {A B : Prop} → (A ⇔ B) → B → A elim2-⇔ (eq _ (impl f₁)) x = f₁ x -- XXX: Eliminating disjunction elim-∨ : {A B C : Prop} → (A ∨ B) → (A → C) → (B → C) → C elim-∨ (ora x) f₁ _ = f₁ x elim-∨ (orb x) _ f₂ = f₂ x -- XXX: Eliminating conjuction elim1-∧ : {A B : Prop} → (A ∧ B) → A elim1-∧ (and x x₁) = x elim2-∧ : {A B : Prop} → (A ∧ B) → B elim2-∧ (and x x₁) = x₁ -- TODO: Example of proofs of tautology -- XXX: Easy one ex1 : {A B : Prop} → ((A ⇒ B) ∧ (B ⇒ A)) ⇔ (A ⇔ B) ex1 {A} {B} = eq (impl (λ x → let x1 = elim1-∧ x x2 = elim2-∧ x in eq (impl (λ x₁ → elim-⇒ x1 x₁)) (impl (λ x₁ → elim-⇒ x2 x₁)))) (impl (λ x → let x1 = elim1-⇔ x x2 = elim2-⇔ x in and (impl (λ x₁ → x1 x₁)) (impl (λ x₁ → x2 x₁)))) -- XXX: Transitivity ex2 : {A B C : Prop} → ((A ⇒ B) ∧ (B ⇒ C)) ⇒ (A ⇒ C) ex2 = impl (λ x → impl (λ x₁ → elim-⇒ (elim2-∧ x) (elim-⇒ (elim1-∧ x) x₁))) -- XXX: Transitivity in the function space of Agda itself. Equivalent to -- the above one. trans : {A B C : Set} → ((A → B) ∧ (B → C)) → (A → C) trans (and x1 x2) z = let t = x1 z t1 = x2 t in t1 -- (elim-⇒ x x₂) transitivity : {A B C : Prop} → (A ⇒ B) ⇒ (B ⇒ C) ⇒ (A ⇒ C) transitivity = impl (λ x → impl (λ x₁ → impl (λ x₂ → elim-⇒ x₁ (elim-⇒ x x₂)))) -- XXX: Moving ∧ into Agda's space. Equivalent to transitivity and trans -- above. trans' : {A B C : Set} → (A → B) → (B → C) → (A → C) trans' x y = λ z → y (x z) -- XXX: absorption law absorption : {P Q : Prop} → (P ∨ (P ∧ Q)) ⇔ P absorption {p} {q} = eq (impl (λ x → let x1 = elim-∨ x (λ p → p) (λ y → elim1-∧ y) in x1)) (impl (λ x → ora x)) -- XXX: commutativity commute : {P Q : Prop} → (P ∧ Q) ⇔ (Q ∧ P) commute = eq (impl (λ x → and (elim2-∧ x) (elim1-∧ x))) (impl (λ x → and (elim2-∧ x) (elim1-∧ x))) -- XXX: associativity associative : {P Q R : Prop} → ((P ∧ Q) ∧ R) ⇔ (P ∧ (Q ∧ R)) associative = eq (impl (λ x → and (elim1-∧ (elim1-∧ x)) (and (elim2-∧ (elim1-∧ x)) (elim2-∧ x)))) (impl (λ x → and (and (elim1-∧ x) (elim1-∧ (elim2-∧ x))) (elim2-∧ (elim2-∧ x)))) elim-neg : {A : Prop} → A → (¬ A) → ⊥ elim-neg y (neg x) = elim-⇒ x y eet : {A B : Prop} → ((¬ A) ∧ (¬ B)) ⇒ (¬ (A ∧ B)) eet = impl (λ x → neg (impl (λ x₁ → elim-neg (elim1-∧ x₁) (elim1-∧ x)))) -- tt : {A : Prop} → (A ∨ (¬ A)) → (¬ (¬ A)) → A -- tt (ora x) (neg y) = x -- tt {A} (orb x) (neg y) = -- let -- z = elim-⇒ y x -- t = elim-neg {!!} x -- in -- {!!} -- XXX: A ⇒ ¬¬ A f : {A : Prop} → A ⇒ (¬ (¬ A)) f = impl (λ x → neg (impl (λ x₁ → elim-neg x x₁))) -- A⇔¬¬A : {A : Prop} → A ⇔ (¬ (¬ A)) -- A⇔¬¬A = eq (impl (λ x → neg (impl (λ x₁ → elim-neg x x₁)))) -- (impl (λ x → {!!})) -- A⇔A⇒⊥⇒⊥ : {A : Prop} → (A ⇔ ((A ⇒ ⊥) ⇒ ⊥)) -- A⇔A⇒⊥⇒⊥ = eq (impl (λ x → impl (λ x₁ → elim-⇒ x₁ x))) -- (impl (λ x → {!!})) -- AC⇒Contra : {A : Prop} → (A ∨ (¬ A)) ⇒ ((¬ (¬ A)) ⇒ A) -- AC⇒Contra = impl (λ x → impl (λ x₁ → {!!})) -- XXX: Axiom of choice one way C-⇒ : {P : Prop} → (P ∨ (¬ P)) ⇒ ⊤ C-⇒ = impl (λ _ → ⋆) -- XXX: Axiom of choice -- C-⇔ : {P : Prop} → (P ∨ (¬ P)) ⇔ ⊤ -- C-⇔ = eq -- (impl (λ _ → ⋆)) -- -- XXX: The following proof is impossible todo -- -- Goal: .P ∨ (¬ .P) -- -- ———————————————————————————————————————————————————————————— -- -- x : ⊤ -- -- .P : Prop -- (impl (λ x → {!!})) -- XXX: We do not have any proof object of P -- -- on the right hand side. This is the -- -- difference between constructive logic, and -- -- classical logic. -- distributive : {p q r : Prop} → (p ∧ (q ∨ r)) ⇔ ((p ∧ q) ∨ (p ∧ r)) -- distributive = -- eq -- (impl (λ x → -- let p = elim1-∧ x -- x2 = elim2-∧ x -- x3 = elim-∨ x2 (λ q → q) (λ x₁ → {!!}) -- in -- ora (and p x3))) -- (impl (λ x → -- let x1 = elim-∨ x (λ l → elim1-∧ l) (λ r → elim1-∧ r) -- x2 = elim-∨ x (λ x₁ → {!!}) (λ r → elim2-∧ r) -- in -- and x1 (orb x2))) and-⇒ : {A B : Prop} → (A ∧ B) ⇒ (A ⇒ B) and-⇒ = impl (λ x → impl (λ x₁ → elim2-∧ x)) tii : {A B C : Prop} → ((A ∧ B) ⇒ C) ⇒ (A ⇒ (B ⇒ C)) tii = impl (λ x → impl (λ x₁ → impl (λ x₂ → elim-⇒ x (and x₁ x₂)))) -- tii2 : {A B : Prop} → (((¬ A) ∨ B) ∧ A) ⇒ B -- tii2 = impl (λ x → -- let -- x₁ = elim1-∧ x -- x₂ = elim2-∧ x -- in -- {!!}) -- contradiction : {A : Prop} → (¬ (¬ A)) ⇒ A -- contradiction = impl (λ x → {!!}) -- XXX: Predicate logic -- XXX: For all introduction data ForAll (A : Set) (B : A → Prop) : Prop where dfun : (∀ (x : A) → (B x)) → (ForAll A B) elim-ForAll : {A : Set} → (x : A) → {B : A → Prop} → (ForAll A B) → (B x) elim-ForAll x (dfun x₁) = x₁ x -- XXX: Exists data Exists (A : Set) (B : A → Prop) : Prop where [_,_] : (x : A) → (B x) → Exists A B elim1-exists : {A : Prop} → {B : A → Prop} → (Exists A B) → A elim1-exists [ x , _ ] = x elim2-exists : {A : Prop} → {B : A → Prop} → (p : Exists A B) → (B (elim1-exists p)) elim2-exists [ _ , x ] = x -- TODO: Proofs in predicate logic -- XXX: model-checking depends on this theorem mthm : {V : Value} → {P : V → Prop} → (Exists V (λ (x : V) → (¬ P x))) ⇒ (¬ ForAll V P) mthm = impl (λ x → neg (impl (λ x₁ → elim-neg (elim-ForAll (elim1-exists x) x₁) (elim2-exists x)))) pex0 : {X : Set} → {P : X → Prop} → (¬ (Exists X P)) ⇒ (ForAll X (λ x → (¬ P x))) pex0 = impl (λ x → dfun (λ x₁ → neg (impl (λ x₂ → let x1 = elim-neg [ x₁ , x₂ ] x in x1)))) pex0' : {X : Set} → {P : X → Prop} → (ForAll X (λ x → (¬ P x))) ⇒ (¬ (Exists X P)) pex0' = impl (λ x → neg (impl (λ x₁ → let x1 = elim1-exists x₁ x1' = elim2-exists x₁ x2 = elim-ForAll x1 x in elim-neg x1' x2))) pex2 : {X Y : Set} → {P : X → Y → Prop} → (Exists Y (λ (y : Y) → (ForAll X (λ (x : X) → P x y)))) ⇒ (ForAll X (λ (x : X) → (Exists Y (λ (y : Y) → P x y)))) pex2 = impl (λ x → dfun (λ x₁ → let x1 = elim1-exists x x2 = elim2-exists x x3 = elim-ForAll x₁ x2 in [ x1 , x3 ])) -- TODO: Tautology in first order predicate logic ptau : {V B : Value} → {A : V → Prop} → (x : V) → (ForAll V (λ _ → (A x) ⇒ B)) ⇔ (Exists V (λ _ → (A x) ⇒ B)) ptau a = eq (impl (λ x → [ a , (impl (λ x₁ → elim-⇒ (elim-ForAll a x) x₁)) ])) (impl (λ x → dfun (λ x₁ → impl (λ x₂ → elim-⇒ (elim2-exists x) x₂))))
{ "alphanum_fraction": 0.3832516912, "avg_line_length": 30.7311827957, "ext": "agda", "hexsha": "e377ad6098599000c257edb7715e39fbe7cac2b1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "amal029/agda-tutorial-dybjer", "max_forks_repo_path": "Sec4.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "amal029/agda-tutorial-dybjer", "max_issues_repo_path": "Sec4.agda", "max_line_length": 97, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7128bb419cd4aa3eeacae1fae1a9eb2e57ee8166", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "amal029/agda-tutorial-dybjer", "max_stars_repo_path": "Sec4.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-08T12:52:30.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:52:30.000Z", "num_tokens": 3288, "size": 8574 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Cocone where open import Level open import Categories.Category open import Categories.Functor hiding (_≡_; _∘_) record Cocone {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} (F : Functor J C) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′) where module J = Category J open Category C open Functor F field N : Obj ψ : ∀ X → ((F₀ X) ⇒ N) .commute : ∀ {X Y} (f : J [ X , Y ]) → ψ X ≡ ψ Y ∘ F₁ f
{ "alphanum_fraction": 0.5863539446, "avg_line_length": 27.5882352941, "ext": "agda", "hexsha": "fc2dd35bb8315ce904b55d1e5192b522678b5665", "lang": "Agda", "max_forks_count": 23, "max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z", "max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "p-pavel/categories", "max_forks_repo_path": "Categories/Cocone.agda", "max_issues_count": 19, "max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2", "max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "p-pavel/categories", "max_issues_repo_path": "Categories/Cocone.agda", "max_line_length": 129, "max_stars_count": 98, "max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "copumpkin/categories", "max_stars_repo_path": "Categories/Cocone.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z", "num_tokens": 183, "size": 469 }
------------------------------------------------------------------------ -- Up-to techniques, compatibility, size-preserving functions, and the -- companion ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} -- The definitions below are parametrised by an indexed container. open import Prelude open import Indexed-container module Up-to {ℓ} {I : Type ℓ} (C : Container I I) where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude.Size open import Bijection equality-with-J using (_↔_) open import Function-universe equality-with-J as F hiding (id; _∘_) open import Function-universe.Size equality-with-J open import Indexed-container.Combinators hiding (id; const) renaming (_∘_ to _⊚_) open import Relation ------------------------------------------------------------------------ -- Up-to techniques -- This definition of soundness is based on the definition of -- "b-soundness" given by Pous and Sangiorgi in "Enhancements of the -- bisimulation proof method", with the following differences: -- -- * The property is stated for an indexed container rather than a -- monotone function on a (particular) complete lattice. -- -- * The extension ⟦ C ⟧ of the container C takes the place of b. -- -- * The type-theoretic greatest fixpoint ν takes the place of a -- set-theoretic greatest fixpoint. Sound : Container I I → Type ℓ Sound F = ν (C ⊚ F) ∞ ⊆ ν C ∞ -- A relation transformer F is a (sound) up-to technique if every -- relation R that is contained in ⟦ C ⟧ (F R) is contained in ν C ∞. Up-to-technique : Trans ℓ I → Type (lsuc ℓ) Up-to-technique F = ∀ {R} → R ⊆ ⟦ C ⟧ (F R) → R ⊆ ν C ∞ -- The two definitions above are pointwise logically equivalent, if -- the second one is restricted to containers (in a certain way). Sound⇔ : ∀ F → Sound F ⇔ Up-to-technique ⟦ F ⟧ Sound⇔ F = record { to = λ sound {R} → R ⊆ ⟦ C ⟧ (⟦ F ⟧ R) ↝⟨ ⊆-congʳ _ (_⇔_.from $ ⟦∘⟧↔ _ C) ⟩ R ⊆ ⟦ C ⊚ F ⟧ R ↝⟨ unfold (C ⊚ F) ⟩ R ⊆ ν (C ⊚ F) ∞ ↝⟨ ⊆-congʳ _ sound ⟩□ R ⊆ ν C ∞ □ ; from = λ up-to → up-to ( ν (C ⊚ F) ∞ ⊆⟨ ν-out _ ⟩ ⟦ C ⊚ F ⟧ (ν (C ⊚ F) ∞) ⊆⟨ ⟦∘⟧↔ _ C ⟩∎ ⟦ C ⟧ (⟦ F ⟧ (ν (C ⊚ F) ∞)) ∎) } ------------------------------------------------------------------------ -- Compatibility -- Compatibility. -- -- This definition corresponds to Pous and Sangiorgi's definition of -- b-compatibility. Compatible : Trans ℓ I → Type (lsuc ℓ) Compatible F = ∀ {R} → F (⟦ C ⟧ R) ⊆ ⟦ C ⟧ (F R) -- If F is monotone and compatible, and R is contained in ⟦ C ⟧ (F R), -- then F ^ω R is a post-fixpoint of ⟦ C ⟧. -- -- The proof of Pous and Sangiorgi's Theorem 6.3.9 contains a similar -- result. compatible→^ω-post-fixpoint : ∀ {F} → Monotone F → Compatible F → ∀ {R} → R ⊆ ⟦ C ⟧ (F R) → F ^ω R ⊆ ⟦ C ⟧ (F ^ω R) compatible→^ω-post-fixpoint {F} mono comp {R = R} R⊆ = uncurry λ n → F ^[ n ] R ⊆⟨ Fⁿ⊆∘F¹⁺ⁿ n ⟩ ⟦ C ⟧ (F ^[ 1 + n ] R) ⊆⟨ map C (1 + n ,_) ⟩∎ ⟦ C ⟧ (F ^ω R) ∎ where Fⁿ⊆∘F¹⁺ⁿ : ∀ n → F ^[ n ] R ⊆ ⟦ C ⟧ (F ^[ suc n ] R) Fⁿ⊆∘F¹⁺ⁿ zero = R ⊆⟨ R⊆ ⟩∎ ⟦ C ⟧ (F R) ∎ Fⁿ⊆∘F¹⁺ⁿ (suc n) = F ^[ 1 + n ] R ⊆⟨⟩ F (F ^[ n ] R) ⊆⟨ mono (Fⁿ⊆∘F¹⁺ⁿ n) ⟩ F (⟦ C ⟧ (F ^[ 1 + n ] R)) ⊆⟨ comp ⟩∎ ⟦ C ⟧ (F ^[ 2 + n ] R) ∎ -- Monotone compatible functions are up-to techniques. -- -- This is basically Pous and Sangiorgi's Theorem 6.3.9. monotone→compatible→up-to : ∀ {F} → Monotone F → Compatible F → Up-to-technique F monotone→compatible→up-to {F} mono comp {R = R} R⊆ = R ⊆⟨ 0 ,_ ⟩ F ^ω R ⊆⟨ unfold C (compatible→^ω-post-fixpoint mono comp R⊆) ⟩∎ ν C ∞ ∎ ------------------------------------------------------------------------ -- Size-preserving functions (using sized types) -- F is size-preserving if, for any relation R, if R is contained in -- ν C i, then F R is contained in ν C i. Size-preserving : Trans ℓ I → Type (lsuc ℓ) Size-preserving F = ∀ {R i} → R ⊆ ν C i → F R ⊆ ν C i -- If a transformer is size-preserving, then it satisfies the -- corresponding property for ν′, and vice versa. -- -- Note that this proof uses the size successor function. size-preserving⇔size-preserving′ : ∀ {F} → Size-preserving F ⇔ (∀ {R i} → R ⊆ ν′ C i → F R ⊆ ν′ C i) force (_⇔_.to size-preserving⇔size-preserving′ pres R⊆ν′Ci x) = pres (λ y → force (R⊆ν′Ci y)) x _⇔_.from size-preserving⇔size-preserving′ pres′ {i = i} R⊆ν′Ci x = force (pres′ {i = ssuc i} (λ x → λ { .force → R⊆ν′Ci x }) x) -- If the relation transformer F is size-preserving, then F is an -- up-to technique. -- -- On the other hand, up-to techniques are not necessarily -- size-preserving, not even for monotone and extensive transformers, -- see -- Bisimilarity.Up-to.Counterexamples.∃monotone×extensive×up-to׬size-preserving. -- Thus the property of being size-preserving is less general than -- that of being an up-to technique. However, the latter property is -- not closed under composition (not even for monotone and extensive -- transformers, see Bisimilarity.Up-to.Counterexamples.¬-∘-closure), -- whereas the former property is (see ∘-closure below). size-preserving→up-to : ∀ {F} → Size-preserving F → Up-to-technique F size-preserving→up-to {F} pres {R = R} R⊆CFR = helper where helper : ∀ {i} → R ⊆ ⟦ C ⟧ (ν′ C i) helper = map C (_⇔_.to size-preserving⇔size-preserving′ pres (λ x → λ { .force → helper x })) ∘ R⊆CFR -- An alternative implementation of helper which might be a bit -- easier to follow. helper′ : ∀ {i} → R ⊆ ν C i helper′ {i} = R ⊆⟨ R⊆CFR ⟩ ⟦ C ⟧ (F R) ⊆⟨ map C (_⇔_.to size-preserving⇔size-preserving′ pres (λ x → λ { .force → helper′ x })) ⟩ ⟦ C ⟧ (ν′ C i) ⊆⟨ id ⟩∎ ν C i ∎ -- If F is monotone, then Size-preserving F is logically equivalent to -- a special case stating that, for any size i, ν C i should be a -- pre-fixpoint of F. -- -- Note that size-preserving relation transformers are not necessarily -- monotone (or extensive), see -- Bisimilarity.Up-to.Counterexamples.∃size-preserving׬[monotone⊎extensive]. -- -- Furthermore there is a container C such that transformers F that -- satisfy the property ∀ {i} → F (ν C i) ⊆ ν C i are not necessarily -- up-to techniques for C, see -- Bisimilarity.Up-to.Counterexamples.∃special-case-of-size-preserving׬up-to. monotone→⇔ : ∀ {F} → Monotone F → Size-preserving F ⇔ (∀ {i} → F (ν C i) ⊆ ν C i) monotone→⇔ mono = record { to = λ pres → pres id ; from = λ pres R⊆νCi → pres ∘ mono R⊆νCi } -- A special case of compatibility. Compatible′ : Trans ℓ I → Type ℓ Compatible′ F = ∀ {i} → F (⟦ C ⟧ (ν′ C i)) ⊆ ⟦ C ⟧ (F (ν′ C i)) -- Monotone transformers that satisfy the special case of -- compatibility are size-preserving. monotone→compatible′→size-preserving : ∀ {F} → Monotone F → Compatible′ F → Size-preserving F monotone→compatible′→size-preserving {F = F} mono comp = _⇔_.from (monotone→⇔ mono) helper where mutual helper : ∀ {i} → F (⟦ C ⟧ (ν′ C i)) ⊆ ⟦ C ⟧ (ν′ C i) helper = map C helper′ ∘ comp helper′ : ∀ {i} → F (ν′ C i) ⊆ ν′ C i force (helper′ x) = helper (mono (λ y → force y) x) -- A variant of helper that is perhaps a bit easier to follow. helper″ : ∀ {i} → F (ν C i) ⊆ ν C i helper″ {i} = F (ν C i) ⊆⟨⟩ F (⟦ C ⟧ (ν′ C i)) ⊆⟨ comp ⟩ ⟦ C ⟧ (F (ν′ C i)) ⊆⟨ map C helper′ ⟩ ⟦ C ⟧ (ν′ C i) ⊆⟨ id ⟩∎ ν C i ∎ -- This definition is definitionally equal to helper. helper″≡helper : (λ {i x} → helper″ {i = i} {x = x}) ≡ helper helper″≡helper = refl -- Monotone, compatible transformers are size-preserving. monotone→compatible→size-preserving : ∀ {F} → Monotone F → Compatible F → Size-preserving F monotone→compatible→size-preserving mono comp = monotone→compatible′→size-preserving mono comp -- Extensive, size-preserving transformers satisfy the special case of -- compatibility. extensive→size-preserving→compatible′ : ∀ {F} → Extensive F → Size-preserving F → Compatible′ F extensive→size-preserving→compatible′ {F} extensive pres {i} = F (⟦ C ⟧ (ν′ C i)) ⊆⟨⟩ F (ν C i) ⊆⟨ pres id ⟩ ν C i ⊆⟨⟩ ⟦ C ⟧ (ν′ C i) ⊆⟨ map C (extensive _) ⟩∎ ⟦ C ⟧ (F (ν′ C i)) ∎ -- For monotone and extensive transformers the special case of -- compatibility is logically equivalent to being size-preserving. -- -- However, size-preserving transformers are not necessarily -- compatible, not even if they are monotone and extensive, see -- Bisimilarity.Up-to.Counterexamples.∃monotone×extensive×size-preserving׬compatible. -- Thus the property of being size-preserving is more general than the -- property of being compatible. However, it is more well-behaved than -- Up-to-technique, because it is closed under composition (see -- ∘-closure below). monotone→extensive→size-preserving⇔compatible′ : ∀ {F} → Monotone F → Extensive F → Size-preserving F ⇔ Compatible′ F monotone→extensive→size-preserving⇔compatible′ mono extensive = record { to = extensive→size-preserving→compatible′ extensive ; from = monotone→compatible′→size-preserving mono } -- The following four lemmas correspond to Pous and Sangiorgi's -- Proposition 6.3.11. -- The identity function is size-preserving. id-size-preserving : Size-preserving id id-size-preserving = id -- If R is contained in ν C ∞, then const R is size-preserving. const-size-preserving : {R : Rel ℓ I} → R ⊆ ν C ∞ → Size-preserving (const R) const-size-preserving R⊆∼ _ = R⊆∼ -- If F and G are both size-preserving, then F ∘ G is also -- size-preserving. ∘-closure : ∀ {F G} → Size-preserving F → Size-preserving G → Size-preserving (F ∘ G) ∘-closure F-pres G-pres = F-pres ∘ G-pres private -- An alternative implementation of ∘-closure which might be a bit -- easier to follow. ∘-closure′ : ∀ {F G} → Size-preserving F → Size-preserving G → Size-preserving (F ∘ G) ∘-closure′ {F} {G} F-pres G-pres {R = R} {i = i} = R ⊆ ν C i ↝⟨ G-pres ⟩ G R ⊆ ν C i ↝⟨ F-pres ⟩□ F (G R) ⊆ ν C i □ -- If F is a family of size-preserving transformers, then ⋃ lzero F is -- also size-preserving. ⋃-closure : {A : Type ℓ} {F : A → Trans ℓ I} → (∀ a → Size-preserving (F a)) → Size-preserving (⋃ lzero F) ⋃-closure {F = F} pres {R = R} {i = i} = R ⊆ ν C i ↝⟨ (λ R⊆∼ {_} → uncurry λ a → F a R ⊆⟨ pres a (λ {_} → R⊆∼ {_}) ⟩∎ ν C i ∎) ⟩□ (λ b → ∃ λ a → F a R b) ⊆ ν C i □ -- If F and G are both size-preserving, then -- λ R → F R ∪ G R is also size-preserving. ∪-closure : {F G : Trans ℓ I} → Size-preserving F → Size-preserving G → Size-preserving (λ R → F R ∪ G R) ∪-closure {F} {G} F-pres G-pres {R = R} {i = i} = R ⊆ ν C i ↝⟨ (λ R⊆∼ {_} → [ F-pres (R⊆∼ {_}) , G-pres (R⊆∼ {_}) ]) ⟩□ F R ∪ G R ⊆ ν C i □ ------------------------------------------------------------------------ -- The companion -- The companion. -- -- The name comes from "Coinduction All the Way Up" by Pous, but this -- definition is based on the one presented by Parrow and Weber in -- "The Largest Respectful Function". Companion : Trans ℓ I Companion R x = ∀ {i} → R ⊆ ν C i → ν C i x -- Another conservative approximation of "up-to technique": being -- below the companion. This notion was presented by Pous in -- "Coinduction All the Way Up". Below-the-companion : Trans ℓ I → Type (lsuc ℓ) Below-the-companion F = ∀ {R} → F R ⊆ Companion R -- A transformer is below the companion iff it is size-preserving. -- -- This is a generalisation of the following result, which is based on -- a proposition due to Pous and Rot. below-the-companion⇔size-preserving : ∀ {F} → Below-the-companion F ⇔ Size-preserving F below-the-companion⇔size-preserving {F} = record { to = λ below R⊆νCi x → below x R⊆νCi ; from = λ pres x R⊆νCi → pres R⊆νCi x } -- A monotone transformer F is below the companion iff, for all -- sizes i, ν C i is a pre-fixpoint of F. -- -- This corresponds roughly to Proposition 5.2 in "Companions, -- Codensity and Causality" by Pous and Rot. monotone→below-the-companion⇔size-preserving : ∀ {F} → Monotone F → Below-the-companion F ⇔ (∀ {i} → F (ν C i) ⊆ ν C i) monotone→below-the-companion⇔size-preserving {F} mono = Below-the-companion F ↝⟨ below-the-companion⇔size-preserving ⟩ Size-preserving F ↝⟨ monotone→⇔ mono ⟩□ (∀ {i} → F (ν C i) ⊆ ν C i) □ -- The companion is size-preserving. companion-size-preserving : Size-preserving Companion companion-size-preserving = _⇔_.to below-the-companion⇔size-preserving id -- The companion is monotone. -- -- This result corresponds to Lemma 2.13 in "The Largest Respectful -- Function". companion-monotone : Monotone Companion companion-monotone R⊆S f S⊆νCi = f (S⊆νCi ∘ R⊆S) -- A preservation lemma. companion-cong : ∀ {k R S} → Extensionality? ⌊ k ⌋-sym ℓ ℓ → (∀ {x} → R x ↝[ ⌊ k ⌋-sym ] S x) → (∀ {x} → Companion R x ↝[ ⌊ k ⌋-sym ] Companion S x) companion-cong {k} {R} {S} ext R↝S {x} = (∀ {i} → R ⊆ ν C i → ν C i x) ↝⟨ implicit-∀-size-cong (lower-extensionality? ⌊ k ⌋-sym _ lzero ext) (→-cong ext (⊆-cong ext R↝S F.id) F.id) ⟩□ (∀ {i} → S ⊆ ν C i → ν C i x) □ -- The companion is an up-to technique. companion-up-to : Up-to-technique Companion companion-up-to = size-preserving→up-to companion-size-preserving -- The following four lemmas correspond to parts of Lemma 3.2 from -- "Coinduction All the Way Up". -- The identity function is below the companion. id-below : Below-the-companion id id-below x f = f x private -- An alternative implementation that might be a bit easier to -- follow. id-below′ : Below-the-companion id id-below′ {R = R} {x = x} Rx {i} = R ⊆ ν C i ↝⟨ (λ f → f Rx) ⟩□ ν C i x □ -- ⟦ C ⟧ is below the companion. ⟦⟧-below : Below-the-companion ⟦ C ⟧ ⟦⟧-below x = ν-in C ∘ (λ f → f x) ∘ map C private -- An alternative implementation that might be a bit easier to -- follow. ⟦⟧-below′ : Below-the-companion ⟦ C ⟧ ⟦⟧-below′ {R = R} {x = x} CR {i} = R ⊆ ν C i ↝⟨ map C ⟩ ⟦ C ⟧ R ⊆ ⟦ C ⟧ (ν C i) ↝⟨ (λ f → f CR) ⟩ ⟦ C ⟧ (ν C i) x ↝⟨ ν-in C ⟩□ ν C i x □ -- The companion composed with itself is below the companion. companion∘companion-below : Below-the-companion (Companion ∘ Companion) companion∘companion-below = _⇔_.from below-the-companion⇔size-preserving (∘-closure companion-size-preserving companion-size-preserving) -- The companion is idempotent (in a certain sense). companion-idempotent : ∀ R {x} → Companion (Companion R) x ⇔ Companion R x companion-idempotent R = record { to = companion∘companion-below ; from = Companion R ⊆⟨ companion-monotone id-below ⟩∎ Companion (Companion R) ∎ } -- An example illustrating how some of the lemmas above can be used: -- If F is below the companion, then ⟦ C ⟧ ∘ F is below -- Companion ∘ Companion, which is below the companion. below-the-companion-example : ∀ {F} → Below-the-companion F → Below-the-companion (⟦ C ⟧ ∘ F) below-the-companion-example {F} = F Below Companion ↝⟨ ∘-cong₂ companion-monotone ⟦⟧-below ⟩ (⟦ C ⟧ ∘ F) Below (Companion ∘ Companion) ↝⟨ (λ below {_ _} → companion∘companion-below ∘ below {_}) ⟩□ (⟦ C ⟧ ∘ F) Below Companion □ where _Below_ : Trans ℓ I → Trans ℓ I → Type (lsuc ℓ) F Below G = ∀ {R} → F R ⊆ G R ∘-cong₂ : ∀ {F₁ F₂ G₁ G₂ : Trans ℓ I} → Monotone F₂ → F₁ Below F₂ → G₁ Below G₂ → (F₁ ∘ G₁) Below (F₂ ∘ G₂) ∘-cong₂ {F₁} {F₂} {G₁} {G₂} F₂-mono F₁⊆F₂ G₁⊆G₂ {R} = F₁ (G₁ R) ⊆⟨ F₁⊆F₂ ⟩ F₂ (G₁ R) ⊆⟨ F₂-mono G₁⊆G₂ ⟩∎ F₂ (G₂ R) ∎ -- The greatest fixpoint ν C ∞ is pointwise logically equivalent to -- the companion applied to an empty relation. -- -- This corresponds to Theorem 3.3 from "Coinduction All the Way Up". ν⇔companion-⊥ : ∀ {x} → ν C ∞ x ⇔ Companion (λ _ → ⊥) x ν⇔companion-⊥ {x} = record { to = λ x _ → x ; from = λ f → f (λ ()) } -- Every "partial" fixpoint ν C i is a pre-fixpoint of the companion. companion-ν⊆ν : ∀ {i} → Companion (ν C i) ⊆ ν C i companion-ν⊆ν {i} = (∀ {j} → ν C i ⊆ ν C j → ν C j _) ↝⟨ (λ hyp → hyp id) ⟩□ ν C i _ □ -- Every "partial" fixpoint ν′ C i is a pre-fixpoint of the companion. companion-ν′⊆ν′ : ∀ {i} → Companion (ν′ C i) ⊆ ν′ C i force (companion-ν′⊆ν′ hyp) = companion-ν⊆ν (companion-monotone (λ x → force x) hyp) -- The companion applied to the greatest fixpoint ν C ∞ is pointwise -- logically equivalent to the greatest fixpoint. -- -- This corresponds to Corollary 3.4 from "Coinduction All the Way -- Up". companion-ν⇔ν : ∀ {x} → Companion (ν C ∞) x ⇔ ν C ∞ x companion-ν⇔ν {x} = record { to = companion-ν⊆ν ; from = ν C ∞ ⊆⟨ _⇔_.to ν⇔companion-⊥ ⟩ Companion (λ _ → ⊥) ⊆⟨ companion-monotone (λ ()) ⟩∎ Companion (ν C ∞) ∎ } -- If "one half of f-symmetry" holds for R, for some involution f, -- then the other half also holds. -- -- (Pous mentions something similar in "Coinduction All the Way Up".) other-half-of-symmetry : {f : I → I} → f ∘ f ≡ id → (R : Rel ℓ I) → R ∘ f ⊆ R → R ⊆ R ∘ f other-half-of-symmetry {f} f-involution R R∘f⊆R = R ⊆⟨ (λ {x} → subst (λ g → R (g x)) (sym f-involution)) ⟩ R ∘ f ∘ f ⊆⟨ R∘f⊆R ⟩∎ R ∘ f ∎ -- The results in the following module are based on Proposition 7.1 in -- "Coinduction All the Way Up". module _ (D : Container I I) (f : I → I) (f-involution : f ∘ f ≡ id) (C⇔⟷D : ∀ {R : Rel ℓ I} {x} → ⟦ C ⟧ R x ⇔ ⟦ D ⊗ reindex f D ⟧ R x) where mutual ν-symmetric : ∀ {i} → ν C i ∘ f ⊆ ν C i ν-symmetric {i} = ν C i ∘ f ⊆⟨⟩ ⟦ C ⟧ (ν′ C i) ∘ f ⊆⟨ _⇔_.to C⇔⟷D ⟩ ⟦ D ⊗ reindex f D ⟧ (ν′ C i) ∘ f ⊆⟨ ⟦⊗⟧↔ _ D (reindex f D) ⟩ ⟦ D ⟧ (ν′ C i) ∘ f ∩ ⟦ reindex f D ⟧ (ν′ C i) ∘ f ⊆⟨ Σ-map id (⟦reindex⟧↔ _ D) ⟩ ⟦ D ⟧ (ν′ C i) ∘ f ∩ ⟦ D ⟧ (ν′ C i ∘ f) ∘ f ∘ f ⊆⟨ (λ {x} → Σ-map id (subst (λ g → ⟦ D ⟧ (ν′ C i ∘ f) (g x)) f-involution)) ⟩ ⟦ D ⟧ (ν′ C i) ∘ f ∩ ⟦ D ⟧ (ν′ C i ∘ f) ⊆⟨ Σ-map (map D (other-half-of-symmetry f-involution (ν′ C i) ν′-symmetric)) (map D ν′-symmetric) ⟩ ⟦ D ⟧ (ν′ C i ∘ f) ∘ f ∩ ⟦ D ⟧ (ν′ C i) ⊆⟨ swap ⟩ ⟦ D ⟧ (ν′ C i) ∩ ⟦ D ⟧ (ν′ C i ∘ f) ∘ f ⊆⟨ Σ-map id (_⇔_.from (⟦reindex⟧↔ _ D)) ⟩ ⟦ D ⟧ (ν′ C i) ∩ ⟦ reindex f D ⟧ (ν′ C i) ⊆⟨ _⇔_.from (⟦⊗⟧↔ _ D (reindex f D)) ⟩ ⟦ D ⊗ reindex f D ⟧ (ν′ C i) ⊆⟨ _⇔_.from C⇔⟷D ⟩ ⟦ C ⟧ (ν′ C i) ⊆⟨ id ⟩∎ ν C i ∎ ν′-symmetric : ∀ {i} → ν′ C i ∘ f ⊆ ν′ C i force (ν′-symmetric x) = ν-symmetric (force x) companion-symmetric : ∀ {R} → Companion R ∘ f ⊆ Companion R companion-symmetric {R} {x} = Companion R (f x) ↔⟨⟩ (∀ {i} → R ⊆ ν C i → ν C i (f x)) ↝⟨ (λ hyp R⊆ν → ν-symmetric (hyp R⊆ν)) ⦂ (_ → (∀ {i} → R ⊆ ν C i → ν C i x)) ⟩ (∀ {i} → R ⊆ ν C i → ν C i x) ↔⟨⟩ Companion R x □ symmetry-lemma : {R S : Rel ℓ I} → R ∘ f ⊆ R → R ⊆ ⟦ C ⟧ (Companion S) ⇔ R ⊆ ⟦ D ⟧ (Companion S) symmetry-lemma {R} {S} R-sym = record { to = to; from = from } where lemma = λ {x} → ⟦ C ⟧ (Companion S) x ↝⟨ C⇔⟷D ⟩ ⟦ D ⊗ reindex f D ⟧ (Companion S) x ↝⟨ ⟦⊗⟧↔ _ D (reindex f D) ⟩ ⟦ D ⟧ (Companion S) x × ⟦ reindex f D ⟧ (Companion S) x ↝⟨ ∃-cong (λ _ → ⟦reindex⟧↔ _ D) ⟩□ ⟦ D ⟧ (Companion S) x × ⟦ D ⟧ (Companion S ∘ f) (f x) □ to : R ⊆ ⟦ C ⟧ (Companion S) → R ⊆ ⟦ D ⟧ (Companion S) to R⊆CCS = R ⊆⟨ R⊆CCS ⟩ ⟦ C ⟧ (Companion S) ⊆⟨ _⇔_.to lemma ⟩ ⟦ D ⟧ (Companion S) ∩ ⟦ D ⟧ (Companion S ∘ f) ∘ f ⊆⟨ proj₁ ⟩∎ ⟦ D ⟧ (Companion S) ∎ from : R ⊆ ⟦ D ⟧ (Companion S) → R ⊆ ⟦ C ⟧ (Companion S) from R⊆DCS = R ⊆⟨ (λ x → x , x) ⟩ R ∩ R ⊆⟨ Σ-map id (other-half-of-symmetry f-involution R R-sym) ⟩ R ∩ R ∘ f ⊆⟨ Σ-map R⊆DCS R⊆DCS ⟩ ⟦ D ⟧ (Companion S) ∩ ⟦ D ⟧ (Companion S) ∘ f ⊆⟨ Σ-map id (map D (other-half-of-symmetry f-involution (Companion S) companion-symmetric)) ⟩ ⟦ D ⟧ (Companion S) ∩ ⟦ D ⟧ (Companion S ∘ f) ∘ f ⊆⟨ _⇔_.from lemma ⟩∎ ⟦ C ⟧ (Companion S) ∎ -- Pous defines the companion in roughly the following way in -- "Coinduction All the Way Up". -- -- Note that this definition is large. Companion₁ : Rel ℓ I → Rel (lsuc ℓ) I Companion₁ R x = ∃ λ (F : Trans ℓ I) → Monotone F × Compatible F × F R x -- Pous' variant of the companion is compatible (modulo size issues). -- -- This corresponds to Lemma 3.2 from "Coinduction All the Way Up". companion₁-compatible : ∀ R → Companion₁ (⟦ C ⟧ R) ⊆ ⟦ C ⟧ (Companion₁ R) companion₁-compatible R {x} (F , mono , comp , FCR) = $⟨ FCR ⟩ F (⟦ C ⟧ R) x ↝⟨ comp ⟩ ⟦ C ⟧ (F R) x ↝⟨ map C (λ FR → F , (λ {_ _} → mono) , (λ {_ _} → comp) , FR) ⟩□ ⟦ C ⟧ (Companion₁ R) x □ -- Pous' variant of the companion is monotone. companion₁-monotone : ∀ {R S} → R ⊆ S → Companion₁ R ⊆ Companion₁ S companion₁-monotone R⊆S = ∃-cong λ _ → ∃-cong λ mono → ∃-cong λ _ → mono R⊆S -- Pous' variant of the companion is contained in Companion. companion₁⊆companion : ∀ {R} → Companion₁ R ⊆ Companion R companion₁⊆companion (F , mono , comp , x) = _⇔_.from below-the-companion⇔size-preserving (monotone→compatible→size-preserving mono comp) x -- The other direction holds iff Companion is compatible. -- -- However, I don't know if Companion is provably compatible (in -- predicative, constructive type theory). companion-compatible⇔companion⊆companion₁ : Compatible Companion ⇔ (∀ {R} → Companion R ⊆ Companion₁ R) companion-compatible⇔companion⊆companion₁ = record { to = λ comp f → (Companion , companion-monotone , comp , f) ; from = λ below f → let (F , mono , comp , FCR) = below f in map C ((λ FR → companion₁⊆companion (F , mono , comp , FR)) ⦂ (_ → Companion _ _)) (comp FCR) } where -- An alternative implementation of the from component which might -- be a bit easier to follow. from′ : (∀ {R} → Companion R ⊆ Companion₁ R) → Compatible Companion from′ below {R = R} = Companion (⟦ C ⟧ R) ⊆⟨ below ⟩ Companion₁ (⟦ C ⟧ R) ⊆⟨ (λ { (F , mono , comp , x) → (_$ x) ( F (⟦ C ⟧ R) ⊆⟨ comp ⟩ ⟦ C ⟧ (F R) ⊆⟨ map C ( F R ⊆⟨ (λ y → F , (λ {_ _} → mono) , (λ {_ _} → comp) , y) ⟩ Companion₁ R ⊆⟨ companion₁⊆companion ⟩∎ Companion R ∎) ⟩∎ ⟦ C ⟧ (Companion R) ∎) }) ⟩∎ ⟦ C ⟧ (Companion R) ∎ -- Assumptions used by companion-compatible below. record Companion-compatible-assumptions : Type (lsuc ℓ) where field -- A strong form of excluded middle, not compatible with -- univalence. excluded-middle : (P : Type ℓ) → Dec P -- The type i < j means that i is a smaller size than j, i ≣ j means -- that i is equal to j, and i ≤ j means that i is smaller than or -- equal to j. infix 4 _<_ _≣_ _≤_ _<_ : Size → Size → Type _<_ = λ i j → Σ (Size< j in-type) λ { k → record { size = i } ≡ k } _≣_ : Size → Size → Type _≣_ = λ i j → _≡_ {A = Size in-type} (record { size = i }) (record { size = j }) _≤_ : Size → Size → Type _≤_ = λ i j → i < j ⊎ i ≣ j -- Successor sizes: Sizes i for which there is a size j < i such -- that every size k < i satisfies k ≤ j. Successor : Size → Type Successor i = ∃ λ (j : Size< i in-type) → (k : Size< i) → k ≤ size j field -- If i is not smaller than or equal to j, then j is smaller -- than i. ≰→> : ∀ {i j} → ¬ i ≤ j → j < i -- If a predicate from a certain class of predicates is satisfied -- for all sizes smaller than i, but not for i itself, then i is a -- successor size. is-successor : {R : Rel ℓ I} → let P = λ i → R ⊆ ν C i in ∀ i → ((j : Size< i) → P j) → ¬ P i → Successor i -- Size elimination. A very similar elimination principle can at -- the time of writing be implemented in Agda, but Andreas Abel -- has suggested that this implementation should not be allowed. size-elim : (P : Size → Type ℓ) → (∀ i → ((j : Size< i) → P j) → P i) → ∀ i → P i -- A variant of excluded-middle. excluded-middle₀ : (P : Type) → Dec P excluded-middle₀ P = ⊎-map lower (_∘ lift) $ excluded-middle (↑ ℓ P) -- "Not for all" implies "exists not". ¬∀→∃¬ : {A : Type} {P : A → Type ℓ} → ¬ (∀ x → P x) → ∃ λ x → ¬ P x ¬∀→∃¬ {P = P} ¬∀ = case excluded-middle (∃ λ x → ¬ P x) of λ where (inj₁ ∃¬P) → ∃¬P (inj₂ ¬∃¬P) → ⊥-elim (¬∀ λ x → case excluded-middle (P x) of λ where (inj₁ Px) → Px (inj₂ ¬Px) → ⊥-elim (¬∃¬P (x , ¬Px))) -- Given the assumptions above every pair of sizes must be related -- by either _<_, _≡_, or flip _<_. However, note that all three -- relations hold for ∞ and ∞, so we do not get a law of trichotomy. compare : ∀ i j → i < j ⊎ i ≣ j ⊎ j < i compare i j = case excluded-middle₀ (i < j) of λ where (inj₁ i<j) → inj₁ i<j (inj₂ i≮j) → case excluded-middle₀ (i ≣ j) of λ where (inj₁ i≡j) → inj₂ (inj₁ i≡j) (inj₂ i≢j) → inj₂ (inj₂ (≰→> [ i≮j , i≢j ])) -- Given certain assumptions one can prove that the companion is -- compatible. (The proof is based on that of Theorem 2.14 in Parrow -- and Weber's "The Largest Respectful Function".) However, I don't -- know if these assumptions are consistent with the variant of Agda -- that is used in this development. I discussed the assumptions with -- Andreas Abel and Andrea Vezzosi. Some potential problems came up in -- the discussion: -- -- * The fact that ∞ : Size< ∞ could perhaps lead to some kind of -- problem. -- -- * The assumptions make it possible to define functions that give -- completely different results for different sizes (assuming that -- there is more than one size). companion-compatible : Companion-compatible-assumptions → Compatible Companion companion-compatible assumptions {R} = case lemma R of λ where (inj₁ R⊆νC) → Companion (⟦ C ⟧ R) ⊆⟨ _$ map C (λ Rx → λ { .force → R⊆νC Rx }) ⟩ ν C ∞ ⊆⟨ map C ((λ ν′C∞x _ → force ν′C∞x) ⦂ (_ → Companion _ _)) ⟩∎ ⟦ C ⟧ (Companion R) ∎ (inj₂ (1+i , (i , <1+i→≤i) , <1+i→R⊆νC , R⊈νC[1+i])) → let CR⊆νC[1+i] = ⟦ C ⟧ R ⊆⟨ map C (<1+i→R⊆νC (size i)) ⟩ ⟦ C ⟧ (ν C (size i)) ⊆⟨ map C (λ x → λ { .force {j} → cast (<1+i→≤i j) x }) ⟩∎ ν C (size 1+i) ∎ νCi⊆CompanionR = ν C (size i) ⊆⟨ (λ hyp → λ { j≤i → cast j≤i hyp }) ⟩ (λ x → ∀ {j} → j ≤ size i → ν C j x) ⊆⟨ (λ hyp → λ { (j , refl) → hyp (<1+i→≤i (size j)) }) ⟩ (λ x → ∀ {j} → j < size 1+i → ν C j x) ⊆⟨ (λ hyp → λ { j<1+i _ → hyp j<1+i }) ⟩ (λ x → ∀ {j} → j < size 1+i → R ⊆ ν C j → ν C j x) ⊆⟨ (λ hyp → λ { 1+i≰j → hyp (≰→> 1+i≰j) }) ⟩ (λ x → ∀ {j} → ¬ size 1+i ≤ j → R ⊆ ν C j → ν C j x) ⊆⟨ (λ hyp → λ { {j} → [ (λ 1+i≤j R⊆νCj → ⊥-elim $ R⊈νC[1+i] ( R ⊆⟨ (λ {x} → R⊆νCj {x}) ⟩ ν C j ⊆⟨ cast 1+i≤j ⟩∎ ν C (size 1+i) ∎)) , hyp ] }) ⟩ (λ x → ∀ {j} → Dec (size 1+i ≤ j) → R ⊆ ν C j → ν C j x) ⊆⟨ (λ hyp → λ { {_} → hyp (excluded-middle₀ _) }) ⟩ (λ x → ∀ {j} → R ⊆ ν C j → ν C j x) ⊆⟨ id ⟩∎ Companion R ∎ ν′C[1+i]⊆νCi : ν′ C (size 1+i) ⊆ ν C (size i) ν′C[1+i]⊆νCi {x} y = let y′ : (j : Size< (size 1+i)) → ν C j x y′ = λ { j → y .force {j = j} } in y′ (size i) in Companion (⟦ C ⟧ R) ⊆⟨ (λ c → c {i = size 1+i} CR⊆νC[1+i]) ⟩ ν C (size 1+i) ⊆⟨⟩ ⟦ C ⟧ (ν′ C (size 1+i)) ⊆⟨ map C ν′C[1+i]⊆νCi ⟩ ⟦ C ⟧ (ν C (size i)) ⊆⟨ map C νCi⊆CompanionR ⟩∎ ⟦ C ⟧ (Companion R) ∎ where open Companion-compatible-assumptions assumptions cast : ∀ {j k} → j ≤ k → ν C k ⊆ ν C j cast (inj₁ (_ , refl)) x = x cast (inj₂ refl) x = x lemma : ∀ R → (∀ {i} → R ⊆ ν C i) ⊎ ∃ λ i → Successor (size i) × ((j : Size< (size i)) → R ⊆ ν C j) × ¬ R ⊆ ν C (size i) lemma R = case excluded-middle (∀ {i} → R ⊆ ν C i) of ⊎-map id (¬ (∀ {i} → R ⊆ ν C i) ↝⟨ (λ hyp₁ hyp₂ → hyp₁ λ { {i} → hyp₂ {i = record { size = i }} }) ⟩ ¬ (∀ {i} → R ⊆ ν C (size i)) ↝⟨ (λ hyp → ¬∀→∃¬ {P = λ _ → _ ⊆ _} (λ ∀iR⊆νCi → hyp λ {i} → ∀iR⊆νCi i)) ⟩ (∃ λ i → ¬ R ⊆ ν C (size i)) ↝⟨ (λ (i , R⊈νCi) → size-elim (λ i → ¬ R ⊆ ν C i → _) (λ i ind-hyp R⊈νCi → case excluded-middle ((j : Size< i in-type) → R ⊆ ν C (size j)) of λ where (inj₁ ∀<R⊆νC) → record { size = i } , (λ { j → ∀<R⊆νC (record { size = j }) }) , R⊈νCi (inj₂ ¬∀<R⊆νC) → let j , R⊈νCj = ¬∀→∃¬ ¬∀<R⊆νC in ind-hyp (size j) R⊈νCj) (size i) R⊈νCi) ⟩ (∃ λ i → ((j : Size< (size i)) → R ⊆ ν C j) × ¬ R ⊆ ν C (size i)) ↝⟨ (λ { (i , hyp) → (i , uncurry (is-successor (size i)) hyp , hyp) }) ⟩□ (∃ λ i → Successor (size i) × ((j : Size< (size i)) → R ⊆ ν C j) × ¬ R ⊆ ν C (size i)) □)
{ "alphanum_fraction": 0.5074565948, "avg_line_length": 36.9073001159, "ext": "agda", "hexsha": "68bf7e0546565acdc6c13136dd5d71587f726e0a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/up-to", "max_forks_repo_path": "src/Up-to.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/up-to", "max_issues_repo_path": "src/Up-to.agda", "max_line_length": 145, "max_stars_count": null, "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/up-to", "max_stars_repo_path": "src/Up-to.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11576, "size": 31851 }
module Homogenous.Reflexivity where import Homogenous.Base import Homogenous.Equality open Homogenous.Base using(Arity; Sig; Fa; Fa1; F; F1; T; It; FIHa; FIH; R) open Homogenous.Equality using(equal; eq_step; eq_step'; eq_step_ar) import PolyDepPrelude open PolyDepPrelude using(Bool; true; false; True; pair; fst; snd; zero; suc; left; right; _::_; nil; unit) import Tools open Tools using(liftAnd) import Reflexivity open Reflexivity using(lref; Refl; refl) -- ----------------------------- -- Reflexivity -- Short-hand notation for mapping a rel. over Fa resp. F Fa1rel : (n : Arity)-> (X : Set) -> (X -> X -> Bool) -> Fa n X -> Fa n (X -> Bool) Fa1rel n X r = Fa1 n (\x -> (\y -> r x y) ) F1rel : (fi : Sig)(X : Set) -> (X -> X -> Bool) -> F fi X -> F fi (X -> Bool) F1rel fi X r = F1 fi (\x -> (\y -> r x y) ) -- Now the real reflexivity lemmas start ref_eq_step_ar : (n : Arity) (Y : Set) (e : Y -> Y -> Bool) (x : Fa n Y) (ih : FIHa n (lref e) x) -> True (eq_step_ar n (Fa1rel n Y e x) x) ref_eq_step_ar (zero) Y e (unit) (unit) = unit ref_eq_step_ar (suc m) Y e (pair y ys) (pair r rs) with e y y | r ref_eq_step_ar (suc m) Y e (pair y ys) (pair r rs) | false | () ref_eq_step_ar (suc m) Y e (pair y ys) (pair r rs) | true | unit = ref_eq_step_ar m Y e ys rs -- Reflexivity for matching constructors is trivial ref_eq_step' : (fi : Sig)(X : Set)(e : X -> X -> Bool)(x : F fi X) -> FIH fi (lref e) x -> True (eq_step' fi (F1rel fi X e x) x) ref_eq_step' (nil) X e () -- empty ref_eq_step' (n :: ns) X e (left x') = ref_eq_step_ar n X e x' ref_eq_step' (n :: ns) X e (right y) = ref_eq_step' ns X e y ref_eq' : (fi : Sig) -> (x : T fi) -> lref (equal fi) x ref_eq' fi = R fi (ref_eq_step' fi (T fi) (equal fi)) ref_eq : (fi : Sig) -> Refl (equal fi) ref_eq fi = refl (R fi (ref_eq_step' fi (T fi) (equal fi)))
{ "alphanum_fraction": 0.5664652568, "avg_line_length": 36.7777777778, "ext": "agda", "hexsha": "c3ac2a0d7bb708cac0a4f5779aaf3a9526d3f931", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/AIM5/PolyDep/Homogenous/Reflexivity.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/AIM5/PolyDep/Homogenous/Reflexivity.agda", "max_line_length": 79, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/AIM5/PolyDep/Homogenous/Reflexivity.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 682, "size": 1986 }
open import Agda.Builtin.Bool test : (true : Bool) → Set test = {!!} -- C-c C-c
{ "alphanum_fraction": 0.5853658537, "avg_line_length": 16.4, "ext": "agda", "hexsha": "5e45d11140d4945d5f2959b7969cf203525d077a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue2522-case.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue2522-case.agda", "max_line_length": 29, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2522-case.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 29, "size": 82 }
{-# OPTIONS --without-K #-} module sets.nat.ordering.leq.core where open import decidable open import equality.core open import function.core open import sets.nat.core open import sets.empty data _≤_ : ℕ → ℕ → Set where z≤n : ∀ {n} → zero ≤ n s≤s : ∀ {m n} (p : m ≤ n) → suc m ≤ suc n ap-pred-≤ : ∀ {n m} → suc n ≤ suc m → n ≤ m ap-pred-≤ (s≤s p) = p refl≤ : {n : ℕ} → n ≤ n refl≤ {0} = z≤n refl≤ {suc n} = s≤s refl≤ ≡⇒≤ : {n m : ℕ} → n ≡ m → n ≤ m ≡⇒≤ refl = refl≤ suc≤ : ∀ {n} → n ≤ suc n suc≤ {0} = z≤n suc≤ {suc n} = s≤s suc≤ suc≰ : ∀ {n} → ¬ (suc n ≤ n) suc≰ {zero} () suc≰ {suc n} p = suc≰ (ap-pred-≤ p) trans≤ : ∀ {n m p} → n ≤ m → m ≤ p → n ≤ p trans≤ z≤n q = z≤n trans≤ (s≤s p) (s≤s q) = s≤s (trans≤ p q) antisym≤ : ∀ {n m} → n ≤ m → m ≤ n → n ≡ m antisym≤ z≤n z≤n = refl antisym≤ (s≤s p) (s≤s q) = ap suc (antisym≤ p q)
{ "alphanum_fraction": 0.5029655991, "avg_line_length": 21.6153846154, "ext": "agda", "hexsha": "4b28620c665403c3d6c45763ba53e6ed9b53a0f8", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/sets/nat/ordering/leq/core.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/sets/nat/ordering/leq/core.agda", "max_line_length": 48, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/sets/nat/ordering/leq/core.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 448, "size": 843 }
-- You can't define the same module twice. module ClashingModule where module A where module A where open A
{ "alphanum_fraction": 0.7727272727, "avg_line_length": 13.75, "ext": "agda", "hexsha": "d732f22995e43bfbf0b295fe0129bca1da409a6f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/ClashingModule.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/ClashingModule.agda", "max_line_length": 42, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/ClashingModule.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 27, "size": 110 }
module Nat where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) data ℕ : Set where zero : ℕ suc : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} _+_ : ℕ → ℕ → ℕ zero + n = n (suc m) + n = suc (m + n) _ : 2 + 3 ≡ 5 _ = begin 2 + 3 ≡⟨⟩ suc (1 + 3) ≡⟨⟩ suc (suc (0 + 3)) ≡⟨⟩ suc (suc 3) ≡⟨⟩ 5 ∎
{ "alphanum_fraction": 0.4876237624, "avg_line_length": 12.625, "ext": "agda", "hexsha": "c48f04dc0d15c691a635bd307464d6d7268063b3", "lang": "Agda", "max_forks_count": 304, "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_path": "extra/extra/Nat.agda", "max_issues_count": 323, "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_path": "extra/extra/Nat.agda", "max_line_length": 50, "max_stars_count": 1003, "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_path": "extra/extra/Nat.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "num_tokens": 192, "size": 404 }
{- This example goes through now that we allow instantiation of blocked terms #-} module Issue439 where record Σ (A : Set) (B : A → Set) : Set where constructor _,_ field p₁ : A p₂ : B p₁ open Σ record ⊤ : Set where data Tree : Set where leaf : Tree node : Tree → Tree → Tree mutual U : Tree → Set U leaf = ⊤ U (node tr₁ tr₂) = Σ (U tr₁) λ a → El a → U tr₂ El : ∀ {tr} → U tr → Set El {leaf} _ = ⊤ El {node tr₁ tr₂} (a , b) = (x : El a) → El (b x) mutual data C : Set where c : (Γ : C) → T Γ → C T : C → Set T Γ = Σ Tree (λ tr → E Γ → U tr) E : C → Set E (c Γ σ) = Σ (E Γ) λ γ → El (p₂ σ γ) postulate e : C M : (Γ : C) → T Γ → Set z : ∀ {Γ σ} → M (c Γ σ) (p₁ σ , λ γ → p₂ σ (p₁ γ)) l : ∀ {Γ} σ {τ} → M (c Γ σ) τ → M Γ (_ , λ γ → p₂ σ γ , λ v → p₂ τ (γ , v)) a : ∀ {Γ tr₁ tr₂ σ} → M Γ (node tr₁ tr₂ , σ) → M Γ (tr₁ , λ γ → p₁ (σ γ)) → M Γ (leaf , _) s : ∀ {Γ} → M Γ (leaf , _) t : ∀ {Γ σ} → M Γ σ → T Γ t {σ = σ} _ = σ foo : M (c e (leaf , _)) (leaf , _) foo = a (l (t s) z) z
{ "alphanum_fraction": 0.4595103578, "avg_line_length": 18.9642857143, "ext": "agda", "hexsha": "5c1021ad4602ca36cabbc4bf78b9c3732d7fbcab", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue439.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue439.agda", "max_line_length": 63, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue439.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 473, "size": 1062 }
{-# OPTIONS --without-K --safe #-} module Data.Quiver.Paths where -- Paths in a Quiver. -- -- This is almost the same as the 'paths' in a relation, as defined in -- Relation.Binary.Construct.Closure.ReflexiveTransitive -- but here the relation is typed, and that has to be respected. So this -- is somewhat duplicated open import Level open import Data.Quiver open import Relation.Binary using (Rel; IsEquivalence; Setoid) import Relation.Binary.Reasoning.Setoid as EqR open import Relation.Binary.Construct.Closure.ReflexiveTransitive open import Relation.Binary.PropositionalEquality as ≡ using (_≡_) module Paths {o ℓ e : Level} (Q : Quiver o ℓ e) where open Quiver Q hiding (setoid) private variable A B : Obj infix 4 _≈*_ data _≈*_ : (p q : Star _⇒_ A B) → Set (o ⊔ ℓ ⊔ e) where ε : {A : Obj} → _≈*_ {A} ε ε _◅_ : {A B C : Obj} {x y : A ⇒ B} {p q : Star _⇒_ B C} (x≈y : x ≈ y) (p≈q : p ≈* q) → x ◅ p ≈* y ◅ q refl : {p : Star _⇒_ A B} → p ≈* p refl {p = ε} = ε refl {p = x ◅ p} = Equiv.refl ◅ refl sym : {p q : Star _⇒_ A B} → p ≈* q → q ≈* p sym ε = ε sym (x≈y ◅ eq) = Equiv.sym x≈y ◅ sym eq ≡⇒≈* : {p q : Star _⇒_ A B} → p ≡ q → p ≈* q ≡⇒≈* ≡.refl = refl ≡⇒≈ : {p q : A ⇒ B} → p ≡ q → p ≈ q ≡⇒≈ ≡.refl = Equiv.refl trans : {p q r : Star _⇒_ A B} → p ≈* q → q ≈* r → p ≈* r trans ε ε = ε trans (x≈y ◅ ss) (y≈z ◅ tt) = Equiv.trans x≈y y≈z ◅ trans ss tt isEquivalence : IsEquivalence (λ (p q : Star _⇒_ A B) → p ≈* q) isEquivalence = record { refl = refl ; sym = sym ; trans = trans } setoid : Obj → Obj → Setoid (o ⊔ ℓ) (o ⊔ ℓ ⊔ e) setoid A B = record { _≈_ = _≈*_ ; isEquivalence = isEquivalence {A} {B} } -- convenient to define here -- -- FIXME: this should go into the standard library at -- Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties ◅◅-identityʳ : (f : Star _⇒_ A B) → f ◅◅ ε ≈* f ◅◅-identityʳ ε = ε ◅◅-identityʳ (x ◅ f) = Equiv.refl ◅ ◅◅-identityʳ f module PathEqualityReasoning {A B} where open EqR (setoid A B) public
{ "alphanum_fraction": 0.5919960957, "avg_line_length": 31.5230769231, "ext": "agda", "hexsha": "8d9ef8faddcccefe1616c72b3394985bfc96b838", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Data/Quiver/Paths.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Data/Quiver/Paths.agda", "max_line_length": 104, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Data/Quiver/Paths.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 860, "size": 2049 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Base definitions for the right-biased universe-sensitive functor -- and monad instances for the Product type. -- -- To minimize the universe level of the RawFunctor, we require that -- elements of B are "lifted" to a copy of B at a higher universe level -- (a ⊔ b). See the Data.Product.Categorical.Examples for how this is -- done. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Level module Data.Product.Categorical.Right.Base {b} (B : Set b) (a : Level) where open import Data.Product using (_×_; map₁; proj₁; proj₂; <_,_>) open import Category.Functor using (RawFunctor) open import Category.Comonad using (RawComonad) ------------------------------------------------------------------------ -- Definitions Productᵣ : Set (a ⊔ b) → Set (a ⊔ b) Productᵣ A = A × B functor : RawFunctor Productᵣ functor = record { _<$>_ = map₁ } comonad : RawComonad Productᵣ comonad = record { extract = proj₁ ; extend = <_, proj₂ > }
{ "alphanum_fraction": 0.563002681, "avg_line_length": 29.4473684211, "ext": "agda", "hexsha": "55264e646052e1b60e1c1adfb43d3ded7450bbb9", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Categorical/Right/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Categorical/Right/Base.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Product/Categorical/Right/Base.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 274, "size": 1119 }
{-# OPTIONS --no-positivity-check #-} module Section4a where open import Section3 public -- 4. The semantic model -- ===================== -- -- As we want to deal with full conversion on open terms and the η-rule, we choose to describe -- the semantics in a Kripke style model [6, 11, 15]. A Kripke model is a set of possible worlds, -- `𝒲 : Set`, with a partial ordering `⊒ : 𝒲 → 𝒲 → Set`, of extensions of worlds. We also have -- a family of ground sets `𝒢 : 𝒲 → Set` over possible worlds which are the interpretation of -- the base type. We also need independence of the proof of `_⊒_`, i.e., if `c₁, c₂ : w′ ⊒ w`, then -- `c₁ ≡ c₂`. (…) record Model : Set₁ where infix 3 _⊒_ field 𝒲 : Set _⊒_ : 𝒲 → 𝒲 → Set refl⊒ : ∀ {w} → w ⊒ w _◇_ : ∀ {w w′ w″} → w′ ⊒ w → w″ ⊒ w′ → w″ ⊒ w uniq⊒ : ∀ {w w′} → (c c′ : w′ ⊒ w) → c ≡ c′ 𝒢 : 𝒲 → Set open Model {{…}} public module _ {{_ : Model}} where trans⊒ : ∀ {w w′ w″} → w″ ⊒ w′ → w′ ⊒ w → w″ ⊒ w trans⊒ = flip _◇_ id₁◇ : ∀ {w w′} → (c : w ⊒ w) (c′ : w′ ⊒ w) → c ◇ c′ ≡ c′ id₁◇ c c′ = uniq⊒ (c ◇ c′) c′ id₂◇ : ∀ {w w′} → (c : w′ ⊒ w) (c′ : w′ ⊒ w′) → c ◇ c′ ≡ c id₂◇ c c′ = uniq⊒ (c ◇ c′) c assoc◇ : ∀ {w w′ w″ w‴} → (c : w′ ⊒ w) (c′ : w″ ⊒ w′) (c″ : w‴ ⊒ w″) → c ◇ (c′ ◇ c″) ≡ (c ◇ c′) ◇ c″ assoc◇ c c′ c″ = uniq⊒ (c ◇ (c′ ◇ c″)) ((c ◇ c′) ◇ c″) comp◇ : ∀ {w w′ w″} → (c : w′ ⊒ w) (c′ : w″ ⊒ w′) (c″ : w″ ⊒ w) → c ◇ c′ ≡ c″ comp◇ c c′ c″ = uniq⊒ (c ◇ c′) c″ -- 4.1. Semantic objects -- --------------------- -- -- We define the set of semantic objects as usual in Kripke semantics. -- -- Forcing is written `w ⊩ A`. For the base type an element in `w ⊩ •` is a family of -- elements in `𝒢 w′`, `w′ ⊒ w`. For the type `A ⊃ B` an element in `w ⊩ A ⊃ B` is a family of -- functions from `w′ ⊩ A` to `w′ ⊩ B`, `w′ ⊒ w`. (…) module _ {{_ : Model}} where -- TODO: Replace with strictly positive definition infix 3 _⊩_ data _⊩_ : 𝒲 → 𝒯 → Set where ⟦𝒢⟧ : ∀ {w} → (∀ {w′} → w′ ⊒ w → 𝒢 w′) → w ⊩ • ⟦ƛ⟧ : ∀ {w A B} → (∀ {w′} → w′ ⊒ w → w′ ⊩ A → w′ ⊩ B) → w ⊩ A ⊃ B -- We use the notational convention `⟦𝒢⟧` for the semantics of the ground type and -- `⟦ƛ⟧` for the semantics of the function type. -- -- We define the following two elimination rules: (…) module _ {{_ : Model}} where _⟦g⟧⟨_⟩ : ∀ {w w′} → w ⊩ • → w′ ⊒ w → 𝒢 w′ (⟦𝒢⟧ f) ⟦g⟧⟨ c ⟩ = f c _⟦∙⟧⟨_⟩_ : ∀ {w w′ A B} → w ⊩ A ⊃ B → w′ ⊒ w → w′ ⊩ A → w′ ⊩ B (⟦ƛ⟧ f) ⟦∙⟧⟨ c ⟩ a = f c a -- The monotonicity function `↑⟨_⟩⊩` lifts a semantic object in one world into a semantic object -- in a bigger world and is defined by induction on the type. (…) module _ {{_ : Model}} where ↑⟨_⟩⊩ : ∀ {A w w′} → w′ ⊒ w → w ⊩ A → w′ ⊩ A ↑⟨_⟩⊩ {•} c f = ⟦𝒢⟧ (λ c′ → f ⟦g⟧⟨ c ◇ c′ ⟩) ↑⟨_⟩⊩ {A ⊃ B} c f = ⟦ƛ⟧ (λ c′ a → f ⟦∙⟧⟨ c ◇ c′ ⟩ a) instance raise⊩ : ∀ {A} → Raiseable (_⊩ A) raise⊩ = record { ↑⟨_⟩ = ↑⟨_⟩⊩ } -- We also need to define an equality, `Eq`, on semantic objects. For the soundness of the -- η-rule we need `f : w ⊩ A ⊃ B` to be equal to `⟦ƛ⟧ (λ c a → f ⟦∙⟧⟨ c ⟩ a)`, which corresponds -- to η-expansion on the semantic level. This means that the equality on our model must be -- extensional and that application and the monotonicity function commutes, i.e., lifting the -- result of an application up to a bigger world should be equal to first lifting the arguments and -- then doing the application. We say that a semantic object is uniform, `𝒰`, if the application and -- monotonicity functions commute for this object (see Scott [17] for a discussion regarding -- commutativity). The predicates `Eq` and `𝒰` are mutually defined. -- -- They both are defined by induction on the types; this way of defining extensionality is -- presented by Gandy [10]. Two semantic objects of base type are equal if they are intensionally -- equal in all bigger worlds and two semantic objects of function type are equal if the -- application of them to a uniform semantic object in a bigger world is extensionally equal. -- -- A semantic object of base type is always uniform. A semantic object of function type is uniform -- if it sends a uniform semantic object in a bigger world to a uniform semantic object, -- if it sends two extensionally equal uniform objects in a bigger worlds to extensionally equal -- semantic objects and if application and monotonicity commute for the semantic object. -- -- The sets `Eq` and `𝒰` are defined by: (…) module _ {{_ : Model}} where mutual data Eq : ∀ {A w} → w ⊩ A → w ⊩ A → Set where eq• : ∀ {w} {f f′ : w ⊩ •} → (∀ {w′} → (c : w′ ⊒ w) → f ⟦g⟧⟨ c ⟩ ≡ f′ ⟦g⟧⟨ c ⟩) → Eq f f′ eq⊃ : ∀ {A B w} {f f′ : w ⊩ A ⊃ B} → (∀ {w′} → (c : w′ ⊒ w) → {a : w′ ⊩ A} → 𝒰 a → Eq (f ⟦∙⟧⟨ c ⟩ a) (f′ ⟦∙⟧⟨ c ⟩ a)) → Eq f f′ data 𝒰 : ∀ {A w} → w ⊩ A → Set where 𝓊• : ∀ {w} {f : w ⊩ •} → 𝒰 f 𝓊⊃ : ∀ {A B w} {f : w ⊩ A ⊃ B} → (∀ {w′} → (c : w′ ⊒ w) → {a : w′ ⊩ A} → 𝒰 a → 𝒰 (f ⟦∙⟧⟨ c ⟩ a)) → (∀ {w′} → (c : w′ ⊒ w) → {a a′ : w′ ⊩ A} → Eq a a′ → 𝒰 a → 𝒰 a′ → Eq (f ⟦∙⟧⟨ c ⟩ a) (f ⟦∙⟧⟨ c ⟩ a′)) → (∀ {w′ w″} → (c : w′ ⊒ w) (c′ : w″ ⊒ w′) (c″ : w″ ⊒ w) → {a : w′ ⊩ A} → 𝒰 a → Eq (↑⟨ c′ ⟩ (f ⟦∙⟧⟨ c ⟩ a)) (f ⟦∙⟧⟨ c″ ⟩ (↑⟨ c′ ⟩ a))) → 𝒰 f -- The equality `Eq` is transitive and symmetric and it is reflexive for uniform objects. module _ {{_ : Model}} where reflEq : ∀ {A w} {a : w ⊩ A} → 𝒰 a → Eq a a reflEq 𝓊• = eq• (λ c → refl) reflEq (𝓊⊃ h₀ h₁ h₂) = eq⊃ (λ c uₐ → reflEq (h₀ c uₐ)) -- TODO: Why do we restrict `Eq` so that it is reflexive only for uniform objects? reflEq′ : ∀ {A w} {a : w ⊩ A} → Eq a a reflEq′ {•} = eq• (λ c → refl) reflEq′ {A ⊃ B} = eq⊃ (λ c uₐ → reflEq′) symEq : ∀ {A w} {a a′ : w ⊩ A} → Eq a a′ → Eq a′ a symEq {•} (eq• h) = eq• (λ c → sym (h c)) symEq {A ⊃ B} (eq⊃ h) = eq⊃ (λ c uₐ → symEq (h c uₐ)) transEq : ∀ {A w} {a a′ a″ : w ⊩ A} → Eq a a′ → Eq a′ a″ → Eq a a″ transEq {•} (eq• h) (eq• h′) = eq• (λ c → trans (h c) (h′ c)) transEq {A ⊃ B} (eq⊃ h) (eq⊃ h′) = eq⊃ (λ c uₐ → transEq (h c uₐ) (h′ c uₐ)) module _ {{_ : Model}} where ≡→Eq : ∀ {A w} {a a′ : w ⊩ A} → 𝒰 a → a ≡ a′ → Eq a a′ ≡→Eq u refl = reflEq u module EqReasoning where infix 1 begin_ begin_ : ∀ {A w} {a a′ : w ⊩ A} → Eq a a′ → Eq a a′ begin eq = eq infixr 2 _Eq⟨⟩_ _Eq⟨⟩_ : ∀ {A w} (a {a′} : w ⊩ A) → Eq a a′ → Eq a a′ a Eq⟨⟩ eq = eq infixr 2 _Eq⟨_⟩_ _Eq⟨_⟩_ : ∀ {A w} (a {a′ a″} : w ⊩ A) → Eq a a′ → Eq a′ a″ → Eq a a″ a Eq⟨ eq ⟩ eq′ = transEq eq eq′ infixr 2 _≡⟨⟩_ _≡⟨⟩_ : ∀ {A w} (a {a′} : w ⊩ A) → Eq a a′ → Eq a a′ a ≡⟨⟩ eq = eq infixr 2 _≡⟨_∣_⟩_ _≡⟨_∣_⟩_ : ∀ {A w} (a {a′ a″} : w ⊩ A) → a ≡ a′ → 𝒰 a → Eq a′ a″ → Eq a a″ a ≡⟨ eq ∣ u ⟩ eq′ = transEq (≡→Eq u eq) eq′ infix 3 _∎⟨_⟩ _∎⟨_⟩ : ∀ {A w} (a : w ⊩ A) → 𝒰 a → Eq a a a ∎⟨ u ⟩ = reflEq u -- Equal uniform values can be substituted in `⟦∙⟧⟨_⟩` and the function `↑⟨_⟩` returns uniform objects -- for uniform input and equal results for equal input. module _ {{_ : Model}} where cong⟦∙⟧⟨_⟩Eq : ∀ {A B w w′} {f f′ : w ⊩ A ⊃ B} {a a′ : w′ ⊩ A} → (c : w′ ⊒ w) → Eq f f′ → 𝒰 f → 𝒰 f′ → Eq a a′ → 𝒰 a → 𝒰 a′ → Eq (f ⟦∙⟧⟨ c ⟩ a) (f′ ⟦∙⟧⟨ c ⟩ a′) cong⟦∙⟧⟨ c ⟩Eq (eq⊃ h) (𝓊⊃ h₀ h₁ h₂) (𝓊⊃ h₀′ h₁′ h₂′) eqₐ uₐ uₐ′ = transEq (h₁ c eqₐ uₐ uₐ′) (h c uₐ′) cong↑⟨_⟩Eq : ∀ {A w w′} {a a′ : w ⊩ A} → (c : w′ ⊒ w) → Eq a a′ → Eq (↑⟨ c ⟩ a) (↑⟨ c ⟩ a′) cong↑⟨ c ⟩Eq (eq• h) = eq• (λ c′ → h (c ◇ c′)) cong↑⟨ c ⟩Eq (eq⊃ h) = eq⊃ (λ c′ uₐ → h (c ◇ c′) uₐ) cong↑⟨_⟩𝒰 : ∀ {A w w′} {a : w ⊩ A} → (c : w′ ⊒ w) → 𝒰 a → 𝒰 (↑⟨ c ⟩ a) cong↑⟨ c ⟩𝒰 𝓊• = 𝓊• cong↑⟨ c ⟩𝒰 (𝓊⊃ h₀ h₁ h₂) = 𝓊⊃ (λ c′ uₐ → h₀ (c ◇ c′) uₐ) (λ c′ eqₐ uₐ uₐ′ → h₁ (c ◇ c′) eqₐ uₐ uₐ′) (λ c′ c″ c‴ uₐ → h₂ (c ◇ c′) c″ (c ◇ c‴) uₐ) -- We also need to prove the following properties about `Eq` and `𝒰` which are used in the proofs of -- soundness and completeness below. module _ {{_ : Model}} where aux₄₁₁⟨_⟩ : ∀ {A w} → (c : w ⊒ w) → {a : w ⊩ A} → 𝒰 a → Eq (↑⟨ c ⟩ a) a aux₄₁₁⟨ c ⟩ {f} 𝓊• = eq• (λ c′ → cong (f ⟦g⟧⟨_⟩) (id₁◇ c c′)) aux₄₁₁⟨ c ⟩ {f} (𝓊⊃ h₀ h₁ h₂) = eq⊃ (λ c′ {a} uₐ → ≡→Eq (h₀ (c ◇ c′) uₐ) (cong (f ⟦∙⟧⟨_⟩ a) (id₁◇ c c′))) aux₄₁₂ : ∀ {A w w′ w″} → (c : w′ ⊒ w) (c′ : w″ ⊒ w′) (c″ : w″ ⊒ w) → {a : w ⊩ A} → 𝒰 a → Eq (↑⟨ c′ ⟩ (↑⟨ c ⟩ a)) (↑⟨ c″ ⟩ a) aux₄₁₂ c c′ c″ {f} 𝓊• = eq• (λ c‴ → cong (f ⟦g⟧⟨_⟩) (trans (assoc◇ c c′ c‴) (comp◇ (c ◇ c′) c‴ (c″ ◇ c‴)))) aux₄₁₂ c c′ c″ {f} (𝓊⊃ h₀ h₁ h₂) = eq⊃ (λ c‴ {a} uₐ → ≡→Eq (h₀ (c ◇ (c′ ◇ c‴)) uₐ) (cong (f ⟦∙⟧⟨_⟩ a) (trans (assoc◇ c c′ c‴) (comp◇ (c ◇ c′) c‴ (c″ ◇ c‴))))) aux₄₁₃ : ∀ {A B w w′} → (c : w′ ⊒ w) (c′ : w′ ⊒ w′) → {f : w ⊩ A ⊃ B} → 𝒰 f → {a : w′ ⊩ A} → 𝒰 a → Eq (f ⟦∙⟧⟨ c ⟩ a) (↑⟨ c ⟩ f ⟦∙⟧⟨ c′ ⟩ a) aux₄₁₃ c c′ {f} (𝓊⊃ h₀ h₁ h₂) {a} uₐ = ≡→Eq (h₀ c uₐ) (cong (f ⟦∙⟧⟨_⟩ a) (sym (id₂◇ c c′))) -- 4.2. Semantic environments -- -------------------------- -- -- We define the set of environments `_⊩⋆_` -- where each variable in a context is associated with a semantic object. (…) -- -- The set is introduced by: (…) module _ {{_ : Model}} where infix 3 _⊩⋆_ data _⊩⋆_ : 𝒲 → 𝒞 → Set where [] : ∀ {w} → w ⊩⋆ [] [_,_≔_] : ∀ {Γ A w} → w ⊩⋆ Γ → (x : Name) {{_ : T (fresh x Γ)}} → w ⊩ A → w ⊩⋆ [ Γ , x ∷ A ] -- We write `[]` for the empty environment and `[ ρ , x ≔ a ]` for updating an environment. -- We define the following operations on semantic environments: -- -- The function `lookup` is defined by induction on the environment. (…) module _ {{_ : Model}} where lookup : ∀ {Γ A w x} → w ⊩⋆ Γ → Γ ∋ x ∷ A → w ⊩ A lookup [ ρ , x ≔ a ] zero = a lookup [ ρ , y ≔ b ] (suc i) = lookup ρ i -- The function `↑⟨_⟩⊩⋆` that lifts -- an environment into a bigger world is also defined by induction on the environment. (…) module _ {{_ : Model}} where ↑⟨_⟩⊩⋆ : ∀ {Γ w w′} → w′ ⊒ w → w ⊩⋆ Γ → w′ ⊩⋆ Γ ↑⟨ c ⟩⊩⋆ [] = [] ↑⟨ c ⟩⊩⋆ [ ρ , x ≔ a ] = [ ↑⟨ c ⟩⊩⋆ ρ , x ≔ ↑⟨ c ⟩ a ] instance raise⊩⋆ : ∀ {Γ} → Raiseable (_⊩⋆ Γ) raise⊩⋆ = record { ↑⟨_⟩ = ↑⟨_⟩⊩⋆ } -- The last function `↓⟨_⟩⊩⋆` is the projection on -- environments and it is defined by induction on the proof of `Γ ⊇ Δ`. (…) module _ {{_ : Model}} where ↓⟨_⟩⊩⋆ : ∀ {Γ Δ w} → Γ ⊇ Δ → w ⊩⋆ Γ → w ⊩⋆ Δ ↓⟨ done ⟩⊩⋆ ρ = [] ↓⟨ step {x = x} c i ⟩⊩⋆ ρ = [ ↓⟨ c ⟩⊩⋆ ρ , x ≔ lookup ρ i ] instance lower⊩⋆ : ∀ {w} → Lowerable (w ⊩⋆_) lower⊩⋆ = record { ↓⟨_⟩ = ↓⟨_⟩⊩⋆ } -- We say that an environment is uniform `𝒰⋆ ρ : Set`, where `ρ : w ⊩⋆ Γ`, if each semantic -- object in the environment is uniform. Two environments are equal `Eq⋆ ρ ρ′ : Set`, -- where `ρ, ρ′ : w ⊩⋆ Γ`, if they are equal component-wise. module _ {{_ : Model}} where data Eq⋆ : ∀ {Γ w} → w ⊩⋆ Γ → w ⊩⋆ Γ → Set where eq⋆[] : ∀ {w} → Eq⋆ ([] {w}) ([] {w}) eq⋆≔ : ∀ {Γ A w x} {{_ : T (fresh x Γ)}} {ρ ρ′ : w ⊩⋆ Γ} {a a′ : w ⊩ A} → Eq⋆ ρ ρ′ → Eq a a′ → Eq⋆ [ ρ , x ≔ a ] [ ρ′ , x ≔ a′ ] data 𝒰⋆ : ∀ {Γ w} → w ⊩⋆ Γ → Set where 𝓊⋆[] : ∀ {w} → 𝒰⋆ ([] {w}) 𝓊⋆≔ : ∀ {Γ A w x} {{_ : T (fresh x Γ)}} {ρ : w ⊩⋆ Γ} {a : w ⊩ A} → 𝒰⋆ ρ → 𝒰 a → 𝒰⋆ [ ρ , x ≔ a ] -- The equality on semantic environments, `Eq⋆`, is transitive, symmetric, and for uniform -- environments also reflexive. module _ {{_ : Model}} where reflEq⋆ : ∀ {Γ w} {ρ : w ⊩⋆ Γ} → 𝒰⋆ ρ → Eq⋆ ρ ρ reflEq⋆ 𝓊⋆[] = eq⋆[] reflEq⋆ (𝓊⋆≔ u⋆ u) = eq⋆≔ (reflEq⋆ u⋆) (reflEq u) symEq⋆ : ∀ {Γ w} {ρ ρ′ : w ⊩⋆ Γ} → Eq⋆ ρ ρ′ → Eq⋆ ρ′ ρ symEq⋆ eq⋆[] = eq⋆[] symEq⋆ (eq⋆≔ eq⋆ eq) = eq⋆≔ (symEq⋆ eq⋆) (symEq eq) transEq⋆ : ∀ {Γ w} {ρ ρ′ ρ″ : w ⊩⋆ Γ} → Eq⋆ ρ ρ′ → Eq⋆ ρ′ ρ″ → Eq⋆ ρ ρ″ transEq⋆ eq⋆[] eq⋆[] = eq⋆[] transEq⋆ (eq⋆≔ eq⋆ eq) (eq⋆≔ eq⋆′ eq′) = eq⋆≔ (transEq⋆ eq⋆ eq⋆′) (transEq eq eq′) module _ {{_ : Model}} where ≡→Eq⋆ : ∀ {Γ w} {ρ ρ′ : w ⊩⋆ Γ} → 𝒰⋆ ρ → ρ ≡ ρ′ → Eq⋆ ρ ρ′ ≡→Eq⋆ u⋆ refl = reflEq⋆ u⋆ module Eq⋆Reasoning where infix 1 begin_ begin_ : ∀ {Γ w} {ρ ρ′ : w ⊩⋆ Γ} → Eq⋆ ρ ρ′ → Eq⋆ ρ ρ′ begin eq⋆ = eq⋆ infixr 2 _Eq⋆⟨⟩_ _Eq⋆⟨⟩_ : ∀ {Γ w} (ρ {ρ′} : w ⊩⋆ Γ) → Eq⋆ ρ ρ′ → Eq⋆ ρ ρ′ ρ Eq⋆⟨⟩ eq⋆ = eq⋆ infixr 2 _Eq⋆⟨_⟩_ _Eq⋆⟨_⟩_ : ∀ {Γ w} (ρ {ρ′ ρ″} : w ⊩⋆ Γ) → Eq⋆ ρ ρ′ → Eq⋆ ρ′ ρ″ → Eq⋆ ρ ρ″ ρ Eq⋆⟨ eq⋆ ⟩ eq⋆′ = transEq⋆ eq⋆ eq⋆′ infixr 2 _≡⟨⟩_ _≡⟨⟩_ : ∀ {Γ w} (ρ {ρ′} : w ⊩⋆ Γ) → Eq⋆ ρ ρ′ → Eq⋆ ρ ρ′ ρ ≡⟨⟩ eq⋆ = eq⋆ infixr 2 _≡⟨_∣_⟩_ _≡⟨_∣_⟩_ : ∀ {Γ w} (ρ {ρ′ ρ″} : w ⊩⋆ Γ) → ρ ≡ ρ′ → 𝒰⋆ ρ → Eq⋆ ρ′ ρ″ → Eq⋆ ρ ρ″ ρ ≡⟨ eq⋆ ∣ u⋆ ⟩ eq⋆′ = transEq⋆ (≡→Eq⋆ u⋆ eq⋆) eq⋆′ infix 3 _∎⟨_⟩ _∎⟨_⟩ : ∀ {Γ w} (ρ : w ⊩⋆ Γ) → 𝒰⋆ ρ → Eq⋆ ρ ρ ρ ∎⟨ u⋆ ⟩ = reflEq⋆ u⋆ -- We can substitute equal semantic environments in `lookup`, `↑⟨_⟩`, `↓⟨_⟩` -- and the result of applying these functions to uniform environments is also uniform. module _ {{_ : Model}} where conglookupEq : ∀ {Γ A w x} → {ρ ρ′ : w ⊩⋆ Γ} → Eq⋆ ρ ρ′ → (i : Γ ∋ x ∷ A) → Eq (lookup ρ i) (lookup ρ′ i) conglookupEq eq⋆[] () conglookupEq (eq⋆≔ eq⋆ eq) zero = eq conglookupEq (eq⋆≔ eq⋆ eq) (suc i) = conglookupEq eq⋆ i cong↑⟨_⟩Eq⋆ : ∀ {Γ w w′} → (c : w′ ⊒ w) → {ρ ρ′ : w ⊩⋆ Γ} → Eq⋆ ρ ρ′ → Eq⋆ (↑⟨ c ⟩ ρ) (↑⟨ c ⟩ ρ′) cong↑⟨ c ⟩Eq⋆ eq⋆[] = eq⋆[] cong↑⟨ c ⟩Eq⋆ (eq⋆≔ eq⋆ eq) = eq⋆≔ (cong↑⟨ c ⟩Eq⋆ eq⋆) (cong↑⟨ c ⟩Eq eq) cong↓⟨_⟩Eq⋆ : ∀ {Γ Δ w} → (c : Γ ⊇ Δ) → {ρ ρ′ : w ⊩⋆ Γ} → Eq⋆ ρ ρ′ → Eq⋆ (↓⟨ c ⟩ ρ) (↓⟨ c ⟩ ρ′) cong↓⟨ done ⟩Eq⋆ eq⋆ = eq⋆[] cong↓⟨ step c i ⟩Eq⋆ eq⋆ = eq⋆≔ (cong↓⟨ c ⟩Eq⋆ eq⋆) (conglookupEq eq⋆ i) conglookup𝒰 : ∀ {Γ A w x} → {ρ : w ⊩⋆ Γ} → 𝒰⋆ ρ → (i : Γ ∋ x ∷ A) → 𝒰 (lookup ρ i) conglookup𝒰 𝓊⋆[] () conglookup𝒰 (𝓊⋆≔ u⋆ u) zero = u conglookup𝒰 (𝓊⋆≔ u⋆ u) (suc i) = conglookup𝒰 u⋆ i cong↑⟨_⟩𝒰⋆ : ∀ {Γ w w′} → (c : w′ ⊒ w) → {ρ : w ⊩⋆ Γ} → 𝒰⋆ ρ → 𝒰⋆ (↑⟨ c ⟩ ρ) cong↑⟨ c ⟩𝒰⋆ 𝓊⋆[] = 𝓊⋆[] cong↑⟨ c ⟩𝒰⋆ (𝓊⋆≔ u⋆ u) = 𝓊⋆≔ (cong↑⟨ c ⟩𝒰⋆ u⋆) (cong↑⟨ c ⟩𝒰 u) cong↓⟨_⟩𝒰⋆ : ∀ {Γ Δ w} → (c : Γ ⊇ Δ) → {ρ : w ⊩⋆ Γ} → 𝒰⋆ ρ → 𝒰⋆ (↓⟨ c ⟩ ρ) cong↓⟨ done ⟩𝒰⋆ u⋆ = 𝓊⋆[] cong↓⟨ step c i ⟩𝒰⋆ u⋆ = 𝓊⋆≔ (cong↓⟨ c ⟩𝒰⋆ u⋆) (conglookup𝒰 u⋆ i) -- We also -- need to prove the following properties about `Eq⋆` for semantic environments which basically -- say that it doesn’t matter in which order we lift and project the substitution: module _ {{_ : Model}} where aux₄₂₁⟨_⟩ : ∀ {Γ Δ A w x} → (c : Γ ⊇ Δ) → {ρ : w ⊩⋆ Γ} → 𝒰⋆ ρ → (i : Γ ∋ x ∷ A) (j : Δ ∋ x ∷ A) → Eq (lookup ρ i) (lookup (↓⟨ c ⟩ ρ) j) aux₄₂₁⟨ done ⟩ u⋆ i () aux₄₂₁⟨ step c i′ ⟩ u⋆ i zero rewrite uniq∋ i′ i = conglookupEq (reflEq⋆ u⋆) i aux₄₂₁⟨ step c i′ ⟩ u⋆ i (suc j) = aux₄₂₁⟨ c ⟩ u⋆ i j conglookup↑⟨_⟩Eq : ∀ {Γ A w w′ x} {ρ : w ⊩⋆ Γ} → (c : w′ ⊒ w) → 𝒰⋆ ρ → (i : Γ ∋ x ∷ A) → Eq (↑⟨ c ⟩ (lookup ρ i)) (lookup (↑⟨ c ⟩ ρ) i) conglookup↑⟨ c ⟩Eq 𝓊⋆[] () conglookup↑⟨ c ⟩Eq (𝓊⋆≔ u⋆ u) zero = cong↑⟨ c ⟩Eq (reflEq u) conglookup↑⟨ c ⟩Eq (𝓊⋆≔ u⋆ u) (suc i) = conglookup↑⟨ c ⟩Eq u⋆ i aux₄₂₃ : ∀ {Γ Δ A w x} {{_ : T (fresh x Δ)}} {{_ : T (fresh x Γ)}} → (c : Γ ⊇ Δ) (c′ : [ Γ , x ∷ A ] ⊇ Δ) → {ρ : w ⊩⋆ Γ} → 𝒰⋆ ρ → {a : w ⊩ A} → Eq⋆ (↓⟨ c′ ⟩ [ ρ , x ≔ a ]) (↓⟨ c ⟩ ρ) aux₄₂₃ done done u⋆ = eq⋆[] aux₄₂₃ {x = x} {{φ}} (step c i) (step c′ zero) u⋆ = elim⊥ (freshlem₁ x φ) aux₄₂₃ {x = x} {{φ}} (step c i) (step c′ (suc i′)) u⋆ rewrite uniq∋ i′ i = eq⋆≔ (aux₄₂₃ {{freshlem₂ x φ}} c c′ u⋆) (reflEq (conglookup𝒰 u⋆ i)) aux₄₂₄⟨_⟩ : ∀ {Γ w} → (c : Γ ⊇ Γ) → {ρ : w ⊩⋆ Γ} → 𝒰⋆ ρ → Eq⋆ (↓⟨ c ⟩ ρ) ρ aux₄₂₄⟨ done ⟩ 𝓊⋆[] = eq⋆[] aux₄₂₄⟨ step c i ⟩ (𝓊⋆≔ u⋆ u) = eq⋆≔ (transEq⋆ (aux₄₂₃ refl⊇ c u⋆) (aux₄₂₄⟨ refl⊇ ⟩ u⋆)) (aux₄₂₁⟨ refl⊇ ⟩ (𝓊⋆≔ u⋆ u) i zero) aux₄₂₅⟨_⟩ : ∀ {Γ w} → (c : w ⊒ w) → {ρ : w ⊩⋆ Γ} → 𝒰⋆ ρ → Eq⋆ (↑⟨ c ⟩ ρ) ρ aux₄₂₅⟨ c ⟩ 𝓊⋆[] = eq⋆[] aux₄₂₅⟨ c ⟩ (𝓊⋆≔ u⋆ u) = eq⋆≔ (aux₄₂₅⟨ c ⟩ u⋆) (aux₄₁₁⟨ c ⟩ u) aux₄₂₆ : ∀ {Γ Δ Θ w} → (c : Δ ⊇ Γ) (c′ : Θ ⊇ Δ) (c″ : Θ ⊇ Γ) → {ρ : w ⊩⋆ Θ} → 𝒰⋆ ρ → Eq⋆ (↓⟨ c ⟩ (↓⟨ c′ ⟩ ρ)) (↓⟨ c″ ⟩ ρ) aux₄₂₆ done c′ done u⋆ = eq⋆[] aux₄₂₆ (step c i) c′ (step c″ i″) u⋆ = eq⋆≔ (aux₄₂₆ c c′ c″ u⋆) (symEq (aux₄₂₁⟨ c′ ⟩ u⋆ i″ i)) aux₄₂₇ : ∀ {Γ w w′ w″} → (c : w′ ⊒ w) (c′ : w″ ⊒ w′) (c″ : w″ ⊒ w) → {ρ : w ⊩⋆ Γ} → 𝒰⋆ ρ → Eq⋆ (↑⟨ c′ ⟩ (↑⟨ c ⟩ ρ)) (↑⟨ c″ ⟩ ρ) aux₄₂₇ c c′ c″ 𝓊⋆[] = eq⋆[] aux₄₂₇ c c′ c″ (𝓊⋆≔ u⋆ u) = eq⋆≔ (aux₄₂₇ c c′ c″ u⋆) (aux₄₁₂ c c′ c″ u) aux₄₂₈ : ∀ {Γ Δ w w′} → (c : Δ ⊇ Γ) (c′ : w′ ⊒ w) → {ρ : w ⊩⋆ Δ} → 𝒰⋆ ρ → Eq⋆ (↑⟨ c′ ⟩ (↓⟨ c ⟩ ρ)) (↓⟨ c ⟩ (↑⟨ c′ ⟩ ρ)) aux₄₂₈ done c′ u⋆ = eq⋆[] aux₄₂₈ (step c i) c′ u⋆ = eq⋆≔ (aux₄₂₈ c c′ u⋆) (conglookup↑⟨ c′ ⟩Eq u⋆ i) -- These properties are used in the proofs of soundness and completeness below. -- 4.3. The semantics of the λ-calculus -- ------------------------------------ -- -- We define evaluation functions for proof trees and substitutions in a given environment: (…) module _ {{_ : Model}} where mutual ⟦_⟧ : ∀ {Γ A w} → Γ ⊢ A → w ⊩⋆ Γ → w ⊩ A ⟦ ν x i ⟧ ρ = lookup ρ i ⟦ ƛ x M ⟧ ρ = ⟦ƛ⟧ (λ c a → ⟦ M ⟧ [ ↑⟨ c ⟩ ρ , x ≔ a ]) ⟦ M ∙ N ⟧ ρ = ⟦ M ⟧ ρ ⟦∙⟧⟨ refl⊒ ⟩ ⟦ N ⟧ ρ ⟦ M ▶ γ ⟧ ρ = ⟦ M ⟧ (⟦ γ ⟧ₛ ρ) ⟦_⟧ₛ : ∀ {Γ Δ w} → Δ ⋙ Γ → w ⊩⋆ Δ → w ⊩⋆ Γ ⟦ π⟨ c ⟩ ⟧ₛ ρ = ↓⟨ c ⟩ ρ ⟦ γ ● γ′ ⟧ₛ ρ = ⟦ γ ⟧ₛ (⟦ γ′ ⟧ₛ ρ) ⟦ [ γ , x ≔ M ] ⟧ₛ ρ = [ ⟦ γ ⟧ₛ ρ , x ≔ ⟦ M ⟧ ρ ]
{ "alphanum_fraction": 0.4090485075, "avg_line_length": 39.7855670103, "ext": "agda", "hexsha": "ee3679d531ab6f4e50a122ce4cfc202d80773f42", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/coquand", "max_forks_repo_path": "src/Section4a.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/coquand", "max_issues_repo_path": "src/Section4a.agda", "max_line_length": 102, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/coquand", "max_stars_repo_path": "src/Section4a.agda", "max_stars_repo_stars_event_max_datetime": "2017-09-07T12:44:40.000Z", "max_stars_repo_stars_event_min_datetime": "2017-03-27T01:29:58.000Z", "num_tokens": 9835, "size": 19296 }
{-# OPTIONS --without-K #-} module sets.list where open import sets.list.core public
{ "alphanum_fraction": 0.7209302326, "avg_line_length": 17.2, "ext": "agda", "hexsha": "d9aeac399cd3d781cbab441ad04f24c8b208b2e4", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/sets/list.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/sets/list.agda", "max_line_length": 33, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/sets/list.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 18, "size": 86 }
module UnicodeSetIndex where X : Set₁₄₀ X = Set₁₃₉
{ "alphanum_fraction": 0.7547169811, "avg_line_length": 8.8333333333, "ext": "agda", "hexsha": "3ed980f479d8a8e999fb39d67b3742aa7f9643cc", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/UnicodeSetIndex.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/UnicodeSetIndex.agda", "max_line_length": 28, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/UnicodeSetIndex.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 24, "size": 53 }
-- Andreas, 2015-05-09 trigger some option errors {-# OPTIONS --dont-termination-check --not-termination-check --without-K=4 --without-k --senf-gurke #-} {- Expected error: Unrecognized options: --dont-termination-check (did you mean --no-termination-check ?) --not-termination-check (did you mean --no-termination-check ?) --without-k (did you mean --without-K ?) --senf-gurke Option error: option `--without-K' doesn't allow an argument -}
{ "alphanum_fraction": 0.6973684211, "avg_line_length": 22.8, "ext": "agda", "hexsha": "76617de30c7610045aee1fe8e65268c0b9501c89", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/UnrecognizedOption.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/UnrecognizedOption.agda", "max_line_length": 64, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/UnrecognizedOption.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 130, "size": 456 }
module utility where open import Algebra using (Monoid) open import Algebra.Structures using (IsMonoid ; IsSemigroup) open import Data.Empty open import Function using (_∘_) open import Relation.Binary using (Decidable) open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; setoid ; sym ; cong) open import Relation.Nullary open import Relation.Nullary.Decidable using (⌊_⌋) open import Data.Bool using (not) open import Data.List open import Data.List.Properties using (map-id ; map-compose ; map-cong) open import Data.List.Any as ListAny using (Any ; any ; here ; there) open import Data.List.Any.Properties using ( ∷↔ ; ++⁻) renaming (++⁺ˡ to ++ˡ ; ++⁺ʳ to ++ʳ) open import Data.Nat using (ℕ ; zero ; suc ; _≟_ ; _+_ ; _∸_) open import Data.Nat.Properties.Simple using (+-comm) open import Data.Nat.Properties using (n∸n≡0 ; m+n∸n≡m) open import Data.Product using (_,_ ; _,′_ ; _×_ ; proj₁ ; proj₂ ; ∃) open import Data.Sum using (_⊎_ ; inj₁ ; inj₂) open import Function using (_∘_ ; id) import Data.List.Membership.Setoid ++-assoc : ∀{A : Set} → (xs ys zs : List A) → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs) ++-assoc {_} xs ys zs = IsSemigroup.assoc (IsMonoid.isSemigroup (Monoid.isMonoid (Data.List.Properties.++-monoid _))) xs _ _ _∈_ : {A : Set} → (x : A) → (xs : List A) → Set _∈_ {A} x xs = Data.List.Membership.Setoid._∈_ (setoid A) x xs _∉_ : {A : Set} → (x : A) → (xs : List A) → Set _∉_ {A} x xs = Data.List.Membership.Setoid._∉_ (setoid A) x xs map-second : {A B C D : Set} → (f : B → D) → A × B × C → A × D × C map-second f = Data.Product.map id (Data.Product.map f id) any-map⁺ : ∀ {A B} {xs : List A} {x} (f : A → B) → x ∈ xs → f x ∈ map f xs any-map⁺ f (here refl) = here refl any-map⁺ f (there x∈xs) = there (any-map⁺ f x∈xs) -- the map-mono like the one in Data.List.Any.Membership -- idk why I can't import that module so I just implement one here map-mono : ∀ {A B} {ys zs : List A} (f : A → B) → (∀ x → x ∈ ys → x ∈ zs) → ∀ fx → fx ∈ map f ys → fx ∈ map f zs map-mono {ys = []} f ys⊆zs fx () map-mono {ys = y ∷ ys} {zs} f ys⊆zs .(f y) (here refl) = any-map⁺ f (ys⊆zs y (here refl)) map-mono {ys = y ∷ ys} {zs} f ys⊆zs fx (there fx∈map-f-ys) = map-mono f (λ x z → ys⊆zs x (there z)) fx fx∈map-f-ys any-map⁺² : ∀ {A B : Set} {xs x fxy} (f : A → List B) → x ∈ xs → fxy ∈ f x → fxy ∈ concatMap f xs any-map⁺² f (here refl) fxy∈fx = ++ˡ fxy∈fx any-map⁺² f (there x∈xs) fxy∈fx = ++ʳ (f _) (any-map⁺² f x∈xs fxy∈fx) map-mono² : ∀ {A B C} {xs xs' : List A} {ys ys' : List B} (f : A → B → C) → (∀ u → u ∈ xs → u ∈ xs') → (∀ v → v ∈ ys → v ∈ ys') → ∀ fuv → fuv ∈ concatMap (λ u → map (f u) ys) xs → fuv ∈ concatMap (λ u → map (f u) ys') xs' map-mono² {xs = []} {xs'} {ys} {ys'} f xs⊆xs' ys⊆ys' fuv () map-mono² {xs = x ∷ xs} {xs'} {ys} {ys'} f xs⊆xs' ys⊆ys' fuv fuv∈[[fuv|ys]|x∷xs] with ++⁻ (map (f x) ys) fuv∈[[fuv|ys]|x∷xs] ... | inj₂ fuv∈[[fuv|ys]|xs] = map-mono² f (λ u → xs⊆xs' u ∘ there) ys⊆ys' fuv fuv∈[[fuv|ys]|xs] ... | inj₁ fuv∈[fxv|ys] = any-map⁺² (λ u → map (f u) ys') (xs⊆xs' x (here refl)) (map-mono (f x) ys⊆ys' fuv fuv∈[fxv|ys]) module ListSet {A : Set} (_≟_ : Decidable {A = A} _≡_) where open import Relation.Nullary.Negation using (¬?) ST : Set ST = List A set-subtract : List A → List A → List A set-subtract S T = filter (λ x → ¬? (ListAny.any (_≟_ x) T)) S set-remove : List A → A → List A set-remove S x = filter (¬? ∘ _≟_ x) S set-remove-removed : ∀{S L} → S ∉ set-remove L S set-remove-removed {S} {[]} () set-remove-removed {S} {x ∷ L} Sin with S ≟ x | set-remove-removed{S}{L} set-remove-removed {S} {x ∷ L} Sin | yes refl | r = r Sin set-remove-removed {S} {x ∷ L} (here px) | no ¬p | r = ¬p px set-remove-removed {S} {x ∷ L} (there Sin) | no ¬p | r = r Sin set-remove-not-eq : ∀{a a' xs} → a ∈ set-remove xs a' → ¬ a' ≡ a set-remove-not-eq {a}{a'}{xs} a∈xs-a' with a' ≟ a ... | yes refl = ⊥-elim (set-remove-removed{a}{xs} a∈xs-a') ... | no ¬refl = ¬refl set-remove-mono-∈ : ∀ {xs a} a' → a ∈ set-remove xs a' → a ∈ xs set-remove-mono-∈ {[]} {a} a' () set-remove-mono-∈ {(x ∷ xs)} {a} a' a∈xs-[a'] with a' ≟ x set-remove-mono-∈ {(x ∷ xs)} {a} a' a∈xs-[a'] | yes a'≡x = there (set-remove-mono-∈ a' a∈xs-[a']) set-remove-mono-∈ {(x ∷ xs)} {a} a' (here refl) | no ¬a'≡x = here refl set-remove-mono-∈ {(x ∷ xs)} {a} a' (there a∈xs-[a']) | no ¬a'≡x = there (set-remove-mono-∈ a' a∈xs-[a']) set-remove-not-removed : ∀ {a' a xs} → ¬ (a' ≡ a) → a ∈ xs → a ∈ set-remove xs a' set-remove-not-removed {a'} {a} {.a ∷ xs} a'≢a (here refl) with a' ≟ a ... | yes a'≡a = ⊥-elim (a'≢a a'≡a) ... | no ¬a'≡a = here refl set-remove-not-removed {a'} {a} {x ∷ xs} a'≢a (there a∈xs) with a' ≟ x ... | yes a'≡x = set-remove-not-removed a'≢a a∈xs ... | no ¬a'≡x = there (set-remove-not-removed a'≢a a∈xs) set-subtract-[] : ∀ xs → set-subtract xs [] ≡ xs set-subtract-[] [] = refl set-subtract-[] (x ∷ xs) rewrite set-subtract-[] xs = refl set-subtract-[a]≡set-remove : ∀ xs a → set-subtract xs (a ∷ []) ≡ set-remove xs a set-subtract-[a]≡set-remove [] a = refl set-subtract-[a]≡set-remove (x ∷ xs) a with x ≟ a | a ≟ x ... | yes refl | no a≢x = ⊥-elim (a≢x refl) ... | no x≢a | yes refl = ⊥-elim (x≢a refl) ... | yes refl | yes a≡x = set-subtract-[a]≡set-remove xs x ... | no x≢a | no a≢x rewrite set-subtract-[a]≡set-remove xs a = refl set-subtract-merge : ∀ {xs ys z} → z ∈ set-subtract xs ys → (z ∈ xs) × (z ∉ ys) set-subtract-merge {[]} () set-subtract-merge {x ∷ xs} {ys} z∈xs-ys with ListAny.any (_≟_ x) ys set-subtract-merge {x ∷ xs} {ys} (here refl) | no x∉ys = here refl ,′ x∉ys set-subtract-merge {x ∷ xs} {ys} (there z∈xs-ys) | no x∉ys = there z∈xs , z∉ys where z∈xs,z∉ys = set-subtract-merge {xs} {ys} z∈xs-ys z∈xs = proj₁ z∈xs,z∉ys z∉ys = proj₂ z∈xs,z∉ys ... | yes x∈ys = there z∈xs , z∉ys where z∈xs,z∉ys = set-subtract-merge {xs} {ys} z∈xs-ys z∈xs = proj₁ z∈xs,z∉ys z∉ys = proj₂ z∈xs,z∉ys set-subtract-split : ∀ {xs ys z} → z ∈ xs → z ∈ set-subtract xs ys ⊎ z ∈ ys set-subtract-split {[]} () set-subtract-split {x ∷ xs} {ys} (here refl) with ListAny.any (_≟_ x) ys ... | yes x∈ys = inj₂ x∈ys ... | no x∉ys = inj₁ ( (here refl) ) set-subtract-split {x ∷ xs} {ys} (there x∈xs) with ListAny.any (_≟_ x) ys | set-subtract-split x∈xs ... | x∈ys⊎x∉ys | inj₂ z∈ys = inj₂ z∈ys ... | yes x∈ys | inj₁ z∈xs-ys = inj₁ z∈xs-ys ... | no x∉ys | inj₁ z∈xs-ys = inj₁ ( (there z∈xs-ys) ) set-subtract-notin : ∀ {xs ys z} → z ∈ xs → z ∉ ys → z ∈ set-subtract xs ys set-subtract-notin{xs}{ys}{z} z∈ z∉ with set-subtract-split{xs}{ys}{z} z∈ ... | inj₁ a = a ... | inj₂ b = ⊥-elim (z∉ b) -- note: the fixity of our triple-apply _#_ combinator -- is different from the usual fixity of _$_. infixl 1 _#_ -- applying three functions to three values in parallel _#_ : {A B C : Set} → {D : A → Set} → {E : B → Set} → {F : C → Set} → ((a : A) → D a) × ((b : B) → E b) × ((c : C) → F c) → (abc : A × B × C) → D (proj₁ abc) × E (proj₁ (proj₂ abc)) × F (proj₂ (proj₂ abc)) (f , g , h) # (x , y , z) = f x ,′ g y ,′ h z infix 6 _U̬_ _U̬_ : List ℕ × List ℕ × List ℕ → List ℕ × List ℕ × List ℕ → List ℕ × List ℕ × List ℕ (S , s , v) U̬ (S1 , s1 , v1) = S ++ S1 ,′ s ++ s1 ,′ v ++ v1 infixr 6 _|̌_ infixr 6 _|¹_ _|¹_ = ListSet.set-subtract Data.Nat._≟_ _|̌_ : List ℕ × List ℕ × List ℕ → List ℕ × List ℕ × List ℕ → List ℕ × List ℕ × List ℕ (S , s , x) |̌ (S1 , s1 , x1) = (S |¹ S1) , (s |¹ s1) , (x |¹ x1) ∪-assoc : ∀ xs³ ys³ zs³ → (xs³ U̬ ys³) U̬ zs³ ≡ xs³ U̬ (ys³ U̬ zs³) ∪-assoc xs³ ys³ zs³ rewrite ++-assoc (proj₁ xs³) (proj₁ ys³) (proj₁ zs³) | ++-assoc (proj₁ (proj₂ xs³)) (proj₁ (proj₂ ys³)) (proj₁ (proj₂ zs³)) | ++-assoc (proj₂ (proj₂ xs³)) (proj₂ (proj₂ ys³)) (proj₂ (proj₂ zs³)) = refl xs++[]≡xs : ∀{A : Set} → (xs : List A) → xs ++ [] ≡ xs xs++[]≡xs xs = proj₂ (Monoid.identity (Data.List.Properties.++-monoid _)) xs x∈xs++[]→x∈xs : ∀{A} → {x : A} → {xs : List A} → x ∈ (xs ++ []) → x ∈ xs x∈xs++[]→x∈xs {xs = xs} x∈xs rewrite xs++[]≡xs xs = x∈xs _⊆¹_ : List ℕ → List ℕ → Set xs ⊆¹ ys = ∀ x → x ∈ xs → x ∈ ys _⊆_ : List ℕ × List ℕ × List ℕ → List ℕ × List ℕ × List ℕ → Set (Ss₁ , ss₁ , xs₁) ⊆ (Ss₂ , ss₂ , xs₂) = (Ss₁ ⊆¹ Ss₂) × (ss₁ ⊆¹ ss₂) × (xs₁ ⊆¹ xs₂) ⊆¹-refl : ∀ {xs} → xs ⊆¹ xs ⊆¹-refl _ p = p ⊆-refl : ∀ {xs³} → xs³ ⊆ xs³ ⊆-refl = ⊆¹-refl ,′ ⊆¹-refl ,′ ⊆¹-refl ⊆-empty-left : ∀ {xs³} → ([] ,′ [] ,′ []) ⊆ xs³ ⊆-empty-left = (λ _ ()) ,′ (λ _ ()) ,′ (λ _ ()) ⊆¹-trans : ∀{xs ys zs} → xs ⊆¹ ys → ys ⊆¹ zs → xs ⊆¹ zs ⊆¹-trans xs⊆ys ys⊆zs w w∈xs = ys⊆zs _ (xs⊆ys _ w∈xs) ⊆-trans : ∀{xs³ ys³ zs³} → xs³ ⊆ ys³ → ys³ ⊆ zs³ → xs³ ⊆ zs³ ⊆-trans xs³⊆ys³ ys³⊆zs³ = ⊆¹-trans ,′ ⊆¹-trans ,′ ⊆¹-trans # xs³⊆ys³ # ys³⊆zs³ ⊆¹-respect-|¹ : ∀{xs ys} zs → xs ⊆¹ ys → (xs |¹ zs) ⊆¹ (ys |¹ zs) ⊆¹-respect-|¹{xs}{ys} zs xs⊂ys a a∈ with ListSet.set-subtract-merge Data.Nat._≟_ {xs}{zs}{a} a∈ ... | (a∈xs , a∉zs) = ListSet.set-subtract-notin Data.Nat._≟_ (xs⊂ys a a∈xs) a∉zs ⊆-respect-|̌ : ∀{xs ys} zs → xs ⊆ ys → (xs |̌ zs) ⊆ (ys |̌ zs) ⊆-respect-|̌ zs sub = ⊆¹-respect-|¹ , ⊆¹-respect-|¹ , ⊆¹-respect-|¹ # zs # sub ∷-respect-⊆¹ : ∀{xs ys} z → xs ⊆¹ ys → (z ∷ xs) ⊆¹ (z ∷ ys) ∷-respect-⊆¹ z sub .z (here refl) = here refl ∷-respect-⊆¹ z sub a (there a∈) = there (sub a a∈) ∪ˡ : ∀{xs³ ys³ zs³} → xs³ ⊆ ys³ → xs³ ⊆ (ys³ U̬ zs³) ∪ˡ (Ss₁⊆Ss₂ , ss₁⊆ss₂ , xs₁⊆xs₂) = (λ S → ++ˡ ∘ Ss₁⊆Ss₂ S) ,′ (λ s → ++ˡ ∘ ss₁⊆ss₂ s) ,′ (λ x → ++ˡ ∘ xs₁⊆xs₂ x) ∪ʳ : ∀{xs³ ys³} → (zs³ : List ℕ × List ℕ × List ℕ) → xs³ ⊆ ys³ → xs³ ⊆ (zs³ U̬ ys³) ∪ʳ xs (Ss₁⊆Ss₂ , ss₁⊆ss₂ , xs₁⊆xs₂) = (λ S → ++ʳ (proj₁ xs) ∘ Ss₁⊆Ss₂ S) ,′ (λ s → ++ʳ (proj₁ (proj₂ xs)) ∘ ss₁⊆ss₂ s) ,′ (λ x → ++ʳ (proj₂ (proj₂ xs)) ∘ xs₁⊆xs₂ x) ∪¹-unjoin-⊆¹ : ∀ {ys zs} xs → (xs ++ ys) ⊆¹ zs → xs ⊆¹ zs × ys ⊆¹ zs ∪¹-unjoin-⊆¹ xs xs++ys⊆zs = (λ x x∈xs → xs++ys⊆zs x (++ˡ x∈xs)) ,′ (λ x x∈ys → xs++ys⊆zs x (++ʳ xs x∈ys)) ∪-unjoin-⊆ : ∀ {ys³ zs³} xs³ → (xs³ U̬ ys³) ⊆ zs³ → xs³ ⊆ zs³ × ys³ ⊆ zs³ ∪-unjoin-⊆ xs³ xs³∪ys³⊆zs³ = unzip³ (∪¹-unjoin-⊆¹ ,′ ∪¹-unjoin-⊆¹ ,′ ∪¹-unjoin-⊆¹ # xs³ # xs³∪ys³⊆zs³) where unzip³ : {A B C D E F : Set} → (A × D) × (B × E) × (C × F) → (A × B × C) × (D × E × F) unzip³ ((a , d) , (b , e) , (c , f)) = (a , b , c) , (d , e , f) ∪-unjoin-⊆ˡ : ∀{xs³ ys³ zs³} → (xs³ U̬ ys³) ⊆ zs³ → xs³ ⊆ zs³ ∪-unjoin-⊆ˡ {xs³} = proj₁ ∘ ∪-unjoin-⊆ xs³ ∪-unjoin-⊆ʳ : ∀ {ys³ zs³} xs³ → (xs³ U̬ ys³) ⊆ zs³ → ys³ ⊆ zs³ ∪-unjoin-⊆ʳ xs³ = proj₂ ∘ ∪-unjoin-⊆ xs³ ∪¹-join-⊆¹ : ∀{xs ys zs} → xs ⊆¹ zs → ys ⊆¹ zs → (xs ++ ys) ⊆¹ zs ∪¹-join-⊆¹ {xs} xs⊆zs ys⊆zs w w∈xs++ys with ++⁻ xs w∈xs++ys ... | inj₁ w∈xs = xs⊆zs _ w∈xs ... | inj₂ w∈ys = ys⊆zs _ w∈ys ∪-join-⊆ : ∀{xs³ ys³ zs³} → xs³ ⊆ zs³ → ys³ ⊆ zs³ → (xs³ U̬ ys³) ⊆ zs³ ∪-join-⊆ xs³⊆zs³ ys³⊆zs³ = ∪¹-join-⊆¹ ,′ ∪¹-join-⊆¹ ,′ ∪¹-join-⊆¹ # xs³⊆zs³ # ys³⊆zs³ ∪-respect-⊆-left : ∀{xs³ ys³ zs³} → xs³ ⊆ ys³ → (xs³ U̬ zs³) ⊆ (ys³ U̬ zs³) ∪-respect-⊆-left {xs³} {ys³} {zs³} xs³⊆ys³ = ∪-join-⊆ (∪ˡ xs³⊆ys³) (∪ʳ ys³ ⊆-refl) ∪-respect-⊆-right : ∀{xs³ ys³} zs³ → xs³ ⊆ ys³ → (zs³ U̬ xs³) ⊆ (zs³ U̬ ys³) ∪-respect-⊆-right {xs³} {ys³} zs³ xs³⊆ys³ = ∪-join-⊆ (∪ˡ (⊆-refl {zs³})) (∪ʳ zs³ xs³⊆ys³) ∪¹-respect-⊆¹-right : ∀ {xs ys} zs → xs ⊆¹ ys → (zs ++ xs) ⊆¹ (zs ++ ys) ∪¹-respect-⊆¹-right zs xs⊆ys = proj₁ (∪-respect-⊆-right (zs ,′ [] ,′ []) (xs⊆ys ,′ ⊆¹-refl {[]} ,′ ⊆¹-refl {[]})) ∪¹-respect-⊆¹-left : ∀ {xs ys zs} → xs ⊆¹ ys → (xs ++ zs) ⊆¹ (ys ++ zs) ∪¹-respect-⊆¹-left{zs = zs} xs⊆ys = proj₁ (∪-respect-⊆-left{zs³ = (zs ,′ [] ,′ [])} (xs⊆ys ,′ ⊆¹-refl {[]} ,′ ⊆¹-refl {[]})) ⊆-subst-left : ∀{xs³ ys³ zs³} → xs³ ≡ ys³ → xs³ ⊆ zs³ → ys³ ⊆ zs³ ⊆-subst-left refl xs³⊆zs³ = xs³⊆zs³ ∪-comm-⊆-left : ∀ {ys³ zs³} xs³ → (xs³ U̬ ys³) ⊆ zs³ → (ys³ U̬ xs³) ⊆ zs³ ∪-comm-⊆-left xs³ xs³∪ys³⊆zs³ = ∪-join-⊆ (proj₂ (∪-unjoin-⊆ xs³ xs³∪ys³⊆zs³)) (proj₁ (∪-unjoin-⊆ xs³ xs³∪ys³⊆zs³)) ∪-comm-⊆-right : ∀ {xs³ ys³} zs³ → xs³ ⊆ (ys³ U̬ zs³) → xs³ ⊆ (zs³ U̬ ys³) ∪-comm-⊆-right zs³ xs³⊆ys³∪zs³ = ⊆-trans xs³⊆ys³∪zs³ (∪-join-⊆ (∪ʳ zs³ ⊆-refl) (∪ˡ ⊆-refl)) distinct' : ∀{A : Set} -> (xs : List A) -> (ys : List A) -> Set distinct'{A} xs ys = (z : A) -> z ∈ xs -> z ∈ ys -> ⊥ distinct : (xs : List ℕ × List ℕ × List ℕ) -> (ys : List ℕ × List ℕ × List ℕ) -> Set distinct (S , s , v) (S1 , s1 , v1) = distinct' S S1 × distinct' s s1 × distinct' v v1 distinct-empty-left : ∀ {xs³} → distinct ([] ,′ [] ,′ []) xs³ distinct-empty-left = (λ _ ()) ,′ (λ _ ()) ,′ (λ _ ()) distinct-empty-right : ∀ {xs³} → distinct xs³ ([] ,′ [] ,′ []) distinct-empty-right = (λ _ _ ()) ,′ (λ _ _ ()) ,′ (λ _ _ ()) distinct'-sym : ∀{A L1 L2} → (distinct'{A} L1 L2) → (distinct'{A} L2 L1) distinct'-sym d = λ z x x₁ → d z x₁ x distinct'-to-left : {xs ys zs : List ℕ} → (distinct' xs ys → distinct' xs zs) → distinct' ys xs → distinct' zs xs distinct'-to-left f ys≠xs = distinct'-sym (f (distinct'-sym ys≠xs)) distinct-sym : ∀{VL1 VL2} → distinct VL1 VL2 → distinct VL2 VL1 distinct-sym (a , b , c) = (distinct'-sym a) , ((distinct'-sym b) , (distinct'-sym c)) dist'++ˡ : ∀{A V1 V2 V3} → (distinct'{A} V1 (V2 ++ V3)) → (distinct'{A} V1 V2) dist'++ˡ {A} {V1} {V2} {V3} d = λ z x x₁ → d z x (++ˡ x₁) dist'++ʳ : ∀{A V1 V2 V3} → (distinct'{A} V1 (V2 ++ V3)) → (distinct'{A} V1 V3) dist'++ʳ {A} {V1} {V2} {V3} d = λ z x x₁ → d z x (++ʳ V2 x₁) dist'++b : ∀{A V1 V2 V3 V4} → (distinct'{A} (V1 ++ V2) (V3 ++ V4)) → (distinct'{A} V1 V3) dist'++b d = λ z x x₁ → d z (++ˡ x) (++ˡ x₁) dist':: : ∀{A V1 V2 S} → (distinct'{A} V1 (S ∷ V2)) → (distinct' V1 V2) dist'::{A}{V1}{V2}{S} d = dist'++ʳ{A}{V1}{[ S ]}{V2} d dist'-sym : ∀{A L1 L2} → (distinct'{A} L1 L2) → (distinct' L2 L1) dist'-sym d = λ z x x₁ → d z x₁ x distinct'-union-left : ∀ {xs ys zs : List ℕ} → distinct' xs zs → distinct' ys zs → distinct' (xs ++ ys) zs distinct'-union-left {xs} xs≠zs ys≠zs x x∈xs++ys x∈zs with ++⁻ xs x∈xs++ys ... | inj₁ x∈xs = xs≠zs x x∈xs x∈zs ... | inj₂ x∈ys = ys≠zs x x∈ys x∈zs distinct-union-left : ∀ {xs ys zs} → distinct xs zs → distinct ys zs → distinct (xs U̬ ys) zs distinct-union-left xs≠zs xs≠ys = distinct'-union-left ,′ distinct'-union-left ,′ distinct'-union-left # xs≠zs # xs≠ys distinct-union-right : ∀ {xs ys zs} → distinct zs xs → distinct zs ys → distinct zs (xs U̬ ys) distinct-union-right zs≠xs zs≠ys = distinct-sym (distinct-union-left (distinct-sym zs≠xs) (distinct-sym zs≠ys)) ⊆¹-respect-distinct'-left : ∀{xs ys zs} → xs ⊆¹ ys → distinct' ys zs → distinct' xs zs ⊆¹-respect-distinct'-left xs⊆ys ys≠zs x x∈xs x∈zs = ys≠zs x (xs⊆ys x x∈xs) x∈zs ⊆-respect-distinct-left : ∀{xs³ ys³ zs³} → xs³ ⊆ ys³ → distinct ys³ zs³ → distinct xs³ zs³ ⊆-respect-distinct-left {xs³} {ys³} {zs³} xs³⊆ys³ ys³≠zs³ = ⊆¹-respect-distinct'-left ,′ ⊆¹-respect-distinct'-left ,′ ⊆¹-respect-distinct'-left # xs³⊆ys³ # ys³≠zs³ ⊆¹-respect-distinct'-right : ∀{xs ys zs} → xs ⊆¹ ys → distinct' zs ys → distinct' zs xs ⊆¹-respect-distinct'-right xs⊆ys zs≠ys = distinct'-sym (⊆¹-respect-distinct'-left xs⊆ys (distinct'-sym zs≠ys)) ⊆-respect-distinct-right : ∀{xs³ ys³ zs³} → xs³ ⊆ ys³ → distinct zs³ ys³ → distinct zs³ xs³ ⊆-respect-distinct-right {xs³} {ys³} {zs³} xs³⊆ys³ zs³≠ys³ = distinct-sym (⊆-respect-distinct-left xs³⊆ys³ (distinct-sym zs³≠ys³)) distinct'-dec : (xs ys : List ℕ) -> Dec (∃ λ z -> z ∈ xs × z ∈ ys) distinct'-dec [] ys = no λ { (z , () , z∈ys) } distinct'-dec (x ∷ xs) ys with ListAny.any (\ x' -> x Data.Nat.≟ x') ys distinct'-dec (x ∷ xs) ys | yes p = yes (x , here refl , p) distinct'-dec (x ∷ xs) ys | no ¬p with distinct'-dec xs ys distinct'-dec (x ∷ xs) ys | no ¬p | yes (z , z∈xs , x∈ys) = yes (z , there z∈xs , x∈ys) distinct'-dec (x ∷ xs) ys | no ¬p₁ | no ¬p = no (\ { (.x , here refl , z∈ys) → ¬p₁ z∈ys ; (z , there z∈xs , z∈ys) → ¬p (z , z∈xs , z∈ys) } ) distinct-dec : (xs ys : List ℕ × List ℕ × List ℕ) -> Dec ((∃ λ S → (S ∈ proj₁ xs) × (S ∈ proj₁ ys)) ⊎ (∃ λ s → (s ∈ proj₁ (proj₂ xs)) × (s ∈ proj₁ (proj₂ ys))) ⊎ (∃ λ x → (x ∈ proj₂ (proj₂ xs)) × (x ∈ proj₂ (proj₂ ys)))) distinct-dec (S1 , s1 , x1) (S2 , s2 , x2) with distinct'-dec S1 S2 distinct-dec (S1 , s1 , x1) (S2 , s2 , x2) | yes S1S2 = yes (inj₁ S1S2) distinct-dec (S1 , s1 , x1) (S2 , s2 , x2) | no ¬S1S2 with distinct'-dec s1 s2 distinct-dec (S1 , s1 , x1) (S2 , s2 , x2) | no ¬S1S2 | yes s1s2 = yes (inj₂ (inj₁ s1s2)) distinct-dec (S1 , s1 , x1) (S2 , s2 , x2) | no ¬S1S2 | no ¬s1s2 with distinct'-dec x1 x2 distinct-dec (S1 , s1 , x1) (S2 , s2 , x2) | no ¬S1S2 | no ¬s1s2 | yes x1x2 = yes (inj₂ (inj₂ x1x2)) distinct-dec (S1 , s1 , x1) (S2 , s2 , x2) | no ¬S1S2 | no ¬s1s2 | no ¬x1x2 = no (λ { (inj₁ x) → ¬S1S2 x ; (inj₂ (inj₁ x)) → ¬s1s2 x ; (inj₂ (inj₂ y)) → ¬x1x2 y }) distinct-not-distinct-dec : ∀ {xs ys} -> distinct xs ys -> ((∃ λ S → (S ∈ proj₁ xs) × (S ∈ proj₁ ys)) ⊎ (∃ λ s → (s ∈ proj₁ (proj₂ xs)) × (s ∈ proj₁ (proj₂ ys))) ⊎ (∃ λ x → (x ∈ proj₂ (proj₂ xs)) × (x ∈ proj₂ (proj₂ ys)))) -> ⊥ distinct-not-distinct-dec {xs} {ys} DXY (inj₁ (NDXYS , NDXYs , NDXYx)) = (proj₁ DXY) NDXYS NDXYs NDXYx distinct-not-distinct-dec {xs} {ys} DXY (inj₂ (inj₁ (NDXYS , NDXYs , NDXYx))) = (proj₁ (proj₂ DXY)) NDXYS NDXYs NDXYx distinct-not-distinct-dec {xs} {ys} DXY (inj₂ (inj₂ (NDXYS , NDXYs , NDXYx))) = (proj₂ (proj₂ DXY)) NDXYS NDXYs NDXYx distinct-dec-is-distinct : ∀ {xs ys} -> (((∃ λ S → (S ∈ proj₁ xs) × (S ∈ proj₁ ys)) ⊎ (∃ λ s → (s ∈ proj₁ (proj₂ xs)) × (s ∈ proj₁ (proj₂ ys))) ⊎ (∃ λ x → (x ∈ proj₂ (proj₂ xs)) × (x ∈ proj₂ (proj₂ ys)))) -> ⊥) -> distinct xs ys distinct-dec-is-distinct {xs} {ys} FAIL = ((λ z z∈xs z∈ys → FAIL (inj₁ (z , z∈xs , z∈ys))) , (λ z z∈xs z∈ys → FAIL (inj₂ (inj₁ (z , z∈xs , z∈ys)))) , (λ z z∈xs z∈ys → FAIL (inj₂ (inj₂ (z , z∈xs , z∈ys))))) case_return_of_ : ∀ {a b} {A : Set a} (x : A) (B : A → Set b) → (∀ x → B x) → B x case x return B of f = f x case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B case x of f = f x typeof : ∀{𝕝}{A : Set 𝕝} → A → Set 𝕝 typeof{_}{A} _ = A fst : ∀{l} {A B C : Set l} → A × B × C → A fst = proj₁ snd : ∀{l} {A B C : Set l} → A × B × C → B snd = proj₁ ∘ proj₂ thd : ∀{l} {A B C : Set l} → A × B × C → C thd = proj₂ ∘ proj₂ ∈:: : ∀{A} {x y : A} → x ∈ (y ∷ []) → x ≡ y ∈:: (here px) = px ∈:: (there ()) n∉map-suc-n-+ : ∀ n xs → ¬ (n ∈ map (suc n +_) xs) n∉map-suc-n-+ n [] () n∉map-suc-n-+ n (x ∷ xs) (here n≡suc⟨n+x⟩) with cong (_∸ n) n≡suc⟨n+x⟩ ... | n∸n≡suc⟨n+x⟩∸n rewrite n∸n≡0 n | +-comm n x | m+n∸n≡m (suc x) n with n∸n≡suc⟨n+x⟩∸n ... | () n∉map-suc-n-+ n (x ∷ xs) (there n∈map-suc-n-+) = n∉map-suc-n-+ n xs n∈map-suc-n-+ map-+-swap-suc : ∀ n xs → map (_+_ n) (map suc xs) ≡ map suc (map (_+_ n) xs) map-+-swap-suc n xs rewrite sym (map-compose {g = _+_ n} {f = suc} xs) | map-cong (λ m → +-comm n (suc m)) xs | map-cong (λ m → cong suc (+-comm m n)) xs | map-compose {g = suc} {f = _+_ n} xs = refl map-+-compose-suc : ∀ n xs → map (_+_ n) (map suc xs) ≡ map (_+_ (suc n)) xs map-+-compose-suc n xs rewrite map-+-swap-suc n xs | sym (map-compose {g = suc} {f = _+_ n} xs) = refl
{ "alphanum_fraction": 0.5294725957, "avg_line_length": 40.8016877637, "ext": "agda", "hexsha": "b8f626be45eae343848835c0dcb270508e9b6b5b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/utility.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/utility.agda", "max_line_length": 126, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/utility.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 9361, "size": 19340 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties, related to reflexive transitive closures, that rely on -- the K rule ------------------------------------------------------------------------ {-# OPTIONS --with-K --safe #-} module Relation.Binary.Construct.Closure.ReflexiveTransitive.Properties.WithK where open import Function open import Relation.Binary open import Relation.Binary.Construct.Closure.ReflexiveTransitive open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------ -- Equality module _ {i t} {I : Set i} {T : Rel I t} {i j k} {x y : T i j} {xs ys} where ◅-injectiveˡ : (Star T i k ∋ x ◅ xs) ≡ y ◅ ys → x ≡ y ◅-injectiveˡ refl = refl ◅-injectiveʳ : (Star T i k ∋ x ◅ xs) ≡ y ◅ ys → xs ≡ ys ◅-injectiveʳ refl = refl
{ "alphanum_fraction": 0.5146726862, "avg_line_length": 29.5333333333, "ext": "agda", "hexsha": "c88cf76c8aa3774523e3e42d7d5830cd81426c71", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/ReflexiveTransitive/Properties/WithK.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/ReflexiveTransitive/Properties/WithK.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Construct/Closure/ReflexiveTransitive/Properties/WithK.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 227, "size": 886 }
{-# OPTIONS --without-K #-} module PointedTypes where open import Agda.Prim open import Data.Unit open import Data.Bool open import Data.Nat hiding (_⊔_) open import Data.Sum open import Data.Product open import Function open import Relation.Binary.PropositionalEquality ------------------------------------------------------------------------------ -- Pointed types -- We need pointed types because paths are ultimately between points. A path -- between false and 0 for example would be expressed as a path between -- (pt false) and (pt 0) which expand to •[ Bool , false ] and •[ ℕ , 0 ] -- First we define a pointed set as a carrier with a distinguished point record Set• (ℓ : Level) : Set (lsuc ℓ) where constructor •[_,_] field ∣_∣ : Set ℓ • : ∣_∣ open Set• public ⊤• : Set• lzero ⊤• = •[ ⊤ , tt ] _⊎•₁_ : {ℓ ℓ' : Level} → (A• : Set• ℓ) → (B• : Set• ℓ') → Set• (ℓ ⊔ ℓ') A• ⊎•₁ B• = •[ ∣ A• ∣ ⊎ ∣ B• ∣ , inj₁ (• A•) ] _⊎•₂_ : {ℓ ℓ' : Level} → (A• : Set• ℓ) → (B• : Set• ℓ') → Set• (ℓ ⊔ ℓ') A• ⊎•₂ B• = •[ ∣ A• ∣ ⊎ ∣ B• ∣ , inj₂ (• B•) ] _ו_ : {ℓ ℓ' : Level} → (A• : Set• ℓ) → (B• : Set• ℓ') → Set• (ℓ ⊔ ℓ') A• ו B• = •[ ∣ A• ∣ × ∣ B• ∣ , (• A• , • B•) ] test0 : Set• lzero test0 = •[ ℕ , 3 ] test1 : Set• (lsuc lzero) test1 = •[ Set , ℕ ] test2 : {ℓ ℓ' : Level} {A : Set ℓ} {B : Set ℓ'} {a : A} → Set• (ℓ ⊔ ℓ') test2 {ℓ} {ℓ'} {A} {B} {a} = •[ A ⊎ B , inj₁ a ] test3 : ∀ {ℓ} → Set• (lsuc (lsuc ℓ)) test3 {ℓ} = •[ Set (lsuc ℓ) , Set ℓ ] test4 : Set• lzero test4 = •[ (Bool → Bool) , not ] -- Now we focus on the points and move the carriers to the background pt : {ℓ : Level} {A : Set ℓ} → (a : A) → Set• ℓ pt {ℓ} {A} a = •[ A , a ] test5 : Set• lzero test5 = pt 3 test6 : Set• (lsuc lzero) test6 = pt ℕ test7 : {ℓ : Level} → Set• (lsuc (lsuc ℓ)) test7 {ℓ} = pt (Set ℓ) -- See: -- http://homotopytypetheory.org/2012/11/21/on-heterogeneous-equality/ beta : {ℓ : Level} {A : Set ℓ} {a : A} → • •[ A , a ] ≡ a beta {ℓ} {A} {a} = refl eta : {ℓ : Level} → (A• : Set• ℓ) → •[ ∣ A• ∣ , • A• ] ≡ A• eta {ℓ} A• = refl ------------------------------------------------------------------------------ -- Functions between pointed types; our focus is on how the functions affect -- the basepoint. We don't care what the functions do on the rest of the type. record _→•_ {ℓ ℓ' : Level} (A• : Set• ℓ) (B• : Set• ℓ') : Set (ℓ ⊔ ℓ') where field fun : ∣ A• ∣ → ∣ B• ∣ resp• : fun (• A•) ≡ • B• open _→•_ public id• : {ℓ : Level} {A• : Set• ℓ} → (A• →• A•) id• = record { fun = id ; resp• = refl } f1 : pt 2 →• pt 4 f1 = record { fun = suc ∘ suc ; resp• = refl } f2 : pt 2 →• pt 4 f2 = record { fun = λ x → 2 * x ; resp• = refl } -- composition of functions between pointed types _⊚_ : {ℓ₁ ℓ₂ ℓ₃ : Level} {A• : Set• ℓ₁} {B• : Set• ℓ₂} {C• : Set• ℓ₃} → (B• →• C•) → (A• →• B•) → (A• →• C•) h ⊚ g = record { fun = fun h ∘ fun g ; resp• = trans (cong (fun h) (resp• g)) (resp• h) } f3 : pt 4 →• pt 2 f3 = record { fun = pred ∘ pred ; resp• = refl } f1∘f3 : pt 4 →• pt 4 f1∘f3 = f1 ⊚ f3 -- two pointed functions are ∼ if they agree on the basepoints; we DON'T CARE -- what they do on the rest of the type. _∼•_ : {ℓ ℓ' : Level} {A• : Set• ℓ} {B• : Set• ℓ'} → (f• g• : A• →• B•) → Set ℓ' _∼•_ {ℓ} {ℓ'} {A•} {B•} f• g• = fun f• (• A•) ≡ fun g• (• A•) f1∼f2 : f1 ∼• f2 f1∼f2 = refl f1∘f3∼id : f1∘f3 ∼• id• f1∘f3∼id = refl -- quasi-inverses record qinv• {ℓ ℓ'} {A• : Set• ℓ} {B• : Set• ℓ'} (f• : A• →• B•) : Set (ℓ ⊔ ℓ') where constructor mkqinv• field g• : B• →• A• α• : (f• ⊚ g•) ∼• id• β• : (g• ⊚ f•) ∼• id• idqinv• : ∀ {ℓ} → {A• : Set• ℓ} → qinv• {ℓ} {ℓ} {A•} {A•} id• idqinv• = record { g• = id• ; α• = refl ; β• = refl } f1qinv : qinv• f1 f1qinv = record { g• = f3 ; α• = refl ; β• = refl } -- equivalences record isequiv• {ℓ ℓ'} {A• : Set• ℓ} {B• : Set• ℓ'} (f• : A• →• B•) : Set (ℓ ⊔ ℓ') where constructor mkisequiv• field g• : B• →• A• α• : (f• ⊚ g•) ∼• id• h• : B• →• A• β• : (h• ⊚ f•) ∼• id• equiv•₁ : ∀ {ℓ ℓ'} {A• : Set• ℓ} {B• : Set• ℓ'} {f• : A• →• B•} → qinv• f• → isequiv• f• equiv•₁ (mkqinv• qg qα qβ) = mkisequiv• qg qα qg qβ f1equiv : isequiv• f1 f1equiv = equiv•₁ f1qinv _≃•_ : ∀ {ℓ ℓ'} (A• : Set• ℓ) (B• : Set• ℓ') → Set (ℓ ⊔ ℓ') A ≃• B = Σ (A →• B) isequiv• idequiv• : ∀ {ℓ} {A• : Set• ℓ} → A• ≃• A• idequiv• = ( id• , equiv•₁ idqinv•) pt24equiv : pt 2 ≃• pt 4 pt24equiv = (f1 , f1equiv) ------------------------------------------------------------------------------ {-- old stuff which we might need again idright : {A B : Set} {a : A} {b : B} {p : •[ A , a ] ⇛ •[ B , b ]} → (trans⇛ p (id⇛ {B} {b})) 2⇛ p idright = 2Path id⇛ id⇛ idleft : {A B : Set} {a : A} {b : B} {p : •[ A , a ] ⇛ •[ B , b ]} → (trans⇛ (id⇛ {A} {a}) p) 2⇛ p idleft = 2Path id⇛ id⇛ assoc : {A B C D : Set} {a : A} {b : B} {c : C} {d : D} {p : •[ A , a ] ⇛ •[ B , b ]} {q : •[ B , b ] ⇛ •[ C , c ]} {r : •[ C , c ] ⇛ •[ D , d ]} → (trans⇛ p (trans⇛ q r)) 2⇛ (trans⇛ (trans⇛ p q) r) assoc = 2Path id⇛ id⇛ bifunctorid⋆ : {A B : Set} {a : A} {b : B} → (times⇛ (id⇛ {A} {a}) (id⇛ {B} {b})) 2⇛ (id⇛ {A × B} {(a , b)}) bifunctorid⋆ = 2Path id⇛ id⇛ bifunctorid₊₁ : {A B : Set} {a : A} → (plus₁⇛ {A} {B} {A} {B} (id⇛ {A} {a})) 2⇛ (id⇛ {A ⊎ B} {inj₁ a}) bifunctorid₊₁ = 2Path id⇛ id⇛ bifunctorid₊₂ : {A B : Set} {b : B} → (plus₂⇛ {A} {B} {A} {B} (id⇛ {B} {b})) 2⇛ (id⇛ {A ⊎ B} {inj₂ b}) bifunctorid₊₂ = 2Path id⇛ id⇛ bifunctorC⋆ : {A B C D E F : Set} {a : A} {b : B} {c : C} {d : D} {e : E} {f : F} {p : •[ A , a ] ⇛ •[ B , b ]} {q : •[ B , b ] ⇛ •[ C , c ]} {r : •[ D , d ] ⇛ •[ E , e ]} {s : •[ E , e ] ⇛ •[ F , f ]} → (trans⇛ (times⇛ p r) (times⇛ q s)) 2⇛ (times⇛ (trans⇛ p q) (trans⇛ r s)) bifunctorC⋆ = 2Path id⇛ id⇛ bifunctorC₊₁₁ : {A B C D E F : Set} {a : A} {b : B} {c : C} {p : •[ A , a ] ⇛ •[ B , b ]} {q : •[ B , b ] ⇛ •[ C , c ]} → (trans⇛ (plus₁⇛ {A} {D} {B} {E} p) (plus₁⇛ {B} {E} {C} {F} q)) 2⇛ (plus₁⇛ {A} {D} {C} {F} (trans⇛ p q)) bifunctorC₊₁₁ = 2Path id⇛ id⇛ bifunctorC₊₂₂ : {A B C D E F : Set} {d : D} {e : E} {f : F} {r : •[ D , d ] ⇛ •[ E , e ]} {s : •[ E , e ] ⇛ •[ F , f ]} → (trans⇛ (plus₂⇛ {A} {D} {B} {E} r) (plus₂⇛ {B} {E} {C} {F} s)) 2⇛ (plus₂⇛ {A} {D} {C} {F} (trans⇛ r s)) bifunctorC₊₂₂ = 2Path id⇛ id⇛ triangle : {A B : Set} {a : A} {b : B} → (trans⇛ (assocr⋆⇛ {A} {⊤} {B} {a} {tt} {b}) (times⇛ id⇛ unite⋆⇛)) 2⇛ (times⇛ (trans⇛ swap⋆⇛ unite⋆⇛) id⇛) triangle = 2Path id⇛ id⇛ -- Now interpret a path (x ⇛ y) as a value of type (1/x , y) Recip : {A : Set} → (x : • A) → Set₁ Recip {A} x = (x ⇛ x) η : {A : Set} {x : • A} → ⊤ → Recip x × • A η {A} {x} tt = (id⇛ x , x) lower : {A : Set} {x : • A} → x ⇛ x -> ⊤ lower c = tt -- The problem here is that we can't assert that y == x. ε : {A : Set} {x : • A} → Recip x × • A → ⊤ ε {A} {x} (rx , y) = lower (id⇛ ( ↑ (fun (ap rx) (focus y)) )) -- makes insufficient sense apr : {A B : Set} {x : • A} {y : • B} → (x ⇛ y) → Recip y → Recip x apr {A} {B} {x} {y} q ry = trans⇛ q (trans⇛ ry (sym⇛ q)) x ≡⟨ q ⟩ y ≡⟨ ry ⟩ y ≡⟨ sym⇛ q ⟩ x ∎ ε : {A B : Set} {x : A} {y : B} → Recip x → Singleton y → x ⇛ y ε rx (singleton y) = rx y pathV : {A B : Set} {x : A} {y : B} → (x ⇛ y) → Recip x × Singleton y pathV unite₊⇛ = {!!} pathV uniti₊⇛ = {!!} -- swap₁₊⇛ : {A B : Set} {x : A} → _⇛_ {A ⊎ B} {B ⊎ A} (inj₁ x) (inj₂ x) pathV (swap₁₊⇛ {A} {B} {x}) = ((λ x' → {!!}) , singleton (inj₂ x)) pathV swap₂₊⇛ = {!!} pathV assocl₁₊⇛ = {!!} pathV assocl₂₁₊⇛ = {!!} pathV assocl₂₂₊⇛ = {!!} pathV assocr₁₁₊⇛ = {!!} pathV assocr₁₂₊⇛ = {!!} pathV assocr₂₊⇛ = {!!} pathV unite⋆⇛ = {!!} pathV uniti⋆⇛ = {!!} pathV swap⋆⇛ = {!!} pathV assocl⋆⇛ = {!!} pathV assocr⋆⇛ = {!!} pathV dist₁⇛ = {!!} pathV dist₂⇛ = {!!} pathV factor₁⇛ = {!!} pathV factor₂⇛ = {!!} pathV dist0⇛ = {!!} pathV factor0⇛ = {!!} pathV {A} {.A} {x} (id⇛ .x) = {!!} pathV (sym⇛ p) = {!!} pathV (trans⇛ p p₁) = {!!} pathV (plus₁⇛ p) = {!!} pathV (plus₂⇛ p) = {!!} pathV (times⇛ p p₁) = {!!} -- these are individual paths so to speak -- should we represent a path like swap+ as a family explicitly: -- swap+ : (x : A) -> x ⇛ swapF x -- I guess we can: swap+ : (x : A) -> case x of inj1 -> swap1 x else swap2 x If A={x0,x1,x2}, 1/A has three values: (x0<-x0, x0<-x1, x0<-x2) (x1<-x0, x1<-x1, x1<-x2) (x2<-x0, x2<-x1, x2<-x2) It is a fake choice between x0, x1, and x2 (some negative information). You base yourself at x0 for example and enforce that any other value can be mapped to x0. So think of a value of type 1/A as an uncertainty about which value of A we have. It could be x0, x1, or x2 but at the end it makes no difference. There is no choice. You can manipulate a value of type 1/A (x0<-x0, x0<-x1, x0<-x2) by with a path to some arbitrary path to b0 for example: (b0<-x0<-x0, b0<-x0<-x1, b0<-x0<-x2) eta_3 will give (x0<-x0, x0<-x1, x0<-x2, x0) for example but any other combination is equivalent. epsilon_3 will take (x0<-x0, x0<-x1, x0<-x2) and one actual xi which is now certain; we can resolve our previous uncertainty by following the path from xi to x0 thus eliminating the fake choice we seemed to have. Explain connection to negative information. Knowing head or tails is 1 bits. Giving you a choice between heads and tails and then cooking this so that heads=tails takes away your choice. -- transp⇛ : {A B : Set} {x y : • A} → -- (f : A → B) → x ⇛ y → ↑ (f (focus x)) ⇛ ↑ (f (focus y)) -- Morphism of pointed space: contains a path! record _⟶_ {A B : Set} (pA : • A) (pB : • B) : Set₁ where field fun : A → B eq : ↑ (fun (focus pA)) ⇛ pB open _⟶_ _○_ : {A B C : Set} {pA : • A} {pB : • B} {pC : • C} → pA ⟶ pB → pB ⟶ pC → pA ⟶ pC f ○ g = record { fun = λ x → (fun g) ((fun f) x) ; eq = trans⇛ (transp⇛ (fun g) (eq f)) (eq g)} mutual ap : {A B : Set} {x : • A} {y : • B} → x ⇛ y → x ⟶ y ap {y = y} unite₊⇛ = record { fun = λ { (inj₁ ()) ; (inj₂ x) → x } ; eq = id⇛ y } ap uniti₊⇛ (singleton x) = singleton (inj₂ x) ap (swap₁₊⇛ {A} {B} {x}) (singleton .(inj₁ x)) = singleton (inj₂ x) ap (swap₂₊⇛ {A} {B} {y}) (singleton .(inj₂ y)) = singleton (inj₁ y) ap (assocl₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ x)) = singleton (inj₁ (inj₁ x)) ap (assocl₂₁₊⇛ {A} {B} {C} {y}) (singleton .(inj₂ (inj₁ y))) = singleton (inj₁ (inj₂ y)) ap (assocl₂₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ (inj₂ z))) = singleton (inj₂ z) ap (assocr₁₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ (inj₁ x))) = singleton (inj₁ x) ap (assocr₁₂₊⇛ {A} {B} {C} {y}) (singleton .(inj₁ (inj₂ y))) = singleton (inj₂ (inj₁ y)) ap (assocr₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ z)) = singleton (inj₂ (inj₂ z)) ap {.(⊤ × A)} {A} {.(tt , x)} {x} unite⋆⇛ (singleton .(tt , x)) = singleton x ap uniti⋆⇛ (singleton x) = singleton (tt , x) ap (swap⋆⇛ {A} {B} {x} {y}) (singleton .(x , y)) = singleton (y , x) ap (assocl⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .(x , (y , z))) = singleton ((x , y) , z) ap (assocr⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .((x , y) , z)) = singleton (x , (y , z)) ap (dist₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ x , z)) = singleton (inj₁ (x , z)) ap (dist₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ y , z)) = singleton (inj₂ (y , z)) ap (factor₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ (x , z))) = singleton (inj₁ x , z) ap (factor₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ (y , z))) = singleton (inj₂ y , z) ap {.(⊥ × A)} {.⊥} {.(• , x)} {•} (dist0⇛ {A} {.•} {x}) (singleton .(• , x)) = singleton • ap factor0⇛ (singleton ()) ap {x = x} (id⇛ .x) = record { fun = λ x → x; eq = id⇛ x } ap (sym⇛ c) = apI c ap (trans⇛ c₁ c₂) = (ap c₁) ○ (ap c₂) ap (transp⇛ f a) = record { fun = λ x → x; eq = transp⇛ f a } ap (plus₁⇛ {A} {B} {C} {D} {x} {z} c) (singleton .(inj₁ x)) with ap c (singleton x) ... | singleton .z = singleton (inj₁ z) ap (plus₂⇛ {A} {B} {C} {D} {y} {w} c) (singleton .(inj₂ y)) with ap c (singleton y) ... | singleton .w = singleton (inj₂ w) ap (times⇛ {A} {B} {C} {D} {x} {y} {z} {w} c₁ c₂) (singleton .(x , y)) with ap c₁ (singleton x) | ap c₂ (singleton y) ... | singleton .z | singleton .w = singleton (z , w) apI : {A B : Set} {x : • A} {y : • B} → x ⇛ y → y ⟶ x apI {y = y} unite₊⇛ = record { fun = inj₂; eq = id⇛ (↑ (inj₂ (focus y))) } apI {A} {.(⊥ ⊎ A)} {x} uniti₊⇛ (singleton .(inj₂ x)) = singleton x apI (swap₁₊⇛ {A} {B} {x}) (singleton .(inj₂ x)) = singleton (inj₁ x) apI (swap₂₊⇛ {A} {B} {y}) (singleton .(inj₁ y)) = singleton (inj₂ y) apI (assocl₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ (inj₁ x))) = singleton (inj₁ x) apI (assocl₂₁₊⇛ {A} {B} {C} {y}) (singleton .(inj₁ (inj₂ y))) = singleton (inj₂ (inj₁ y)) apI (assocl₂₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ z)) = singleton (inj₂ (inj₂ z)) apI (assocr₁₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ x)) = singleton (inj₁ (inj₁ x)) apI (assocr₁₂₊⇛ {A} {B} {C} {y}) (singleton .(inj₂ (inj₁ y))) = singleton (inj₁ (inj₂ y)) apI (assocr₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ (inj₂ z))) = singleton (inj₂ z) apI unite⋆⇛ (singleton x) = singleton (tt , x) apI {A} {.(⊤ × A)} {x} uniti⋆⇛ (singleton .(tt , x)) = singleton x apI (swap⋆⇛ {A} {B} {x} {y}) (singleton .(y , x)) = singleton (x , y) apI (assocl⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .((x , y) , z)) = singleton (x , (y , z)) apI (assocr⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .(x , (y , z))) = singleton ((x , y) , z) apI (dist₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ (x , z))) = singleton (inj₁ x , z) apI (dist₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ (y , z))) = singleton (inj₂ y , z) apI (factor₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ x , z)) = singleton (inj₁ (x , z)) apI (factor₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ y , z)) = singleton (inj₂ (y , z)) apI dist0⇛ (singleton ()) apI {.⊥} {.(⊥ × A)} {•} (factor0⇛ {A} {.•} {x}) (singleton .(• , x)) = singleton • apI {x = x} (id⇛ .x) = record { fun = λ x → x; eq = id⇛ x } apI (sym⇛ c) = ap c apI (trans⇛ c₁ c₂) = (apI c₂) ○ (apI c₁) apI (transp⇛ f a) = record { fun = λ x → x; eq = transp⇛ f (sym⇛ a) } apI (plus₁⇛ {A} {B} {C} {D} {x} {z} c) (singleton .(inj₁ z)) with apI c (singleton z) ... | singleton .x = singleton (inj₁ x) apI (plus₂⇛ {A} {B} {C} {D} {y} {w} c) (singleton .(inj₂ w)) with apI c (singleton w) ... | singleton .y = singleton (inj₂ y) apI (times⇛ {A} {B} {C} {D} {x} {y} {z} {w} c₁ c₂) (singleton .(z , w)) with apI c₁ (singleton z) | apI c₂ (singleton w) ... | singleton .x | singleton .y = singleton (x , y) --}
{ "alphanum_fraction": 0.4745150502, "avg_line_length": 33.5201793722, "ext": "agda", "hexsha": "ad427e47db742b99c9084f315ed3e6dc7cdad518", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "PointedTypes.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "PointedTypes.agda", "max_line_length": 95, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "PointedTypes.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 7289, "size": 14950 }
------------------------------------------------------------------------------ -- Properties for the equality on Conat ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Conat.Equality.PropertiesATP where open import FOTC.Base open import FOTC.Data.Conat open import FOTC.Data.Conat.Equality.Type ------------------------------------------------------------------------------ -- Because a greatest post-fixed point is a fixed-point, then the -- relation _≈N_ is also a pre-fixed point of the functional ≈-F, i.e. -- -- ≈-F _≈_ ≤ _≈_ (see FOTC.Data.Conat.Equality.Type). -- See Issue https://github.com/asr/apia/issues/81 . ≈-inR : D → D → Set ≈-inR m n = m ≡ zero ∧ n ≡ zero ∨ (∃[ m' ] ∃[ n' ] m ≡ succ₁ m' ∧ n ≡ succ₁ n' ∧ m' ≈ n') {-# ATP definition ≈-inR #-} ≈-in : ∀ {m n} → m ≡ zero ∧ n ≡ zero ∨ (∃[ m' ] ∃[ n' ] m ≡ succ₁ m' ∧ n ≡ succ₁ n' ∧ m' ≈ n') → m ≈ n ≈-in h = ≈-coind ≈-inR h' h where postulate h' : ∀ {m n} → ≈-inR m n → m ≡ zero ∧ n ≡ zero ∨ (∃[ m' ] ∃[ n' ] m ≡ succ₁ m' ∧ n ≡ succ₁ n' ∧ ≈-inR m' n') {-# ATP prove h' #-} -- See Issue https://github.com/asr/apia/issues/81 . ≈-reflR : D → D → Set ≈-reflR a b = Conat a ∧ Conat b ∧ a ≡ b {-# ATP definition ≈-reflR #-} ≈-refl : ∀ {n} → Conat n → n ≈ n ≈-refl {n} Cn = ≈-coind ≈-reflR h₁ h₂ where postulate h₁ : ∀ {a b} → ≈-reflR a b → a ≡ zero ∧ b ≡ zero ∨ (∃[ a' ] ∃[ b' ] a ≡ succ₁ a' ∧ b ≡ succ₁ b' ∧ ≈-reflR a' b') {-# ATP prove h₁ #-} postulate h₂ : ≈-reflR n n {-# ATP prove h₂ #-} postulate ≡→≈ : ∀ {m n} → Conat m → Conat n → m ≡ n → m ≈ n {-# ATP prove ≡→≈ ≈-refl #-}
{ "alphanum_fraction": 0.4419354839, "avg_line_length": 31, "ext": "agda", "hexsha": "285b995b9bc1ef9e6522fef700fbdf8f9a3bfa21", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Data/Conat/Equality/PropertiesATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Data/Conat/Equality/PropertiesATP.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/Conat/Equality/PropertiesATP.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 686, "size": 1860 }
{- Product of structures S and T: X ↦ S X × T X -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Structures.Relational.Product where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Structure open import Cubical.Foundations.RelationalStructure open import Cubical.Foundations.SIP open import Cubical.Foundations.Univalence open import Cubical.Data.Sigma open import Cubical.HITs.SetQuotients open import Cubical.Structures.Product private variable ℓ ℓ₁ ℓ₁' ℓ₂ ℓ₂' : Level -- Structured relations preservesSetsProduct : {S₁ : Type ℓ → Type ℓ₁} {S₂ : Type ℓ → Type ℓ₂} → preservesSets S₁ → preservesSets S₂ → preservesSets (ProductStructure S₁ S₂) preservesSetsProduct p₁ p₂ setX = isSet× (p₁ setX) (p₂ setX) ProductRelStr : {S₁ : Type ℓ → Type ℓ₁} (ρ₁ : StrRel S₁ ℓ₁') {S₂ : Type ℓ → Type ℓ₂} (ρ₂ : StrRel S₂ ℓ₂') → StrRel (ProductStructure S₁ S₂) (ℓ-max ℓ₁' ℓ₂') ProductRelStr ρ₁ ρ₂ R (s₁ , s₂) (t₁ , t₂) = ρ₁ R s₁ t₁ × ρ₂ R s₂ t₂ open SuitableStrRel productSuitableRel : {S₁ : Type ℓ → Type ℓ₁} {ρ₁ : StrRel S₁ ℓ₁'} {S₂ : Type ℓ → Type ℓ₂} {ρ₂ : StrRel S₂ ℓ₂'} → SuitableStrRel S₁ ρ₁ → SuitableStrRel S₂ ρ₂ → SuitableStrRel (ProductStructure S₁ S₂) (ProductRelStr ρ₁ ρ₂) productSuitableRel θ₁ θ₂ .quo (X , s₁ , s₂) R (r₁ , r₂) .fst .fst = θ₁ .quo (X , s₁) R r₁ .fst .fst , θ₂ .quo (X , s₂) R r₂ .fst .fst productSuitableRel θ₁ θ₂ .quo (X , s₁ , s₂) R (r₁ , r₂) .fst .snd = θ₁ .quo (X , s₁) R r₁ .fst .snd , θ₂ .quo (X , s₂) R r₂ .fst .snd productSuitableRel θ₁ θ₂ .quo (X , s₁ , s₂) R (r₁ , r₂) .snd ((q₁ , q₂) , (c₁ , c₂)) i .fst = θ₁ .quo (X , s₁) R r₁ .snd (q₁ , c₁) i .fst , θ₂ .quo (X , s₂) R r₂ .snd (q₂ , c₂) i .fst productSuitableRel θ₁ θ₂ .quo (X , s₁ , s₂) R (r₁ , r₂) .snd ((q₁ , q₂) , (c₁ , c₂)) i .snd = θ₁ .quo (X , s₁) R r₁ .snd (q₁ , c₁) i .snd , θ₂ .quo (X , s₂) R r₂ .snd (q₂ , c₂) i .snd productSuitableRel θ₁ θ₂ .symmetric R (r₁ , r₂) = θ₁ .symmetric R r₁ , θ₂ .symmetric R r₂ productSuitableRel θ₁ θ₂ .transitive R R' (r₁ , r₂) (r₁' , r₂') = θ₁ .transitive R R' r₁ r₁' , θ₂ .transitive R R' r₂ r₂' productSuitableRel θ₁ θ₂ .prop propR (s₁ , s₂) (t₁ , t₂) = isProp× (θ₁ .prop propR s₁ t₁) (θ₂ .prop propR s₂ t₂) productRelMatchesEquiv : {S₁ : Type ℓ → Type ℓ₁} (ρ₁ : StrRel S₁ ℓ₁') {ι₁ : StrEquiv S₁ ℓ₁'} {S₂ : Type ℓ → Type ℓ₂} (ρ₂ : StrRel S₂ ℓ₂') {ι₂ : StrEquiv S₂ ℓ₂'} → StrRelMatchesEquiv ρ₁ ι₁ → StrRelMatchesEquiv ρ₂ ι₂ → StrRelMatchesEquiv (ProductRelStr ρ₁ ρ₂) (ProductEquivStr ι₁ ι₂) productRelMatchesEquiv ρ₁ ρ₂ μ₁ μ₂ A B e = Σ-cong-equiv (μ₁ _ _ e) (λ _ → μ₂ _ _ e)
{ "alphanum_fraction": 0.6621873834, "avg_line_length": 39.9850746269, "ext": "agda", "hexsha": "03106a480cad0c6309ac6c51045cd7f78739a526", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "RobertHarper/cubical", "max_forks_repo_path": "Cubical/Structures/Relational/Product.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "RobertHarper/cubical", "max_issues_repo_path": "Cubical/Structures/Relational/Product.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "RobertHarper/cubical", "max_stars_repo_path": "Cubical/Structures/Relational/Product.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1182, "size": 2679 }
module Issue498b where record ⊤ : Set where constructor tt postulate U : Set → Set pr : ∀ {A} → A → U A _*_ : ∀ {A B} → U A → (A → U B) → U B module M (I : Set)(J : I → Set)(K : (i : I)(j : J i) → Set) where data D (P : I → Set) : I → Set where r : ∀ {i} → P i → D P i d : (i : I)(j : J i) (f : K i j → D P i) → D P i module N (e : (i : I)(j : J i) → U (K i j)) where du : ∀ {P}{i : I} → D P i → U (P i) du (r p) = pr p du (d i j f) = e i j * λ k → du (f k) data j : ⊤ → Set where cj : j _ k : (i : ⊤)(j : j i) → Set k _ j = ⊤ e : (i : ⊤)(j : j i) → U (k i j) e tt cj = pr tt open M ⊤ j k open N e
{ "alphanum_fraction": 0.4036418816, "avg_line_length": 17.8108108108, "ext": "agda", "hexsha": "f23b0e42672dab4492067a0f7cac41f3db11faeb", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue498b.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue498b.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue498b.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 310, "size": 659 }
-- Andreas, 2016-10-08 issue #2243 -- This is a test case reported at #708 by pepijnkokke open import Common.Bool using (Bool; true; false) open import Common.Reflection using (QName) example : QName → Bool example (quote Bool) = true example (quote Bool) = false example _ = false
{ "alphanum_fraction": 0.7084745763, "avg_line_length": 26.8181818182, "ext": "agda", "hexsha": "42cd6734232bad57308f382f2bba43e410d61e79", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue708quote.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue708quote.agda", "max_line_length": 54, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue708quote.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 80, "size": 295 }
module Data.Unsigned where open import Data.Bit using (Bit ; b0 ; b1 ; Bits-num ; Overflowing ; _overflow:_ ; result ; carry ; WithCarry ; _with-carry:_ ; toBool ; tryToFinₙ ; !ₙ ) renaming ( _+_ to bit+ ; _-_ to bit- ; ! to bit! ; _&_ to bit& ; _~|_ to bit| ; _^_ to bit^ ; _>>_ to bit>> ; _<<_ to bit<< ) open import Data.Unit using (⊤) open import Data.Nat using (ℕ) open import Data.Vec using (Vec; head; replicate) open import Data.Nat.Literal using (Number) open import Data.Maybe using (just; nothing) infixl 8 _-_ _+_ infixl 7 _<<_ _>>_ infixl 6 _&_ infixl 5 _^_ infixl 4 _~|_ record Unsigned (n : ℕ) : Set where constructor mk-uint field bits : Vec Bit n open Unsigned public instance Unsigned-num : {m : ℕ} → Number (Unsigned m) Unsigned-num {m} .Number.Constraint = Number.Constraint (Bits-num {m}) Unsigned-num {m} .Number.fromNat n ⦃ p ⦄ = mk-uint (mk-bits p) where mk-bits : Number.Constraint (Bits-num {m}) n → Vec Bit m mk-bits p = Number.fromNat Bits-num n ⦃ p ⦄ _+_ : {n : ℕ} → Unsigned n → Unsigned n → Overflowing (Unsigned n) p + q = mk-uint (result sum) overflow: toBool (head (carry sum)) where sum = bit+ (bits p) (bits q) _-_ : {n : ℕ} → Unsigned n → Unsigned n → Overflowing (Unsigned n) p - q = mk-uint (result sub) overflow: toBool (bit! (head (carry sub))) where sub = bit- (bits p) (bits q) rotr : {n : ℕ} → Unsigned n → Unsigned n → WithCarry (Unsigned n) (Unsigned n) rotr {n} (mk-uint ps) (mk-uint qs) = new-result with-carry: new-carry where shifted : WithCarry (Vec Bit n) (Vec Bit n) shifted with tryToFinₙ qs ... | just i = bit>> ps i ... | nothing = replicate b0 with-carry: ps new-result : Unsigned n new-result = mk-uint (result shifted) new-carry : Unsigned n new-carry = mk-uint (carry shifted) rotl : {n : ℕ} → Unsigned n → Unsigned n → WithCarry (Unsigned n) (Unsigned n) rotl {n} (mk-uint ps) (mk-uint qs) = new-result with-carry: new-carry where shifted : WithCarry (Vec Bit n) (Vec Bit n) shifted with tryToFinₙ qs ... | just i = bit<< ps i ... | nothing = replicate b0 with-carry: ps new-result : Unsigned n new-result = mk-uint (result shifted) new-carry : Unsigned n new-carry = mk-uint (carry shifted) _>>_ : {n : ℕ} → Unsigned n → Unsigned n → Unsigned n ps >> qs = result (rotr ps qs) _<<_ : {n : ℕ} → Unsigned n → Unsigned n → Unsigned n ps << qs = result (rotl ps qs) ! : {n : ℕ} → Unsigned n → Unsigned n ! (mk-uint ps) = mk-uint (!ₙ ps) _&_ : {n : ℕ} → Unsigned n → Unsigned n → Unsigned n (mk-uint ps) & (mk-uint qs) = mk-uint (bit& ps qs) _~|_ : {n : ℕ} → Unsigned n → Unsigned n → Unsigned n (mk-uint ps) ~| (mk-uint qs) = mk-uint (bit| ps qs) _^_ : {n : ℕ} → Unsigned n → Unsigned n → Unsigned n (mk-uint ps) ^ (mk-uint qs) = mk-uint (bit^ ps qs)
{ "alphanum_fraction": 0.6175647306, "avg_line_length": 28.58, "ext": "agda", "hexsha": "7c9bad78a86a82edd29eaa3b08f868fc4ec30cc1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9f5129d97ee7b89fb8e43136779a78806b7506ab", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "brunoczim/Celeste", "max_forks_repo_path": "formalization/Data/Unsigned.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9f5129d97ee7b89fb8e43136779a78806b7506ab", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "brunoczim/Celeste", "max_issues_repo_path": "formalization/Data/Unsigned.agda", "max_line_length": 78, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9f5129d97ee7b89fb8e43136779a78806b7506ab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "brunoczim/Celeste", "max_stars_repo_path": "formalization/Data/Unsigned.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-16T17:31:57.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-16T17:31:57.000Z", "num_tokens": 1012, "size": 2858 }
{-# OPTIONS --without-K --safe #-} module Definition.Conversion.Universe where open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.RedSteps open import Definition.Conversion open import Definition.Conversion.Reduction open import Definition.Conversion.Lift import Tools.PropositionalEquality as PE -- Algorithmic equality of terms in WHNF of type U are equal as types. univConv↓ : ∀ {A B Γ} → Γ ⊢ A [conv↓] B ∷ U → Γ ⊢ A [conv↓] B univConv↓ (ne-ins t u () x) univConv↓ (univ x x₁ x₂) = x₂ -- Algorithmic equality of terms of type U are equal as types. univConv↑ : ∀ {A B Γ} → Γ ⊢ A [conv↑] B ∷ U → Γ ⊢ A [conv↑] B univConv↑ ([↑]ₜ B₁ t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) rewrite PE.sym (whnfRed* D Uₙ) = reductionConv↑ (univ* d) (univ* d′) (liftConv (univConv↓ t<>u))
{ "alphanum_fraction": 0.6748878924, "avg_line_length": 29.7333333333, "ext": "agda", "hexsha": "94696de098ec3a221effa932d2b74c36c8c467ac", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/Conversion/Universe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/Conversion/Universe.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/Conversion/Universe.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 286, "size": 892 }
{-# OPTIONS --without-K #-} {- Here, we derive our main theorem: there is a type in the n-th universe that is not an n-type, implying the n-th universe is not n-truncated. The n-th universe restricted to n-types is hence a 'strict' n-type. For this, we first derive local-global looping in a modular way. A technical point worth noting is that Agda does not implement cumulative universes. Since that means the crucial steps in our transformations (where we pass between universes uning univalence) can not be expressed using equality without resorting to explicit lifting, we decide to explicitely uses equivalences (and pointed equivalences, respectively) instead where possible. As a drawback, we have to use lemmata showing preservation of (pointed) equivalences of various (pointed) type constructions, a parametricity property derived for free from univalence-induced equalities. -} module HHHUU-ComplicatedTypes where open import lib.Basics hiding (_⊔_) open import lib.Equivalences2 open import lib.NType2 open import lib.types.Bool open import lib.types.Nat hiding (_+_) open import lib.types.Paths open import lib.types.Sigma open import lib.types.Pi open import lib.types.TLevel open import Preliminaries open import Pointed open import UniverseOfNTypes -- The argument that (Type lzero) is not a set is standard. -- We omit it and the argument that (Type (S lzero)) is not a 1-Type: -- they are both special cases of the general theorem we prove. -- The general theorem is formalised in this file. --Definition 7.3.1 -- We have fibered notions of the loop space contruction and n-truncatedness. module _ {i} {X : Type• i} {j} where {- Note that the definition of the family of path types differs slightly from that in the thesis, which would correspond to transport P p x == x. We use dependent paths since this follows the design of the HoTT community's Agda library. There is no actual difference; both types are equivalent. -} Ω̃ : Fam• X j → Fam• (Ω X) j Ω̃ (P , x) = ((λ p → x == x [ P ↓ p ]) , idp) fam-has-level : ℕ₋₂ → Fam• X j → Type (i ⊔ j) fam-has-level n Q = (a : base X) → has-level n (fst Q a) {- == Pointed dependent sums == Pointed families as defined above enable us to introduce a Σ-connective for pointed types. Because of the abstract nature of some of our lemmata, we give Σ• in its uncurried form and first define the type of its parameter. -} Σ•-param : ∀ i j → Type (lsucc (i ⊔ j)) Σ•-param i j = Σ (Type• i) (λ X → Fam• X j) module _ {i j} where Ω-Σ•-param : Σ•-param i j → Σ•-param i j Ω-Σ•-param (X , W) = (Ω X , Ω̃ W) -- Definition 7.3.2 Σ• : Σ•-param i j → Type• (i ⊔ j) Σ• (X , Q) = (Σ (base X) (fst Q) , (pt X , snd Q)) -- Lemma 7.3.3 {- Commutativity of pointed dependent sums and the loop space construction will become an important technical tool, enabling us to work at a more abstract level later on. -} Ω-Σ•-comm : (R : Σ•-param i j) → Ω (Σ• R) ≃• Σ• (Ω-Σ•-param R) Ω-Σ•-comm _ = (=Σ-eqv _ _ , idp) ⁻¹• {- Pointed dependent products. This is not quite the equivalent of Π for pointed types: the domain parameter is just an ordinary non-pointed type. However, to enable our goal of abstractly working with pointed types, defining this notion is useful. -} Π•-param : ∀ i j → Type (lsucc (i ⊔ j)) Π•-param i j = Σ (Type i) (λ A → A → Type• j) module _ {i j} where Ω-Π•-param : Π•-param i j → Π•-param i j Ω-Π•-param (A , F) = (A , Ω ∘ F) -- Definition 7.3.4 Π• : Π•-param i j → Type• (i ⊔ j) Π• (A , Y) = (Π A (base ∘ Y) , pt ∘ Y) -- Lemma 7.3.5 {- Pointed dependent products and loop space construction on its codomain parameter commute as well. -} Ω-Π•-comm : (R : Π•-param i j) → Ω (Π• R) ≃• Π• (Ω-Π•-param R) Ω-Π•-comm _ = (app=-equiv , idp) Ω^-Π•-comm : (C : Type i) (F : C → Type• j) (n : ℕ) → (Ω ^ n) (Π• (C , F)) ≃• Π• (C , ((Ω ^ n) ∘ F)) Ω^-Π•-comm C F 0 = ide• _ Ω^-Π•-comm C F (S n) = Ω^-Π•-comm C _ n ∘e• equiv-Ω^ n (Ω-Π•-comm _) equiv-Π• : ∀ {i₀ i₁ j₀ j₁} {R₀ : Π•-param i₀ j₀} {R₁ : Π•-param i₁ j₁} → Σ (fst R₀ ≃ fst R₁) (λ u → ∀ a → snd R₀ (<– u a) ≃• snd R₁ a) → Π• R₀ ≃• Π• R₁ equiv-Π• (u , v) = (equiv-Π u (fst ∘ v) , λ= (snd ∘ v)) -- Lemma 7.4.1 -- In an n-th loop space, we can forget components of truncation level n. forget-Ω^-Σ•₂ : ∀ {i j} {X : Type• i} (Q : Fam• X j) (n : ℕ) → fam-has-level (n -2) Q → (Ω ^ n) (Σ• (X , Q)) ≃• (Ω ^ n) X forget-Ω^-Σ•₂ {X = X} Q O h = (Σ₂-contr h , idp) forget-Ω^-Σ•₂ {i} {X = X} Q (S n) h = (Ω ^ (S n)) (Σ• (X , Q)) ≃•⟨ equiv-Ω^ n (Ω-Σ•-comm _) ⟩ (Ω ^ n) (Σ• (Ω X , Ω̃ Q)) ≃•⟨ forget-Ω^-Σ•₂ {i} _ n (λ _ → ↓-level h) ⟩ (Ω ^ (S n)) X ≃•∎ -- Lemma 7.4.2 {- Our Local-global looping principle. We would like to state this principle in the form of Ωⁿ⁺¹ (Type i , A) == ∀• a → Ωⁿ (A , a) for n ≥ 1. Unfortunately, the two sides have different universe levels since (Type i , A) lives in Type• (suc i) instead of Type• i. Morally, this is outbalanced by the extra Ω on the left-hand side, which might help explain on an intuitive level why the n-th universe ends up being not an n-type. The reason why the univalence principle (A ≡ B) ≃ (A ≃ B) cannot be written as (A ≡ B) ≡ (A ≃ B) is precisely the same. -} module _ {i} {A : Type i} where -- The degenerate pre-base case carries around a propositional component. Ω-Type : Ω (Type i , A) ≃• Σ• (Π• (A , λ a → (A , a)) , (is-equiv , idf-is-equiv _)) Ω-Type = Ω (Type i , A) ≃•⟨ ide• _ ⟩ ((A == A) , idp) ≃•⟨ ua-equiv• ⁻¹• ⟩ ((A ≃ A) , ide _) ≃•⟨ ide• _ ⟩ ((Σ (A → A) is-equiv) , (idf _ , idf-is-equiv _)) ≃•⟨ ide• _ ⟩ Σ• (Π• (A , λ a → (A , a)) , (is-equiv , idf-is-equiv _)) ≃•∎ -- The base case. Ω²-Type : (Ω ^ 2) (Type i , A) ≃• Π• (A , λ a → Ω (A , a)) Ω²-Type = (Ω ^ 2) (Type i , A) ≃•⟨ equiv-Ω Ω-Type ⟩ Ω (Σ• (Π• (A , λ a → (A , a)) , (is-equiv , idf-is-equiv _))) ≃•⟨ forget-Ω^-Σ•₂ {i} _ 1 (is-equiv-is-prop ∘ _) ⟩ Ω (Π• (A , λ a → (A , a))) ≃•⟨ Ω-Π•-comm _ ⟩ Π• (A , λ a → Ω (A , a)) ≃•∎ -- The general case follows by permuting Ω and Π• repeatedly. Ω^-Type : (n : ℕ) → (Ω ^ (n + 2)) (Type i , A) ≃• Π• (A , λ a → (Ω ^ (n + 1)) (A , a)) Ω^-Type n = Ω^-Π•-comm _ _ n ∘e• equiv-Ω^ n Ω²-Type -- Lemma 7.4.3 is taken from the library -- lib.NType2._-Type-level_ {- The pointed family P (see thesis). It takes an n-type A and returns the space of (n+1)-loops with basepoint A in U_n^n (the n-th universe restricted to n-types). This crucial restriction to n-types implies it is just a set. -} module _ (n : ℕ) (A : ⟨ n ⟩ -Type 「 n 」) where -- Definition of P and -- Corollary 7.4.4 P : ⟨0⟩ -Type• 「 n + 1 」 P = Ω^-≤' (n + 1) q where q : ⟨ n + 1 ⟩ -Type• 「 n + 1 」 q = –> Σ-comm-snd (((⟨ n ⟩ -Type-≤ 「 n 」) , A)) -- Forgetting about the truncation level, we may present P as follows: Q : Type• 「 n + 1 」 Q = (Ω ^ (n + 1)) (Type 「 n 」 , fst A) P-is-Q : fst P ≃• Q P-is-Q = equiv-Ω^ n (forget-Ω^-Σ•₂ _ 1 (λ _ → has-level-is-prop)) -- Definition of the type 'Loop' and -- Lemma 7.4.5 {- The type 'Loop' of (images of) n-loops in U_(n-1)^(n-1) is just the dependent sum over P except for the special case n ≡ 0, where we take U_(-1)^(-1) (and hence Loop) to be the booleans. The boilerplate with raise-≤T is just to verify that Loop n is n-truncated. The bulk of the rest of this module consists of showing the n-th universe is not n-truncated at basepoint Loop n, i.e. that Q n (Loop n) is not contractible. Warning: The indexing of Loop starts at -1 in the thesis, but we use natural numbers here (starting at 0), thus everything is shifted by one. -} Loop : (n : ℕ) → ⟨ n ⟩ -Type 「 n 」 Loop 0 = (Bool , Bool-is-set) Loop (S n) = Σ-≤ (⟨ n ⟩ -Type-≤ 「 n 」) (λ A → raise-≤T {n = ⟨ n + 1 ⟩} (≤T-+2+-l ⟨0⟩ (-2≤T _)) (fst (<– Σ-comm-snd (P n A)))) -- Lemma 7.4.6, preparations -- The base case is given in Section 7.2 or the thesis. -- It is done as usual (there is a non-trivial automorphism on booleans). -- Let us go slowly. module negation where -- Negation. ~ : Bool → Bool ~ = λ {true → false; false → true} -- Negation is an equivalence. e : Bool ≃ Bool e = equiv ~ ~ inv inv where inv = λ {true → idp; false → idp} base-case : ¬ (is-contr• (Q 0 (Loop 0))) base-case c = Bool-false≠true false-is-true where -- Negation being equal to the identity yields a contradiction. false-is-true = false =⟨ ! (coe-β e true) ⟩ coe (ua e) true =⟨ ap (λ p → coe p true) (! (c (ua e))) ⟩ coe idp true =⟨ idp ⟩ true ∎ -- Let us now turn towards the successor case. module _ (m : ℕ) where -- We expand the type we are later going to assume contractible. Q-L-is-… = Q (m + 1) (Loop (m + 1)) ≃•⟨ ide• _ ⟩ (Ω ^ (m + 2)) (_ , ⟦ Loop (m + 1) ⟧) ≃•⟨ (Ω^-Type m) ⟩ Π• (_ , λ {(A , q) → Ω ^ (m + 1) $ (⟦ Loop (m + 1) ⟧ , (A , q))}) ≃•⟨ ide• _ ⟩ Π• (_ , λ {(A , q) → Ω ^ (m + 1) $ Σ• ((_ , A) , (base ∘ fst ∘ P m , q))}) ≃•∎ -- What we really want is to arrive at contractibility of E (m ≥ 1)... E = Π• (⟦ Loop (m + 1) ⟧ , λ {(A , q) → Ω ^ (m + 1) $ ((⟨ m ⟩ -Type 「 m 」) , A)}) -- ...or at least show that the following element f of E is trivial (m ≡ 0). f : base E f (_ , q) = q -- We want to use our assumption of contractibility of Q (n + 1) (Loop (n + 1)) -- to show that f is trivial, i.e. constant with value the basepoint. f-is-trivial : (m : ℕ) → is-contr• (Q (m + 1) (Loop (m + 1))) → f m == pt (E m) -- m ≡ 0 f-is-trivial 0 c = ap (λ f' → fst ∘ f') (! (–> (equiv-is-contr• …-is-E') c f')) where -- This is almost E, except for the additional component -- specifying that the first component p should commute with q. E' = Π• (_ , λ {(A , q) → (Σ (A == A) (λ p → q == q [ (λ x → x == x) ↓ p ]) , (idp , idp))}) -- This "almost" E comes from Q 1 (Loop 1), hence can be shown contractible. …-is-E' : Q 1 (Loop 1) ≃• E' …-is-E' = equiv-Π• (ide _ , Ω-Σ•-comm ∘ _) ∘e• Q-L-is-… 0 -- Fortunately, f can be 'extended' to an element f' of E', -- and triviality of f' implies triviality of f. f' = λ {(_ , q) → (q , ↓-idf=idf-in (∙=∙' q q))} -- m ≥ 1: We can show Q (k + 2) (Loop (k + 2)) ≃ E (k + 1), -- thus E is contractible, hence f trivial. f-is-trivial (S k) c = ! (–> (equiv-is-contr• (…-is-E ∘e• Q-L-is-… (k + 1))) c (f (k + 1))) where …-is-E : _ ≃• E (k + 1) …-is-E = equiv-Π• (ide _ , equiv-Ω^ k ∘ (λ {(A , q) → forget-Ω^-Σ•₂ {「 k + 2 」} (base ∘ fst ∘ P (k + 1) , q) 2 (snd ∘ P (k + 1))})) -- Lemma 7.4.6, part 1 -- Our main lemma: like in the thesis, but in negative form. -- This is sufficient to prove our results, and easier to formalise. main : (n : ℕ) → ¬ (is-contr• (Q n (Loop n))) main 0 = negation.base-case main (S m) c = main m step where {- We know Q (m + 1) (Loop (m + 1)) is contractible, use that to show that the above f is trivial, deduce f (Loop m , p) ≡ p is trivial for all p in P m (Loop m), which implies P m (Loop m) is contractible. But this is just another form of Q m (Loop m), so the conclusion follows by induction hypothesis. -} step : is-contr• (Q m (Loop m)) step = –> (equiv-is-contr• (P-is-Q m (Loop m))) (λ q → app= (! (f-is-trivial m c)) (Loop m , q)) -- Lemma 7.4.6, part 2 -- Alternate form of the main lemma main' : (n : ℕ) → ¬ (is-contr• ((Ω ^ (n + 1)) ((⟨ n ⟩ -Type 「 n 」) , Loop n ))) main' n = main n ∘ –> (equiv-is-contr• (P-is-Q n (Loop n))) -- Small helper thingy helpy : ∀ {i} {n : ℕ} {X : Type• i} → has-level• (n -1) X → is-contr• ((Ω ^ n) X) helpy {n = n} {X} = <– contr•-equiv-prop ∘ trunc-many n ∘ transport (λ k → has-level• (k -2) X) (+-comm 1 n) -- Main theorems now fall out as corollaries. module _ (n : ℕ) where {- Recall that L n is n-truncated. We also know it is not (n-1)-truncated, it is thus a 'strict' n-type. -} Loop-is-not-trunc : ¬ (has-level (n -1) ⟦ Loop n ⟧) Loop-is-not-trunc = main n ∘ helpy ∘ (λ t → universe-=-level t t) -- Theorem 7.4.7 -- The n-th universe is not n-truncated. Type-is-not-trunc : ¬ (has-level ⟨ n ⟩ (Type 「 n 」)) Type-is-not-trunc = main n ∘ helpy -- Theorem 7.4.8 -- MAIN RESULT: -- The n-th universe restricted to n-types is a 'strict' (n+1)-type. -- We do not repeat that it is (n+1)-truncated; this is formalised above -- (7.4.3). Instead, we only show that it is not an n-type. Type-≤-is-not-trunc : ¬ (has-level ⟨ n ⟩ (⟨ n ⟩ -Type 「 n 」)) Type-≤-is-not-trunc = main' n ∘ helpy
{ "alphanum_fraction": 0.5561823449, "avg_line_length": 38.6961651917, "ext": "agda", "hexsha": "18df341da36d566d78e8c81528bd3e7f95dc6b53", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "nicolai/thesis/HHHUU-ComplicatedTypes.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "nicolai/thesis/HHHUU-ComplicatedTypes.agda", "max_line_length": 83, "max_stars_count": 1, "max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nicolaikraus/HoTT-Agda", "max_stars_repo_path": "nicolai/thesis/HHHUU-ComplicatedTypes.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z", "num_tokens": 5027, "size": 13118 }
module Issue478c where record Ko (Q : Set) : Set₁ where field T : Set foo : (Q : Set)(ko : Ko Q) → Ko.T ko foo Q ko = Set -- We should make sure not to destroy printing -- outside the record module. Type should be -- printed as it's given: Ko.T ko
{ "alphanum_fraction": 0.6614173228, "avg_line_length": 19.5384615385, "ext": "agda", "hexsha": "4528378e65a57c99e42ac103b3ecbd19eebc2799", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/Issue478c.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/Issue478c.agda", "max_line_length": 46, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/Issue478c.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 79, "size": 254 }
module NoSuchPrimitiveFunction where postulate X : Set primitive fooBar : X
{ "alphanum_fraction": 0.7682926829, "avg_line_length": 10.25, "ext": "agda", "hexsha": "ab61f53a2409e608000b85744ee5f8a2417fc21b", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/NoSuchPrimitiveFunction.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/NoSuchPrimitiveFunction.agda", "max_line_length": 36, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/NoSuchPrimitiveFunction.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 22, "size": 82 }
------------------------------------------------------------------------ -- INCREMENTAL λ-CALCULUS -- -- Change Structures. -- -- This module defines the notion of change structures, -- as well as change structures for groups, functions and lists. -- -- This module corresponds to Section 2 of the PLDI paper. ------------------------------------------------------------------------ module Base.Change.Algebra where open import Relation.Binary.PropositionalEquality open import Level -- Change Algebras -- =============== -- -- In the paper, change algebras are called "change structures" -- and they are described in Section 2.1. We follow the design of -- the Agda standard library and define change algebras as two -- records, so Definition 2.1 from the PLDI paper maps to the -- records IsChangeAlgebra and ChangeAlgebra. -- -- A value of type (IsChangeAlgebra Change update diff) proves that -- Change, update and diff together form a change algebra. -- -- A value of type (ChangeAlgebra Carrier) contains the necessary -- ingredients to create a change algebra for a carrier set. -- -- In the paper, Carrier is called V (Def. 2.1a), -- Change is called Δ (Def. 2.1b), -- update is written as infix ⊕ (Def. 2.1c), -- diff is written as infix ⊝ (Def. 2.1d), -- and update-diff is specified in Def. 2.1e. record IsChangeAlgebra {c} {Carrier : Set c} (Change : Carrier → Set c) (update : (v : Carrier) (dv : Change v) → Carrier) (diff : (u v : Carrier) → Change v) (nil : (u : Carrier) → Change u) : Set (c) where field update-diff : ∀ u v → update v (diff u v) ≡ u -- This corresponds to Lemma 2.3 from the paper. update-nil : ∀ v → update v (nil v) ≡ v -- abbreviations before : ∀ {v} → Change v → Carrier before {v} _ = v after : ∀ {v} → Change v → Carrier after {v} dv = update v dv record ChangeAlgebra {c} (Carrier : Set c) : Set (suc c) where field Change : Carrier → Set c update : (v : Carrier) (dv : Change v) → Carrier diff : (u v : Carrier) → Change v -- This generalizes Def. 2.2. from the paper. nil : (u : Carrier) → Change u isChangeAlgebra : IsChangeAlgebra Change update diff nil infixl 6 update diff open IsChangeAlgebra isChangeAlgebra public -- The following open ... public statement lets us use infix ⊞ -- and ⊟ for update and diff. In the paper, we use infix ⊕ and -- ⊝. open ChangeAlgebra {{...}} public using ( update-diff ; update-nil ; nil ; before ; after ) renaming ( Change to Δ ; update to _⊞_ ; diff to _⊟_ ) -- Families of Change Algebras -- =========================== -- -- This is some Agda machinery to allow subscripting change -- algebra operations to avoid ambiguity. In the paper, -- we simply write (in the paragraph after Def. 2.1): -- -- We overload operators ∆, ⊝ and ⊕ to refer to the -- corresponding operations of different change structures; we -- will subscript these symbols when needed to prevent -- ambiguity. -- -- The following definitions implement this idea formally. record ChangeAlgebraFamily {a p} {A : Set a} (P : A → Set p): Set (suc p ⊔ a) where constructor family field change-algebra : ∀ x → ChangeAlgebra (P x) module _ x where open ChangeAlgebra (change-algebra x) public module Family = ChangeAlgebraFamily {{...}} open Family public using ( ) renaming ( Change to Δ₍_₎ ; nil to nil₍_₎ ; update-diff to update-diff₍_₎ ; update-nil to update-nil₍_₎ ; change-algebra to change-algebra₍_₎ ; before to before₍_₎ ; after to after₍_₎ ) -- XXX not clear this is ever used instance change-algebra-family-inst = change-algebra₍_₎ infixl 6 update′ diff′ update′ = Family.update syntax update′ x v dv = v ⊞₍ x ₎ dv diff′ = Family.diff syntax diff′ x u v = u ⊟₍ x ₎ v -- Derivatives -- =========== -- -- This corresponds to Def. 2.4 in the paper. RawChange : ∀ {a b} {A : Set a} {B : Set b} → {{CA : ChangeAlgebra A}} → {{CB : ChangeAlgebra B}} → (f : A → B) → Set (a ⊔ b) RawChange f = ∀ a (da : Δ a) → Δ (f a) IsDerivative : ∀ {a b} {A : Set a} {B : Set b} → {{CA : ChangeAlgebra A}} → {{CB : ChangeAlgebra B}} → (f : A → B) → (df : RawChange f) → Set (a ⊔ b) IsDerivative f df = ∀ a da → f a ⊞ df a da ≡ f (a ⊞ da) -- This is a variant of IsDerivative for change algebra families. RawChange₍_,_₎ : ∀ {a b p q} {A : Set a} {B : Set b} {P : A → Set p} {Q : B → Set q} → {{CP : ChangeAlgebraFamily P}} → {{CQ : ChangeAlgebraFamily Q}} → (x : A) → (y : B) → (f : P x → Q y) → Set (p ⊔ q) RawChange₍ x , y ₎ f = ∀ px (dpx : Δ₍ x ₎ px) → Δ₍ y ₎ (f px) IsDerivative₍_,_₎ : ∀ {a b p q} {A : Set a} {B : Set b} {P : A → Set p} {Q : B → Set q} → {{CP : ChangeAlgebraFamily P}} → {{CQ : ChangeAlgebraFamily Q}} → (x : A) → (y : B) → (f : P x → Q y) → (df : RawChange₍_,_₎ x y f) → Set (p ⊔ q) IsDerivative₍_,_₎ {P = P} {{CP}} {{CQ}} x y f df = IsDerivative {{change-algebra₍ _ ₎}} {{change-algebra₍ _ ₎}} f df where CPx = change-algebra₍_₎ {{CP}} x CQy = change-algebra₍_₎ {{CQ}} y -- Lemma 2.5 appears in Base.Change.Equivalence. -- Abelian Groups Induce Change Algebras -- ===================================== -- -- In the paper, as the first example for change structures after -- Def. 2.1, we mention that "each abelian group ... induces a -- change structure". This is the formalization of this result. -- -- The module GroupChanges below takes a proof that A forms an -- abelian group and provides a changeAlgebra for A. The proof of -- Def 2.1e is by equational reasoning using the group axioms, in -- the definition of changeAlgebra.isChangeAlgebra.update-diff. open import Algebra.Structures open import Data.Product open import Function -- For non-abelian groups module PlainGroupChanges {a} (A : Set a) {_⊕_} {ε} {_⁻¹} {{isGroup : IsGroup {A = A} _≡_ _⊕_ ε _⁻¹}} where open IsGroup isGroup hiding ( refl ; sym ) renaming ( ∙-cong to _⟨⊕⟩_ ) open ≡-Reasoning _⊝_ : A → A → A v ⊝ u = (u ⁻¹) ⊕ v changeAlgebraGroup : ChangeAlgebra A changeAlgebraGroup = record { Change = const A ; update = _⊕_ ; diff = _⊝_ ; nil = const ε ; isChangeAlgebra = record { update-diff = λ u v → begin v ⊕ (u ⊝ v) ≡⟨⟩ v ⊕ ((v ⁻¹) ⊕ u) ≡⟨ sym (assoc _ _ _) ⟩ (v ⊕ (v ⁻¹)) ⊕ u ≡⟨ proj₂ inverse v ⟨⊕⟩ refl ⟩ ε ⊕ u ≡⟨ proj₁ identity u ⟩ u ∎ ; update-nil = proj₂ identity } } module GroupChanges {a} (A : Set a) {_⊕_} {ε} {_⁻¹} {{isAbelianGroup : IsAbelianGroup {A = A} _≡_ _⊕_ ε _⁻¹}} where open IsAbelianGroup isAbelianGroup hiding ( refl ) renaming ( _-_ to _⊝_ ; ∙-cong to _⟨⊕⟩_ ) open ≡-Reasoning changeAlgebraGroup : ChangeAlgebra A changeAlgebraGroup = record { Change = const A ; update = _⊕_ ; diff = _⊝_ ; nil = const ε ; isChangeAlgebra = record { update-diff = λ u v → begin v ⊕ (u ⊝ v) ≡⟨ comm _ _ ⟩ (u ⊝ v ) ⊕ v ≡⟨⟩ (u ⊕ (v ⁻¹)) ⊕ v ≡⟨ assoc _ _ _ ⟩ u ⊕ ((v ⁻¹) ⊕ v) ≡⟨ refl ⟨⊕⟩ proj₁ inverse v ⟩ u ⊕ ε ≡⟨ proj₂ identity u ⟩ u ∎ ; update-nil = proj₂ identity } } -- Function Changes -- ================ -- -- This is one of our most important results: Change structures -- can be lifted to function spaces. We formalize this as a module -- FunctionChanges that takes the change algebras for A and B as -- arguments, and provides a changeAlgebra for (A → B). The proofs -- are by equational reasoning using 2.1e for A and B. module FunctionChanges {a} {b} (A : Set a) (B : Set b) {{CA : ChangeAlgebra A}} {{CB : ChangeAlgebra B}} where -- This corresponds to Definition 2.6 in the paper. record FunctionChange (f : A → B) : Set (a ⊔ b) where field -- Definition 2.6a apply : RawChange f -- Definition 2.6b. -- (for some reason, the version in the paper has the arguments of ≡ -- flipped. Since ≡ is symmetric, this doesn't matter). correct : (a : A) (da : Δ a) → f (a ⊞ da) ⊞ apply (a ⊞ da) (nil (a ⊞ da)) ≡ f a ⊞ apply a da open FunctionChange public open ≡-Reasoning open import Postulate.Extensionality funDiff : (g f : A → B) → FunctionChange f funDiff = λ g f → record { apply = λ a da → g (a ⊞ da) ⊟ f a -- the proof of correct is the first half of what we -- have to prove for Theorem 2.7. ; correct = λ a da → begin f (a ⊞ da) ⊞ (g (a ⊞ da ⊞ nil (a ⊞ da)) ⊟ f (a ⊞ da)) ≡⟨ cong (λ □ → f (a ⊞ da) ⊞ (g □ ⊟ f (a ⊞ da))) (update-nil (a ⊞ da)) ⟩ f (a ⊞ da) ⊞ (g (a ⊞ da) ⊟ f (a ⊞ da)) ≡⟨ update-diff (g (a ⊞ da)) (f (a ⊞ da)) ⟩ g (a ⊞ da) ≡⟨ sym (update-diff (g (a ⊞ da)) (f a)) ⟩ f a ⊞ (g (a ⊞ da) ⊟ f a) ∎ } funUpdate : ∀ (f : A → B) (df : FunctionChange f) → A → B funUpdate = λ f df a → f a ⊞ apply df a (nil a) funNil : (f : A → B) → FunctionChange f funNil = λ f → funDiff f f private -- Realizer for funNil funNil-realizer : (f : A → B) → RawChange f funNil-realizer f = λ a da → f (a ⊞ da) ⊟ f a -- Note that it cannot use nil (f a), that would not be a correct function change! funNil-correct : ∀ f a da → funNil-realizer f a da ≡ apply (funNil f) a da funNil-correct f a da = refl mutual -- I have to write the type of funUpdateDiff without using changeAlgebra, -- so I just use the underlying implementations. funUpdateDiff : ∀ u v → funUpdate v (funDiff u v) ≡ u instance changeAlgebraFun : ChangeAlgebra (A → B) changeAlgebraFun = record { Change = FunctionChange -- in the paper, update and diff below are in Def. 2.7 ; update = funUpdate ; diff = funDiff ; nil = funNil ; isChangeAlgebra = record -- the proof of update-diff is the second half of what -- we have to prove for Theorem 2.8. { update-diff = funUpdateDiff ; update-nil = λ v → funUpdateDiff v v } } -- XXX remove mutual recursion by inlining the algebra in here? funUpdateDiff = λ g f → ext (λ a → begin f a ⊞ (g (a ⊞ (nil a)) ⊟ f a) ≡⟨ cong (λ □ → f a ⊞ (g □ ⊟ f a)) (update-nil a) ⟩ f a ⊞ (g a ⊟ f a) ≡⟨ update-diff (g a) (f a) ⟩ g a ∎) -- This is Theorem 2.9 in the paper. incrementalization : ∀ (f : A → B) df a da → (f ⊞ df) (a ⊞ da) ≡ f a ⊞ apply df a da incrementalization f df a da = correct df a da -- This is Theorem 2.10 in the paper. However, the derivative of f is just -- the apply component of `nil f`, not the full `nil f`, which also includes -- a proof. This is not an issue in the paper, which is formulated in a -- proof-irrelevant metalanguage. nil-is-derivative : ∀ (f : A → B) → IsDerivative f (apply (nil f)) nil-is-derivative f a da = begin f a ⊞ apply (nil f) a da ≡⟨ sym (incrementalization f (nil f) a da) ⟩ (f ⊞ nil f) (a ⊞ da) ≡⟨ cong (λ □ → □ (a ⊞ da)) (update-nil f) ⟩ f (a ⊞ da) ∎ -- Show that any derivative is a valid function change. -- In the paper, this is never actually stated. We just prove that nil -- changes are derivatives; the paper keeps talking about "the derivative", -- suggesting derivatives are unique. If derivatives were unique, we could -- say that the nil change is *the* derivative, hence the derivative is the -- nil change (hence also a change). -- -- In fact, derivatives are only unique up to change equivalence and -- extensional equality; this is proven in Base.Change.Equivalence.derivative-unique. -- Derivative-is-valid : ∀ {f : A → B} df (IsDerivative-f-df : IsDerivative f df) a da → f (a ⊞ da) ⊞ (df (a ⊞ da) (nil (a ⊞ da))) ≡ f a ⊞ df a da Derivative-is-valid {f} df IsDerivative-f-df a da rewrite IsDerivative-f-df (a ⊞ da) (nil (a ⊞ da)) | update-nil (a ⊞ da) = sym (IsDerivative-f-df a da) DerivativeAsChange : ∀ {f : A → B} {df} (IsDerivative-f-df : IsDerivative f df) → Δ f DerivativeAsChange {df = df} IsDerivative-f-df = record { apply = df ; correct = Derivative-is-valid df IsDerivative-f-df } -- In Equivalence.agda, derivative-is-nil-alternative then proves that a derivative is also a nil change. -- Reexport a few members with A and B marked as implicit parameters. This -- matters especially for changeAlgebra, since otherwise it can't be used for -- instance search. module _ {a} {b} {A : Set a} {B : Set b} {{CA : ChangeAlgebra A}} {{CB : ChangeAlgebra B}} where open FunctionChanges A B {{CA}} {{CB}} public using ( changeAlgebraFun ; apply ; correct ; incrementalization ; DerivativeAsChange ; FunctionChange ; nil-is-derivative ) module BinaryFunctionChanges {a} {b} {c} (A : Set a) (B : Set b) (C : Set c) {{CA : ChangeAlgebra A}} {{CB : ChangeAlgebra B}} {{CC : ChangeAlgebra C}} where incrementalization-binary : ∀ (f : A → B → C) df a da b db → (f ⊞ df) (a ⊞ da) (b ⊞ db) ≡ f a b ⊞ apply (apply df a da) b db incrementalization-binary f df x dx y dy rewrite cong (λ □ → □ (y ⊞ dy)) (incrementalization f df x dx) = incrementalization (f x) (apply df x dx) y dy -- List (== Environment) Changes -- ============================= -- -- Here, we define a change structure on environments, given a -- change structure on the values in the environments. In the -- paper, we describe this in Definition 3.5. But note that this -- Agda formalization uses de Bruijn indices instead of names, so -- environments are just lists. Therefore, when we use Definition -- 3.5 in the paper, in this formalization, we use the list-like -- change structure defined here. open import Data.List open import Data.List.All data All′ {a p q} {A : Set a} {P : A → Set p} (Q : {x : A} → P x → Set q) : {xs : List A} (pxs : All P xs) → Set (p ⊔ q ⊔ a) where [] : All′ Q [] _∷_ : ∀ {x xs} {px : P x} {pxs : All P xs} (qx : Q px) (qxs : All′ Q pxs) → All′ Q (px ∷ pxs) module ListChanges {a} {A : Set a} (P : A → Set) {{C : ChangeAlgebraFamily P}} where update-all : ∀ {xs} → (pxs : All P xs) → All′ Δ pxs → All P xs update-all {[]} [] [] = [] update-all {x ∷ xs} (px ∷ pxs) (dpx ∷ dpxs) = (px ⊞ dpx) ∷ update-all pxs dpxs diff-all : ∀ {xs} → (pxs′ pxs : All P xs) → All′ Δ pxs diff-all [] [] = [] diff-all (px′ ∷ pxs′) (px ∷ pxs) = (px′ ⊟ px) ∷ diff-all pxs′ pxs update-diff-all : ∀ {xs} → (pxs′ pxs : All P xs) → update-all pxs (diff-all pxs′ pxs) ≡ pxs′ update-diff-all [] [] = refl update-diff-all (px′ ∷ pxs′) (px ∷ pxs) = cong₂ _∷_ (update-diff px′ px) (update-diff-all pxs′ pxs) instance changeAlgebraListChanges : ChangeAlgebraFamily (All P) changeAlgebraListChanges = record { change-algebra = λ xs → record { Change = All′ Δ ; update = update-all ; diff = diff-all ; nil = λ xs → diff-all xs xs ; isChangeAlgebra = record { update-diff = update-diff-all ; update-nil = λ xs₁ → update-diff-all xs₁ xs₁ } } }
{ "alphanum_fraction": 0.5637813212, "avg_line_length": 32.3190184049, "ext": "agda", "hexsha": "8706bf52d4f7e98946b535703f30ee16bd6422a7", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Base/Change/Algebra.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Base/Change/Algebra.agda", "max_line_length": 156, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Base/Change/Algebra.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 5169, "size": 15804 }
module Web.URI.Port.Primitive where postulate Port? : Set {-# COMPILED_TYPE Port? String #-} postulate :80 : Port? {-# COMPILED :80 ":80" #-} postulate ε : Port? {-# COMPILED ε "" #-}
{ "alphanum_fraction": 0.6363636364, "avg_line_length": 17, "ext": "agda", "hexsha": "1fe5c2b0e8f9d3907ecc02018e4d6a0c690ceeed", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:37:59.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:37:59.000Z", "max_forks_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-web-uri", "max_forks_repo_path": "src/Web/URI/Port/Primitive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-web-uri", "max_issues_repo_path": "src/Web/URI/Port/Primitive.agda", "max_line_length": 35, "max_stars_count": 1, "max_stars_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-uri", "max_stars_repo_path": "src/Web/URI/Port/Primitive.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-23T04:56:25.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-23T04:56:25.000Z", "num_tokens": 54, "size": 187 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything module Cubical.Algebra.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Relation.Binary.Base using (Rel) open import Cubical.Relation.Binary.Definitions open import Cubical.Algebra.Base open import Cubical.Algebra.Definitions open import Cubical.Data.Sum.Base using (inl; inr) open import Cubical.Data.Sigma using (_,_) open import Cubical.HITs.PropositionalTruncation open import Cubical.Relation.Binary.Reasoning.Equality private variable ℓ : Level A : Type ℓ ---------------------------------------------------------------------- -- Operation properties are propositions private isPropImpΠ2 : ∀ {ℓ′ ℓ′′} {B : A → Type ℓ′} {C : ∀ x → B x → Type ℓ′′} → (∀ x y → isProp (C x y)) → isProp (∀ {x y} → C x y) isPropImpΠ2 isPropC f g i {x} {y} = isPropC x y (f {x} {y}) (g {x} {y}) i module _ (isSetA : isSet A) where isPropAssociative : (_•_ : Op₂ A) → isProp (Associative _•_) isPropAssociative _ = isPropΠ3 λ _ _ _ → isSetA _ _ isPropCommutative : (_•_ : Op₂ A) → isProp (Commutative _•_) isPropCommutative _ = isPropΠ2 λ _ _ → isSetA _ _ isPropLeftIdentity : (_•_ : Op₂ A) (e : A) → isProp (LeftIdentity e _•_) isPropLeftIdentity _ _ = isPropΠ λ _ → isSetA _ _ isPropRightIdentity : (_•_ : Op₂ A) (e : A) → isProp (RightIdentity e _•_) isPropRightIdentity _ _ = isPropΠ λ _ → isSetA _ _ isPropIdentity : (_•_ : Op₂ A) (e : A) → isProp (Identity e _•_) isPropIdentity _•_ e = isProp× (isPropLeftIdentity _•_ e) (isPropRightIdentity _•_ e) isPropLeftZero : (_•_ : Op₂ A) (z : A) → isProp (LeftZero z _•_) isPropLeftZero _ _ = isPropΠ λ _ → isSetA _ _ isPropRightZero : (_•_ : Op₂ A) (z : A) → isProp (RightZero z _•_) isPropRightZero _ _ = isPropΠ λ _ → isSetA _ _ isPropZero : (_•_ : Op₂ A) (z : A) → isProp (Zero z _•_) isPropZero _•_ z = isProp× (isPropLeftZero _•_ z) (isPropRightZero _•_ z) isPropLeftInverse : (_•_ : Op₂ A) (_⁻¹ : Op₁ A) (e : A) → isProp (LeftInverse e _⁻¹ _•_) isPropLeftInverse _ _ _ = isPropΠ λ _ → isSetA _ _ isPropRightInverse : (_•_ : Op₂ A) (_⁻¹ : Op₁ A) (e : A) → isProp (RightInverse e _⁻¹ _•_) isPropRightInverse _ _ _ = isPropΠ λ _ → isSetA _ _ isPropInverse : (_•_ : Op₂ A) (_⁻¹ : Op₁ A) (e : A) → isProp (Inverse e _⁻¹ _•_) isPropInverse _•_ _⁻¹ e = isProp× (isPropLeftInverse _•_ _⁻¹ e) (isPropRightInverse _•_ _⁻¹ e) isPropLeftConical : (_•_ : Op₂ A) (e : A) → isProp (LeftConical e _•_) isPropLeftConical _ _ = isPropΠ3 λ _ _ _ → isSetA _ _ isPropRightConical : (_•_ : Op₂ A) (e : A) → isProp (RightConical e _•_) isPropRightConical _ _ = isPropΠ3 λ _ _ _ → isSetA _ _ isPropConical : (_•_ : Op₂ A) (e : A) → isProp (Conical e _•_) isPropConical _•_ e = isProp× (isPropLeftConical _•_ e) (isPropRightConical _•_ e) isPropDistrˡ : (_*_ _+_ : Op₂ A) → isProp (_*_ DistributesOverˡ _+_) isPropDistrˡ _ _ = isPropΠ3 λ _ _ _ → isSetA _ _ isPropDistrʳ : (_*_ _+_ : Op₂ A) → isProp (_*_ DistributesOverʳ _+_) isPropDistrʳ _ _ = isPropΠ3 λ _ _ _ → isSetA _ _ isPropDistr : (_*_ _+_ : Op₂ A) → isProp (_*_ DistributesOver _+_) isPropDistr _*_ _+_ = isProp× (isPropDistrˡ _*_ _+_) (isPropDistrʳ _*_ _+_) isPropIdempotentOn : (_•_ : Op₂ A) (x : A) → isProp (_•_ IdempotentOn x) isPropIdempotentOn _ _ = isSetA _ _ isPropIdempotent : (_•_ : Op₂ A) → isProp (Idempotent _•_) isPropIdempotent _•_ = isPropΠ λ x → isPropIdempotentOn _•_ x isPropIdempotentFun : (f : Op₁ A) → isProp (IdempotentFun f) isPropIdempotentFun _ = isPropΠ λ _ → isSetA _ _ isPropSelective : (_•_ : Op₂ A) → isProp (Selective _•_) isPropSelective _ = isPropΠ2 λ _ _ → squash isPropAbsorbs : (_⋀_ _⋁_ : Op₂ A) → isProp (_⋀_ Absorbs _⋁_) isPropAbsorbs _ _ = isPropΠ2 λ _ _ → isSetA _ _ isPropAbsorptive : (_⋀_ _⋁_ : Op₂ A) → isProp (Absorptive _⋀_ _⋁_) isPropAbsorptive _⋀_ _⋁_ = isProp× (isPropAbsorbs _⋀_ _⋁_) (isPropAbsorbs _⋁_ _⋀_) isPropInvolutive : (f : Op₁ A) → isProp (Involutive f) isPropInvolutive _ = isPropΠ λ _ → isSetA _ _ isPropLeftCancel : (_•_ : Op₂ A) → isProp (LeftCancellative _•_) isPropLeftCancel _ = isPropΠ λ _ → isPropImpΠ2 λ _ _ → isPropΠ λ _ → isSetA _ _ isPropRightCancel : (_•_ : Op₂ A) → isProp (RightCancellative _•_) isPropRightCancel _ = isPropImpΠ2 λ _ _ → isPropΠ2 λ _ _ → isSetA _ _ isPropCancellative : (_•_ : Op₂ A) → isProp (Cancellative _•_) isPropCancellative _•_ = isProp× (isPropLeftCancel _•_) (isPropRightCancel _•_) isPropInterchangeable : (_•_ _◦_ : Op₂ A) → isProp (Interchangeable _•_ _◦_) isPropInterchangeable _ _ = isPropΠ2 λ _ _ → isPropΠ2 λ _ _ → isSetA _ _ sel⇒idem : {_•_ : Op₂ A} → Selective _•_ → Idempotent _•_ sel⇒idem {_•_ = _•_} sel x = rec (isPropIdempotentOn _•_ x) (λ { (inl p) → p ; (inr p) → p }) (sel x x) module _ {ℓ′} {B : Type ℓ′} (isSetB : isSet B) where isPropHomomorphic₀ : (f : A → B) (x : A) (y : B) → isProp (Homomorphic₀ f x y) isPropHomomorphic₀ _ _ _ = isSetB _ _ isPropHomomorphic₁ : (f : A → B) (g : Op₁ A) (h : Op₁ B) → isProp (Homomorphic₁ f g h) isPropHomomorphic₁ _ _ _ = isPropΠ λ _ → isSetB _ _ isPropHomomorphic₂ : (f : A → B) (• : Op₂ A) (◦ : Op₂ B) → isProp (Homomorphic₂ f • ◦) isPropHomomorphic₂ _ _ _ = isPropΠ2 λ _ _ → isSetB _ _ id-unique′ : ∀ {_•_ : Op₂ A} {e i} → LeftIdentity e _•_ → RightIdentity i _•_ → e ≡ i id-unique′ {_} {_} {_•_} {e} {i} idˡ idʳ = e ≡˘⟨ idʳ e ⟩ e • i ≡⟨ idˡ i ⟩ i ∎ id-unique : ∀ {_•_ : Op₂ A} {e i} → Identity e _•_ → Identity i _•_ → e ≡ i id-unique (idˡ , _) (_ , idʳ) = id-unique′ idˡ idʳ id-collapseʳ : ∀ {_•_ : Op₂ A} {e i} → LeftIdentity e _•_ → RightIdentity i _•_ → Identity e _•_ id-collapseʳ {_} {_} {_•_} idˡ idʳ = idˡ , subst (λ e → RightIdentity e _•_) (sym (id-unique′ idˡ idʳ)) idʳ id-collapseˡ : ∀ {_•_ : Op₂ A} {e i} → LeftIdentity e _•_ → RightIdentity i _•_ → Identity i _•_ id-collapseˡ {_} {_} {_•_} idˡ idʳ = subst (λ e → LeftIdentity e _•_) (id-unique′ idˡ idʳ) idˡ , idʳ ------------------------------------------------------------------------ -- Magma-like Algebra module _ {_•_ : Op₂ A} (comm : Commutative _•_) where comm+cancelˡ⇒cancelʳ : LeftCancellative _•_ → RightCancellative _•_ comm+cancelˡ⇒cancelʳ cancelˡ {x = x} {y} z eq = cancelˡ z ( z • x ≡⟨ comm z x ⟩ x • z ≡⟨ eq ⟩ y • z ≡⟨ comm y z ⟩ z • y ∎) comm+cancelʳ⇒cancelˡ : RightCancellative _•_ → LeftCancellative _•_ comm+cancelʳ⇒cancelˡ cancelʳ x {y} {z} eq = cancelʳ x ( y • x ≡⟨ comm y x ⟩ x • y ≡⟨ eq ⟩ x • z ≡⟨ comm x z ⟩ z • x ∎) ------------------------------------------------------------------------ -- Monoid-like Algebra module _ {_•_ : Op₂ A} (comm : Commutative _•_) {e : A} where comm+idˡ⇒idʳ : LeftIdentity e _•_ → RightIdentity e _•_ comm+idˡ⇒idʳ idˡ x = x • e ≡⟨ comm x e ⟩ e • x ≡⟨ idˡ x ⟩ x ∎ comm+idʳ⇒idˡ : RightIdentity e _•_ → LeftIdentity e _•_ comm+idʳ⇒idˡ idʳ x = e • x ≡⟨ comm e x ⟩ x • e ≡⟨ idʳ x ⟩ x ∎ comm+zeˡ⇒zeʳ : LeftZero e _•_ → RightZero e _•_ comm+zeˡ⇒zeʳ zeˡ x = x • e ≡⟨ comm x e ⟩ e • x ≡⟨ zeˡ x ⟩ e ∎ comm+zeʳ⇒zeˡ : RightZero e _•_ → LeftZero e _•_ comm+zeʳ⇒zeˡ zeʳ x = e • x ≡⟨ comm e x ⟩ x • e ≡⟨ zeʳ x ⟩ e ∎ ------------------------------------------------------------------------ -- Group-like Algebra module _ {_•_ : Op₂ A} {_⁻¹ : Op₁ A} {e} (comm : Commutative _•_) where comm+invˡ⇒invʳ : LeftInverse e _⁻¹ _•_ → RightInverse e _⁻¹ _•_ comm+invˡ⇒invʳ invˡ x = x • (x ⁻¹) ≡⟨ comm x (x ⁻¹) ⟩ (x ⁻¹) • x ≡⟨ invˡ x ⟩ e ∎ comm+invʳ⇒invˡ : RightInverse e _⁻¹ _•_ → LeftInverse e _⁻¹ _•_ comm+invʳ⇒invˡ invʳ x = (x ⁻¹) • x ≡⟨ comm (x ⁻¹) x ⟩ x • (x ⁻¹) ≡⟨ invʳ x ⟩ e ∎ module _ {_•_ : Op₂ A} {_⁻¹ : Op₁ A} {e} where assoc+id+invʳ⇒invʳ-unique : Associative _•_ → Identity e _•_ → RightInverse e _⁻¹ _•_ → ∀ x y → (x • y) ≡ e → x ≡ (y ⁻¹) assoc+id+invʳ⇒invʳ-unique assoc (idˡ , idʳ) invʳ x y eq = x ≡⟨ sym (idʳ x) ⟩ x • e ≡˘⟨ cong (x •_) (invʳ y) ⟩ x • (y • (y ⁻¹)) ≡˘⟨ assoc x y (y ⁻¹) ⟩ (x • y) • (y ⁻¹) ≡⟨ cong (_• (y ⁻¹)) eq ⟩ e • (y ⁻¹) ≡⟨ idˡ (y ⁻¹) ⟩ y ⁻¹ ∎ assoc+id+invˡ⇒invˡ-unique : Associative _•_ → Identity e _•_ → LeftInverse e _⁻¹ _•_ → ∀ x y → (x • y) ≡ e → y ≡ (x ⁻¹) assoc+id+invˡ⇒invˡ-unique assoc (idˡ , idʳ) invˡ x y eq = y ≡˘⟨ idˡ y ⟩ e • y ≡˘⟨ cong (_• y) (invˡ x) ⟩ ((x ⁻¹) • x) • y ≡⟨ assoc (x ⁻¹) x y ⟩ (x ⁻¹) • (x • y) ≡⟨ cong ((x ⁻¹) •_) eq ⟩ (x ⁻¹) • e ≡⟨ idʳ (x ⁻¹) ⟩ x ⁻¹ ∎ assoc+idˡ+invˡ⇒cancelˡ : Associative _•_ → LeftIdentity e _•_ → LeftInverse e _⁻¹ _•_ → LeftCancellative _•_ assoc+idˡ+invˡ⇒cancelˡ assoc idˡ invˡ x {y} {z} eq = y ≡˘⟨ idˡ y ⟩ e • y ≡˘⟨ cong (_• y) (invˡ x) ⟩ ((x ⁻¹) • x) • y ≡⟨ assoc (x ⁻¹) x y ⟩ (x ⁻¹) • (x • y) ≡⟨ cong ((x ⁻¹) •_) eq ⟩ (x ⁻¹) • (x • z) ≡˘⟨ assoc (x ⁻¹) x z ⟩ ((x ⁻¹) • x) • z ≡⟨ cong (_• z) (invˡ x) ⟩ e • z ≡⟨ idˡ z ⟩ z ∎ assoc+idʳ+invʳ⇒cancelʳ : Associative _•_ → RightIdentity e _•_ → RightInverse e _⁻¹ _•_ → RightCancellative _•_ assoc+idʳ+invʳ⇒cancelʳ assoc idʳ invʳ {x} {y} z eq = x ≡˘⟨ idʳ x ⟩ x • e ≡˘⟨ cong (x •_) (invʳ z) ⟩ x • (z • (z ⁻¹)) ≡˘⟨ assoc x z (z ⁻¹) ⟩ (x • z) • (z ⁻¹) ≡⟨ cong (_• (z ⁻¹)) eq ⟩ (y • z) • (z ⁻¹) ≡⟨ assoc y z (z ⁻¹) ⟩ y • (z • (z ⁻¹)) ≡⟨ cong (y •_) (invʳ z) ⟩ y • e ≡⟨ idʳ y ⟩ y ∎ ---------------------------------------------------------------------- -- Bisemigroup-like Algebra module _ {_*_ _+_ : Op₂ A} (*-comm : Commutative _*_) where comm+distrˡ⇒distrʳ : _*_ DistributesOverˡ _+_ → _*_ DistributesOverʳ _+_ comm+distrˡ⇒distrʳ distrˡ x y z = (y + z) * x ≡⟨ *-comm (y + z) x ⟩ x * (y + z) ≡⟨ distrˡ x y z ⟩ (x * y) + (x * z) ≡⟨ cong₂ _+_ (*-comm x y) (*-comm x z) ⟩ (y * x) + (z * x) ∎ comm+distrʳ⇒distrˡ : _*_ DistributesOverʳ _+_ → _*_ DistributesOverˡ _+_ comm+distrʳ⇒distrˡ distrʳ x y z = x * (y + z) ≡⟨ *-comm x (y + z) ⟩ (y + z) * x ≡⟨ distrʳ x y z ⟩ (y * x) + (z * x) ≡⟨ cong₂ _+_ (*-comm y x) (*-comm z x) ⟩ (x * y) + (x * z) ∎ ---------------------------------------------------------------------- -- Ring-like Algebra module _ {_+_ _*_ : Op₂ A} { -_ : Op₁ A} {0# : A} where assoc+distribʳ+idʳ+invʳ⇒zeˡ : Associative _+_ → _*_ DistributesOverʳ _+_ → RightIdentity 0# _+_ → RightInverse 0# -_ _+_ → LeftZero 0# _*_ assoc+distribʳ+idʳ+invʳ⇒zeˡ +-assoc distribʳ idʳ invʳ x = 0# * x ≡⟨ sym (idʳ _) ⟩ (0# * x) + 0# ≡˘⟨ cong ((0# * x) +_) (invʳ _) ⟩ (0# * x) + ((0# * x) + (-(0# * x))) ≡˘⟨ +-assoc _ _ _ ⟩ ((0# * x) + (0# * x)) + (-(0# * x)) ≡˘⟨ cong (_+ (-(0# * x))) (distribʳ _ _ _) ⟩ ((0# + 0#) * x) + (-(0# * x)) ≡⟨ cong (λ v → (v * x) + (-(0# * x))) (idʳ 0#) ⟩ (0# * x) + (-(0# * x)) ≡⟨ invʳ _ ⟩ 0# ∎ assoc+distribˡ+idʳ+invʳ⇒zeʳ : Associative _+_ → _*_ DistributesOverˡ _+_ → RightIdentity 0# _+_ → RightInverse 0# -_ _+_ → RightZero 0# _*_ assoc+distribˡ+idʳ+invʳ⇒zeʳ +-assoc distribˡ idʳ invʳ x = x * 0# ≡⟨ sym (idʳ _) ⟩ (x * 0#) + 0# ≡˘⟨ cong ((x * 0#) +_) (invʳ _) ⟩ (x * 0#) + ((x * 0#) + (-(x * 0#))) ≡˘⟨ +-assoc _ _ _ ⟩ ((x * 0#) + (x * 0#)) + (-(x * 0#)) ≡˘⟨ cong (_+ (-(x * 0#))) (distribˡ _ _ _) ⟩ (x * (0# + 0#)) + (-(x * 0#)) ≡⟨ cong (λ v → (x * v) + (-(x * 0#))) (idʳ 0#) ⟩ (x * 0#) + (-(x * 0#)) ≡⟨ invʳ _ ⟩ 0# ∎ ---------------------------------------------------------------------- -- Other module _ {c ℓ} {A : Type c} (R : Rel A ℓ) (reflexive : Reflexive R) (• : Op₂ A) where cong₂⇒lcong : Congruent₂ R • → LeftCongruent R • cong₂⇒lcong cong₂ {x} {y} {z} yRz = cong₂ reflexive yRz cong₂⇒rcong : Congruent₂ R • → RightCongruent R • cong₂⇒rcong cong₂ {x} {y} {z} yRz = cong₂ yRz reflexive module _ {c ℓ} {A : Type c} (R : Rel A ℓ) (transitive : Transitive R) (• : Op₂ A) where lcong+rcong⇒cong₂ : LeftCongruent R • → RightCongruent R • → Congruent₂ R • lcong+rcong⇒cong₂ lcong rcong xRy uRv = transitive (lcong uRv) (rcong xRy)
{ "alphanum_fraction": 0.5158049308, "avg_line_length": 38.8558558559, "ext": "agda", "hexsha": "f2117e6774f70a92051f0d48d09e651c6b53d96e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Properties.agda", "max_line_length": 107, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5678, "size": 12939 }
{- Macros (autoDesc, AutoStructure, AutoEquivStr, autoUnivalentStr) for automatically generating structure definitions. For example: autoDesc (λ (X : Type₀) → X → X × ℕ) ↦ function+ var (var , constant ℕ) We prefer to use the constant structure whenever possible, e.g., [autoDesc (λ (X : Type₀) → ℕ → ℕ)] is [constant (ℕ → ℕ)] rather than [function (constant ℕ) (constant ℕ)]. Writing [auto* (λ X → ⋯)] doesn't seem to work, but [auto* (λ (X : Type ℓ) → ⋯)] does. -} {-# OPTIONS --cubical --no-exact-split --safe #-} module Cubical.Structures.Auto where open import Cubical.Foundations.Prelude open import Cubical.Data.Sigma open import Cubical.Data.Nat open import Cubical.Data.List open import Cubical.Data.Bool open import Cubical.Data.Maybe open import Cubical.Structures.Macro as Macro import Agda.Builtin.Reflection as R -- Magic number private FUEL = 10000 -- Mark part of a structure definition to use transport-based structured equivalences abstract Transp[_] : ∀ {ℓ} → Type ℓ → Type ℓ Transp[ A ] = A -- Some reflection utilities private _>>=_ = R.bindTC _<|>_ = R.catchTC _>>_ : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → R.TC A → R.TC B → R.TC B f >> g = f >>= λ _ → g infixl 4 _>>=_ _>>_ _<|>_ varg : ∀ {ℓ} {A : Type ℓ} → A → R.Arg A varg = R.arg (R.arg-info R.visible R.relevant) tLevel = R.def (quote Level) [] tType : R.Term → R.Term tType ℓ = R.def (quote Type) [ varg ℓ ] tTranspDesc : R.Term → R.Term tTranspDesc ℓ = R.def (quote TranspDesc) [ varg ℓ ] tDesc : R.Term → R.Term tDesc ℓ = R.def (quote Desc) [ varg ℓ ] func : (ℓ ℓ' : Level) → Type (ℓ-suc (ℓ-max ℓ ℓ')) func ℓ ℓ' = Type ℓ → Type ℓ' tStruct : R.Term → R.Term → R.Term tStruct ℓ ℓ' = R.def (quote func) (varg ℓ ∷ varg ℓ' ∷ []) newMeta = R.checkType R.unknown -- We try to build a descriptor by unifying the provided structure with combinators we're aware of. We -- redefine the structure combinators as the *Shape terms below so that we don't depend on the specific way -- these are defined in other files (order of implicit arguments and so on); the syntactic analysis that goes -- on here means that we would get mysterious errors if those changed. private constantShape : ∀ {ℓ'} (ℓ : Level) (A : Type ℓ') → (Type ℓ → Type ℓ') constantShape _ A _ = A pointedShape : (ℓ : Level) → Type ℓ → Type ℓ pointedShape _ X = X productShape : ∀ {ℓ₀ ℓ₁} (ℓ : Level) → (Type ℓ → Type ℓ₀) → (Type ℓ → Type ℓ₁) → Type ℓ → Type (ℓ-max ℓ₀ ℓ₁) productShape _ A₀ A₁ X = A₀ X × A₁ X functionShape : ∀ {ℓ₀ ℓ₁} (ℓ : Level) → (Type ℓ → Type ℓ₀) → (Type ℓ → Type ℓ₁) → Type ℓ → Type (ℓ-max ℓ₀ ℓ₁) functionShape _ A₀ A₁ X = A₀ X → A₁ X maybeShape : ∀ {ℓ₀} (ℓ : Level) → (Type ℓ → Type ℓ₀) → Type ℓ → Type ℓ₀ maybeShape _ A₀ X = Maybe (A₀ X) transpShape : ∀ {ℓ₀} (ℓ : Level) → (Type ℓ → Type ℓ₀) → Type ℓ → Type ℓ₀ transpShape _ A₀ X = Transp[ A₀ X ] private -- Build transport structure descriptor from a function [t : Type ℓ → Type ℓ'] buildTranspDesc : ℕ → R.Term → R.Term → R.Term → R.TC R.Term buildTranspDesc zero ℓ ℓ' t = R.typeError (R.strErr "Ran out of fuel! at \n" ∷ R.termErr t ∷ []) buildTranspDesc (suc fuel) ℓ ℓ' t = tryConstant t <|> tryPointed t <|> tryProduct t <|> tryFunction t <|> tryMaybe t <|> R.typeError (R.strErr "Can't automatically generate a transp structure for\n" ∷ R.termErr t ∷ []) where tryConstant : R.Term → R.TC R.Term tryConstant t = newMeta (tType ℓ') >>= λ A → R.unify t (R.def (quote constantShape) (varg ℓ ∷ varg A ∷ [])) >> R.returnTC (R.con (quote TranspDesc.constant) (varg A ∷ [])) tryPointed : R.Term → R.TC R.Term tryPointed t = R.unify t (R.def (quote pointedShape) (varg ℓ ∷ [])) >> R.returnTC (R.con (quote TranspDesc.var) []) tryFunction : R.Term → R.TC R.Term tryFunction t = newMeta tLevel >>= λ ℓ₀ → newMeta tLevel >>= λ ℓ₁ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → newMeta (tStruct ℓ ℓ₁) >>= λ A₁ → R.unify t (R.def (quote functionShape) (varg ℓ ∷ varg A₀ ∷ varg A₁ ∷ [])) >> buildTranspDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → buildTranspDesc fuel ℓ ℓ₁ A₁ >>= λ d₁ → R.returnTC (R.con (quote TranspDesc.function) (varg d₀ ∷ varg d₁ ∷ [])) tryProduct : R.Term → R.TC R.Term tryProduct t = newMeta tLevel >>= λ ℓ₀ → newMeta tLevel >>= λ ℓ₁ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → newMeta (tStruct ℓ ℓ₁) >>= λ A₁ → R.unify t (R.def (quote productShape) (varg ℓ ∷ varg A₀ ∷ varg A₁ ∷ [])) >> buildTranspDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → buildTranspDesc fuel ℓ ℓ₁ A₁ >>= λ d₁ → R.returnTC (R.con (quote TranspDesc._,_) (varg d₀ ∷ varg d₁ ∷ [])) tryMaybe : R.Term → R.TC R.Term tryMaybe t = newMeta tLevel >>= λ ℓ₀ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → R.unify t (R.def (quote maybeShape) (varg ℓ ∷ varg A₀ ∷ [])) >> buildTranspDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → R.returnTC (R.con (quote TranspDesc.maybe) (varg d₀ ∷ [])) autoTranspDesc' : R.Term → R.Term → R.TC Unit autoTranspDesc' t hole = R.inferType hole >>= λ H → newMeta tLevel >>= λ ℓ → newMeta tLevel >>= λ ℓ' → R.unify (tTranspDesc ℓ) H >> R.checkType t (tStruct ℓ ℓ') >> buildTranspDesc FUEL ℓ ℓ' t >>= R.unify hole -- Build structure descriptor from a function [t : Type ℓ → Type ℓ'] buildDesc : ℕ → R.Term → R.Term → R.Term → R.TC R.Term buildDesc zero ℓ ℓ' t = R.typeError (R.strErr "Ran out of fuel! at \n" ∷ R.termErr t ∷ []) buildDesc (suc fuel) ℓ ℓ' t = tryConstant t <|> tryPointed t <|> tryProduct t <|> tryFunction t <|> tryMaybe t <|> tryTransp t <|> R.typeError (R.strErr "Can't automatically generate a structure for\n" ∷ R.termErr t ∷ []) where tryConstant : R.Term → R.TC R.Term tryConstant t = newMeta (tType ℓ') >>= λ A → R.unify t (R.def (quote constantShape) (varg ℓ ∷ varg A ∷ [])) >> R.returnTC (R.con (quote Desc.constant) (varg A ∷ [])) tryPointed : R.Term → R.TC R.Term tryPointed t = R.unify t (R.def (quote pointedShape) (varg ℓ ∷ [])) >> R.returnTC (R.con (quote Desc.var) []) tryProduct : R.Term → R.TC R.Term tryProduct t = newMeta tLevel >>= λ ℓ₀ → newMeta tLevel >>= λ ℓ₁ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → newMeta (tStruct ℓ ℓ₁) >>= λ A₁ → R.unify t (R.def (quote productShape) (varg ℓ ∷ varg A₀ ∷ varg A₁ ∷ [])) >> buildDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → buildDesc fuel ℓ ℓ₁ A₁ >>= λ d₁ → R.returnTC (R.con (quote Desc._,_) (varg d₀ ∷ varg d₁ ∷ [])) tryFunction : R.Term → R.TC R.Term tryFunction t = newMeta tLevel >>= λ ℓ₀ → newMeta tLevel >>= λ ℓ₁ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → newMeta (tStruct ℓ ℓ₁) >>= λ A₁ → R.unify t (R.def (quote functionShape) (varg ℓ ∷ varg A₀ ∷ varg A₁ ∷ [])) >> buildTranspDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → buildDesc fuel ℓ ℓ₁ A₁ >>= λ d₁ → R.returnTC (R.con (quote Desc.function+) (varg d₀ ∷ varg d₁ ∷ [])) tryMaybe : R.Term → R.TC R.Term tryMaybe t = newMeta tLevel >>= λ ℓ₀ → newMeta (tStruct ℓ ℓ₀) >>= λ A₀ → R.unify t (R.def (quote maybeShape) (varg ℓ ∷ varg A₀ ∷ [])) >> buildDesc fuel ℓ ℓ₀ A₀ >>= λ d₀ → R.returnTC (R.con (quote Desc.maybe) (varg d₀ ∷ [])) tryTransp : R.Term → R.TC R.Term tryTransp t = newMeta (tStruct ℓ ℓ') >>= λ A₀ → R.unify t (R.def (quote transpShape) (varg ℓ ∷ varg A₀ ∷ [])) >> buildTranspDesc fuel ℓ ℓ' A₀ >>= λ d₀ → R.returnTC (R.con (quote Desc.transpDesc) (varg d₀ ∷ [])) autoDesc' : R.Term → R.Term → R.TC Unit autoDesc' t hole = R.inferType hole >>= λ H → newMeta tLevel >>= λ ℓ → newMeta tLevel >>= λ ℓ' → R.unify (tDesc ℓ) H >> R.checkType t (tStruct ℓ ℓ') >> buildDesc FUEL ℓ ℓ' t >>= R.unify hole macro -- (Type ℓ → Type ℓ₁) → TranspDesc ℓ autoTranspDesc : R.Term → R.Term → R.TC Unit autoTranspDesc = autoTranspDesc' -- (S : Type ℓ → Type ℓ₁) → EquivAction (AutoStructure S) autoEquivAction : R.Term → R.Term → R.TC Unit autoEquivAction t hole = newMeta (tTranspDesc R.unknown) >>= λ d → R.unify hole (R.def (quote transpMacroAction) [ varg d ]) >> autoTranspDesc' t d -- (S : Type ℓ → Type ℓ₁) → TransportStr (autoEquivAction S) autoTransportStr : R.Term → R.Term → R.TC Unit autoTransportStr t hole = newMeta (tTranspDesc R.unknown) >>= λ d → R.unify hole (R.def (quote transpMacroTransportStr) [ varg d ]) >> autoTranspDesc' t d -- (S : Type ℓ → Type ℓ₁) → Desc ℓ autoDesc : R.Term → R.Term → R.TC Unit autoDesc = autoDesc' -- (S : Type ℓ → Type ℓ₁) → (Type ℓ → Type ℓ₁) -- Removes Transp[_] annotations AutoStructure : R.Term → R.Term → R.TC Unit AutoStructure t hole = newMeta (tDesc R.unknown) >>= λ d → R.unify hole (R.def (quote MacroStructure) [ varg d ]) >> autoDesc' t d -- (S : Type ℓ → Type ℓ₁) → StrEquiv (AutoStructure S) _ AutoEquivStr : R.Term → R.Term → R.TC Unit AutoEquivStr t hole = newMeta (tDesc R.unknown) >>= λ d → R.unify hole (R.def (quote MacroEquivStr) [ varg d ]) >> autoDesc' t d -- (S : Type ℓ → Type ℓ₁) → UnivalentStr (AutoStructure S) (AutoEquivStr S) autoUnivalentStr : R.Term → R.Term → R.TC Unit autoUnivalentStr t hole = newMeta (tDesc R.unknown) >>= λ d → R.unify hole (R.def (quote MacroUnivalentStr) [ varg d ]) >> autoDesc' t d
{ "alphanum_fraction": 0.6010138346, "avg_line_length": 35.8674242424, "ext": "agda", "hexsha": "9726285ec22334cc9338fd91d2967599b02de473", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_path": "Cubical/Structures/Auto.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "knrafto/cubical", "max_issues_repo_path": "Cubical/Structures/Auto.agda", "max_line_length": 116, "max_stars_count": null, "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_path": "Cubical/Structures/Auto.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3489, "size": 9469 }
{- Please do not move this file. Changes should only be made if necessary. This file contains benchmarks for the paper: Synthetic Cohomology Theory in Cubical Agda Command to run the benchmarks and get timings: agda -v profile.definitions:10 Benchmarks.agda This assumes that there is no Benchmarks.agdai file. If there is one, then it should be removed before the above command is run. -} {-# OPTIONS --no-exact-split --safe #-} module Cubical.Experiments.ZCohomology.Benchmarks where open import Cubical.Foundations.Everything open import Cubical.Data.Nat open import Cubical.Data.Bool open import Cubical.Data.Int open import Cubical.HITs.Sn open import Cubical.Algebra.Group hiding (ℤ ; Bool) open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.Groups.Sn open import Cubical.ZCohomology.Groups.Wedge open import Cubical.ZCohomology.Groups.Torus open import Cubical.ZCohomology.Groups.KleinBottle open import Cubical.ZCohomology.Groups.WedgeOfSpheres open import Cubical.ZCohomology.Groups.RP2 open import Cubical.Data.Sigma open import Cubical.HITs.KleinBottle open import Cubical.HITs.RPn.Base open IsGroupHom open Iso -- S¹ (everything fast) module S1-tests where ϕ : coHom 1 (S₊ 1) → ℤ ϕ = fun (fst (Hⁿ-Sⁿ≅ℤ 0)) ϕ⁻¹ : ℤ → coHom 1 (S₊ 1) ϕ⁻¹ = inv (fst (Hⁿ-Sⁿ≅ℤ 0)) test₁ : ϕ (ϕ⁻¹ 0) ≡ 0 -- 30ms test₁ = refl test₂ : ϕ (ϕ⁻¹ 1) ≡ 1 -- <10ms test₂ = refl test₃ : ϕ (ϕ⁻¹ 0 +ₕ ϕ⁻¹ 0) ≡ 0 -- <10ms test₃ = refl test₄ : ϕ (ϕ⁻¹ 0 +ₕ ϕ⁻¹ 1) ≡ 1 -- 10ms test₄ = refl test₅ : ϕ (ϕ⁻¹ 1 +ₕ ϕ⁻¹ 0) ≡ 1 -- 11ms test₅ = refl test₆ : ϕ (ϕ⁻¹ -3 +ₕ ϕ⁻¹ 4) ≡ 1 -- 29ms test₆ = refl test₇ : ϕ (ϕ⁻¹ -5 +ₕ ϕ⁻¹ -2) ≡ -7 -- 28ms test₇ = refl -- S² module S2-tests where ϕ : coHom 2 (S₊ 2) → ℤ ϕ = fun (fst (Hⁿ-Sⁿ≅ℤ 1)) ϕ⁻¹ : ℤ → coHom 2 (S₊ 2) ϕ⁻¹ = inv (fst (Hⁿ-Sⁿ≅ℤ 1)) test₁ : ϕ (ϕ⁻¹ 0) ≡ 0 -- 13ms test₁ = refl test₂ : ϕ (ϕ⁻¹ 1) ≡ 1 -- 16ms test₂ = refl test₃ : ϕ (ϕ⁻¹ 0 +ₕ ϕ⁻¹ 0) ≡ 0 -- 278ms test₃ = refl test₄ : ϕ (ϕ⁻¹ 0 +ₕ ϕ⁻¹ 1) ≡ 1 -- 290ms test₄ = refl {- test₅ : ϕ (ϕ⁻¹ 1 +ₕ ϕ⁻¹ 0) ≡ 1 -- nope test₅ = refl test₆ : ϕ (ϕ⁻¹ 1 +ₕ ϕ⁻¹ 1) ≡ 2 -- nope test₆ = refl test₇ : ϕ (ϕ⁻¹ 2 +ₕ ϕ⁻¹ 4) ≡ 6 -- nope test₇ = refl -} module S1∨S1∨S2-tests₁ where -- everything fast ϕ : coHom 1 S²⋁S¹⋁S¹ → ℤ × ℤ ϕ = fun (fst H¹-S²⋁S¹⋁S¹) ϕ⁻¹ : ℤ × ℤ → coHom 1 S²⋁S¹⋁S¹ ϕ⁻¹ = inv (fst H¹-S²⋁S¹⋁S¹) test₁ : ϕ (ϕ⁻¹ (0 , 0)) ≡ (0 , 0) -- <10ms test₁ = refl test₂ : ϕ (ϕ⁻¹ (3 , 1)) ≡ (3 , 1) -- 21ms test₂ = refl test₃ : ϕ (ϕ⁻¹ (0 , 0) +ₕ ϕ⁻¹ (0 , 0)) ≡ (0 , 0) -- 15ms test₃ = refl test₄ : ϕ (ϕ⁻¹ (0 , 1) +ₕ ϕ⁻¹ (1 , 0)) ≡ (1 , 1) -- 21ms test₄ = refl test₅ : ϕ (ϕ⁻¹ (3 , 2) +ₕ ϕ⁻¹ (-1 , 5)) ≡ (2 , 7) -- 47ms test₅ = refl module S1∨S1∨S2-tests₂ where ϕ : coHom 2 S²⋁S¹⋁S¹ → ℤ ϕ = fun (fst H²-S²⋁S¹⋁S¹) ϕ⁻¹ : ℤ → coHom 2 S²⋁S¹⋁S¹ ϕ⁻¹ = inv (fst H²-S²⋁S¹⋁S¹) test₁ : ϕ (ϕ⁻¹ 0) ≡ 0 -- 157ms test₁ = refl test₂ : ϕ (ϕ⁻¹ 3) ≡ 3 -- 119ms test₂ = refl test₃ : ϕ (ϕ⁻¹ 0 +ₕ ϕ⁻¹ 0) ≡ 0 -- 1,820ms test₃ = refl module Torus-test₁ where -- fast ϕ : coHom 1 (S₊ 1 × S₊ 1) → ℤ × ℤ ϕ = fun (fst H¹-T²≅ℤ×ℤ) ϕ⁻¹ : ℤ × ℤ → coHom 1 (S₊ 1 × S₊ 1) ϕ⁻¹ = inv (fst H¹-T²≅ℤ×ℤ) test₁ : ϕ (ϕ⁻¹ (0 , 0)) ≡ (0 , 0) -- <10ms test₁ = refl test₂ : ϕ (ϕ⁻¹ (3 , 1)) ≡ (3 , 1) -- 18ms test₂ = refl test₃ : ϕ (ϕ⁻¹ (0 , 0) +ₕ ϕ⁻¹ (0 , 0)) ≡ (0 , 0) -- 15ms test₃ = refl test₄ : ϕ (ϕ⁻¹ (0 , 1) +ₕ ϕ⁻¹ (1 , 0)) ≡ (1 , 1) -- 20ms test₄ = refl test₅ : ϕ (ϕ⁻¹ (-3 , 2) +ₕ ϕ⁻¹ (-1 , 5)) ≡ (-4 , 7) -- 44ms test₅ = refl module Torus-test₂ where ϕ : coHom 2 (S₊ 1 × S₊ 1) → ℤ ϕ = fun (fst H²-T²≅ℤ) ϕ⁻¹ : ℤ → coHom 2 (S₊ 1 × S₊ 1) ϕ⁻¹ = inv (fst H²-T²≅ℤ) test₁ : ϕ (ϕ⁻¹ 0) ≡ 0 -- 121ms test₁ = refl test₂ : ϕ (ϕ⁻¹ 3) ≡ 3 -- 142ms test₂ = refl test₃ : ϕ (ϕ⁻¹ 0 +ₕ ϕ⁻¹ 0) ≡ 0 -- 3,674ms test₃ = refl test₄ : ϕ (ϕ⁻¹ 0 +ₕ ϕ⁻¹ 1) ≡ 1 -- 3,772ms test₄ = refl {- test₅ : ϕ (ϕ⁻¹ 1 +ₕ ϕ⁻¹ 0) ≡ 1 -- nope test₅ = refl -} module Klein-test₁ where -- fast ϕ : coHom 1 KleinBottle → ℤ ϕ = fun (fst H¹-𝕂²≅ℤ) ϕ⁻¹ : ℤ → coHom 1 KleinBottle ϕ⁻¹ = inv (fst H¹-𝕂²≅ℤ) test₁ : ϕ (ϕ⁻¹ 0) ≡ 0 -- <10ms test₁ = refl test₂ : ϕ (ϕ⁻¹ 3) ≡ 3 -- 12ms test₂ = refl test₃ : ϕ (ϕ⁻¹ 0 +ₕ ϕ⁻¹ 0) ≡ 0 -- <10ms test₃ = refl test₄ : ϕ (ϕ⁻¹ 0 +ₕ ϕ⁻¹ 1) ≡ 1 -- 11ms test₄ = refl test₅ : ϕ (ϕ⁻¹ 1 +ₕ ϕ⁻¹ 0) ≡ 1 -- 12ms test₅ = refl test₆ : ϕ (ϕ⁻¹ -3 +ₕ ϕ⁻¹ 4) ≡ 1 -- 29ms test₆ = refl test₇ : ϕ (ϕ⁻¹ -5 +ₕ ϕ⁻¹ -2) ≡ -7 -- 29ms test₇ = refl -- The example in the paper: test : ϕ (ϕ⁻¹ 1 +ₕ ϕ⁻¹ 2) ≡ 3 -- 15ms test = refl module Klein-test₂ where ϕ : coHom 2 KleinBottle → Bool ϕ = fun (fst H²-𝕂²≅Bool) ϕ⁻¹ : Bool → coHom 2 KleinBottle ϕ⁻¹ = inv (fst H²-𝕂²≅Bool) {- test₀ : ϕ (0ₕ _) ≡ true -- fails already here... test₀ = refl -} module RP2-test₂ where ϕ : coHom 2 RP² → Bool ϕ = fun (fst H²-RP²≅Bool) ϕ⁻¹ : Bool → coHom 2 RP² ϕ⁻¹ = inv (fst H²-RP²≅Bool) test₀ : ϕ (0ₕ _) ≡ true -- 1,210ms (unlike for Klein, this works) test₀ = refl {- test₁ : ϕ (ϕ⁻¹ true) ≡ true -- nope test₁ = refl -}
{ "alphanum_fraction": 0.5561176691, "avg_line_length": 20.5269230769, "ext": "agda", "hexsha": "1378e360fc9a88c54845b45e122a2e7cc8c54b14", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "kl-i/cubical-0.3", "max_forks_repo_path": "Cubical/Experiments/ZCohomology/Benchmarks.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "kl-i/cubical-0.3", "max_issues_repo_path": "Cubical/Experiments/ZCohomology/Benchmarks.agda", "max_line_length": 70, "max_stars_count": null, "max_stars_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "kl-i/cubical-0.3", "max_stars_repo_path": "Cubical/Experiments/ZCohomology/Benchmarks.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2947, "size": 5337 }
{-# OPTIONS --without-K --safe #-} module Categories.Functor.Instance.Core where -- Core Functor (from Cats to Groupoids). -- This is the right-adjoint of the forgetful functor from Groupoids to -- Cats (see Categories.Functor.Adjoint.Instance.Core) open import Level using (_⊔_) open import Categories.Category using (Category) import Categories.Category.Construction.Core as C open import Categories.Category.Groupoid using (Groupoid) open import Categories.Category.Instance.Cats using (Cats) open import Categories.Category.Instance.Groupoids using (Groupoids) open import Categories.Functor using (Functor; _∘F_; id) open import Categories.Functor.Properties using ([_]-resp-≅; [_]-resp-≃) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism) import Categories.Morphism as Morphism open import Categories.Morphism.IsoEquiv using (⌞_⌟) import Categories.Morphism.Reasoning as MR Core : ∀ {o ℓ e} → Functor (Cats o ℓ e) (Groupoids o (ℓ ⊔ e) e) Core {o} {ℓ} {e} = record { F₀ = CoreGrpd ; F₁ = CoreFunctor ; identity = CoreId ; homomorphism = λ {A B C F G} → CoreHom {A} {B} {C} {F} {G} ; F-resp-≈ = CoreRespNI } where CoreGrpd : Category o ℓ e → Groupoid o (ℓ ⊔ e) e CoreGrpd C = record { category = C.Core C ; isGroupoid = C.Core-isGroupoid C } CoreFunctor : {A B : Category o ℓ e} → Functor A B → Functor (C.Core A) (C.Core B) CoreFunctor {A} {B} F = record { F₀ = F₀ ; F₁ = [ F ]-resp-≅ ; identity = ⌞ identity ⌟ ; homomorphism = ⌞ homomorphism ⌟ ; F-resp-≈ = [ F ]-resp-≃ } where open Functor F CoreId : {A : Category o ℓ e} → NaturalIsomorphism (CoreFunctor {A} id) id CoreId {A} = record { F⇒G = record { η = λ _ → ≅.refl ; commute = λ _ → ⌞ MR.id-comm-sym A ⌟ ; sym-commute = λ _ → ⌞ MR.id-comm A ⌟ } ; F⇐G = record { η = λ _ → ≅.refl ; commute = λ _ → ⌞ MR.id-comm-sym A ⌟ ; sym-commute = λ _ → ⌞ MR.id-comm A ⌟ } ; iso = λ _ → record { isoˡ = ⌞ identity² ⌟ ; isoʳ = ⌞ identity² ⌟ } } where open Category A open Morphism A CoreHom : {A B C : Category o ℓ e} {F : Functor A B} {G : Functor B C} → NaturalIsomorphism (CoreFunctor (G ∘F F)) (CoreFunctor G ∘F CoreFunctor F) CoreHom {A} {B} {C} {F} {G} = record { F⇒G = record { η = λ _ → ≅.refl ; commute = λ _ → ⌞ MR.id-comm-sym C ⌟ ; sym-commute = λ _ → ⌞ MR.id-comm C ⌟ } ; F⇐G = record { η = λ _ → ≅.refl ; commute = λ _ → ⌞ MR.id-comm-sym C ⌟ ; sym-commute = λ _ → ⌞ MR.id-comm C ⌟ } ; iso = λ _ → record { isoˡ = ⌞ identity² ⌟ ; isoʳ = ⌞ identity² ⌟ } } where open Category C open Morphism C CoreRespNI : {A B : Category o ℓ e} {F G : Functor A B} → NaturalIsomorphism F G → NaturalIsomorphism (CoreFunctor F) (CoreFunctor G) CoreRespNI {A} {B} {F} {G} μ = record { F⇒G = record { η = λ _ → FX≅GX ; commute = λ _ → ⌞ ⇒.commute _ ⌟ ; sym-commute = λ _ → ⌞ ⇒.sym-commute _ ⌟ } ; F⇐G = record { η = λ _ → ≅.sym FX≅GX ; commute = λ _ → ⌞ ⇐.commute _ ⌟ ; sym-commute = λ _ → ⌞ ⇐.sym-commute _ ⌟ } ; iso = λ X → record { isoˡ = ⌞ iso.isoˡ X ⌟ ; isoʳ = ⌞ iso.isoʳ X ⌟ } } where open NaturalIsomorphism μ open Morphism B
{ "alphanum_fraction": 0.5655053268, "avg_line_length": 41.3452380952, "ext": "agda", "hexsha": "de66da1b4a2364b52e7ca12c93ac5ea1fecfd93d", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Functor/Instance/Core.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Functor/Instance/Core.agda", "max_line_length": 123, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Functor/Instance/Core.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 1231, "size": 3473 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Results concerning the excluded middle axiom. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Axiom.ExcludedMiddle where open import Level open import Relation.Nullary ------------------------------------------------------------------------ -- Definition -- The classical statement of excluded middle says that every -- statement/set is decidable (i.e. it either holds or it doesn't hold). ExcludedMiddle : (ℓ : Level) → Set (suc ℓ) ExcludedMiddle ℓ = {P : Set ℓ} → Dec P
{ "alphanum_fraction": 0.4793261868, "avg_line_length": 29.6818181818, "ext": "agda", "hexsha": "8ac27d22b405fcc0f84db1e29b8a3bc9651833b2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Axiom/ExcludedMiddle.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Axiom/ExcludedMiddle.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Axiom/ExcludedMiddle.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 117, "size": 653 }
module CyclicModuleDependency where import CyclicModuleDependency
{ "alphanum_fraction": 0.8970588235, "avg_line_length": 13.6, "ext": "agda", "hexsha": "d556ae966ae6819d3a85e2199d741f9370d62f8e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/CyclicModuleDependency.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/CyclicModuleDependency.agda", "max_line_length": 35, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/CyclicModuleDependency.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 13, "size": 68 }
-- Andreas, 2013-05-02 This ain't a bug, it is a feature. -- {-# OPTIONS -v scope.name:10 #-} -- {-# OPTIONS -v scope:10 #-} -- {-# OPTIONS -v scope.mod.inst:30 #-} module _ where module M (_ : Set₁) where record R : Set₁ where field X : Set open M Set using (R) X : R → Set X = R.X -- A glimpse at the scope (showing only concrete names, though) -- modules -- * scope Issue836a -- private names R --> [Issue836a._.R] -- public modules M --> [Issue836a.M] -- * scope Issue836a.M -- public names R --> [Issue836a.M.R] -- public modules R --> [Issue836a.M.R] -- * scope Issue836a.M.R -- public names X --> [Issue836a.M.R.X] -- * scope Issue836a._ -- public names R --> [Issue836a._.R] -- public modules R --> [Issue836a._.R] -- * scope Issue836a._.R -- public names X --> [Issue836a._.R.X] -- Nisse: -- The open directive did not mention the /module/ R, so (I think -- that) the code above should be rejected. -- Andreas -- NO, it is a feature that projections can also be accessed via -- the record /type/. -- The following directive is (and should be) rejected: -- open R -- Bug.agda:19,6-7 -- No such module R -- when scope checking the declaration -- open R
{ "alphanum_fraction": 0.6061093248, "avg_line_length": 24.88, "ext": "agda", "hexsha": "dc636f2800d99b19e9a9198688b784e1704b2089", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue836a.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue836a.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue836a.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 388, "size": 1244 }
-- There was a bug where the arguments to a let function got reversed. module LetLHS where f : {A B : Set} -> A -> B -> A f {A}{B} = let const : A -> B -> A const x y = x in const
{ "alphanum_fraction": 0.5240384615, "avg_line_length": 26, "ext": "agda", "hexsha": "e389a704e11e7cdb55c8da40c5a96887984bd792", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/LetLHS.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/LetLHS.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/LetLHS.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 63, "size": 208 }
------------------------------------------------------------------------------ -- Testing the translation of the propositional functions ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module PropositionalFunction2 where ------------------------------------------------------------------------------ postulate D : Set P : D → Set a : D _∨_ : Set → Set → Set A : D → Set A x = P x ∨ P x {-# ATP definition A #-} -- In this case the propositional function uses predicates and logical -- constants. postulate foo : A a → A a {-# ATP prove foo #-}
{ "alphanum_fraction": 0.4054758801, "avg_line_length": 27.3928571429, "ext": "agda", "hexsha": "b7fd20554c5936675c02beef941dbb1e67454a24", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "test/Succeed/fol-theorems/PropositionalFunction2.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "test/Succeed/fol-theorems/PropositionalFunction2.agda", "max_line_length": 78, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "test/Succeed/fol-theorems/PropositionalFunction2.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 142, "size": 767 }
module Examples.Max where open import Data.Empty open import Data.Bool open import Data.Nat open import Data.Product open import Data.List hiding (sum) open import Data.Vec hiding (init) open import Relation.Nullary open import Relation.Binary.PropositionalEquality import DTGP data Word : Set where nat : ℕ → Word sucSuc times : Word pre : Word → ℕ → ℕ pre (nat _) n = n pre sucSuc n = 1 + n pre times n = 2 + n post : Word → ℕ → ℕ post (nat _) n = 1 + n post sucSuc n = 1 + n post times n = 1 + n open DTGP pre post Data.Nat._≟_ eval : ∀ {inp out} → Term inp out → Vec ℕ inp → Vec ℕ out eval [] is = is eval (nat o ∷ xs) is with eval xs is ... | os = o ∷ os eval (sucSuc ∷ xs) is with eval xs is ... | o ∷ os = (2 + o) ∷ os eval (times ∷ xs) is with eval xs is ... | o₂ ∷ o₁ ∷ os = (o₁ * o₂) ∷ os score : Term 0 1 → ℕ score xs = sum (eval xs []) open Evolution score match : (w : Word) (out : ℕ) → Dec (∃ λ n → out ≡ pre w n) match (nat _) n = yes (n , refl) match sucSuc zero = no ¬p where ¬p : Σ ℕ (λ n → 0 ≡ suc n) → ⊥ ¬p (_ , ()) match sucSuc (suc n) = yes (n , refl) match times zero = no ¬p where ¬p : Σ ℕ (λ n → 0 ≡ suc (suc n)) → ⊥ ¬p (_ , ()) match times (suc zero) = no ¬p where ¬p : Σ ℕ (λ n → 1 ≡ suc (suc n)) → ⊥ ¬p (_ , ()) match times (suc (suc n)) = yes (n , refl) open Initialization match choices : List Word choices = nat 1 ∷ nat 2 ∷ nat 3 ∷ sucSuc ∷ times ∷ [] population : Population _ _ _ population = fromList (init 4 0 1 choices) answer : Population _ _ _ answer = evolve 1337 1 population
{ "alphanum_fraction": 0.6097087379, "avg_line_length": 23.0597014925, "ext": "agda", "hexsha": "69b6bf6c581698ee8887c02eb579ad372fc32e25", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:53:14.000Z", "max_forks_repo_forks_event_min_datetime": "2018-04-17T02:02:58.000Z", "max_forks_repo_head_hexsha": "31d79242908f2d80ea8e0c02931f4fdc5a3e5d1f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/dtgp", "max_forks_repo_path": "src/Examples/Max.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "31d79242908f2d80ea8e0c02931f4fdc5a3e5d1f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/dtgp", "max_issues_repo_path": "src/Examples/Max.agda", "max_line_length": 58, "max_stars_count": 9, "max_stars_repo_head_hexsha": "31d79242908f2d80ea8e0c02931f4fdc5a3e5d1f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/dtgp", "max_stars_repo_path": "src/Examples/Max.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T21:39:58.000Z", "max_stars_repo_stars_event_min_datetime": "2015-07-20T16:46:00.000Z", "num_tokens": 567, "size": 1545 }
------------------------------------------------------------------------------ -- Testing the use of numeric literals ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Nat.NumericLiterals where open import FOTC.Base open import FOTC.Data.Nat ------------------------------------------------------------------------------ data ℕ : Set where z : ℕ s : ℕ → ℕ {-# BUILTIN NATURAL ℕ #-} toD : ℕ → D toD z = zero toD (s n) = succ₁ (toD n) ten : D ten = toD 10
{ "alphanum_fraction": 0.3771676301, "avg_line_length": 23.8620689655, "ext": "agda", "hexsha": "252ec56c191fecd07541f5d5a3326855f7bc5443", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Data/Nat/NumericLiterals.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Data/Nat/NumericLiterals.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Data/Nat/NumericLiterals.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 141, "size": 692 }
module RW.Data.RTrie where open import RW.Data.RTrie.Decl public open import RW.Data.RTrie.Insert using (insertTerm) public open import RW.Data.RTrie.Lookup renaming (lookup to lookupTerm) public
{ "alphanum_fraction": 0.7511737089, "avg_line_length": 26.625, "ext": "agda", "hexsha": "3419cacb308908cff9e6590f9bddf3d1e8ab9290", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "VictorCMiraldo/agda-rw", "max_forks_repo_path": "RW/Data/RTrie.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "VictorCMiraldo/agda-rw", "max_issues_repo_path": "RW/Data/RTrie.agda", "max_line_length": 42, "max_stars_count": 16, "max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "VictorCMiraldo/agda-rw", "max_stars_repo_path": "RW/Data/RTrie.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z", "max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z", "num_tokens": 58, "size": 213 }
open import Data.String using ( String ) open import Data.ByteString using ( ByteString ; Style ; lazy ; strict ) open import Data.ByteString.UTF8 using ( toString ; fromString ) open import System.IO.Primitive using ( HandleR ; HandleW ; hOpenR ; hOpenW ; hCloseR ; hCloseW ; hGetStrict ; hGetLazy ; hPutStrict ; hPutLazy ) -- A proposed binding for the Haskell IO library. -- The semantics is strict IO, there is no visibility for semi-closed handles. module System.IO where open System.IO.Primitive public using ( Unit ; IO ; unit ; return ; _>>=_ ; commit ; onCommit ; stdin ; stdout ; stderr ) -- Command is a synonym for IO Unit Command : Set Command = IO Unit skip : Command skip = return unit -- Other operations are defined in terms of _>>=_ infixl 1 _>>_ infixl 4 _<$>_ _<*>_ _>>_ : {A B : Set} → (IO A) → (IO B) → (IO B) a >> b = a >>= (λ x → b) _<$>_ : {A B : Set} → (A → B) → (IO A) → (IO B) _<$>_ f a = a >>= (λ x → return (f x)) _<*>_ : {A B : Set} → (IO (A → B)) → (IO A) → (IO B) _<*>_ f a = f >>= (λ x → x <$> a) -- TODO: Use the new "syntax" construct to define do-like notation? -- TODO: RW and Append mode? data IOMode : Set where read write : IOMode Handle : IOMode → Set Handle read = HandleR Handle write = HandleW -- TODO: There should really be a separate type for file paths, -- and some sanity-checking to support protection against -- injection attacks. hOpen : {m : IOMode} → String → IO (Handle m) hOpen {read} = hOpenR hOpen {write} = hOpenW hGetBytes : {s : Style} → (Handle read) → IO (ByteString s) hGetBytes {lazy} = hGetLazy hGetBytes {strict} = hGetStrict getBytes : {s : Style} → IO (ByteString s) getBytes = hGetBytes stdin hPutBytes : {s : Style} → (Handle write) → (ByteString s) → Command hPutBytes {lazy} = hPutLazy hPutBytes {strict} = hPutStrict putBytes : {s : Style} → (ByteString s) → Command putBytes = hPutBytes stdout hClose : {m : IOMode} → (Handle m) → Command hClose {read} = hCloseR hClose {write} = hCloseW -- TODO: Better handling of codecs, don't just hard-wire UTF-8! -- TODO: Lazy vs strict strings? -- Default arguments would help a lot here. hGetStr : (Handle read) → (IO String) hGetStr hdl = toString <$> hGetBytes {lazy} hdl getStr : (IO String) getStr = hGetStr stdin hPutStr : (Handle write) → String → Command hPutStr hdl s = hPutBytes {lazy} hdl (fromString s) putStr : String → Command putStr = hPutStr stdout
{ "alphanum_fraction": 0.667218543, "avg_line_length": 27.1460674157, "ext": "agda", "hexsha": "98277125f147e11fe61765592042edc2107095cb", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:23.000Z", "max_forks_repo_forks_event_min_datetime": "2017-08-10T06:12:54.000Z", "max_forks_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ilya-fiveisky/agda-system-io", "max_forks_repo_path": "src/System/IO.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ilya-fiveisky/agda-system-io", "max_issues_repo_path": "src/System/IO.agda", "max_line_length": 145, "max_stars_count": 10, "max_stars_repo_head_hexsha": "d06c219c7b7afc85aae3b1d4d66951b889aa7371", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ilya-fiveisky/agda-system-io", "max_stars_repo_path": "src/System/IO.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-15T04:35:41.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-04T13:45:16.000Z", "num_tokens": 756, "size": 2416 }
module Implicits.Resolution.Infinite.Undecidable where open import Prelude hiding (Bool; Dec) open import Data.Fin.Substitution open import Function.Equivalence using (_⇔_; equivalence) open import Relation.Nullary.Decidable as DecM using () open import Relation.Nullary open import Extensions.ListFirst open import SystemF.Everything as F using () open import Implicits.Resolution.Ambiguous.Resolution as A open import Implicits.Resolution.Deterministic.Resolution as D open import Implicits.Resolution.Infinite.Resolution as I open import Implicits.Syntax open import Implicits.Substitutions open import Implicits.Resolution.Ambiguous.Undecidable using () renaming (module Undecidable to AUndec) open import Implicits.Resolution.Infinite.Expressiveness private -- type of inhabitation problem decider ?:-dec : Set ?:-dec = ∀ {n ν} (Γ : F.Ctx ν n) (a : F.Type ν) → Dec (∃ λ t → Γ F.⊢ t ∈ a) -- assuming that System F have an EBNF form -- and assuming that System F type inhabitation is undecidable, -- we prove that Infinite resolution is undecidable module Undecidable (?:-undec : ¬ ?:-dec) (nf : ∀ {ν n} {Γ : F.Ctx ν n} {t a} → Γ F.⊢ t ∈ a → ∃ λ (t₂ : F.Term ν n) → Γ F.⊢ t₂ ⇑ a) where open Infinite⇔Ambiguous nf open AUndec ?:-undec using () renaming (undecidable to ⊢ᵣᵃ-undec; ⊢ᵣ-Dec to ⊢ᵣᵃ-Dec) -- type of decider for infinite resolution ⊢ᵣ-Dec : Set ⊢ᵣ-Dec = ∀ {ν} (Δ : ICtx ν) (a : Type ν) → Dec (Δ I.⊢ᵣ a) -- proof that such a decider would imply a decider for ambiguous resolution reduction : ⊢ᵣ-Dec → ⊢ᵣᵃ-Dec reduction f Δ x = DecM.map (equivalent Δ x) (f Δ x) -- completing the proof undecidable : ¬ ⊢ᵣ-Dec undecidable f = ⊢ᵣᵃ-undec (reduction f)
{ "alphanum_fraction": 0.7177230047, "avg_line_length": 35.5, "ext": "agda", "hexsha": "ebf77e70d36097d171897df5435ed6ad2547c9f0", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Implicits/Resolution/Infinite/Undecidable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Implicits/Resolution/Infinite/Undecidable.agda", "max_line_length": 103, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Implicits/Resolution/Infinite/Undecidable.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 574, "size": 1704 }
{-# OPTIONS --without-K #-} open import Base module Spaces.Interval where private data #I : Set where #zer : #I #one : #I I : Set I = #I zer : I zer = #zer one : I one = #one postulate -- HIT seg : zer ≡ one I-rec : ∀ {i} (P : I → Set i) (x₀ : P zer) (x₁ : P one) (p : transport P seg x₀ ≡ x₁) → ((t : I) → P t) I-rec P x₀ x₁ p #zer = x₀ I-rec P x₀ x₁ p #one = x₁ postulate -- HIT β : ∀ {i} (P : I → Set i) (x₀ : P zer) (x₁ : P one) (p : transport P seg x₀ ≡ x₁) → apd (I-rec P x₀ x₁ p) seg ≡ p I-rec-nondep : ∀ {i} (C : Set i) (x₀ x₁ : C) (p : x₀ ≡ x₁) → (I → C) I-rec-nondep C x₀ x₁ p #zer = x₀ I-rec-nondep C x₀ x₁ p #one = x₁ postulate -- HIT β-nondep : ∀ {i} (C : Set i) (x₀ x₁ : C) (p : x₀ ≡ x₁) → ap (I-rec-nondep C x₀ x₁ p) seg ≡ p
{ "alphanum_fraction": 0.4981226533, "avg_line_length": 19.0238095238, "ext": "agda", "hexsha": "543adc9826ca5906395c5026349f5c04961d1539", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/Spaces/Interval.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/Spaces/Interval.agda", "max_line_length": 68, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/Spaces/Interval.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 360, "size": 799 }
-- {-# OPTIONS --show-implicit --show-irrelevant #-} module Data.QuadTree.FunctorProofs.Valid-QuadrantFunctor where open import Haskell.Prelude renaming (zero to Z; suc to S) open import Data.Logic open import Data.QuadTree.InternalAgda open import Agda.Primitive open import Data.QuadTree.FunctorProofs.FunctorLaws open import Data.QuadTree.Implementation.Definition open import Data.QuadTree.Implementation.ValidTypes open import Data.QuadTree.Implementation.Functors open import Data.QuadTree.Implementation.QuadrantLenses ValidFunctor-Quadrant-IdentityLaw : (dep : Nat) -> IdentityLaw (λ y -> VQuadrant y {dep}) {{quadrantFunctor dep}} ValidFunctor-Quadrant-IdentityLaw dep (CVQuadrant (Leaf v)) = refl ValidFunctor-Quadrant-IdentityLaw dep@(S deps) (CVQuadrant qd@(Node (Leaf a) (Leaf b) (Leaf c) (Leaf d)) {p}) = ifcFalse (a == b && b == c && c == d) (notTrueToFalse $ andSndI {a = (depth qd <= dep)} p) ValidFunctor-Quadrant-IdentityLaw dep@(S deps) (CVQuadrant (Node a@(Leaf _) b@(Leaf _) c@(Leaf _) d@(Node _ _ _ _)) {p}) = cong4 combine (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant a)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant b)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant c)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant d)) ValidFunctor-Quadrant-IdentityLaw dep@(S deps) (CVQuadrant (Node a@(Leaf _) b@(Leaf _) c@(Node _ _ _ _) d) {p}) = cong4 combine (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant a)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant b)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant c)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant d)) ValidFunctor-Quadrant-IdentityLaw dep@(S deps) (CVQuadrant (Node a@(Leaf _) b@(Node _ _ _ _) c d) {p}) = cong4 combine (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant a)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant b)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant c)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant d)) ValidFunctor-Quadrant-IdentityLaw dep@(S deps) (CVQuadrant (Node a@(Node _ _ _ _) b c d) {p}) = cong4 combine (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant a)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant b)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant c)) (ValidFunctor-Quadrant-IdentityLaw deps (CVQuadrant d)) postulate eq-subst : {a b : Set} {{eqA : Eq a}} {{eqB : Eq b}} -> (f : a -> b) -> (x y : a) -> (x == y) ≡ (f x == f y) combine-fmap : {t s : Set} {{eqT : Eq t}} {{eqS : Eq s}} {dep : Nat} -> (a b c d : VQuadrant t {dep}) -> (f : t -> s) -> combine (fmapₑ (quadrantFunctor dep) f a) (fmapₑ (quadrantFunctor dep) f b) (fmapₑ (quadrantFunctor dep) f c) (fmapₑ (quadrantFunctor dep) f d) ≡ fmapₑ (quadrantFunctor (S dep)) f (combine a b c d) combine-fmap {t} {s} {dep = dep} (CVQuadrant a@(Leaf va)) (CVQuadrant b@(Leaf vb)) (CVQuadrant c@(Leaf vc)) (CVQuadrant d@(Leaf vd)) f = ifc (va == vb && vb == vc && vc == vd) then (λ {{p}} -> begin (ifc (f va == f vb) && (f vb == f vc) && (f vc == f vd) then _ else _) =⟨ ifcTrue _ (useEq (cong3 (λ e1 e2 e3 -> e1 && e2 && e3) (eq-subst f va vb) (eq-subst f vb vc) (eq-subst f vc vd)) p) ⟩ fmapₑ (quadrantFunctor (S dep)) f (CVQuadrant (Leaf va)) =⟨ cong (fmapₑ (quadrantFunctor (S dep)) f) (sym $ ifcTrue ((va == vb) && (vb == vc) && (vc == vd)) p) ⟩ fmapₑ (quadrantFunctor (S dep)) f (ifc (va == vb) && (vb == vc) && (vc == vd) then CVQuadrant (Leaf va) else CVQuadrant (Node (Leaf va) (Leaf vb) (Leaf vc) (Leaf vd))) end) else (λ {{p}} -> begin (ifc (f va == f vb) && (f vb == f vc) && (f vc == f vd) then _ else _) =⟨ sym $ cong {y = (CVQuadrant (Node (Leaf va) (Leaf vb) (Leaf vc) (Leaf vd)) {andCombine (zeroLteAny dep) (falseToNotTrue p)})} p1 (ifcFalse ((va == vb) && (vb == vc) && (vc == vd)) p) ⟩ fmapₑ (quadrantFunctor (S dep)) f (ifc (va == vb) && (vb == vc) && (vc == vd) then CVQuadrant (Leaf va) else CVQuadrant (Node (Leaf va) (Leaf vb) (Leaf vc) (Leaf vd))) end) where p1 : VQuadrant t {S dep} -> VQuadrant s {S dep} p1 q = (fmapₑ (quadrantFunctor (S dep)) f) q combine-fmap (CVQuadrant (Leaf _)) (CVQuadrant (Leaf _)) (CVQuadrant (Leaf _)) (CVQuadrant (Node _ _ _ _)) f = refl combine-fmap (CVQuadrant (Leaf _)) (CVQuadrant (Leaf _)) (CVQuadrant (Node _ _ _ _)) (CVQuadrant d) f = refl combine-fmap (CVQuadrant (Leaf _)) (CVQuadrant (Node _ _ _ _)) (CVQuadrant c) (CVQuadrant d) f = refl combine-fmap (CVQuadrant (Node _ _ _ _)) (CVQuadrant b) (CVQuadrant c) (CVQuadrant d) f = refl ValidFunctor-Quadrant-CompositionLaw : (dep : Nat) -> CompositionLaw (λ y -> VQuadrant y {dep}) {{quadrantFunctor dep}} ValidFunctor-Quadrant-CompositionLaw dep (CVQuadrant (Leaf x)) f g = refl ValidFunctor-Quadrant-CompositionLaw dep@(S deps) {t1} {t2} {t3} cvq@(CVQuadrant qd@(Node a@(Leaf va) b@(Leaf vb) c@(Leaf vc) d@(Leaf vd)) {p}) f g = begin combine (mgf sa) (mgf sb) (mgf sc) (mgf sd) =⟨ cong4 combine (ValidFunctor-Quadrant-CompositionLaw deps sa f g) (ValidFunctor-Quadrant-CompositionLaw deps sb f g) (ValidFunctor-Quadrant-CompositionLaw deps sc f g) (ValidFunctor-Quadrant-CompositionLaw deps sd f g) ⟩ combine (mg $ mf sa) (mg $ mf sb) (mg $ mf sc) (mg $ mf sd) =⟨ combine-fmap (mf sa) (mf sb) (mf sc) (mf sd) g ⟩ fmapₑ (quadrantFunctor dep) g (combine (mf sa) (mf sb) (mf sc) (mf sd)) end where mf = fmapₑ (quadrantFunctor deps) f mg = fmapₑ (quadrantFunctor deps) g mgf = fmapₑ (quadrantFunctor deps) (g ∘ f) sa = (CVQuadrant a {aSub {dep = deps} a b c d p}) sb = (CVQuadrant b {bSub {dep = deps} a b c d p}) sc = (CVQuadrant c {cSub {dep = deps} a b c d p}) sd = (CVQuadrant d {dSub {dep = deps} a b c d p}) ValidFunctor-Quadrant-CompositionLaw dep@(S deps) cvq@(CVQuadrant (Node a@(Leaf va) b@(Leaf vb) c@(Leaf vc) d@(Node _ _ _ _)) {p}) f g = begin combine (mgf sa) (mgf sb) (mgf sc) (mgf sd) =⟨ cong4 combine (ValidFunctor-Quadrant-CompositionLaw deps sa f g) (ValidFunctor-Quadrant-CompositionLaw deps sb f g) (ValidFunctor-Quadrant-CompositionLaw deps sc f g) (ValidFunctor-Quadrant-CompositionLaw deps sd f g) ⟩ combine (mg $ mf sa) (mg $ mf sb) (mg $ mf sc) (mg $ mf sd) =⟨ combine-fmap (mf sa) (mf sb) (mf sc) (mf sd) g ⟩ fmapₑ (quadrantFunctor dep) g (combine (mf sa) (mf sb) (mf sc) (mf sd)) end where mf = fmapₑ (quadrantFunctor deps) f mg = fmapₑ (quadrantFunctor deps) g mgf = fmapₑ (quadrantFunctor deps) (g ∘ f) sa = (CVQuadrant a {aSub {dep = deps} a b c d p}) sb = (CVQuadrant b {bSub {dep = deps} a b c d p}) sc = (CVQuadrant c {cSub {dep = deps} a b c d p}) sd = (CVQuadrant d {dSub {dep = deps} a b c d p}) ValidFunctor-Quadrant-CompositionLaw dep@(S deps) cvq@(CVQuadrant (Node a@(Leaf _) b@(Leaf _) c@(Node _ _ _ _) d) {p}) f g = trans (cong4 combine (ValidFunctor-Quadrant-CompositionLaw deps sa f g) (ValidFunctor-Quadrant-CompositionLaw deps sb f g) (ValidFunctor-Quadrant-CompositionLaw deps sc f g) (ValidFunctor-Quadrant-CompositionLaw deps sd f g)) (combine-fmap (mf sa) (mf sb) (mf sc) (mf sd) g) where mf = fmapₑ (quadrantFunctor deps) f sa = (CVQuadrant a {aSub {dep = deps} a b c d p}) sb = (CVQuadrant b {bSub {dep = deps} a b c d p}) sc = (CVQuadrant c {cSub {dep = deps} a b c d p}) sd = (CVQuadrant d {dSub {dep = deps} a b c d p}) ValidFunctor-Quadrant-CompositionLaw dep@(S deps) cvq@(CVQuadrant (Node a@(Leaf _) b@(Node _ _ _ _) c d) {p}) f g = trans (cong4 combine (ValidFunctor-Quadrant-CompositionLaw deps sa f g) (ValidFunctor-Quadrant-CompositionLaw deps sb f g) (ValidFunctor-Quadrant-CompositionLaw deps sc f g) (ValidFunctor-Quadrant-CompositionLaw deps sd f g)) (combine-fmap (mf sa) (mf sb) (mf sc) (mf sd) g) where mf = fmapₑ (quadrantFunctor deps) f sa = (CVQuadrant a {aSub {dep = deps} a b c d p}) sb = (CVQuadrant b {bSub {dep = deps} a b c d p}) sc = (CVQuadrant c {cSub {dep = deps} a b c d p}) sd = (CVQuadrant d {dSub {dep = deps} a b c d p}) ValidFunctor-Quadrant-CompositionLaw dep@(S deps) cvq@(CVQuadrant (Node a@(Node _ _ _ _) b c d) {p}) f g = trans (cong4 combine (ValidFunctor-Quadrant-CompositionLaw deps sa f g) (ValidFunctor-Quadrant-CompositionLaw deps sb f g) (ValidFunctor-Quadrant-CompositionLaw deps sc f g) (ValidFunctor-Quadrant-CompositionLaw deps sd f g)) (combine-fmap (mf sa) (mf sb) (mf sc) (mf sd) g) where mf = fmapₑ (quadrantFunctor deps) f sa = (CVQuadrant a {aSub {dep = deps} a b c d p}) sb = (CVQuadrant b {bSub {dep = deps} a b c d p}) sc = (CVQuadrant c {cSub {dep = deps} a b c d p}) sd = (CVQuadrant d {dSub {dep = deps} a b c d p})
{ "alphanum_fraction": 0.6148988548, "avg_line_length": 58.7610062893, "ext": "agda", "hexsha": "c22ffa22fe53f2b88bad1e56c2565a2dc2706601", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "JonathanBrouwer/research-project", "max_forks_repo_path": "src/Data/QuadTree/FunctorProofs/Valid-QuadrantFunctor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "JonathanBrouwer/research-project", "max_issues_repo_path": "src/Data/QuadTree/FunctorProofs/Valid-QuadrantFunctor.agda", "max_line_length": 179, "max_stars_count": 1, "max_stars_repo_head_hexsha": "4959a3c9cd8563a1726e0e968e6a179008cd4d9f", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "JonathanBrouwer/research-project", "max_stars_repo_path": "src/Data/QuadTree/FunctorProofs/Valid-QuadrantFunctor.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:10:20.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:10:20.000Z", "num_tokens": 3360, "size": 9343 }