Search is not available for this dataset
text
string
meta
dict
module _ where data Bool : Set where false true : Bool {-# COMPILED_DATA Bool Bool False True #-} postulate IO : Set → Set return : {A : Set} → A → IO A {-# COMPILED_TYPE IO IO #-} {-# COMPILED return \ _ -> return #-} {-# COMPILED_UHC return \ _ x -> UHC.Agda.Builtins.primReturn x #-} {-# COMPILED_JS return function(u) { return function(x) { return function(cb) { cb(x); }; }; } #-} {-# IMPORT Data.Maybe #-} {-# HASKELL printMaybe = putStrLn . Data.Maybe.fromMaybe "" #-} returnTrue : IO Bool returnTrue = return true {-# COMPILED_EXPORT returnTrue returnTrue #-}
{ "alphanum_fraction": 0.6421232877, "avg_line_length": 22.4615384615, "ext": "agda", "hexsha": "82f5b6469b76a69c4e940eab92f7ee89cd38e51d", "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": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/OldCompilerPragmas.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "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": "alhassy/agda", "max_issues_repo_path": "test/Succeed/OldCompilerPragmas.agda", "max_line_length": 98, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/OldCompilerPragmas.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": 162, "size": 584 }
open import Nat open import Prelude open import List open import contexts open import core open import lemmas-env open import lemmas-progress open import decidability open import results-checks -- TODO we're forced to prove this weaker version, since the strong version is -- unprovable. That said, this weak version is still disappointing, so we -- should come up with some more thoerems to shore up its deficiencies - -- in particular, we should do something to mitigate the fact that an e -- may succeed for every even n and fail for every odd n -- - also, that evaluation may return different results for different n -- TODO complete, then delete -- e => r → ∀{n} e [n]=> r -- something similar for =>∅ ? -- (Σ[r] (e => r) ∧ e => ∅) → ⊥ -- ∀{k} → Σ[r] (e [k]=> r) ∨ e [k]=> ∅ module progress where progress : ∀{Δ Σ' Γ E e τ n} → Δ , Σ' , Γ ⊢ E → Δ , Σ' , Γ ⊢ e :: τ → -- Either there's some properly-typed result that e will eval to ... Σ[ r ∈ result ] Σ[ k ∈ constraints ] ( (E ⊢ e ⌊ ⛽⟨ n ⟩ ⌋⇒ r ⊣ k) ∧ Δ , Σ' ⊢ r ·: τ) -- ... or evaluation will have a constraint failure ∨ E ⊢ e ⌊ ⛽⟨ n ⟩ ⌋⇒∅ xc-progress : ∀{Δ Σ' r1 r2 τ n} → Δ , Σ' ⊢ r1 ·: τ → Δ , Σ' ⊢ r2 ·: τ → Σ[ k ∈ constraints ] Constraints⦃ r1 , r2 ⦄⌊ ⛽⟨ n ⟩ ⌋:= k ∨ Constraints⦃ r1 , r2 ⦄⌊ ⛽⟨ n ⟩ ⌋:=∅ xb-progress : ∀{Δ Σ' r ex τ n} → Δ , Σ' ⊢ r ·: τ → Δ , Σ' ⊢ ex :· τ → Σ[ k ∈ constraints ] (r ⇐ ex ⌊ ⛽⟨ n ⟩ ⌋:= k) ∨ r ⇐ ex ⌊ ⛽⟨ n ⟩ ⌋:=∅ rule-fails : {n↓ : Nat} {E : env} {r : result} {ex : ex} → Set rule-fails {n↓} {E} {r} {ex} = Σ[ c-j ∈ Nat ] Σ[ x-j ∈ Nat ] Σ[ e-j ∈ exp ] ( r ⇐ C[ c-j ] ¿¿ ⌊ ⛽⟨ 1+ n↓ ⟩ ⌋:=∅ ∨ Σ[ k1 ∈ constraints ] ( r ⇐ C[ c-j ] ¿¿ ⌊ ⛽⟨ 1+ n↓ ⟩ ⌋:= k1 ∧ (E ,, (x-j , C⁻[ c-j ] r)) ⊢ e-j ⌊ ⛽⟨ n↓ ⟩ ⌋⇒∅) ∨ Σ[ k1 ∈ constraints ] Σ[ k2 ∈ constraints ] Σ[ r-j ∈ result ] ( r ⇐ C[ c-j ] ¿¿ ⌊ ⛽⟨ 1+ n↓ ⟩ ⌋:= k1 ∧ (E ,, (x-j , C⁻[ c-j ] r)) ⊢ e-j ⌊ ⛽⟨ n↓ ⟩ ⌋⇒ r-j ⊣ k2 ∧ r-j ⇐ ex ⌊ ⛽⟨ n↓ ⟩ ⌋:=∅)) lemma-xb-progress-case : ∀{Δ Σ' E r rules ex τ n n↓} → (n == 1+ n↓) → (len : Nat) → (unchecked : rule ctx) → len == ∥ unchecked ∥ → (failed : (rule-fails {n↓} {E} {r} {ex}) ctx) → (∀{c rule} → (c , rule) ∈ unchecked → (c , rule) ∈ rules) → (∀{c c-j x-j e-j p-j} → (c , c-j , x-j , e-j , p-j) ∈ failed → c == c-j ∧ (c , |C x-j => e-j) ∈ rules) → (∀{c} → dom rules c → dom unchecked c ∨ dom failed c) → Δ , Σ' ⊢ [ E ]case r of⦃· rules ·⦄ ·: τ → Δ , Σ' ⊢ ex :· τ → ex ≠ ¿¿ → Σ[ k ∈ constraints ] ([ E ]case r of⦃· rules ·⦄ ⇐ ex ⌊ ⛽⟨ n ⟩ ⌋:= k) ∨ [ E ]case r of⦃· rules ·⦄ ⇐ ex ⌊ ⛽⟨ n ⟩ ⌋:=∅ progress {n = Z} Γ⊢E ta = Inl (_ , _ , ELimit , π2 (typ-inhabitance-pres Γ⊢E ta)) progress {n = 1+ n} Γ⊢E ta'@(TAFix ta) = Inl (_ , _ , EFix , TAFix Γ⊢E ta') progress {n = 1+ n} Γ⊢E (TAVar x∈Γ) with env-all-Γ Γ⊢E x∈Γ ... | _ , x∈E , ta = Inl (_ , _ , EVar x∈E , ta) progress {n = 1+ n} Γ⊢E (TAApp _ ta-f ta-arg) with progress Γ⊢E ta-arg ... | Inr arg-fails = Inr (EFAppArg arg-fails) ... | Inl (rarg , _ , arg-evals , ta-rarg) with progress Γ⊢E ta-f ... | Inr f-fails = Inr (EFAppFun f-fails) progress {n = 1+ n} Γ⊢E (TAApp _ ta-f ta-arg) | Inl (rarg , _ , arg-evals , ta-rarg) | Inl ([ E' ]fix f ⦇·λ x => ef ·⦈ , _ , f-evals , ta'@(TAFix Γ'⊢E' (TAFix ta-ef))) with progress {n = n} (EnvInd (EnvInd Γ'⊢E' ta') ta-rarg) ta-ef ... | Inr ef-fails = Inr (EFAppFixEval CF⛽ refl f-evals arg-evals ef-fails) ... | Inl (ref , _ , ef-evals , ta-ref) = Inl (_ , _ , EAppFix CF⛽ refl f-evals arg-evals ef-evals , ta-ref) progress {n = 1+ n} Γ⊢E (TAApp _ ta-f ta-arg) | Inl (rarg , _ , arg-evals , ta-rarg) | Inl ([ E' ]??[ u ] , _ , f-evals , ta-rf) = Inl (_ , _ , EAppUnfinished f-evals (λ ()) arg-evals , TAApp ta-rf ta-rarg) progress {n = 1+ n} Γ⊢E (TAApp _ ta-f ta-arg) | Inl (rarg , _ , arg-evals , ta-rarg) | Inl ((rf-f ∘ rf-arg) , _ , f-evals , ta-rf) = Inl (_ , _ , EAppUnfinished f-evals (λ ()) arg-evals , TAApp ta-rf ta-rarg) progress {n = 1+ n} Γ⊢E (TAApp _ ta-f ta-arg) | Inl (rarg , _ , arg-evals , ta-rarg) | Inl (fst _ , _ , f-evals , ta-rf) = Inl (_ , _ , EAppUnfinished f-evals (λ ()) arg-evals , TAApp ta-rf ta-rarg) progress {n = 1+ n} Γ⊢E (TAApp _ ta-f ta-arg) | Inl (rarg , _ , arg-evals , ta-rarg) | Inl (snd _ , _ , f-evals , ta-rf) = Inl (_ , _ , EAppUnfinished f-evals (λ ()) arg-evals , TAApp ta-rf ta-rarg) progress {n = 1+ n} Γ⊢E (TAApp _ ta-f ta-arg) | Inl (rarg , _ , arg-evals , ta-rarg) | Inl ([ E' ]case rf of⦃· rules ·⦄ , _ , f-evals , ta-rf) = Inl (_ , _ , EAppUnfinished f-evals (λ ()) arg-evals , TAApp ta-rf ta-rarg) progress {n = 1+ n} Γ⊢E (TAApp _ ta-f ta-arg) | Inl (rarg , _ , arg-evals , ta-rarg) | Inl ((C⁻[ _ ] _) , _ , f-evals , ta-rf) = Inl (_ , _ , EAppUnfinished f-evals (λ ()) arg-evals , TAApp ta-rf ta-rarg) progress {n = 1+ n} Γ⊢E TAUnit = Inl (_ , _ , EUnit , TAUnit) progress {n = 1+ n} Γ⊢E (TAPair _ ta1 ta2) with progress Γ⊢E ta1 ... | Inr fails = Inr (EFPair1 fails) ... | Inl (_ , _ , evals1 , ta-r1) with progress Γ⊢E ta2 ... | Inr fails = Inr (EFPair2 fails) ... | Inl (_ , _ , evals2 , ta-r2) = Inl (_ , _ , EPair evals1 evals2 , TAPair ta-r1 ta-r2) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TAFst ta) with progress Γ⊢E ta ... | Inr fails = Inr (EFFst fails) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TAFst ta) | Inl (⟨ r1 , r2 ⟩ , _ , evals , TAPair ta-r1 ta-r2) = Inl (_ , _ , EFst evals , ta-r1) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TAFst ta) | Inl ([ x ]fix x₁ ⦇·λ x₂ => x₃ ·⦈ , _ , evals , TAFix _ ()) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TAFst ta) | Inl ((C⁻[ x ] q) , _ , evals , ta-r) = Inl (_ , _ , EFstUnfinished evals (λ ()) , TAFst ta-r) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TAFst ta) | Inl ([ x ]??[ x₁ ] , _ , evals , ta-r) = Inl (_ , _ , EFstUnfinished evals (λ ()) , TAFst ta-r) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TAFst ta) | Inl ((q ∘ q₁) , _ , evals , ta-r) = Inl (_ , _ , EFstUnfinished evals (λ ()) , TAFst ta-r) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TAFst ta) | Inl (fst q , _ , evals , ta-r) = Inl (_ , _ , EFstUnfinished evals (λ ()) , TAFst ta-r) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TAFst ta) | Inl (snd q , _ , evals , ta-r) = Inl (_ , _ , EFstUnfinished evals (λ ()) , TAFst ta-r) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TAFst ta) | Inl ([ x ]case q of⦃· x₁ ·⦄ , _ , evals , ta-r) = Inl (_ , _ , EFstUnfinished evals (λ ()) , TAFst ta-r) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TASnd ta) with progress Γ⊢E ta ... | Inr fails = Inr (EFSnd fails) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TASnd ta) | Inl (⟨ r1 , r2 ⟩ , _ , evals , TAPair ta-r1 ta-r2) = Inl (_ , _ , ESnd evals , ta-r2) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TASnd ta) | Inl ([ x ]fix x₁ ⦇·λ x₂ => x₃ ·⦈ , _ , evals , TAFix _ ()) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TASnd ta) | Inl ((C⁻[ x ] q) , _ , evals , ta-r) = Inl (_ , _ , ESndUnfinished evals (λ ()) , TASnd ta-r) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TASnd ta) | Inl ([ x ]??[ x₁ ] , _ , evals , ta-r) = Inl (_ , _ , ESndUnfinished evals (λ ()) , TASnd ta-r) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TASnd ta) | Inl ((q ∘ q₁) , _ , evals , ta-r) = Inl (_ , _ , ESndUnfinished evals (λ ()) , TASnd ta-r) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TASnd ta) | Inl (fst q , _ , evals , ta-r) = Inl (_ , _ , ESndUnfinished evals (λ ()) , TASnd ta-r) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TASnd ta) | Inl (snd q , _ , evals , ta-r) = Inl (_ , _ , ESndUnfinished evals (λ ()) , TASnd ta-r) progress {Δ} {Σ'} {E = E} {τ = τ} {1+ n} Γ⊢E (TASnd ta) | Inl ([ x ]case q of⦃· x₁ ·⦄ , _ , evals , ta-r) = Inl (_ , _ , ESndUnfinished evals (λ ()) , TASnd ta-r) progress {n = 1+ n} Γ⊢E (TACtor d∈Σ' c∈d ta) with progress Γ⊢E ta ... | Inr e-fails = Inr (EFCtor e-fails) ... | Inl (_ , _ , e-evals , ta-r) = Inl (_ , _ , ECtor e-evals , TACtor d∈Σ' c∈d ta-r) progress {Σ' = Σ'} {n = 1+ n} Γ⊢E (TACase d∈σ' e-ta cctx⊆rules h-rules) with progress Γ⊢E e-ta ... | Inr e-fails = Inr (EFMatchScrut e-fails) ... | Inl ([ x ]fix x₁ ⦇·λ x₂ => x₃ ·⦈ , _ , e-evals , TAFix _ ()) ... | Inl ([ x ]??[ x₁ ] , _ , e-evals , ta-re) = Inl (_ , _ , EMatchUnfinished e-evals (λ ()) , TACase d∈σ' Γ⊢E ta-re cctx⊆rules (λ form → let _ , _ , _ , c∈cctx , ec-ta = h-rules form in _ , c∈cctx , ec-ta)) ... | Inl ((re ∘ re₁) , _ , e-evals , ta-re) = Inl (_ , _ , EMatchUnfinished e-evals (λ ()) , TACase d∈σ' Γ⊢E ta-re cctx⊆rules (λ form → let _ , _ , _ , c∈cctx , ec-ta = h-rules form in _ , c∈cctx , ec-ta)) ... | Inl (fst _ , _ , e-evals , ta-re) = Inl (_ , _ , EMatchUnfinished e-evals (λ ()) , TACase d∈σ' Γ⊢E ta-re cctx⊆rules (λ form → let _ , _ , _ , c∈cctx , ec-ta = h-rules form in _ , c∈cctx , ec-ta)) ... | Inl (snd _ , _ , e-evals , ta-re) = Inl (_ , _ , EMatchUnfinished e-evals (λ ()) , TACase d∈σ' Γ⊢E ta-re cctx⊆rules (λ form → let _ , _ , _ , c∈cctx , ec-ta = h-rules form in _ , c∈cctx , ec-ta)) ... | Inl ([ x ]case re of⦃· x₁ ·⦄ , _ , e-evals , ta-re) = Inl (_ , _ , EMatchUnfinished e-evals (λ ()) , TACase d∈σ' Γ⊢E ta-re cctx⊆rules (λ form → let _ , _ , _ , c∈cctx , ec-ta = h-rules form in _ , c∈cctx , ec-ta)) ... | Inl ((C⁻[ _ ] _) , _ , e-evals , ta-re) = Inl (_ , _ , EMatchUnfinished e-evals (λ ()) , TACase d∈σ' Γ⊢E ta-re cctx⊆rules (λ form → let _ , _ , _ , c∈cctx , ec-ta = h-rules form in _ , c∈cctx , ec-ta)) ... | Inl ((C[ c ] re) , _ , e-evals , TACtor d∈'σ' c∈cctx' ta-re) rewrite ctxunicity d∈'σ' d∈σ' with π2 (cctx⊆rules (_ , c∈cctx')) ... | form with h-rules form ... | _ , _ , _ , c∈cctx , ec-ta rewrite ctxunicity c∈cctx c∈cctx' with progress {n = n} (EnvInd Γ⊢E ta-re) ec-ta ... | Inr ec-fails = Inr (EFMatchRule CF⛽ form e-evals ec-fails) ... | Inl (_ , _ , ec-evals , ta-rec) = Inl (_ , _ , EMatch CF⛽ form e-evals ec-evals , ta-rec) progress {n = 1+ n} Γ⊢E (TAHole u∈Δ) = Inl (_ , _ , EHole , TAHole u∈Δ Γ⊢E) progress {n = 1+ n} Γ⊢E (TAAsrt _ ta1 ta2) with progress Γ⊢E ta1 ... | Inr e1-fails = Inr (EFAsrtL e1-fails) ... | Inl (r1 , _ , e1-evals , ta-r1) with progress Γ⊢E ta2 ... | Inr e2-fails = Inr (EFAsrtR e2-fails) ... | Inl (r2 , _ , e2-evals , ta-r2) with xc-progress ta-r1 ta-r2 ... | Inl (_ , c-succ) = Inl (_ , _ , EAsrt e1-evals e2-evals c-succ , TAUnit) ... | Inr c-fail = Inr (EFAsrt e1-evals e2-evals c-fail) lemma-xc-no-coerce : ∀{Δ Σ' r1 r2 τ n} → Δ , Σ' ⊢ r1 ·: τ → Δ , Σ' ⊢ r2 ·: τ → r1 ≠ r2 → (∀{ex} → Coerce r1 := ex → ⊥) → r1 ≠ ⟨⟩ → (∀{r'1 r'2} → r1 ≠ ⟨ r'1 , r'2 ⟩) → (∀{c r} → r1 ≠ (C[ c ] r)) → Σ[ k ∈ constraints ] Constraints⦃ r1 , r2 ⦄⌊ ⛽⟨ n ⟩ ⌋:= k ∨ Constraints⦃ r1 , r2 ⦄⌊ ⛽⟨ n ⟩ ⌋:=∅ lemma-xc-no-coerce ta1 (TAFix x x₁) r1≠r2 no-coerce not-unit not-pair not-ctor = Inr (XCFNoCoerce r1≠r2 (Inl not-pair) (Inl not-ctor) no-coerce λ ()) lemma-xc-no-coerce ta1 (TAApp ta2 ta3) r1≠r2 no-coerce not-unit not-pair not-ctor = Inr (XCFNoCoerce r1≠r2 (Inl not-pair) (Inl not-ctor) no-coerce λ ()) lemma-xc-no-coerce ta1 TAUnit r1≠r2 no-coerce not-unit not-pair not-ctor with xb-progress ta1 TAUnit ... | Inl (_ , xb) = Inl (_ , (XCBackProp1 r1≠r2 (Inl not-pair) (Inl not-ctor) CoerceUnit xb)) ... | Inr xb-fails = Inr (XCFXB1 r1≠r2 (Inl not-pair) (Inl not-ctor) CoerceUnit xb-fails) lemma-xc-no-coerce ta1 ta2@(TAPair _ _) r1≠r2 no-coerce not-unit not-pair not-ctor with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inl not-pair) (Inl not-ctor) no-coerce λ {c-r2 → nc (_ , c-r2)}) ... | Inl (_ , c-r2) with xb-progress ta1 (Coerce-preservation ta2 c-r2) ... | Inr xb-fails = Inr (XCFXB1 r1≠r2 (Inl not-pair) (Inl not-ctor) c-r2 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp1 r1≠r2 (Inl not-pair) (Inl not-ctor) c-r2 xb)) lemma-xc-no-coerce ta1 (TAFst ta2) r1≠r2 no-coerce not-unit not-pair not-ctor = Inr (XCFNoCoerce r1≠r2 (Inl not-pair) (Inl not-ctor) no-coerce λ ()) lemma-xc-no-coerce ta1 (TASnd ta2) r1≠r2 no-coerce not-unit not-pair not-ctor = Inr (XCFNoCoerce r1≠r2 (Inl not-pair) (Inl not-ctor) no-coerce λ ()) lemma-xc-no-coerce ta1 ta2@(TACtor _ _ _) r1≠r2 no-coerce not-unit not-pair not-ctor with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inl not-pair) (Inl not-ctor) no-coerce λ {c-r2 → nc (_ , c-r2)}) ... | Inl (_ , c-r2) with xb-progress ta1 (Coerce-preservation ta2 c-r2) ... | Inr xb-fails = Inr (XCFXB1 r1≠r2 (Inl not-pair) (Inl not-ctor) c-r2 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp1 r1≠r2 (Inl not-pair) (Inl not-ctor) c-r2 xb)) lemma-xc-no-coerce ta1 (TAUnwrapCtor x x₁ ta2) r1≠r2 no-coerce not-unit not-pair not-ctor = Inr (XCFNoCoerce r1≠r2 (Inl not-pair) (Inl not-ctor) no-coerce λ ()) lemma-xc-no-coerce ta1 (TACase x x₁ ta2 x₂ x₃) r1≠r2 no-coerce not-unit not-pair not-ctor = Inr (XCFNoCoerce r1≠r2 (Inl not-pair) (Inl not-ctor) no-coerce λ ()) lemma-xc-no-coerce ta1 (TAHole x x₁) r1≠r2 no-coerce not-unit not-pair not-ctor = Inr (XCFNoCoerce r1≠r2 (Inl not-pair) (Inl not-ctor) no-coerce λ ()) xc-progress {r1 = r1} {r2} ta1 ta2 with result-==-dec r1 r2 ... | Inl refl = Inl (_ , XCExRefl) xc-progress {r1 = _} {_} ta1@(TAFix x x₁) ta2 | Inr r1≠r2 = lemma-xc-no-coerce ta1 ta2 r1≠r2 (λ ()) (λ ()) (λ ()) λ () xc-progress {r1 = _} {_} ta1@(TAApp _ _) ta2 | Inr r1≠r2 = lemma-xc-no-coerce ta1 ta2 r1≠r2 (λ ()) (λ ()) (λ ()) λ () xc-progress {r1 = _} {_} TAUnit ta2 | Inr r1≠r2 with xb-progress ta2 TAUnit ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inl (λ ())) (Inl (λ ())) CoerceUnit xb)) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inl (λ ())) (Inl (λ ())) CoerceUnit xb-fails) xc-progress (TAPair ta1a ta1b) (TAPair ta2a ta2b) | Inr r1≠r2 with xc-progress ta1a ta2a ... | Inr xca-fails = Inr (XCFPair1 xca-fails) ... | Inl (_ , xca) with xc-progress ta1b ta2b ... | Inr xcb-fails = Inr (XCFPair2 xcb-fails) ... | Inl (_ , xcb) = Inl (_ , XCPair r1≠r2 xca xcb) xc-progress ta1@(TAPair _ _) ta2@(TAApp _ _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress ta1@(TAPair _ _) ta2@(TAFst _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress ta1@(TAPair _ _) ta2@(TASnd _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress ta1@(TAPair _ _) ta2@(TAUnwrapCtor _ _ _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress ta1@(TAPair _ _) ta2@(TACase _ _ _ _ _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress ta1@(TAPair _ _) ta2@(TAHole _ _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress ta1@(TAFst _) ta2 | Inr r1≠r2 = lemma-xc-no-coerce ta1 ta2 r1≠r2 (λ ()) (λ ()) (λ ()) λ () xc-progress {r1 = _} {_} ta1@(TASnd _) ta2 | Inr r1≠r2 = lemma-xc-no-coerce ta1 ta2 r1≠r2 (λ ()) (λ ()) (λ ()) λ () xc-progress (TACtor {c = c1} d∈σ1 c1∈cctx ta1) (TACtor {c = c2} d∈σ2 c2∈cctx ta2) | Inr r1≠r2 with natEQ c1 c2 ... | Inr ne = Inr (XCFCtorMM ne) ... | Inl refl rewrite ctxunicity d∈σ1 d∈σ2 | ctxunicity c1∈cctx c2∈cctx with xc-progress ta1 ta2 ... | Inr xc-fails = Inr (XCFCtor xc-fails) ... | Inl (_ , xc) = Inl (_ , XCCtor (λ where refl → r1≠r2 refl) xc) xc-progress ta1@(TACtor _ _ _) ta2@(TAApp _ _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress ta1@(TACtor _ _ _) ta2@(TAFst _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress ta1@(TACtor _ _ _) ta2@(TASnd _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress ta1@(TACtor _ _ _) ta2@(TAUnwrapCtor _ _ _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress ta1@(TACtor _ _ _) ta2@(TACase _ _ _ _ _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress ta1@(TACtor _ _ _) ta2@(TAHole _ _) | Inr r1≠r2 with Coerce-dec ... | Inr nc = Inr (XCFNoCoerce r1≠r2 (Inr (λ ())) (Inr (λ ())) (λ {c-r1 → nc (_ , c-r1)}) λ ()) ... | Inl (_ , c-r1) with xb-progress ta2 (Coerce-preservation ta1 c-r1) ... | Inr xb-fails = Inr (XCFXB2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb-fails) ... | Inl (_ , xb) = Inl (_ , (XCBackProp2 r1≠r2 (Inr (λ ())) (Inr (λ ())) c-r1 xb)) xc-progress {r1 = _} {_} ta1@(TAUnwrapCtor _ _ _) ta2 | Inr r1≠r2 = lemma-xc-no-coerce ta1 ta2 r1≠r2 (λ ()) (λ ()) (λ ()) λ () xc-progress {r1 = _} {_} ta1@(TACase _ _ _ _ _) ta2 | Inr r1≠r2 = lemma-xc-no-coerce ta1 ta2 r1≠r2 (λ ()) (λ ()) (λ ()) λ () xc-progress {r1 = _} {_} ta1@(TAHole _ _) ta2 | Inr r1≠r2 = lemma-xc-no-coerce ta1 ta2 r1≠r2 (λ ()) (λ ()) (λ ()) λ () xb-progress {n = Z} _ _ = Inl (_ , XBLimit) xb-progress {ex = ex} {n = 1+ n} ta-r ta-ex with ex-¿¿-dec {ex} ... | Inl refl = Inl (_ , XBNone) xb-progress {n = 1+ n} ta-f@(TAFix Γ⊢E (TAFix ta-e)) (TAMap _ ta-v ta-ex) | Inr ne with progress {n = n} (EnvInd (EnvInd Γ⊢E ta-f) ta-v) ta-e ... | Inr fails = Inr (XBFFixEval CF⛽ refl fails) ... | Inl (_ , _ , evals , ta) with xb-progress {n = n} ta ta-ex ... | Inr fails = Inr (XBFFix CF⛽ refl evals fails) ... | Inl (_ , xb) = Inl (_ , XBFix CF⛽ refl evals xb) xb-progress (TAFix x (TAFix _)) TADC | Inr ne = Inl (_ , XBNone) xb-progress (TAApp {arg = v} ta-rf ta-rarg) ta-ex | Inr ne with value-dec {v} ... | Inr nv = Inr (XBFAppNonVal ne nv) ... | Inl val with xb-progress ta-rf (TAMap val ta-rarg ta-ex) ... | Inr fails = Inr (XBFApp ne val fails) ... | Inl (_ , xb) = Inl (_ , XBApp ne val xb) xb-progress TAUnit TAUnit | Inr ne = Inl (_ , XBUnit) xb-progress TAUnit TADC | Inr ne = Inl (_ , XBNone) xb-progress (TAPair ta-r1 ta-r2) (TAPair ta-ex1 ta-ex2) | Inr ne with xb-progress ta-r1 ta-ex1 ... | Inr fails = Inr (XBFPair1 fails) ... | Inl (_ , xb1) with xb-progress ta-r2 ta-ex2 ... | Inr fails = Inr (XBFPair2 fails) ... | Inl (_ , xb2) = Inl (_ , XBPair xb1 xb2) xb-progress (TAPair ta-r1 ta-r2) TADC | Inr ne = Inl (_ , XBNone) xb-progress (TAFst ta-r) ta-ex | Inr ne with xb-progress ta-r (TAPair ta-ex TADC) ... | Inr fails = Inr (XBFFst ne fails) ... | Inl (_ , xb) = Inl (_ , XBFst ne xb) xb-progress (TASnd ta-r) ta-ex | Inr ne with xb-progress ta-r (TAPair TADC ta-ex) ... | Inr fails = Inr (XBFSnd ne fails) ... | Inl (_ , xb) = Inl (_ , XBSnd ne xb) xb-progress (TACtor {c = c1} h1a h1b ta-r) (TACtor {c = c2} h2a h2b ta-ex) | Inr ne with natEQ c1 c2 ... | Inr ne' = Inr (XBFCtorMM ne') ... | Inl refl rewrite ctxunicity h1a h2a | ctxunicity h1b h2b with xb-progress ta-r ta-ex ... | Inr fails = Inr (XBFCtor fails) ... | Inl (_ , xb) = Inl (_ , XBCtor xb) xb-progress (TACtor x x₁ ta-r) TADC | Inr ne = Inl (_ , XBNone) xb-progress (TAUnwrapCtor h1 h2 ta-r) ta-ex | Inr ne with xb-progress ta-r (TACtor h1 h2 ta-ex) ... | Inr fails = Inr (XBFUnwrapCtor ne fails) ... | Inl (_ , xb) = Inl (_ , XBUnwrapCtor ne xb) xb-progress {n = 1+ n} ta-C@(TACase {rules = rules} x x₁ ta-r x₂ x₃) ta-ex | Inr ne = lemma-xb-progress-case {n = 1+ n} {n} refl ∥ rules ∥ rules refl ∅ (λ y → y) (λ ()) Inl ta-C ta-ex ne xb-progress (TAHole x x₁) TAUnit | Inr ne = Inl (_ , XBHole ne λ ()) xb-progress (TAHole x x₁) (TAPair ta-ex ta-ex₁) | Inr ne = Inl (_ , XBHole ne λ ()) xb-progress (TAHole x x₁) (TACtor x₂ x₃ ta-ex) | Inr ne = Inl (_ , XBHole ne λ ()) xb-progress (TAHole x x₁) TADC | Inr ne = Inl (_ , XBNone) xb-progress (TAHole x x₁) (TAMap x₂ x₃ ta-ex) | Inr ne = Inr XBFHole lemma-xb-progress-case {E = E} {r} {rules} {ex} {n = n} {n↓} refl Z [] len-unchecked failed unchecked-wf failed-wf exh ta-C ta-ex n¿¿ = Inr (XBFMatch CF⛽ n¿¿ all-failed) where all-failed : ∀{c-j x-j : Nat} {e-j : exp} → (c-j , |C x-j => e-j) ∈ rules → r ⇐ C[ c-j ] ¿¿ ⌊ ⛽⟨ n ⟩ ⌋:=∅ ∨ Σ[ k1 ∈ constraints ] ( r ⇐ C[ c-j ] ¿¿ ⌊ ⛽⟨ n ⟩ ⌋:= k1 ∧ (E ,, (x-j , C⁻[ c-j ] r)) ⊢ e-j ⌊ ⛽⟨ n↓ ⟩ ⌋⇒∅) ∨ Σ[ k1 ∈ constraints ] Σ[ k2 ∈ constraints ] Σ[ r-j ∈ result ] ( r ⇐ C[ c-j ] ¿¿ ⌊ ⛽⟨ n ⟩ ⌋:= k1 ∧ (E ,, (x-j , C⁻[ c-j ] r)) ⊢ e-j ⌊ ⛽⟨ n↓ ⟩ ⌋⇒ r-j ⊣ k2 ∧ r-j ⇐ ex ⌊ ⛽⟨ n↓ ⟩ ⌋:=∅) all-failed c-j∈rules with exh (_ , c-j∈rules) ... | Inl (_ , ()) ... | Inr ((c-j , x-j , e-j , p-j) , c-j∈f) with failed-wf c-j∈f ... | refl , c-j∈'rules with ctxunicity c-j∈rules c-j∈'rules ... | refl = p-j lemma-xb-progress-case {n = 1+ n↓} {n↓} refl (1+ len) unchecked len-unchecked failed unchecked-wf failed-wf exh ta-C@(TACase {rules = rules} d∈σ' Γ⊢E ta-r _ ta-rules) ta-ex n¿¿ with ctx-elim {Γ = unchecked} ... | Inl refl = abort (0≠1+n (! len-unchecked)) ... | Inr (c , |C x-j => e-j , unchecked' , refl , c#unchecked') with unchecked-wf (x,a∈Γ,,x,a {Γ = unchecked'}) ... | c∈rules with ta-rules c∈rules ... | _ , c∈cctx , ta-be with xb-progress ta-r (TACtor d∈σ' c∈cctx TADC) ... | Inr fails = lemma-xb-progress-case refl len unchecked' (1+inj (len-unchecked · ctx-decreasing c#unchecked')) (failed ,, (c , fail)) unchecked-wf' failed-wf' exh' ta-C ta-ex n¿¿ where fail = c , x-j , e-j , (Inl fails) unchecked-wf' : ∀{c' rule'} → (c' , rule') ∈ unchecked' → (c' , rule') ∈ rules unchecked-wf' {c' = c'} c'∈uc' with natEQ c c' ... | Inl refl = abort (c#unchecked' (_ , c'∈uc')) ... | Inr cne = unchecked-wf (x∈Γ→x∈Γ+ (flip cne) c'∈uc') failed-wf' : ∀{c' c-j' x-j' e-j' p-j'} → (c' , c-j' , x-j' , e-j' , p-j') ∈ (failed ,, (c , fail)) → c' == c-j' ∧ ((c' , (|C x-j' => e-j')) ∈ rules) failed-wf' {c' = c'} {c-j'} c'∈f+ with natEQ c c' ... | Inr cne = failed-wf (x∈Γ+→x∈Γ (flip cne) c'∈f+) ... | Inl refl with ctxunicity c'∈f+ (x,a∈Γ,,x,a {Γ = failed}) ... | refl = refl , c∈rules exh' : ∀{c'} → dom rules c' → dom unchecked' c' ∨ dom (failed ,, (c , fail)) c' exh' {c' = c'} c'∈rules with natEQ c c' ... | Inl refl = Inr (_ , x,a∈Γ,,x,a {Γ = failed}) ... | Inr cne with exh c'∈rules ... | Inl (_ , c'∈uc) = Inl (_ , (x∈Γ+→x∈Γ (flip cne) c'∈uc)) ... | Inr (_ , c'∈f) = Inr (_ , x∈Γ→x∈Γ+ (flip cne) c'∈f) ... | Inl (_ , xb-r) with progress {n = n↓} (EnvInd Γ⊢E (TAUnwrapCtor d∈σ' c∈cctx ta-r)) ta-be ... | Inr fails = lemma-xb-progress-case refl len unchecked' (1+inj (len-unchecked · ctx-decreasing c#unchecked')) (failed ,, (c , fail)) unchecked-wf' failed-wf' exh' ta-C ta-ex n¿¿ where fail = c , x-j , e-j , (Inr (Inl (_ , xb-r , fails))) unchecked-wf' : ∀{c' rule'} → (c' , rule') ∈ unchecked' → (c' , rule') ∈ rules unchecked-wf' {c' = c'} c'∈uc' with natEQ c c' ... | Inl refl = abort (c#unchecked' (_ , c'∈uc')) ... | Inr cne = unchecked-wf (x∈Γ→x∈Γ+ (flip cne) c'∈uc') failed-wf' : ∀{c' c-j' x-j' e-j' p-j'} → (c' , c-j' , x-j' , e-j' , p-j') ∈ (failed ,, (c , fail)) → c' == c-j' ∧ ((c' , (|C x-j' => e-j')) ∈ rules) failed-wf' {c' = c'} {c-j'} c'∈f+ with natEQ c c' ... | Inr cne = failed-wf (x∈Γ+→x∈Γ (flip cne) c'∈f+) ... | Inl refl with ctxunicity c'∈f+ (x,a∈Γ,,x,a {Γ = failed}) ... | refl = refl , c∈rules exh' : ∀{c'} → dom rules c' → dom unchecked' c' ∨ dom (failed ,, (c , fail)) c' exh' {c' = c'} c'∈rules with natEQ c c' ... | Inl refl = Inr (_ , x,a∈Γ,,x,a {Γ = failed}) ... | Inr cne with exh c'∈rules ... | Inl (_ , c'∈uc) = Inl (_ , (x∈Γ+→x∈Γ (flip cne) c'∈uc)) ... | Inr (_ , c'∈f) = Inr (_ , x∈Γ→x∈Γ+ (flip cne) c'∈f) ... | Inl (_ , _ , evals , ta-br) with xb-progress {n = n↓} ta-br ta-ex ... | Inr fails = lemma-xb-progress-case refl len unchecked' (1+inj (len-unchecked · ctx-decreasing c#unchecked')) (failed ,, (c , fail)) unchecked-wf' failed-wf' exh' ta-C ta-ex n¿¿ where fail = c , x-j , e-j , (Inr (Inr (_ , _ , _ , xb-r , evals , fails))) unchecked-wf' : ∀{c' rule'} → (c' , rule') ∈ unchecked' → (c' , rule') ∈ rules unchecked-wf' {c' = c'} c'∈uc' with natEQ c c' ... | Inl refl = abort (c#unchecked' (_ , c'∈uc')) ... | Inr cne = unchecked-wf (x∈Γ→x∈Γ+ (flip cne) c'∈uc') failed-wf' : ∀{c' c-j' x-j' e-j' p-j'} → (c' , c-j' , x-j' , e-j' , p-j') ∈ (failed ,, (c , fail)) → c' == c-j' ∧ ((c' , (|C x-j' => e-j')) ∈ rules) failed-wf' {c' = c'} {c-j'} c'∈f+ with natEQ c c' ... | Inr cne = failed-wf (x∈Γ+→x∈Γ (flip cne) c'∈f+) ... | Inl refl with ctxunicity c'∈f+ (x,a∈Γ,,x,a {Γ = failed}) ... | refl = refl , c∈rules exh' : ∀{c'} → dom rules c' → dom unchecked' c' ∨ dom (failed ,, (c , fail)) c' exh' {c' = c'} c'∈rules with natEQ c c' ... | Inl refl = Inr (_ , x,a∈Γ,,x,a {Γ = failed}) ... | Inr cne with exh c'∈rules ... | Inl (_ , c'∈uc) = Inl (_ , (x∈Γ+→x∈Γ (flip cne) c'∈uc)) ... | Inr (_ , c'∈f) = Inr (_ , x∈Γ→x∈Γ+ (flip cne) c'∈f) ... | Inl (_ , xb) = Inl (_ , (XBMatch CF⛽ n¿¿ c∈rules xb-r evals xb)) {- TODO delete - this strong version is unprovable module progress where progress : ∀{Δ Σ' Γ E e τ} → Δ , Σ' , Γ ⊢ E → Δ , Σ' , Γ ⊢ e :: τ → -- Either there's some properly-typed result that e will eval to -- for any beta reduction limit ... Σ[ r ∈ result ] ( Δ , Σ' ⊢ r ·: τ ∧ ∀{n} → Σ[ k ∈ constraints ] (E ⊢ e ⌊ ⛽⟨ n ⟩ ⌋⇒ r ⊣ k)) ∨ -- ... or evaluation will have a constraint failure for any -- beta reduction limit (∀{n} → E ⊢ e ⌊ ⛽⟨ n ⟩ ⌋⇒∅) progress Γ⊢E ta'@(TALam _ ta) = Inl (_ , TALam Γ⊢E ta' , (_ , EFun)) progress Γ⊢E ta'@(TAFix _ _ ta) = Inl (_ , TAFix Γ⊢E ta' , (_ , EFix)) progress Γ⊢E (TAVar x∈Γ) with env-all-Γ Γ⊢E x∈Γ ... | _ , x∈E , ta = Inl (_ , ta , (_ , EVar x∈E)) progress Γ⊢E (TAApp _ ta-f ta-arg) with progress Γ⊢E ta-arg ... | Inr arg-fails = Inr (EFAppArg arg-fails) ... | Inl (_ , ta-rarg , arg-evals) with progress Γ⊢E ta-f ... | Inr f-fails = Inr (EFAppFun f-fails) progress Γ⊢E (TAApp _ ta-f ta-arg) | Inl (_ , ta-rarg , arg-evals) | Inl (([ E' ]λ x => ef) , TALam Γ'⊢E' (TALam x#Γ' ta-ef) , f-evals) with progress (EnvInd Γ'⊢E' ta-rarg) ta-ef ... | q = {!!} progress Γ⊢E (TAApp _ ta-f ta-arg) | Inl (_ , ta-rarg , arg-evals) | Inl ([ E' ]fix f ⦇·λ x => ef ·⦈ , ta-rf , f-evals) = {!!} progress Γ⊢E (TAApp _ ta-f ta-arg) | Inl (_ , ta-rarg , arg-evals) | Inl ([ x ]??[ x₁ ] , ta-rf , f-evals) = {!!} progress Γ⊢E (TAApp _ ta-f ta-arg) | Inl (_ , ta-rarg , arg-evals) | Inl ((rf ∘ rf₁) , ta-rf , f-evals) = {!!} progress Γ⊢E (TAApp _ ta-f ta-arg) | Inl (_ , ta-rarg , arg-evals) | Inl ((get[ x th-of x₁ ] rf) , ta-rf , f-evals) = {!!} progress Γ⊢E (TAApp _ ta-f ta-arg) | Inl (_ , ta-rarg , arg-evals) | Inl ([ x ]case rf of⦃· x₁ ·⦄ , ta-rf , f-evals) = {!!} progress Γ⊢E (TAApp _ ta-f ta-arg) | Inl (_ , ta-rarg , arg-evals) | Inl (PF x , ta-rf , f-evals) = {!!} progress Γ⊢E (TATpl ∥es∥==∥τs∥ _ tas) = {!!} progress {Δ} {Σ'} {E = E} {τ = τ} Γ⊢E (TAGet {i = i} {len} {e} len==∥τs∥ i<∥τs∥ ta) with progress Γ⊢E ta ... | Inr e-fails = Inr (EFGet e-fails) ... | Inl (⟨ rs ⟩ , TATpl ∥rs∥==∥τs∥ tas , e-evals) = let i<∥rs∥ = tr (λ y → i < y) (! ∥rs∥==∥τs∥) i<∥τs∥ in Inl (_ , tas i<∥rs∥ i<∥τs∥ , _ , EGet (len==∥τs∥ · ! ∥rs∥==∥τs∥) i<∥rs∥ (π2 e-evals)) ... | Inl (([ x ]λ x₁ => x₂) , TALam _ () , e-evals) ... | Inl ([ x ]fix x₁ ⦇·λ x₂ => x₃ ·⦈ , TAFix _ () , e-evals) ... | Inl ([ x ]??[ x₁ ] , ta-r , e-evals) rewrite len==∥τs∥ = Inl (_ , TAGet i<∥τs∥ ta-r , _ , EGetUnfinished (π2 e-evals) λ ()) ... | Inl ((r ∘ r₁) , ta-r , e-evals) rewrite len==∥τs∥ = Inl (_ , TAGet i<∥τs∥ ta-r , _ , EGetUnfinished (π2 e-evals) λ ()) ... | Inl ((get[ x th-of x₁ ] r) , ta-r , e-evals) rewrite len==∥τs∥ = Inl (_ , TAGet i<∥τs∥ ta-r , _ , EGetUnfinished (π2 e-evals) λ ()) ... | Inl ([ x ]case r of⦃· x₁ ·⦄ , ta-r , e-evals) rewrite len==∥τs∥ = Inl (_ , TAGet i<∥τs∥ ta-r , _ , EGetUnfinished (π2 e-evals) λ ()) ... | Inl (PF x , TAPF () , e-evals) progress Γ⊢E (TACtor d∈Σ' c∈d ta) with progress Γ⊢E ta ... | Inl (_ , ta-r , e-evals) = Inl (_ , TACtor d∈Σ' c∈d ta-r , _ , ECtor (π2 e-evals)) ... | Inr e-fails = Inr (EFCtor e-fails) progress Γ⊢E (TACase x ta x₁ x₂) = {!!} progress Γ⊢E (TAHole u∈Δ) = Inl (_ , TAHole u∈Δ Γ⊢E , (_ , EHole)) progress Γ⊢E (TAPF ta) = Inl (_ , TAPF ta , (_ , EPF)) progress Γ⊢E (TAAsrt x ta ta₁) = {!!} -}
{ "alphanum_fraction": 0.4787115247, "avg_line_length": 56.6964285714, "ext": "agda", "hexsha": "52fb06fae80e92039df97af7fdbb93888573d42d", "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": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnat-myth-", "max_forks_repo_path": "progress.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "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": "hazelgrove/hazelnat-myth-", "max_issues_repo_path": "progress.agda", "max_line_length": 178, "max_stars_count": 1, "max_stars_repo_head_hexsha": "a8f9299090d95f4ef1a6c2f15954c2981c0ee25c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnat-myth-", "max_stars_repo_path": "progress.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-19T23:42:31.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-19T23:42:31.000Z", "num_tokens": 15241, "size": 34925 }
{-# OPTIONS --rewriting --without-K #-} open import Prelude open import GSeTT.Syntax open import GSeTT.Rules open import GSeTT.Uniqueness-Derivations open import Sets ℕ eqdecℕ open import GSeTT.Dec-Type-Checking open import CaTT.Ps-contexts {- PS-contexts -} module CaTT.Relation where -- The relation ◃ generating cases data _,_◃₀_ Γ x y : Set₁ where ◃∂⁻ : ∀{A z} → Γ ⊢t (Var y) # (⇒ A (Var x) (Var z)) → Γ , x ◃₀ y ◃∂⁺ : ∀{A z} → Γ ⊢t (Var x) # (⇒ A (Var z) (Var y)) → Γ , x ◃₀ y -- Transitive closure : we associate on the right data _,_◃_ Γ x y : Set₁ where gen : Γ , x ◃₀ y → Γ , x ◃ y ◃T : ∀{z} → Γ , x ◃ z → Γ , z ◃₀ y → Γ , x ◃ y rel : ∀ Γ x y → Set₁ rel Γ x y = Γ , x ◃ y W◃₀ : ∀ {Γ x y z A} → (Γ :: (z , A)) ⊢C → Γ , x ◃₀ y → (Γ :: (z , A)) , x ◃₀ y W◃₀ Γ+⊢ (◃∂⁻ Γ⊢x) = ◃∂⁻ (wkt Γ⊢x Γ+⊢) W◃₀ Γ+⊢ (◃∂⁺ Γ⊢x) = ◃∂⁺ (wkt Γ⊢x Γ+⊢) W◃ : ∀ {Γ x y z A} → (Γ :: (z , A)) ⊢C → Γ , x ◃ y → (Γ :: (z , A)) , x ◃ y W◃ Γ+⊢ (gen x◃₀y) = gen (W◃₀ Γ+⊢ x◃₀y) W◃ Γ+⊢ (◃T x◃y y◃₀z) = ◃T (W◃ Γ+⊢ x◃y) (W◃₀ Γ+⊢ y◃₀z) WW◃ : ∀ {Γ x y z f A B} → ((Γ :: (z , A)) :: (f , B)) ⊢C → Γ , x ◃ y → ((Γ :: (z , A)) :: (f , B)) , x ◃ y WW◃ Γ+⊢@(cc Γ⊢ _ idp) x◃y = W◃ Γ+⊢ (W◃ Γ⊢ x◃y) ◃-trans : ∀ {Γ x y z} → Γ , x ◃ y → Γ , y ◃ z → Γ , x ◃ z ◃-trans x◃y (gen y◃₀z) = ◃T x◃y y◃₀z ◃-trans x◃y (◃T y◃z z◃₀w) = ◃T (◃-trans x◃y y◃z) z◃₀w -- TODO : Move at the right place x#A∈Γ→x∈Γ : ∀ {Γ x A} → x # A ∈ Γ → x ∈ Γ x#A∈Γ→x∈Γ {Γ :: (y , _)} (inl x#A∈Γ) = inl (x#A∈Γ→x∈Γ x#A∈Γ) x#A∈Γ→x∈Γ {Γ :: (y , _)} (inr (idp , idp)) = inr idp Γ⊢x:A→x∈Γ : ∀ {Γ x A} → Γ ⊢t (Var x) # A → x ∈ Γ Γ⊢x:A→x∈Γ (var _ x#A∈Γ) = x#A∈Γ→x∈Γ x#A∈Γ data _,_⟿_ : Pre-Ctx → ℕ → ℕ → Set₁ where -- y is an iterated target of x in Γ ∂⁺⟿ : ∀{Γ x a y A} → Γ ⊢t (Var x) # (⇒ A (Var a) (Var y)) → Γ , x ⟿ y x⟿∂⁺ : ∀{Γ x a y z A} → Γ ⊢t (Var x) # (⇒ A (Var a) (Var y)) → Γ , y ⟿ z → Γ , x ⟿ z W⟿ : ∀ {Γ x y z A} → (Γ :: (z , A)) ⊢C → Γ , x ⟿ y → (Γ :: (z , A)) , x ⟿ y W⟿ Γ+⊢ (∂⁺⟿ Γ⊢x) = ∂⁺⟿ (wkt Γ⊢x Γ+⊢) W⟿ Γ+⊢ (x⟿∂⁺ Γ⊢x x⟿y) = x⟿∂⁺ (wkt Γ⊢x Γ+⊢) (W⟿ Γ+⊢ x⟿y) WW⟿ : ∀ {Γ x y z w A B} → ((Γ :: (z , A)) :: (w , B)) ⊢C → Γ , x ⟿ y → ((Γ :: (z , A)) :: (w , B)) , x ⟿ y WW⟿ Γ++⊢@(cc Γ+⊢ _ idp) x⟿y = W⟿ Γ++⊢ (W⟿ Γ+⊢ x⟿y) ⟿→◃ : ∀ {Γ x y} → Γ , x ⟿ y → Γ , x ◃ y ⟿→◃ (∂⁺⟿ Γ⊢x) = gen (◃∂⁺ Γ⊢x) ⟿→◃ (x⟿∂⁺ Γ⊢x x⟿y) = ◃-trans (gen (◃∂⁺ Γ⊢x)) (⟿→◃ x⟿y) Γ++ : ∀ {Γ x A} → Γ ⊢ps x # A → Pre-Ctx Γ++ {Γ} {x} {A} _ = (Γ :: (length Γ , A)) :: (S (length Γ) , ⇒ A (Var x) (Var (length Γ))) //⟿ : ∀ {Γ Δ x y A a} → Γ ⊢t (Var x) # A → Δ ⊢t (Var y) # A → Γ , x ⟿ a → Δ , y ⟿ a //⟿ Γ⊢x Δ⊢y (∂⁺⟿ Γ⊢x') with unique-type Γ⊢x Γ⊢x' idp ... | idp = ∂⁺⟿ Δ⊢y //⟿ Γ⊢x Δ⊢y (x⟿∂⁺ Γ⊢x' x⟿a) with unique-type Γ⊢x Γ⊢x' idp ... | idp = x⟿∂⁺ Δ⊢y (//⟿ (Γ⊢tgt (Γ⊢t:A→Γ⊢A Γ⊢x)) (Γ⊢tgt (Γ⊢t:A→Γ⊢A Δ⊢y)) x⟿a) T⟿ : ∀ {Γ x y z} → Γ , x ⟿ y → Γ , y ⟿ z → Γ , x ⟿ z T⟿ (∂⁺⟿ Γ⊢x) y⟿z = x⟿∂⁺ Γ⊢x y⟿z T⟿ (x⟿∂⁺ Γ⊢x x⟿y) y⟿z = x⟿∂⁺ Γ⊢x (T⟿ x⟿y y⟿z) ⟿dim : ∀ {Γ x y A B} → Γ ⊢t Var x # A → Γ ⊢t Var y # B → Γ , x ⟿ y → dim B < dim A ⟿dim Γ⊢x:A Γ⊢y:B (∂⁺⟿ Γ⊢x) with unique-type Γ⊢x:A Γ⊢x idp | unique-type Γ⊢y:B (Γ⊢tgt(Γ⊢t:A→Γ⊢A Γ⊢x)) idp ... | idp | idp = n≤n _ ⟿dim Γ⊢x:A Γ⊢y:B (x⟿∂⁺ Γ⊢x z⟿y) with unique-type Γ⊢x:A Γ⊢x idp ... | idp = n≤m→n≤Sm (⟿dim (Γ⊢tgt(Γ⊢t:A→Γ⊢A Γ⊢x)) Γ⊢y:B z⟿y) 𝔻0-◃ : ∀ z → ¬ ((nil :: (0 , ∗)) , 0 ◃ z) 𝔻0-◃ z (gen (◃∂⁻ (var _ (inl ())))) 𝔻0-◃ z (gen (◃∂⁻ (var _ (inr ())))) 𝔻0-◃ z (gen (◃∂⁺ (var _ (inl ())))) 𝔻0-◃ z (gen (◃∂⁺ (var _ (inr ())))) 𝔻0-◃ z (◃T 0◃x _) = 𝔻0-◃ _ 0◃x 𝔻0-⟿ : ∀ z → ¬ ((nil :: (0 , ∗)) , 0 ⟿ z) 𝔻0-⟿ z (∂⁺⟿ (var _ (inl ()))) 𝔻0-⟿ z (∂⁺⟿ (var _ (inr ()))) 𝔻0-⟿ z (x⟿∂⁺ (var _ (inl ())) _) 𝔻0-⟿ z (x⟿∂⁺ (var _ (inr ())) _) n≮n : ∀ n → ¬ (n < n) n≮n n n<n = Sn≰n _ n<n ⟿-is-tgt : ∀ {Γ x y z A} → Γ ⊢t Var x # ⇒ A (Var y) (Var z) → Γ , x ⟿ y → y == z ⟿-is-tgt Γ⊢x (∂⁺⟿ Γ⊢'x) with unique-type Γ⊢x Γ⊢'x idp ... | idp = idp ⟿-is-tgt Γ⊢x (x⟿∂⁺ Γ⊢'x y'⟿y) with unique-type Γ⊢x Γ⊢'x idp ... | idp = ⊥-elim (Sn≰n _ (⟿dim (Γ⊢tgt (Γ⊢t:A→Γ⊢A Γ⊢'x)) (Γ⊢src (Γ⊢t:A→Γ⊢A Γ⊢x)) y'⟿y)) no-loop : ∀{Γ x y z T a A} → Γ ⊢ps a # A → Γ ⊢t (Var x) # ⇒ T (Var y) (Var z) → y ≠ z no-loop pss (var _ (inl ())) idp no-loop pss (var _ (inr ())) idp no-loop (psd Γ⊢psf) Γ⊢x idp = no-loop Γ⊢psf Γ⊢x idp no-loop (pse Γ⊢psb idp idp idp idp idp) (var _ (inl (inl x∈Γ))) idp = no-loop Γ⊢psb (var (Γ⊢psx:A→Γ⊢ Γ⊢psb) x∈Γ) idp no-loop (pse Γ⊢psb idp idp idp idp idp) (var _ (inl (inr (idp , idp)))) idp = no-loop Γ⊢psb (Γ⊢psx:A→Γ⊢x:A Γ⊢psb) idp no-loop (pse Γ⊢psb idp idp idp idp idp) (var _ (inr (idp , idp))) idp = x∉ (Γ⊢psx:A→Γ⊢ Γ⊢psb) (n≤n _) (Γ⊢psx:A→Γ⊢x:A Γ⊢psb) dangling-is-not-a-source : ∀ {Γ x A} → Γ ⊢ps x # A → (∀ f z {B} → ¬ (Γ ⊢t Var f # ⇒ B (Var x) (Var z))) post-dangling-is-not-a-source : ∀ {Γ x A} → Γ ⊢ps x # A → (∀ {y B} f z → Γ , x ⟿ y → ¬ (Γ ⊢t (Var f) # ⇒ B (Var y) (Var z))) dangling-is-not-a-source pss _ _ (var _ (inl ())) dangling-is-not-a-source pss _ _ (var _ (inr ())) dangling-is-not-a-source {x = x} (psd Γ⊢ps) t u Γ⊢t = post-dangling-is-not-a-source Γ⊢ps t u (∂⁺⟿ (psvar Γ⊢ps)) Γ⊢t dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (var _ (inl (inl x∈Γ))) = x∉ (psv Γ⊢ps) (n≤Sn _) (Γ⊢src (Γ⊢t:A→Γ⊢A (var (psv Γ⊢ps) x∈Γ))) dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (var _ (inl (inr (idp , idp)))) = x∉ (psv Γ⊢ps) (n≤Sn _) (Γ⊢src (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps))) dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (var _ (inr (idp , idp))) = x∉ (psv Γ⊢ps) (n≤Sn _) (psvar Γ⊢ps) post-dangling-is-not-a-source pss t u x⟿y Γ⊢t = 𝔻0-⟿ _ x⟿y post-dangling-is-not-a-source (psd Γ⊢ps) t u x⟿y Γ⊢t = post-dangling-is-not-a-source Γ⊢ps t u (T⟿ (∂⁺⟿ (psvar Γ⊢ps)) x⟿y) Γ⊢t post-dangling-is-not-a-source Γ+⊢@(pse Γ⊢ps idp idp idp idp idp) t u (∂⁺⟿ Γ⊢Sl) Γ⊢t with unique-type Γ⊢Sl (psvar Γ+⊢) idp post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (∂⁺⟿ Γ⊢Sl) (var _ (inl (inl t∈Γ))) | idp = x∉ (psv Γ⊢ps) (n≤n _) (Γ⊢src (Γ⊢t:A→Γ⊢A (var (psv Γ⊢ps) t∈Γ))) post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (∂⁺⟿ Γ⊢Sl) (var _ (inl (inr (idp , idp)))) | idp = x∉ (psv Γ⊢ps) (n≤n _) (Γ⊢src (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps))) post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (∂⁺⟿ Γ⊢Sl) (var _ (inr (idp , idp))) | idp = x∉ (psv Γ⊢ps) (n≤n _) (psvar Γ⊢ps) post-dangling-is-not-a-source Γ+⊢@(pse Γ⊢ps idp idp idp idp idp) t u (x⟿∂⁺ Γ⊢Sl x⟿y) Γ⊢t with unique-type Γ⊢Sl (psvar Γ+⊢) idp post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (x⟿∂⁺ Γ⊢Sl x⟿y) (var Γ+⊢ (inl (inl t∈Γ))) | idp = post-dangling-is-not-a-source Γ⊢ps _ _ (//⟿ (var Γ+⊢ (inl (inr (idp , idp)))) (psvar Γ⊢ps) x⟿y) (var (psv Γ⊢ps) t∈Γ) post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (x⟿∂⁺ Γ⊢Sl x⟿y) (var Γ+⊢ (inl (inr (idp , idp)))) | idp with ⟿-is-tgt (var Γ+⊢ (inl (inr (idp , idp)))) x⟿y ... | idp = no-loop Γ⊢ps (psvar Γ⊢ps) idp post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (x⟿∂⁺ Γ⊢Sl x⟿y) (var Γ++⊢@(cc Γ+⊢ _ p) (inr (idp , idp))) | idp = n≮n _ (⟿dim (var Γ++⊢ (inl (inr (idp , idp)))) (wkt (wkt (psvar Γ⊢ps) Γ+⊢) Γ++⊢) x⟿y) ⊢psx-◃₀→⟿ : ∀ {Γ x a A} → Γ ⊢ps x # A → Γ , x ◃₀ a → Γ , x ⟿ a ⊢psx-◃₀→⟿ Γ⊢psx (◃∂⁻ Γ⊢a) = ⊥-elim (dangling-is-not-a-source Γ⊢psx _ _ Γ⊢a) ⊢psx-◃₀→⟿ Γ⊢psx (◃∂⁺ Γ⊢x) = ∂⁺⟿ Γ⊢x ⊢psx-◃₀→⟿+ : ∀ {Γ x y a A} → Γ ⊢ps x # A → Γ , x ⟿ y → Γ , y ◃₀ a → Γ , y ⟿ a ⊢psx-◃₀→⟿+ Γ⊢psx x⟿y (◃∂⁻ Γ⊢a) = ⊥-elim (post-dangling-is-not-a-source Γ⊢psx _ _ x⟿y Γ⊢a) ⊢psx-◃₀→⟿+ Γ⊢psx x⟿y (◃∂⁺ Γ⊢y) = ∂⁺⟿ Γ⊢y ⊢psx-◃→⟿ : ∀ {Γ x a A} → Γ ⊢ps x # A → Γ , x ◃ a → Γ , x ⟿ a ⊢psx-◃→⟿+ : ∀ {Γ x a b A} → Γ ⊢ps x # A → Γ , x ⟿ a → Γ , a ◃ b → Γ , a ⟿ b ⊢psx-◃→⟿ Γ⊢psx (gen x◃₀a) = ⊢psx-◃₀→⟿ Γ⊢psx x◃₀a ⊢psx-◃→⟿ Γ⊢psx (◃T x◃z z◃₀a) = T⟿ (⊢psx-◃→⟿ Γ⊢psx x◃z) (⊢psx-◃₀→⟿+ Γ⊢psx (⊢psx-◃→⟿ Γ⊢psx x◃z) z◃₀a) ⊢psx-◃→⟿+ Γ⊢psx x⟿y (gen y◃₀a) = ⊢psx-◃₀→⟿+ Γ⊢psx x⟿y y◃₀a ⊢psx-◃→⟿+ Γ⊢psx x⟿y (◃T y◃z z◃₀a) = T⟿ (⊢psx-◃→⟿+ Γ⊢psx x⟿y y◃z) (⊢psx-◃₀→⟿+ Γ⊢psx (T⟿ x⟿y (⊢psx-◃→⟿+ Γ⊢psx x⟿y y◃z)) z◃₀a) -- easy to finish, and follows the paper proof psx-◃-linear→ : ∀ {Γ x A} → Γ ⊢ps x # A → (∀ a b → a ∈ Γ → b ∈ Γ → (((Γ , a ◃ b) + (Γ , b ◃ a)) + (a == b))) psx-◃-linear→ pss .0 .0 (inr idp) (inr idp) = inr idp psx-◃-linear→ (psd Γ⊢psx) a b a∈Γ b∈Γ = psx-◃-linear→ Γ⊢psx a b a∈Γ b∈Γ psx-◃-linear→ Γ++⊢ps@(pse Γ⊢psx idp idp idp idp idp) a b (inl (inl a∈Γ)) (inl (inl b∈Γ)) with psx-◃-linear→ Γ⊢psx a b a∈Γ b∈Γ ... | inl (inl a◃b) = inl (inl (WW◃ (psv Γ++⊢ps) a◃b)) ... | inl (inr b◃a) = inl (inr (WW◃ (psv Γ++⊢ps) b◃a)) ... | inr idp = inr idp psx-◃-linear→ Γ++⊢ps@(pse {x = x} Γ⊢psx idp idp idp idp idp) a .(length _) (inl (inl a∈Γ)) (inl (inr idp)) with psx-◃-linear→ Γ⊢psx a x a∈Γ (Γ⊢x:A→x∈Γ (psvar Γ⊢psx)) -- a ∈ Γ , b = y ... | inl (inl a◃x) = inl (inl (◃-trans (WW◃ (psv Γ++⊢ps) a◃x) (◃T (gen (◃∂⁻ (psvar Γ++⊢ps))) ((◃∂⁺ (psvar Γ++⊢ps)))))) -- a ◃ x ... | inl (inr x◃a) = inl (inr (⟿→◃ (//⟿ (psvar Γ⊢psx) (var (psv Γ++⊢ps) (inl (inr (idp , idp)))) (⊢psx-◃→⟿ Γ⊢psx x◃a)))) -- x ◃ a ... | inr idp = inl (inl (◃T (gen (◃∂⁻ (psvar Γ++⊢ps))) (◃∂⁺ (psvar Γ++⊢ps)))) -- a = x psx-◃-linear→ Γ++⊢ps@(pse {x = x} Γ⊢psx idp idp idp idp idp) a .(S (length _)) (inl (inl a∈Γ)) (inr idp) with psx-◃-linear→ Γ⊢psx a x a∈Γ (Γ⊢x:A→x∈Γ (psvar Γ⊢psx)) -- a ∈ Γ , b = f (**) ... | inl (inl a◃x) = inl (inl (◃T (WW◃ (psv Γ++⊢ps) a◃x) (◃∂⁻ (psvar Γ++⊢ps)))) -- a ◃ x ... | inl (inr x◃a) = inl (inr (⟿→◃ (x⟿∂⁺ (psvar Γ++⊢ps) (//⟿ (psvar Γ⊢psx) (var (psv Γ++⊢ps) (inl (inr (idp , idp)))) (⊢psx-◃→⟿ Γ⊢psx x◃a))))) -- x ◃ a ... | inr idp = inl (inl (gen (◃∂⁻ (psvar Γ++⊢ps)))) -- a = x psx-◃-linear→ Γ++⊢ps@(pse {x = x} Γ⊢psx idp idp idp idp idp) .(length _) b (inl (inr idp)) (inl (inl b∈Γ)) with psx-◃-linear→ Γ⊢psx b x b∈Γ (Γ⊢x:A→x∈Γ (psvar Γ⊢psx)) -- a = y, b ∈ Γ ... | inl (inl b◃x) = inl (inr (◃-trans (WW◃ (psv Γ++⊢ps) b◃x) (◃T (gen (◃∂⁻ (psvar Γ++⊢ps))) (◃∂⁺ (psvar Γ++⊢ps))))) -- b ◃ x ... | inl (inr x◃b) = inl (inl (⟿→◃ (//⟿ (psvar Γ⊢psx) (var (psv Γ++⊢ps) (inl (inr (idp , idp)))) (⊢psx-◃→⟿ Γ⊢psx x◃b)))) -- x ◃ b ... | inr idp = inl (inr (◃T (gen (◃∂⁻ (psvar Γ++⊢ps))) (◃∂⁺ (psvar Γ++⊢ps)))) -- b = x psx-◃-linear→ (pse Γ⊢psx idp idp idp idp idp) .(length _) .(length _) (inl (inr idp)) (inl (inr idp)) = inr idp psx-◃-linear→ Γ++⊢ps@(pse Γ⊢psx idp idp idp idp idp) .(length _) .(S (length _)) (inl (inr idp)) (inr idp) = inl (inr (gen (◃∂⁺ (psvar Γ++⊢ps)))) -- a = y, b = f psx-◃-linear→ Γ++⊢ps@(pse {x = x} Γ⊢psx idp idp idp idp idp) .(S (length _)) b (inr idp) (inl (inl b∈Γ)) with psx-◃-linear→ Γ⊢psx b x b∈Γ (Γ⊢x:A→x∈Γ (psvar Γ⊢psx)) -- a = f b ∈ Γ ... | inl (inl b◃x) = inl (inr (◃T (WW◃ (psv Γ++⊢ps) b◃x) (◃∂⁻ (psvar Γ++⊢ps)))) -- b ◃ x ... | inl (inr x◃b) = inl (inl (⟿→◃ (x⟿∂⁺ (psvar Γ++⊢ps) (//⟿ (psvar Γ⊢psx) (var (psv Γ++⊢ps) (inl (inr (idp , idp)))) (⊢psx-◃→⟿ Γ⊢psx x◃b))))) -- x ◃ b ... | inr idp = inl (inr (gen (◃∂⁻ (psvar Γ++⊢ps)))) -- b = x psx-◃-linear→ Γ++⊢ps@(pse Γ⊢psx idp idp idp idp idp) .(S (length _)) .(length _) (inr idp) (inl (inr idp)) = inl (inl (gen (◃∂⁺ (psvar Γ++⊢ps)))) -- a = f, b = y psx-◃-linear→ (pse Γ⊢psx idp idp idp idp idp) .(S (length _)) .(S (length _)) (inr idp) (inr idp) = inr idp strengthen : ∀ {Γ x A y B} → (Γ :: (y , B)) ⊢t Var x # A → x ∈ Γ → Γ ⊢t Var x # A strengthen (var (cc Γ⊢ _ idp) (inl x#A∈Γ)) x∈Γ = var Γ⊢ x#A∈Γ strengthen (var (cc Γ⊢ _ idp) (inr (idp , idp))) x∈Γ = ⊥-elim (l∉ Γ⊢ (n≤n _) x∈Γ) strengthen+ : ∀ {Γ x A y B z C} → ((Γ :: (y , B)) :: (z , C)) ⊢t Var x # A → x ∈ Γ → Γ ⊢t Var x # A strengthen+ Γ++⊢x x∈Γ = strengthen (strengthen Γ++⊢x (inl x∈Γ)) x∈Γ ◃₀∈ : ∀ {Γ x a} → Γ , x ◃₀ a → a ∈ Γ ◃₀∈ (◃∂⁻ Γ⊢a) = Γ⊢x:A→x∈Γ Γ⊢a ◃₀∈ (◃∂⁺ Γ⊢x) = Γ⊢x:A→x∈Γ (Γ⊢tgt (Γ⊢t:A→Γ⊢A Γ⊢x)) ◃∈ : ∀ {Γ x a} → Γ , x ◃ a → a ∈ Γ ◃∈ (gen x◃₀a) = ◃₀∈ x◃₀a ◃∈ (◃T _ z◃₀x) = ◃₀∈ z◃₀x ∈◃₀ : ∀ {Γ x a} → Γ , x ◃₀ a → x ∈ Γ ∈◃₀ (◃∂⁻ Γ⊢a) = Γ⊢x:A→x∈Γ (Γ⊢src (Γ⊢t:A→Γ⊢A Γ⊢a)) ∈◃₀ (◃∂⁺ Γ⊢x) = Γ⊢x:A→x∈Γ Γ⊢x ∈◃ : ∀ {Γ x a} → Γ , x ◃ a → x ∈ Γ ∈◃ (gen x◃₀a) = ∈◃₀ x◃₀a ∈◃ (◃T x◃z _) = ∈◃ x◃z WWpsx : ∀ {Γ x A} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps ⊢t (Var x) # A WWpsx Γ⊢ps = wkt (wkt (psvar Γ⊢ps) (cc (psv Γ⊢ps) (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps)) idp)) (psv (pse Γ⊢ps idp idp idp idp idp)) dangling-◃₀ : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , S (length Γ) ◃₀ a → a == length Γ dangling-◃₀ Γ⊢ps (◃∂⁻ Γ⊢a) = ⊥-elim (dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ Γ⊢a) dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inl (inl Sl∈Γ)))) = ⊥-elim (l∉ (psv Γ⊢ps) (n≤Sn _) (x#A∈Γ→x∈Γ Sl∈Γ)) dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inl (inr (Sl=l , idp))))) = ⊥-elim (Sn≠n _ Sl=l) dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inr (_ , idp)))) = idp ◃₀-dangling : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃₀ S (length Γ) → a == x ◃₀-dangling Γ⊢ps (◃∂⁻ Γ+⊢Sl) with unique-type Γ+⊢Sl (psvar (pse Γ⊢ps idp idp idp idp idp)) idp ... | idp = idp ◃₀-dangling Γ⊢ps (◃∂⁺ (var x (inl (inl a∈Γ)))) = ⊥-elim (x∉ (psv Γ⊢ps) (n≤Sn _) (Γ⊢tgt (Γ⊢t:A→Γ⊢A (var (psv Γ⊢ps) a∈Γ)))) ◃₀-dangling Γ⊢ps (◃∂⁺ (var x (inl (inr (idp , idp))))) = ⊥-elim (x∉ (psv Γ⊢ps) (n≤Sn _) (Γ⊢tgt (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps)))) ◃₀-dangling Γ⊢ps (◃∂⁺ (var x (inr (idp , abs)))) = ⊥-elim (Sn≠n _ (=Var (snd (=⇒ abs)))) ◃₀-dangling-tgt : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃₀ length Γ → (a == S (length Γ)) + (Γ++ Γ⊢ps , a ◃₀ x) ◃₀-dangling-tgt Γ⊢ps (◃∂⁻ Γ+⊢l) with unique-type Γ+⊢l (var (psv (pse Γ⊢ps idp idp idp idp idp)) (inl (inr (idp , idp)))) idp ... | idp = inr (◃∂⁻ (WWpsx Γ⊢ps)) ◃₀-dangling-tgt Γ⊢ps (◃∂⁺ (var x (inl (inl a∈Γ)))) = ⊥-elim (x∉ (psv Γ⊢ps) (n≤n _) (Γ⊢tgt (Γ⊢t:A→Γ⊢A (var (psv Γ⊢ps) a∈Γ)))) ◃₀-dangling-tgt Γ⊢ps (◃∂⁺ (var x (inl (inr (idp , idp))))) = ⊥-elim (x∉ (psv Γ⊢ps) (n≤n _) (Γ⊢tgt (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps)))) ◃₀-dangling-tgt Γ⊢ps (◃∂⁺ (var x (inr (p , _)))) = inl p ◃-dangling : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃ S (length Γ) → (a == x) + (Γ++ Γ⊢ps , a ◃ x) ◃-dangling Γ⊢ps (gen x◃₀Sl) with ◃₀-dangling Γ⊢ps x◃₀Sl ... | idp = inl idp ◃-dangling Γ⊢ps (◃T a◃x x◃₀Sl) with ◃₀-dangling Γ⊢ps x◃₀Sl ... | idp = inr a◃x ◃-dangling-tgt : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃ length Γ → (a == S (length Γ) + (a == x)) + (Γ++ Γ⊢ps , a ◃ x) ◃-dangling-tgt Γ⊢ps (gen a◃₀l) with ◃₀-dangling-tgt Γ⊢ps a◃₀l ... | inl idp = inl (inl idp) ... | inr a◃₀x = inr (gen a◃₀x) ◃-dangling-tgt Γ⊢ps (◃T a◃z z◃₀l) with ◃₀-dangling-tgt Γ⊢ps z◃₀l ... | inl idp with ◃-dangling Γ⊢ps a◃z ... | inl idp = inl (inr idp) ... | inr a◃x = inr a◃x ◃-dangling-tgt Γ⊢ps (◃T a◃z z◃₀l) | inr z◃₀x = inr (◃T a◃z z◃₀x) strengthen-◃₀ : ∀ {Γ x A a b} → (Γ⊢ps : Γ ⊢ps x # A) → a ∈ Γ → b ∈ Γ → Γ++ Γ⊢ps , a ◃₀ b → Γ , a ◃₀ b strengthen-◃₀ Γ⊢ps a∈Γ b∈Γ (◃∂⁻ Γ⊢b) = ◃∂⁻ (strengthen+ Γ⊢b b∈Γ) strengthen-◃₀ Γ⊢ps a∈Γ b∈Γ (◃∂⁺ Γ⊢a) = ◃∂⁺ (strengthen+ Γ⊢a a∈Γ) -- useful particular case strengthen-◃₀-dangling : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , length Γ ◃₀ a → Γ , x ◃₀ a strengthen-◃₀-dangling Γ⊢ps (◃∂⁻ Γ⊢a) = ⊥-elim (post-dangling-is-not-a-source (pse Γ⊢ps idp idp idp idp idp) _ _ (∂⁺⟿ (psvar (pse Γ⊢ps idp idp idp idp idp))) Γ⊢a) strengthen-◃₀-dangling Γ⊢ps (◃∂⁺ (var _ (inl (inl l∈Γ)))) = ⊥-elim (l∉ (psv Γ⊢ps) (n≤n _) (x#A∈Γ→x∈Γ l∈Γ)) strengthen-◃₀-dangling Γ⊢ps (◃∂⁺ (var _ (inl (inr (_ , idp))))) = ◃∂⁺ (psvar Γ⊢ps) strengthen-◃₀-dangling Γ⊢ps (◃∂⁺ (var _ (inr (l=Sl , _)))) = ⊥-elim (Sn≠n _ (l=Sl ^)) ∈-dangling : ∀ {Γ x A} → Γ ⊢ps x # A → x ∈ Γ ∈-dangling Γ⊢ps = Γ⊢x:A→x∈Γ (psvar Γ⊢ps) ∈-dangling-◃₀ : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃₀ x → a ∈ Γ ∈-dangling-◃₀ Γ⊢ps (◃∂⁻ Γ+⊢x) with unique-type Γ+⊢x (WWpsx Γ⊢ps) idp ... | idp = Γ⊢x:A→x∈Γ (Γ⊢src (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps))) ∈-dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inl (inl a∈Γ)))) = x#A∈Γ→x∈Γ a∈Γ ∈-dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inl (inr (idp , idp))))) with unique-type (psvar Γ⊢ps) (Γ⊢tgt (Γ⊢t:A→Γ⊢A (psvar Γ⊢ps))) idp ... | () ∈-dangling-◃₀ Γ⊢ps (◃∂⁺ (var _ (inr (idp , idp)))) = ⊥-elim (x∉ (psv Γ⊢ps) (n≤n _) (psvar Γ⊢ps)) strengthen-dangling-◃₀ : ∀ {Γ x A a} → (Γ⊢ps : Γ ⊢ps x # A) → Γ++ Γ⊢ps , a ◃₀ x → Γ , a ◃₀ x strengthen-dangling-◃₀ Γ⊢ps a◃₀x = strengthen-◃₀ Γ⊢ps (∈-dangling-◃₀ Γ⊢ps a◃₀x) (∈-dangling Γ⊢ps) a◃₀x -- Not easy to find a way to express in a terminating way pse-◃-elim : ∀ {Γ x A a b} → (Γ⊢ps : Γ ⊢ps x # A) → a ∈ Γ → b ∈ Γ → Γ++ Γ⊢ps , a ◃ b → Γ , a ◃ b pse-◃-elim Γ⊢ps a∈Γ b∈Γ (gen a◃₀b) = gen (strengthen-◃₀ Γ⊢ps a∈Γ b∈Γ a◃₀b) pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T a◃z z◃₀b) with ◃∈ a◃z pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T a◃z z◃₀b) | inl (inl z∈Γ) = ◃T (pse-◃-elim Γ⊢ps a∈Γ z∈Γ a◃z) (strengthen-◃₀ Γ⊢ps z∈Γ b∈Γ z◃₀b) pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T (gen a◃₀l) l◃₀b) | inl (inr idp) with ◃₀-dangling-tgt Γ⊢ps a◃₀l ... | inl idp = ⊥-elim (l∉ (psv Γ⊢ps) (n≤Sn _) a∈Γ) ... | inr a◃₀x = ◃T (gen (strengthen-◃₀ Γ⊢ps a∈Γ (∈-dangling Γ⊢ps) a◃₀x)) (strengthen-◃₀-dangling Γ⊢ps l◃₀b) pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T (◃T a◃z z◃₀l) l◃₀b) | inl (inr idp) with ◃₀-dangling-tgt Γ⊢ps z◃₀l ... | inr z◃₀x = ◃T (◃T (pse-◃-elim Γ⊢ps a∈Γ (∈-dangling-◃₀ Γ⊢ps z◃₀x) a◃z) (strengthen-dangling-◃₀ Γ⊢ps z◃₀x)) (strengthen-◃₀-dangling Γ⊢ps l◃₀b) pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T (◃T (gen a◃₀Sl) Sl◃₀l) l◃₀b) | inl (inr idp) | inl idp with ◃₀-dangling Γ⊢ps a◃₀Sl ... | idp = gen (strengthen-◃₀-dangling Γ⊢ps l◃₀b) pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T (◃T (◃T a◃z z◃₀Sl) Sl◃₀l) l◃₀b) | inl (inr idp) | inl idp with ◃₀-dangling Γ⊢ps z◃₀Sl ... | idp = ◃T (pse-◃-elim Γ⊢ps a∈Γ (∈-dangling Γ⊢ps) a◃z) (strengthen-◃₀-dangling Γ⊢ps l◃₀b) pse-◃-elim Γ⊢ps a∈Γ b∈Γ (◃T a◃z z◃₀b) | inr idp with dangling-◃₀ Γ⊢ps z◃₀b ... | idp = ⊥-elim (l∉ (psv Γ⊢ps) (n≤n _) b∈Γ) psx-◃-linear← : ∀ {Γ z A} → Γ ⊢ps z # A → (∀ x → x ∈ Γ → ¬ (Γ , x ◃ x)) psx-◃-linear← pss .0 (inr idp) x◃x = 𝔻0-◃ 0 x◃x psx-◃-linear← (psd Γ⊢psz) x x∈Γ x◃x = psx-◃-linear← Γ⊢psz x x∈Γ x◃x psx-◃-linear← (pse Γ⊢psz idp idp idp idp idp) x (inl (inl x∈Γ)) x◃x = psx-◃-linear← Γ⊢psz x x∈Γ (pse-◃-elim Γ⊢psz x∈Γ x∈Γ x◃x) psx-◃-linear← Γ+⊢ps@(pse Γ⊢psz idp idp idp idp idp) x (inl (inr idp)) x◃x = ⊥-elim (Sn≰n _ (⟿dim (var (psv Γ+⊢ps) (inl (inr (idp , idp)))) (var (psv Γ+⊢ps) (inl (inr (idp , idp)))) (⊢psx-◃→⟿+ Γ+⊢ps (∂⁺⟿ (psvar Γ+⊢ps)) x◃x))) psx-◃-linear← Γ+⊢ps@(pse Γ⊢psz idp idp idp idp idp) x (inr idp) x◃x = ⊥-elim (Sn≰n _ (⟿dim (psvar Γ+⊢ps) (psvar Γ+⊢ps) (⊢psx-◃→⟿ Γ+⊢ps x◃x))) ◃-linear : Pre-Ctx → Set₁ ◃-linear Γ = ∀ x y → x ∈ Γ → y ∈ Γ → (x ≠ y) ↔ ((Γ , x ◃ y) + (Γ , y ◃ x)) ps-◃-linear : ∀ Γ → Γ ⊢ps → ◃-linear Γ fst (ps-◃-linear Γ (ps Γ⊢psz) x y x∈Γ y∈Γ) x≠y with psx-◃-linear→ Γ⊢psz x y x∈Γ y∈Γ ... | inl H = H ... | inr x=y = ⊥-elim (x≠y x=y) snd (ps-◃-linear Γ (ps Γ⊢psz) x .x x∈Γ y∈Γ) (inl x◃x) idp = psx-◃-linear← Γ⊢psz x x∈Γ x◃x snd (ps-◃-linear Γ (ps Γ⊢psz) x .x x∈Γ y∈Γ) (inr x◃x) idp = psx-◃-linear← Γ⊢psz x x∈Γ x◃x
{ "alphanum_fraction": 0.4744052676, "avg_line_length": 61.7442622951, "ext": "agda", "hexsha": "1414835b4c8d349d318ffbf34d2e4e65286e6a62", "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": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thibautbenjamin/catt-formalization", "max_forks_repo_path": "CaTT/Relation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "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": "thibautbenjamin/catt-formalization", "max_issues_repo_path": "CaTT/Relation.agda", "max_line_length": 226, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thibautbenjamin/catt-formalization", "max_stars_repo_path": "CaTT/Relation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 12567, "size": 18832 }
{-# OPTIONS --rewriting --without-K #-} open import Prelude open import GSeTT.Syntax open import GSeTT.Rules open import GSeTT.Uniqueness-Derivations open import Sets ℕ eqdecℕ open import GSeTT.Dec-Type-Checking open import CaTT.Ps-contexts open import CaTT.Relation {- PS-contexts -} module CaTT.Uniqueness-Derivations-Ps where Γ⊢psx-dim≤ : ∀ {Γ x A} → Γ ⊢ps x # A → dim A ≤ dimC Γ Γ⊢psx-dim≤ pss = n≤n 0 Γ⊢psx-dim≤ (psd Γ⊢psy) = Sn≤m→n≤m (Γ⊢psx-dim≤ Γ⊢psy) Γ⊢psx-dim≤ {((Γ :: (_ , A)) :: (_ , _))} {_} {_} (pse Γ⊢psx idp idp idp idp idp) with dec-≤ (dimC (Γ :: (length Γ , A))) (S (dim A)) ... | inr res = Sn≤m→n≤m (≰ res) ... | inl res = n≤n (S (dim A)) Γ⊢psx-dim : ∀ {Γ x y A B} → Γ ⊢ps x # A → Γ ⊢ps y # B → dim A == dim B → x == y Γ⊢psx-dim pss pss dimA=dimB = idp Γ⊢psx-dim {x = x} {y = y} {A = A} {B = B} (psd {x = x₁} Γ⊢psx) (psd {x = x₂} Γ⊢psy) dimA=dimB = =Var (tgt= (unique-type (Γ⊢psx:A→Γ⊢x:A Γ⊢psx) (Γ⊢psx:A→Γ⊢x:A Γ⊢psy) (ap Var (Γ⊢psx-dim Γ⊢psx Γ⊢psy (ap S dimA=dimB))))) Γ⊢psx-dim {B = ∗} pss (psd Γ⊢psy) dimA=dimB = ⊥-elim (Sn≰n _ ((Γ⊢psx-dim≤ Γ⊢psy))) Γ⊢psx-dim {A = ∗} (psd Γ⊢psx) pss dimA=dimB = ⊥-elim (Sn≰n _ ((Γ⊢psx-dim≤ Γ⊢psx))) Γ⊢psx-dim (pse _ _ _ _ idp idp) (pse _ _ _ _ idp idp) dimA==dimB = idp Γ⊢psx-dim Γ++⊢psx@(psd Γ++⊢_) Γ++⊢psy@(pse _ idp idp idp idp idp) dimA=dimB with psx-◃-linear→ Γ++⊢psx _ _ (Γ⊢x:A→x∈Γ (psvar Γ++⊢psx)) (Γ⊢x:A→x∈Γ (psvar Γ++⊢psy)) ... | inl (inl x◃Sl) = ⊥-elim (Sn≰n-t (dimA=dimB ^) (⟿dim (psvar Γ++⊢psx) (psvar Γ++⊢psy) (⊢psx-◃→⟿ Γ++⊢psx x◃Sl))) ... | inl (inr Sl◃x) = ⊥-elim (Sn≰n-t (dimA=dimB) (⟿dim (psvar Γ++⊢psy) (psvar Γ++⊢psx) (⊢psx-◃→⟿ Γ++⊢psy Sl◃x))) ... | inr idp = idp Γ⊢psx-dim Γ++⊢psx@(pse _ idp idp idp idp idp) Γ++⊢psy@(psd _) dimA=dimB with psx-◃-linear→ Γ++⊢psx _ _ (Γ⊢x:A→x∈Γ (psvar Γ++⊢psx)) (Γ⊢x:A→x∈Γ (psvar Γ++⊢psy)) ... | inl (inl Sl◃y) = ⊥-elim (Sn≰n-t (dimA=dimB ^) (⟿dim (psvar Γ++⊢psx) (psvar Γ++⊢psy) (⊢psx-◃→⟿ Γ++⊢psx Sl◃y))) ... | inl (inr y◃Sl) = ⊥-elim (Sn≰n-t (dimA=dimB) (⟿dim (psvar Γ++⊢psy) (psvar Γ++⊢psx) (⊢psx-◃→⟿ Γ++⊢psy y◃Sl))) ... | inr idp = idp has-all-paths-⊢psx : ∀ {Γ x A} → has-all-paths (Γ ⊢ps x # A) has-all-paths-⊢psx pss pss = idp has-all-paths-⊢psx (psd a) (psd b) with (Γ⊢psx-dim a b idp) ... | idp with unique-type (psvar a) (psvar b) idp ... | p = psd↓ a b (=Var (snd (fst (=⇒ p)))) (has-all-paths-⊢psx _ _) has-all-paths-⊢psx pss (psd b) with (psvar b) ... | var _ (inl ()) ... | var _ (inr ()) has-all-paths-⊢psx (psd a) pss with (psvar a) ... | var _ (inl ()) ... | var _ (inr ()) has-all-paths-⊢psx (psd a) (pse b idp idp idp idp idp) with (psvar a) ... | var _ (inl (inl contra)) = ⊥-elim (l∉ (psv b) (n≤Sn _) (Γ⊢x:A→x∈Γ (Γ⊢tgt (Γ⊢t:A→Γ⊢A (var (psv b) contra))))) has-all-paths-⊢psx (pse a idp idp idp idp idp) (psd b) with psvar b ... | var _ (inl (inl contra)) = ⊥-elim (l∉ (psv a) (n≤Sn _) (Γ⊢x:A→x∈Γ (Γ⊢tgt (Γ⊢t:A→Γ⊢A (var (psv a) contra))))) has-all-paths-⊢psx (pse a idp idp idp idp idp) (pse b p q r s u) = let eq = =Var (snd (fst (=⇒ r))) in pse↓ a _ _ _ _ _ b _ _ _ _ _ eq (has-all-paths-⊢psx _ _) has-all-paths-⊢ps : ∀ Γ → has-all-paths (Γ ⊢ps) has-all-paths-⊢ps Γ (ps Γ⊢psx₁) (ps Γ⊢psx₂) = ps↓ Γ⊢psx₁ Γ⊢psx₂ (Γ⊢psx-dim Γ⊢psx₁ Γ⊢psx₂ idp) (has-all-paths-⊢psx _ _) is-prop-⊢ps : ∀ Γ → is-prop (Γ ⊢ps) is-prop-⊢ps Γ = has-all-paths-is-prop (has-all-paths-⊢ps Γ) eqdec-ps : eqdec ps-ctx eqdec-ps (Γ , Γ⊢ps) (Δ , Δ⊢ps) with eqdec-PreCtx Γ Δ ... | inl idp = inl (Σ= idp (is-prop-has-all-paths (is-prop-⊢ps Γ) _ _)) ... | inr Γ≠Δ = inr λ{idp → Γ≠Δ idp}
{ "alphanum_fraction": 0.5496225888, "avg_line_length": 54.196969697, "ext": "agda", "hexsha": "9cddd6a2ba6a0500df24d5d04d8c4ca32ce44f9a", "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": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "thibautbenjamin/catt-formalization", "max_forks_repo_path": "CaTT/Uniqueness-Derivations-Ps.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "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": "thibautbenjamin/catt-formalization", "max_issues_repo_path": "CaTT/Uniqueness-Derivations-Ps.agda", "max_line_length": 218, "max_stars_count": null, "max_stars_repo_head_hexsha": "3a02010a869697f4833c9bc6047d66ca27b87cf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thibautbenjamin/catt-formalization", "max_stars_repo_path": "CaTT/Uniqueness-Derivations-Ps.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2086, "size": 3577 }
module LateMetaVariableInstantiation where data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} postulate yippie : (A : Set) → A slow : (A : Set) → ℕ → A slow A zero = yippie A slow A (suc n) = slow _ n data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x foo : slow ℕ 1000 ≡ yippie ℕ foo = refl -- Consider the function slow. Previously normalisation of slow n -- seemed to take time proportional to n². The reason was that, even -- though the meta-variable corresponding to the underscore was -- solved, the stored code still contained a meta-variable: -- slow A (suc n) = slow (_173 A n) n -- (For some value of 173.) The evaluation proceeded as follows: -- slow A 1000 = -- slow (_173 A 999) 999 = -- slow (_173 (_173 A 999) 998) 998 = -- ... -- Furthermore, in every iteration the Set argument was traversed, to -- see if there was any de Bruijn index to raise.
{ "alphanum_fraction": 0.6247401247, "avg_line_length": 25.3157894737, "ext": "agda", "hexsha": "6ed7c0221bbeab9397ddf657d5c16365636831aa", "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": "benchmark/misc/LateMetaVariableInstantiation.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": "benchmark/misc/LateMetaVariableInstantiation.agda", "max_line_length": 70, "max_stars_count": 1, "max_stars_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "masondesu/agda", "max_stars_repo_path": "benchmark/misc/LateMetaVariableInstantiation.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 295, "size": 962 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category open import Categories.Monad module Categories.Category.Construction.EilenbergMoore {o ℓ e} {C : Category o ℓ e} (M : Monad C) where open import Level open import Categories.Morphism.Reasoning C private module C = Category C module M = Monad M open C open M.F open HomReasoning record Module : Set (o ⊔ ℓ ⊔ e) where field A : Obj action : F₀ A ⇒ A commute : action ∘ F₁ action ≈ action ∘ M.μ.η A identity : action ∘ M.η.η A ≈ C.id record Module⇒ (X Y : Module) : Set (ℓ ⊔ e) where private module X = Module X module Y = Module Y field arr : X.A ⇒ Y.A commute : arr ∘ X.action ≈ Y.action ∘ F₁ arr EilenbergMoore : Category (o ⊔ ℓ ⊔ e) (ℓ ⊔ e) e EilenbergMoore = record { Obj = Module ; _⇒_ = Module⇒ ; _≈_ = λ f g → Module⇒.arr f ≈ Module⇒.arr g ; id = record { arr = C.id ; commute = id-comm-sym ○ ∘-resp-≈ʳ (⟺ identity) } ; _∘_ = compose ; assoc = assoc ; sym-assoc = sym-assoc ; identityˡ = identityˡ ; identityʳ = identityʳ ; identity² = identity² ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≈ = ∘-resp-≈ } where compose : ∀ {X Y Z} → Module⇒ Y Z → Module⇒ X Y → Module⇒ X Z compose {X} {Y} {Z} f g = record { arr = f.arr ∘ g.arr ; commute = begin (f.arr ∘ g.arr) ∘ Module.action X ≈⟨ pullʳ g.commute ⟩ f.arr ∘ Module.action Y ∘ F₁ g.arr ≈⟨ pullˡ f.commute ⟩ (Module.action Z ∘ F₁ f.arr) ∘ F₁ g.arr ≈˘⟨ pushʳ homomorphism ⟩ Module.action Z ∘ F₁ (f.arr ∘ g.arr) ∎ } where module f = Module⇒ f module g = Module⇒ g
{ "alphanum_fraction": 0.5397350993, "avg_line_length": 27.0447761194, "ext": "agda", "hexsha": "9208c3e16cc79f7a5758d2f2eb669d23156a0847", "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": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Construction/EilenbergMoore.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "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": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Construction/EilenbergMoore.agda", "max_line_length": 103, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Construction/EilenbergMoore.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 668, "size": 1812 }
-- A variant of code reported by Andreas Abel. {-# OPTIONS --guardedness --sized-types #-} open import Agda.Builtin.Size data ⊥ : Set where mutual data D : Size → Set where inn : ∀ i → D' i → D (↑ i) record D' (i : Size) : Set where coinductive constructor ♯ field ♭ : D i open D' iter : ∀{i} → D i → ⊥ iter (inn i t) = iter (♭ t) -- Should be rejected by termination checker bla : D' ∞ ♭ bla = inn ∞ bla false : ⊥ false = iter (♭ bla)
{ "alphanum_fraction": 0.5824411135, "avg_line_length": 16.1034482759, "ext": "agda", "hexsha": "b6bd7cef81b9dbca821f03e40b50027f37afcdcf", "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/Issue1209-5.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/Issue1209-5.agda", "max_line_length": 46, "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/Issue1209-5.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": 160, "size": 467 }
-- data construction, disproving module Auto-DataConstruction where open import Auto.Prelude module Disproving where h0 : {X : Set} → (xs ys : List X) → (xs ++ ys) ≡ (ys ++ xs) h0 = {!-d Fin!}
{ "alphanum_fraction": 0.64, "avg_line_length": 16.6666666667, "ext": "agda", "hexsha": "d212a37dd757f8516b54ef057c05d0988821a330", "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/Auto-DataConstruction.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/Auto-DataConstruction.agda", "max_line_length": 60, "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/Auto-DataConstruction.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": 64, "size": 200 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.Sum.Relation.Binary.LeftOrder directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Sum.Relation.LeftOrder where open import Data.Sum.Relation.Binary.LeftOrder public {-# WARNING_ON_IMPORT "Data.Sum.Relation.LeftOrder was deprecated in v1.0. Use Data.Sum.Relation.Binary.LeftOrder instead." #-}
{ "alphanum_fraction": 0.5482041588, "avg_line_length": 29.3888888889, "ext": "agda", "hexsha": "e209a3b3c6be4da8c8a9dd43fdccc19547df63ab", "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": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Sum/Relation/LeftOrder.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "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": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Sum/Relation/LeftOrder.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Sum/Relation/LeftOrder.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": 93, "size": 529 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.ListedFiniteSet.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Logic open import Cubical.Foundations.Everything private variable A : Type₀ infixr 20 _∷_ infix 30 _∈_ data LFSet (A : Type₀) : Type₀ where [] : LFSet A _∷_ : (x : A) → (xs : LFSet A) → LFSet A dup : ∀ x xs → x ∷ x ∷ xs ≡ x ∷ xs comm : ∀ x y xs → x ∷ y ∷ xs ≡ y ∷ x ∷ xs trunc : isSet (LFSet A) -- Membership. -- -- Doing some proofs with equational reasoning adds an extra "_∙ refl" -- at the end. -- We might want to avoid it, or come up with a more clever equational reasoning. _∈_ : A → LFSet A → hProp z ∈ [] = ⊥ z ∈ (y ∷ xs) = (z ≡ₚ y) ⊔ (z ∈ xs) z ∈ dup x xs i = proof i where -- proof : z ∈ (x ∷ x ∷ xs) ≡ z ∈ (x ∷ xs) proof = z ≡ₚ x ⊔ (z ≡ₚ x ⊔ z ∈ xs) ≡⟨ ⊔-assoc (z ≡ₚ x) (z ≡ₚ x) (z ∈ xs) ⟩ (z ≡ₚ x ⊔ z ≡ₚ x) ⊔ z ∈ xs ≡⟨ cong (_⊔ (z ∈ xs)) (⊔-idem (z ≡ₚ x)) ⟩ z ≡ₚ x ⊔ z ∈ xs ∎ z ∈ comm x y xs i = proof i where -- proof : z ∈ (x ∷ y ∷ xs) ≡ z ∈ (y ∷ x ∷ xs) proof = z ≡ₚ x ⊔ (z ≡ₚ y ⊔ z ∈ xs) ≡⟨ ⊔-assoc (z ≡ₚ x) (z ≡ₚ y) (z ∈ xs) ⟩ (z ≡ₚ x ⊔ z ≡ₚ y) ⊔ z ∈ xs ≡⟨ cong (_⊔ (z ∈ xs)) (⊔-comm (z ≡ₚ x) (z ≡ₚ y)) ⟩ (z ≡ₚ y ⊔ z ≡ₚ x) ⊔ z ∈ xs ≡⟨ sym (⊔-assoc (z ≡ₚ y) (z ≡ₚ x) (z ∈ xs)) ⟩ z ≡ₚ y ⊔ (z ≡ₚ x ⊔ z ∈ xs) ∎ x ∈ trunc xs ys p q i j = isSetHProp (x ∈ xs) (x ∈ ys) (cong (x ∈_) p) (cong (x ∈_) q) i j
{ "alphanum_fraction": 0.4658869396, "avg_line_length": 32.7446808511, "ext": "agda", "hexsha": "bf58facf07d747b8e7a9703c20c65ae0f047f2a3", "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": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/HITs/ListedFiniteSet/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "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": "cj-xu/cubical", "max_issues_repo_path": "Cubical/HITs/ListedFiniteSet/Base.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/HITs/ListedFiniteSet/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 736, "size": 1539 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Nat open import lib.types.Sigma module lib.types.PathSeq where {- This is a library on reified equational reasoning. When you write the following (with the usual equational reasoning combinators): t : a == e t = a =⟨ p ⟩ b =⟨ q ⟩ c =⟨ r ⟩ d =⟨ s ⟩ e ∎ it just creates the concatenation of [p], [q], [r] and [s] and there is no way to say “remove the last step to get the path from [a] to [d]”. With the present library you would write: t : PathSeq a e t = a =⟪ p ⟫ b =⟪ q ⟫ c =⟪ r ⟫ d =⟪ s ⟫ e ∎∎ Then the actual path from [a] to [e] is [↯ t], and you can strip any number of steps from the beginning or the end: ↯ t !2 -} infix 15 _∎∎ infixr 10 _=⟪_⟫_ infixr 10 _=⟪idp⟫_ data PathSeq {i} {A : Type i} : A → A → Type i where _∎∎ : (a : A) → PathSeq a a _=⟪_⟫_ : (a : A) {a' a'' : A} (p : a == a') (s : PathSeq a' a'') → PathSeq a a'' infix 30 _=-=_ _=-=_ = PathSeq _=⟪idp⟫_ : ∀ {i} {A : Type i} (a : A) {a' : A} (s : PathSeq a a') → PathSeq a a' a =⟪idp⟫ s = s module _ {i} {A : Type i} where infix 0 ↯_ ↯_ : {a a' : A} (s : PathSeq a a') → a == a' ↯ a ∎∎ = idp ↯ a =⟪ p ⟫ a' ∎∎ = p ↯ a =⟪ p ⟫ s = p ∙ (↯ s) private point-from-start : (n : ℕ) {a a' : A} (s : PathSeq a a') → A point-from-start O {a} s = a point-from-start (S n) (a ∎∎) = a point-from-start (S n) (a =⟪ p ⟫ s) = point-from-start n s _-! : (n : ℕ) {a a' : A} (s : PathSeq a a') → PathSeq (point-from-start n s) a' (O -!) s = s (S n -!) (a ∎∎) = a ∎∎ (S n -!) (a =⟪ p ⟫ s) = (n -!) s private last1 : {a a' : A} (s : PathSeq a a') → A last1 (a ∎∎) = a last1 (a =⟪ p ⟫ a' ∎∎) = a last1 (a =⟪ p ⟫ s) = last1 s strip : {a a' : A} (s : PathSeq a a') → PathSeq a (last1 s) strip (a ∎∎) = a ∎∎ strip (a =⟪ p ⟫ a' ∎∎) = a ∎∎ strip (a =⟪ p ⟫ a' =⟪ p' ⟫ s) = a =⟪ p ⟫ strip (a' =⟪ p' ⟫ s) point-from-end : (n : ℕ) {a a' : A} (s : PathSeq a a') → A point-from-end O {a} {a'} s = a' point-from-end (S n) s = point-from-end n (strip s) !- : (n : ℕ) {a a' : A} (s : PathSeq a a') → PathSeq a (point-from-end n s) !- O s = s !- (S n) s = !- n (strip s) _-# : (n : ℕ) {a a' : A} (s : PathSeq a a') → PathSeq a (point-from-start n s) (O -#) s = _ ∎∎ (S n -#) (a ∎∎) = a ∎∎ (S n -#) (a =⟪ p ⟫ s) = a =⟪ p ⟫ (n -#) s private split : {a a' : A} (s : PathSeq a a') → Σ A (λ a'' → (PathSeq a a'') × (a'' == a')) split (a ∎∎) = (a , ((a ∎∎) , idp)) split (a =⟪ p ⟫ a' ∎∎) = (a , ((a ∎∎) , p)) split (a =⟪ p ⟫ s) = let (a'' , (t , q)) = split s in (a'' , ((a =⟪ p ⟫ t) , q)) infix 80 _∙∙_ _∙∙_ : {a a' a'' : A} (s : PathSeq a a') (p : a' == a'') → PathSeq a a'' (a ∎∎) ∙∙ p = a =⟪ p ⟫ _ ∎∎ (a =⟪ p ⟫ s) ∙∙ p' = a =⟪ p ⟫ s ∙∙ p' point-from-end' : (n : ℕ) {a a' : A} (s : PathSeq a a') → A point-from-end' n (a ∎∎) = a point-from-end' O (a =⟪ p ⟫ s) = point-from-end' O s point-from-end' (S n) (a =⟪ p ⟫ s) = point-from-end' n (fst (snd (split (a =⟪ p ⟫ s)))) #- : (n : ℕ) {a a' : A} (s : PathSeq a a') → PathSeq (point-from-end' n s) a' #- n (a ∎∎) = a ∎∎ #- O (a =⟪ p ⟫ s) = #- O s #- (S n) (a =⟪ p ⟫ s) = let (a' , (t , q)) = split (a =⟪ p ⟫ s) in #- n t ∙∙ q infix 120 _!0 _!1 _!2 _!3 _!4 _!5 _!0 = !- 0 _!1 = !- 1 _!2 = !- 2 _!3 = !- 3 _!4 = !- 4 _!5 = !- 5 0! = 0 -! 1! = 1 -! 2! = 2 -! 3! = 3 -! 4! = 4 -! 5! = 5 -! infix 120 _#0 _#1 _#2 _#3 _#4 _#5 _#0 = #- 0 _#1 = #- 1 _#2 = #- 2 _#3 = #- 3 _#4 = #- 4 _#5 = #- 5 0# = 0 -# 1# = 1 -# 2# = 2 -# 3# = 3 -# 4# = 4 -# 5# = 5 -# private postulate -- Demo a b c d e : A p : a == b q : b == c r : c == d s : d == e t : PathSeq a e t = a =⟪ p ⟫ b =⟪idp⟫ b =⟪ q ⟫ c =⟪ idp ⟫ c =⟪ r ⟫ d =⟪ s ⟫ e =⟪idp⟫ e ∎∎ t' : a == e t' = ↯ a =⟪ p ⟫ b =⟪ q ⟫ c =⟪ idp ⟫ c =⟪ r ⟫ d =⟪ s ⟫ e ∎∎ ex0 : t' == (↯ t) ex0 = idp ex1 : t' == p ∙ q ∙ r ∙ s ex1 = idp ex2 : (↯ t !1) == p ∙ q ∙ r ex2 = idp ex3 : (↯ t !3) == p ∙ q -- The [idp] count ex3 = idp ex4 : (↯ 2! t) == r ∙ s ex4 = idp ex5 : (↯ 4! t) == s ex5 = idp ex6 : (↯ t #1) == s ex6 = idp ex7 : (↯ t #3) == r ∙ s ex7 = idp ex8 : (↯ 2# t) == p ∙ q ex8 = idp ex9 : (↯ 4# t) == p ∙ q ∙ r ex9 = idp apd= : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B} (p : f ∼ g) {a b : A} (q : a == b) → apd f q ▹ p b == p a ◃ apd g q apd= {B = B} p {b} idp = idp▹ {B = B} (p b) ∙ ! (◃idp {B = B} (p b)) apd=-red : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B} (p : f ∼ g) {a b : A} (q : a == b) {u : B b} (s : g b =-= u) → apd f q ▹ (↯ _ =⟪ p b ⟫ s) == p a ◃ (apd g q ▹ (↯ s)) apd=-red {B = B} p {b} idp s = coh (p b) s where coh : ∀ {i} {A : Type i} {u v w : A} (p : u == v) (s : v =-= w) → (idp ∙' (↯ _ =⟪ p ⟫ s)) == p ∙ idp ∙' (↯ s) coh idp (a ∎∎) = idp coh idp (a =⟪ p₁ ⟫ s₁) = idp
{ "alphanum_fraction": 0.3887497592, "avg_line_length": 23.3828828829, "ext": "agda", "hexsha": "4c446b70c42b12325201c0d7ebd44173309ab384", "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": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "core/lib/types/PathSeq.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "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": "timjb/HoTT-Agda", "max_issues_repo_path": "core/lib/types/PathSeq.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "core/lib/types/PathSeq.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2696, "size": 5191 }
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category open import Categories.Object.Terminal open import Level module Categories.Object.Terminal.Exponentials {o ℓ e : Level} (C : Category o ℓ e) (T : Terminal C) where open Category C open Terminal T import Categories.Object.Exponential import Categories.Object.Product import Categories.Object.Product.Morphisms import Categories.Object.Terminal.Products open Categories.Object.Exponential C hiding (repack) open Categories.Object.Product C open Categories.Object.Product.Morphisms C open Categories.Object.Terminal.Products C T [_↑⊤] : Obj → Obj [ B ↑⊤] = B [_↑⊤]-exponential : (B : Obj) → Exponential ⊤ B [ B ↑⊤]-exponential = record { B^A = [ B ↑⊤] ; product = [ B ×⊤]-product ; eval = id ; λg = λ {X} p g → g ∘ repack [ X ×⊤]-product p ; β = λ {X} p {g} → begin id ∘ (g ∘ [ p ]⟨ id , ! ⟩) ∘ [ p ]π₁ ↓⟨ identityˡ ⟩ (g ∘ [ p ]⟨ id , ! ⟩) ∘ [ p ]π₁ ↓⟨ assoc ⟩ g ∘ [ p ]⟨ id , ! ⟩ ∘ [ p ]π₁ ↓⟨ refl ⟩∘⟨ Product.⟨⟩∘ p ⟩ g ∘ [ p ]⟨ id ∘ [ p ]π₁ , ! ∘ [ p ]π₁ ⟩ ↓⟨ refl ⟩∘⟨ Product.⟨⟩-cong₂ p identityˡ (!-unique₂ (! ∘ [ p ]π₁) [ p ]π₂) ⟩ g ∘ [ p ]⟨ [ p ]π₁ , [ p ]π₂ ⟩ ↓⟨ refl ⟩∘⟨ Product.η p ⟩ g ∘ id ↓⟨ identityʳ ⟩ g ∎ ; λ-unique = λ{X} p {g}{h} h-commutes → begin h ↑⟨ identityʳ ⟩ h ∘ id ↑⟨ refl ⟩∘⟨ Product.commute₁ p ⟩ h ∘ [ p ]π₁ ∘ [ p ]⟨ id , ! ⟩ ↑⟨ assoc ⟩ (h ∘ [ p ]π₁) ∘ [ p ]⟨ id , ! ⟩ ↑⟨ identityˡ ⟩∘⟨ refl ⟩ (id ∘ h ∘ [ p ]π₁) ∘ [ p ]⟨ id , ! ⟩ ↓⟨ h-commutes ⟩∘⟨ refl ⟩ g ∘ repack [ X ×⊤]-product p ∎ } where open HomReasoning open Equiv [⊤↑_] : Obj → Obj [⊤↑ B ] = ⊤ [⊤↑_]-exponential : (A : Obj) → Exponential A ⊤ [⊤↑ A ]-exponential = record { B^A = [⊤↑ A ] ; product = [⊤× A ]-product ; eval = ! ; λg = λ _ _ → ! ; β = λ _ → !-unique₂ _ _ ; λ-unique = λ _ _ → !-unique₂ _ _ }
{ "alphanum_fraction": 0.4604118993, "avg_line_length": 27.3125, "ext": "agda", "hexsha": "c8fe885d01ea224f38a58bdfdb7f2c934caef1a5", "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/Object/Terminal/Exponentials.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/Object/Terminal/Exponentials.agda", "max_line_length": 84, "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/Object/Terminal/Exponentials.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": 869, "size": 2185 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Groups.Definition open import Setoids.Setoids open import Sets.EquivalenceRelations open import Groups.Subgroups.Normal.Definition module Groups.Subgroups.Normal.Examples {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} (G : Group S _+_) where open import Groups.Subgroups.Examples G open Setoid S open Equivalence eq open Group G trivialSubgroupIsNormal : normalSubgroup G trivialSubgroup trivialSubgroupIsNormal {g} k=0 = transitive (+WellDefined reflexive (transitive (+WellDefined k=0 reflexive) identLeft)) (invRight {g}) improperSubgroupIsNormal : normalSubgroup G improperSubgroup improperSubgroupIsNormal _ = record {}
{ "alphanum_fraction": 0.7676056338, "avg_line_length": 33.8095238095, "ext": "agda", "hexsha": "75e62319f40de41a01c3ac989ae48724a52e1b18", "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": "Groups/Subgroups/Normal/Examples.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": "Groups/Subgroups/Normal/Examples.agda", "max_line_length": 136, "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": "Groups/Subgroups/Normal/Examples.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": 197, "size": 710 }
module Isomorphism where import Sets open Sets infix 20 _≅_ data _≅_ (A B : Set) : Set where iso : (i : A -> B)(j : B -> A) -> (forall x -> j (i x) == x) -> (forall y -> i (j y) == y) -> A ≅ B refl-≅ : (A : Set) -> A ≅ A refl-≅ A = iso id id (\x -> refl) (\x -> refl) iso[×] : {A₁ A₂ B₁ B₂ : Set} -> A₁ ≅ A₂ -> B₁ ≅ B₂ -> A₁ [×] B₁ ≅ A₂ [×] B₂ iso[×] (iso a₁₂ a₂₁ p₁₁ p₂₂) (iso b₁₂ b₂₁ q₁₁ q₂₂) = iso ab₁₂ ab₂₁ pq₁₁ pq₂₂ where ab₁₂ = a₁₂ <×> b₁₂ ab₂₁ = a₂₁ <×> b₂₁ pq₂₂ : (z : _ [×] _) -> ab₁₂ (ab₂₁ z) == z pq₂₂ < x , y > = subst (\ ∙ -> < ∙ , b₁₂ (b₂₁ y) > == < x , y >) (p₂₂ x) $ cong < x ,∙> (q₂₂ y) pq₁₁ : (z : _ [×] _) -> ab₂₁ (ab₁₂ z) == z pq₁₁ < x , y > = subst (\ ∙ -> < ∙ , b₂₁ (b₁₂ y) > == < x , y >) (p₁₁ x) $ cong < x ,∙> (q₁₁ y) iso[+] : {A₁ A₂ B₁ B₂ : Set} -> A₁ ≅ A₂ -> B₁ ≅ B₂ -> A₁ [+] B₁ ≅ A₂ [+] B₂ iso[+] (iso a₁₂ a₂₁ p₁₁ p₂₂) (iso b₁₂ b₂₁ q₁₁ q₂₂) = iso ab₁₂ ab₂₁ pq₁₁ pq₂₂ where ab₁₂ = a₁₂ <+> b₁₂ ab₂₁ = a₂₁ <+> b₂₁ pq₂₂ : (z : _ [+] _) -> ab₁₂ (ab₂₁ z) == z pq₂₂ (inl x) = cong inl (p₂₂ x) pq₂₂ (inr y) = cong inr (q₂₂ y) pq₁₁ : (z : _ [+] _) -> ab₂₁ (ab₁₂ z) == z pq₁₁ (inl x) = cong inl (p₁₁ x) pq₁₁ (inr y) = cong inr (q₁₁ y)
{ "alphanum_fraction": 0.4321179209, "avg_line_length": 25.78, "ext": "agda", "hexsha": "91f9fecdf1f6af52dba068e8d287c9e0f622381c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/clowns/Isomorphism.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": "examples/outdated-and-incorrect/clowns/Isomorphism.agda", "max_line_length": 77, "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": "examples/outdated-and-incorrect/clowns/Isomorphism.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": 679, "size": 1289 }
{-# OPTIONS --cubical --no-import-sorts #-} module MoreLogic where -- hProp logic open import MoreLogic.Reasoning public open import MoreLogic.Definitions public open import MoreLogic.Properties public
{ "alphanum_fraction": 0.7941176471, "avg_line_length": 25.5, "ext": "agda", "hexsha": "207f590394c1e603bf5915ea80bfd786ea06f4ab", "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": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/MoreLogic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "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": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/MoreLogic.agda", "max_line_length": 43, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/MoreLogic.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 46, "size": 204 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Reflexivity {{eqrel : EqRelSet}} where open import Definition.Untyped open import Definition.Typed open import Definition.LogicalRelation open import Tools.Embedding open import Tools.Product import Tools.PropositionalEquality as PE -- Reflexivity of reducible types. reflEq : ∀ {l Γ A} ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ A ≡ A / [A] reflEq (Uᵣ′ l′ l< ⊢Γ) = (U₌ PE.refl) reflEq (ℕᵣ D) = ιx (ℕ₌ (red D)) reflEq (ne′ K [ ⊢A , ⊢B , D ] neK K≡K) = ιx (ne₌ _ [ ⊢A , ⊢B , D ] neK K≡K) reflEq (Πᵣ′ F G [ ⊢A , ⊢B , D ] ⊢F ⊢G A≡A [F] [G] G-ext) = Π₌ _ _ D A≡A (λ ρ ⊢Δ → reflEq ([F] ρ ⊢Δ)) (λ ρ ⊢Δ [a] → reflEq ([G] ρ ⊢Δ [a])) reflEq (emb′ 0<1 [A]) = ιx (reflEq [A]) reflNatural-prop : ∀ {Γ n} → Natural-prop Γ n → [Natural]-prop Γ n n reflNatural-prop (sucᵣ (ℕₜ n d t≡t prop)) = sucᵣ (ℕₜ₌ n n d d t≡t (reflNatural-prop prop)) reflNatural-prop zeroᵣ = zeroᵣ reflNatural-prop (ne (neNfₜ neK ⊢k k≡k)) = ne (neNfₜ₌ neK neK k≡k) -- Reflexivity of reducible terms. reflEqTerm : ∀ {l Γ A t} ([A] : Γ ⊩⟨ l ⟩ A) → Γ ⊩⟨ l ⟩ t ∷ A / [A] → Γ ⊩⟨ l ⟩ t ≡ t ∷ A / [A] reflEqTerm (Uᵣ′ ⁰ 0<1 ⊢Γ) (Uₜ A d typeA A≡A [A]) = Uₜ₌ A A d d typeA typeA A≡A [A] [A] (reflEq [A]) reflEqTerm (ℕᵣ D) (ιx (ℕₜ n [ ⊢t , ⊢u , d ] t≡t prop)) = ιx (ℕₜ₌ n n [ ⊢t , ⊢u , d ] [ ⊢t , ⊢u , d ] t≡t (reflNatural-prop prop)) reflEqTerm (ne′ K D neK K≡K) (ιx (neₜ k d (neNfₜ neK₁ ⊢k k≡k))) = ιx (neₜ₌ k k d d (neNfₜ₌ neK₁ neK₁ k≡k)) reflEqTerm (Πᵣ′ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Πₜ f d funcF f≡f [f] [f]₁) = Πₜ₌ f f d d funcF funcF f≡f (Πₜ f d funcF f≡f [f] [f]₁) (Πₜ f d funcF f≡f [f] [f]₁) (λ ρ ⊢Δ [a] → [f] ρ ⊢Δ [a] [a] (reflEqTerm ([F] ρ ⊢Δ) [a])) reflEqTerm (emb′ 0<1 [A]) (ιx t) = ιx (reflEqTerm [A] t)
{ "alphanum_fraction": 0.5409663866, "avg_line_length": 35.2592592593, "ext": "agda", "hexsha": "31f5d882f82b053ff07c428cc564542fc86a511e", "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": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Properties/Reflexivity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "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": "loic-p/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Properties/Reflexivity.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Properties/Reflexivity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 997, "size": 1904 }
open import Oscar.Prelude open import Oscar.Class.IsPrecategory open import Oscar.Class.Transitivity module Oscar.Class.Precategory where record Precategory 𝔬 𝔯 ℓ : Ø ↑̂ (𝔬 ∙̂ 𝔯 ∙̂ ℓ) where constructor ∁ infix 4 _∼̇_ field {𝔒} : Ø 𝔬 _∼_ : 𝔒 → 𝔒 → Ø 𝔯 _∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ _↦_ : Transitivity.type _∼_ ⦃ `IsPrecategory ⦄ : IsPrecategory _∼_ _∼̇_ _↦_
{ "alphanum_fraction": 0.6183206107, "avg_line_length": 23.1176470588, "ext": "agda", "hexsha": "d0afccfbfa6f68adec2b7f43f1dc521223a90b26", "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/Precategory.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/Precategory.agda", "max_line_length": 51, "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/Precategory.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 185, "size": 393 }
------------------------------------------------------------------------ -- Fixity and associativity ------------------------------------------------------------------------ module RecursiveDescent.Hybrid.Mixfix.Fixity where open import Data.Fin using (Fin; zero; suc; #_) open import Data.Fin.Props using (eq?) open import Relation.Nullary open import Relation.Binary open import Relation.Binary.PropositionalEquality data Associativity : Set where left : Associativity right : Associativity non : Associativity -- A combination of fixity and associativity. Only infix operators -- have associativity. -- Note that infix is a reserved word. data Fixity : Set where prefx : Fixity infx : (assoc : Associativity) -> Fixity postfx : Fixity closed : Fixity Fixity-is-finite : LeftInverse Fixity (Fin 6) Fixity-is-finite = record { from = from ; to = to ; left-inverse = left-inverse } where to : Fixity -> Fin 6 to prefx = # 0 to (infx left) = # 1 to (infx right) = # 2 to (infx non) = # 3 to postfx = # 4 to closed = # 5 from : Fin 6 -> Fixity from zero = prefx from (suc zero) = infx left from (suc (suc zero)) = infx right from (suc (suc (suc zero))) = infx non from (suc (suc (suc (suc zero)))) = postfx from (suc (suc (suc (suc (suc zero))))) = closed from (suc (suc (suc (suc (suc (suc ())))))) left-inverse : from LeftInverseOf to left-inverse prefx = refl left-inverse (infx left) = refl left-inverse (infx right) = refl left-inverse (infx non) = refl left-inverse postfx = refl left-inverse closed = refl _≟_ : Decidable (_≡_ {Fixity}) _≟_ = eq? injection where open LeftInverse Fixity-is-finite
{ "alphanum_fraction": 0.5584763948, "avg_line_length": 29.125, "ext": "agda", "hexsha": "460b5a16cb0d5995c6b52280d2fd69c522b3197d", "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": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "misc/RecursiveDescent/Hybrid/Mixfix/Fixity.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": "2018-01-24T16:39:37.000Z", "max_issues_repo_issues_event_min_datetime": "2018-01-22T22:21:41.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "misc/RecursiveDescent/Hybrid/Mixfix/Fixity.agda", "max_line_length": 72, "max_stars_count": 7, "max_stars_repo_head_hexsha": "b396d35cc2cb7e8aea50b982429ee385f001aa88", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yurrriq/parser-combinators", "max_stars_repo_path": "misc/RecursiveDescent/Hybrid/Mixfix/Fixity.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-22T05:35:31.000Z", "max_stars_repo_stars_event_min_datetime": "2016-12-13T05:23:14.000Z", "num_tokens": 536, "size": 1864 }
module logic where open import Level open import Relation.Nullary open import Relation.Binary hiding (_⇔_ ) open import Data.Empty data Bool : Set where true : Bool false : Bool record _∧_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n ⊔ m) where constructor ⟪_,_⟫ field proj1 : A proj2 : B data _∨_ {n m : Level} (A : Set n) ( B : Set m ) : Set (n ⊔ m) where case1 : A → A ∨ B case2 : B → A ∨ B _⇔_ : {n m : Level } → ( A : Set n ) ( B : Set m ) → Set (n ⊔ m) _⇔_ A B = ( A → B ) ∧ ( B → A ) ∧-exch : {n m : Level} {A : Set n} { B : Set m } → A ∧ B → B ∧ A ∧-exch p = ⟪ _∧_.proj2 p , _∧_.proj1 p ⟫ ∨-exch : {n m : Level} {A : Set n} { B : Set m } → A ∨ B → B ∨ A ∨-exch (case1 x) = case2 x ∨-exch (case2 x) = case1 x contra-position : {n m : Level } {A : Set n} {B : Set m} → (A → B) → ¬ B → ¬ A contra-position {n} {m} {A} {B} f ¬b a = ¬b ( f a ) double-neg : {n : Level } {A : Set n} → A → ¬ ¬ A double-neg A notnot = notnot A double-neg2 : {n : Level } {A : Set n} → ¬ ¬ ¬ A → ¬ A double-neg2 notnot A = notnot ( double-neg A ) de-morgan : {n : Level } {A B : Set n} → A ∧ B → ¬ ( (¬ A ) ∨ (¬ B ) ) de-morgan {n} {A} {B} and (case1 ¬A) = ⊥-elim ( ¬A ( _∧_.proj1 and )) de-morgan {n} {A} {B} and (case2 ¬B) = ⊥-elim ( ¬B ( _∧_.proj2 and )) dont-or : {n m : Level} {A : Set n} { B : Set m } → A ∨ B → ¬ A → B dont-or {A} {B} (case1 a) ¬A = ⊥-elim ( ¬A a ) dont-or {A} {B} (case2 b) ¬A = b dont-orb : {n m : Level} {A : Set n} { B : Set m } → A ∨ B → ¬ B → A dont-orb {A} {B} (case2 b) ¬B = ⊥-elim ( ¬B b ) dont-orb {A} {B} (case1 a) ¬B = a infixr 130 _∧_ infixr 140 _∨_ infixr 150 _⇔_ _/\_ : Bool → Bool → Bool true /\ true = true _ /\ _ = false _\/_ : Bool → Bool → Bool false \/ false = false _ \/ _ = true not_ : Bool → Bool not true = false not false = true _<=>_ : Bool → Bool → Bool true <=> true = true false <=> false = true _ <=> _ = false open import Relation.Binary.PropositionalEquality record Bijection {n m : Level} (R : Set n) (S : Set m) : Set (n Level.⊔ m) where field fun← : S → R fun→ : R → S fiso← : (x : R) → fun← ( fun→ x ) ≡ x fiso→ : (x : S ) → fun→ ( fun← x ) ≡ x injection : {n m : Level} (R : Set n) (S : Set m) (f : R → S ) → Set (n Level.⊔ m) injection R S f = (x y : R) → f x ≡ f y → x ≡ y ¬t=f : (t : Bool ) → ¬ ( not t ≡ t) ¬t=f true () ¬t=f false () infixr 130 _\/_ infixr 140 _/\_ ≡-Bool-func : {A B : Bool } → ( A ≡ true → B ≡ true ) → ( B ≡ true → A ≡ true ) → A ≡ B ≡-Bool-func {true} {true} a→b b→a = refl ≡-Bool-func {false} {true} a→b b→a with b→a refl ... | () ≡-Bool-func {true} {false} a→b b→a with a→b refl ... | () ≡-Bool-func {false} {false} a→b b→a = refl bool-≡-? : (a b : Bool) → Dec ( a ≡ b ) bool-≡-? true true = yes refl bool-≡-? true false = no (λ ()) bool-≡-? false true = no (λ ()) bool-≡-? false false = yes refl ¬-bool-t : {a : Bool} → ¬ ( a ≡ true ) → a ≡ false ¬-bool-t {true} ne = ⊥-elim ( ne refl ) ¬-bool-t {false} ne = refl ¬-bool-f : {a : Bool} → ¬ ( a ≡ false ) → a ≡ true ¬-bool-f {true} ne = refl ¬-bool-f {false} ne = ⊥-elim ( ne refl ) ¬-bool : {a : Bool} → a ≡ false → a ≡ true → ⊥ ¬-bool refl () lemma-∧-0 : {a b : Bool} → a /\ b ≡ true → a ≡ false → ⊥ lemma-∧-0 {true} {true} refl () lemma-∧-0 {true} {false} () lemma-∧-0 {false} {true} () lemma-∧-0 {false} {false} () lemma-∧-1 : {a b : Bool} → a /\ b ≡ true → b ≡ false → ⊥ lemma-∧-1 {true} {true} refl () lemma-∧-1 {true} {false} () lemma-∧-1 {false} {true} () lemma-∧-1 {false} {false} () bool-and-tt : {a b : Bool} → a ≡ true → b ≡ true → ( a /\ b ) ≡ true bool-and-tt refl refl = refl bool-∧→tt-0 : {a b : Bool} → ( a /\ b ) ≡ true → a ≡ true bool-∧→tt-0 {true} {true} refl = refl bool-∧→tt-0 {false} {_} () bool-∧→tt-1 : {a b : Bool} → ( a /\ b ) ≡ true → b ≡ true bool-∧→tt-1 {true} {true} refl = refl bool-∧→tt-1 {true} {false} () bool-∧→tt-1 {false} {false} () bool-or-1 : {a b : Bool} → a ≡ false → ( a \/ b ) ≡ b bool-or-1 {false} {true} refl = refl bool-or-1 {false} {false} refl = refl bool-or-2 : {a b : Bool} → b ≡ false → (a \/ b ) ≡ a bool-or-2 {true} {false} refl = refl bool-or-2 {false} {false} refl = refl bool-or-3 : {a : Bool} → ( a \/ true ) ≡ true bool-or-3 {true} = refl bool-or-3 {false} = refl bool-or-31 : {a b : Bool} → b ≡ true → ( a \/ b ) ≡ true bool-or-31 {true} {true} refl = refl bool-or-31 {false} {true} refl = refl bool-or-4 : {a : Bool} → ( true \/ a ) ≡ true bool-or-4 {true} = refl bool-or-4 {false} = refl bool-or-41 : {a b : Bool} → a ≡ true → ( a \/ b ) ≡ true bool-or-41 {true} {b} refl = refl bool-and-1 : {a b : Bool} → a ≡ false → (a /\ b ) ≡ false bool-and-1 {false} {b} refl = refl bool-and-2 : {a b : Bool} → b ≡ false → (a /\ b ) ≡ false bool-and-2 {true} {false} refl = refl bool-and-2 {false} {false} refl = refl
{ "alphanum_fraction": 0.5022643063, "avg_line_length": 28.0809248555, "ext": "agda", "hexsha": "31d19632181f2dc8f0f19464b4439ed34a914000", "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": "64d5f1ec0a6d81b7b9c45a289f669bbf32c9c891", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/HyperReal-in-agda", "max_forks_repo_path": "src/logic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "64d5f1ec0a6d81b7b9c45a289f669bbf32c9c891", "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": "shinji-kono/HyperReal-in-agda", "max_issues_repo_path": "src/logic.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "64d5f1ec0a6d81b7b9c45a289f669bbf32c9c891", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/HyperReal-in-agda", "max_stars_repo_path": "src/logic.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2163, "size": 4858 }
{-# OPTIONS --safe #-} module Cubical.Categories.Instances.Semilattice where open import Cubical.Foundations.Prelude open import Cubical.Algebra.Semilattice open import Cubical.Categories.Category open import Cubical.Categories.Instances.Poset open Category module _ {ℓ} (L : Semilattice ℓ) where open MeetSemilattice L SemilatticeCategory : Category ℓ ℓ SemilatticeCategory = PosetCategory IndPoset
{ "alphanum_fraction": 0.803874092, "avg_line_length": 21.7368421053, "ext": "agda", "hexsha": "86cdd6418a27903748b76db1172895567e213d4e", "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": "63c770b381039c0132c17d7913f4566b35984701", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mzeuner/cubical", "max_forks_repo_path": "Cubical/Categories/Instances/Semilattice.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "63c770b381039c0132c17d7913f4566b35984701", "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": "mzeuner/cubical", "max_issues_repo_path": "Cubical/Categories/Instances/Semilattice.agda", "max_line_length": 53, "max_stars_count": null, "max_stars_repo_head_hexsha": "63c770b381039c0132c17d7913f4566b35984701", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mzeuner/cubical", "max_stars_repo_path": "Cubical/Categories/Instances/Semilattice.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 108, "size": 413 }
-- Andreas, 2013-03-22 module Issue473a where data D : Set where d : D data P : D → Set where p : P d record Rc : Set where constructor c field f : D works : {r : Rc} → P (Rc.f r) → Set works p = D works' : (r : Rc) → P (Rc.f r) → Set works' (c .d) p = D -- We remove the constructor: record R : Set where field f : D test : {r : R} → P (R.f r) → Set test p = D
{ "alphanum_fraction": 0.5605263158, "avg_line_length": 14.0740740741, "ext": "agda", "hexsha": "f2d12f0e443dd7b13dcc32b11c536f62f4e6a5bc", "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/Issue473a.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/Issue473a.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/Succeed/Issue473a.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": 151, "size": 380 }
-- Ad-hoc monoid typeclass module module Utils.Monoid where open import Data.List open import Data.String record Monoid {α}(A : Set α) : Set α where constructor rec field append : A → A → A identity : A infixr 5 _<>_ _<>_ : ∀ {α}{A : Set α} ⦃ _ : Monoid A ⦄ → A → A → A _<>_ ⦃ dict ⦄ a b = Monoid.append dict a b mempty : ∀ {α}{A : Set α} ⦃ _ : Monoid A ⦄ → A mempty ⦃ dict ⦄ = Monoid.identity dict instance MonoidList : ∀ {α A} → Monoid {α} (List A) MonoidList = rec Data.List._++_ [] MonoidString : Monoid String MonoidString = rec Data.String._++_ ""
{ "alphanum_fraction": 0.6095076401, "avg_line_length": 20.3103448276, "ext": "agda", "hexsha": "1198c5b1ba1cee854f6c36f3c35416b9bf5d68dd", "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": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_forks_repo_path": "Utils/Monoid.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "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": "AndrasKovacs/SemanticsWithApplications", "max_issues_repo_path": "Utils/Monoid.agda", "max_line_length": 52, "max_stars_count": 8, "max_stars_repo_head_hexsha": "05200d60b4a4b2c6fa37806ced9247055d24db94", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AndrasKovacs/SemanticsWithApplications", "max_stars_repo_path": "Utils/Monoid.agda", "max_stars_repo_stars_event_max_datetime": "2020-02-02T10:01:52.000Z", "max_stars_repo_stars_event_min_datetime": "2016-09-12T04:25:39.000Z", "num_tokens": 221, "size": 589 }
{-# OPTIONS --without-K #-} -- Exposes the core of hott module hott.core where -- The basic types of hott open import hott.core.equality public -- Equality type open import hott.core.sigma public -- Dependent pairs open import hott.core.universe public -- Universes open import hott.core.universe.pointed public -- and the pointed ones.
{ "alphanum_fraction": 0.6675324675, "avg_line_length": 29.6153846154, "ext": "agda", "hexsha": "ac3d6ace8433cc70e1bdf5b509ebfde66ce90aa0", "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": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_path": "agda/hott/core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "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": "piyush-kurur/hott", "max_issues_repo_path": "agda/hott/core.agda", "max_line_length": 63, "max_stars_count": null, "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_path": "agda/hott/core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 79, "size": 385 }
-- 2016-01-14 Andreas, issue reported by Martin Stone Davis open import Common.Equality module _ {K : Set} where record Map : Set where field unmap : K record _∉_ (k : K) (m : Map) : Set where field un∉ : Map.unmap m ≡ k pattern ∉∅ = record { un∉ = refl } not-here : ∀ {k : K} {m : Map} (k∉m : k ∉ m) → Set not-here ∉∅ = K -- WAS: internal error due to record pattern not yet treated -- for pattern synonyms.
{ "alphanum_fraction": 0.6191588785, "avg_line_length": 19.4545454545, "ext": "agda", "hexsha": "f92d62a8c9007f8b7b63390f570565a8c62e8036", "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/Issue1774.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/Issue1774.agda", "max_line_length": 60, "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/Issue1774.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": 153, "size": 428 }
open import Theory open import Categories.Category using (Category) open import Categories.Category.CartesianClosed module Soundness {o ℓ e} (𝒞 : Category o ℓ e) (CC : CartesianClosed 𝒞) {ℓ₁ ℓ₂ ℓ₃} (Th : Theory ℓ₁ ℓ₂ ℓ₃) where open Theory.Theory Th open import Semantics 𝒞 CC Sg open import Syntax open Term Sg open import Categories.Category.Cartesian 𝒞 open import Categories.Category.BinaryProducts 𝒞 open import Categories.Object.Product 𝒞 open import Categories.Object.Terminal 𝒞 using (Terminal) open Category 𝒞 open CartesianClosed CC open Cartesian cartesian open BinaryProducts products module T = Terminal terminal open import Data.Product using (Σ; Σ-syntax; proj₁; proj₂) module _ (M : Model 𝒞 CC Th) where open Structure (proj₁ M) open HomReasoning soundness : forall {Γ A} {e₁ e₂ : Γ ⊢ A} -> Γ ⊢ e₁ ≡ e₂ -> ⟦ e₁ ⟧ ≈ ⟦ e₂ ⟧ soundness-sub : forall {Γ Γ′} {γ₁ γ₂ : Γ ⊨ Γ′} -> Γ ⊨ γ₁ ≡ γ₂ -> ⟦ γ₁ ⟧S ≈ ⟦ γ₂ ⟧S soundness (ax x) = proj₂ M x soundness refl = Equiv.refl soundness (sym D) = Equiv.sym (soundness D) soundness (trans D D₁) = Equiv.trans (soundness D) (soundness D₁) soundness sub/id = identityʳ soundness sub/∙ = sym-assoc soundness (eta/Unit e) = T.!-unique ⟦ e ⟧ soundness (beta/*₁ _ e₂) = project₁ soundness (beta/*₂ e₁ _) = project₂ soundness (eta/* _) = g-η soundness (beta/=> e e′) = begin ⟦ app (abs e) e′ ⟧ ≈˘⟨ ∘-resp-≈ʳ (Equiv.trans ⁂∘⟨⟩ (⟨⟩-cong₂ identityʳ identityˡ)) ⟩ eval′ ∘ (λg ⟦ e ⟧ ⁂ Category.id 𝒞) ∘ ⟨ Category.id 𝒞 , ⟦ e′ ⟧ ⟩ ≈⟨ Equiv.trans sym-assoc (∘-resp-≈ˡ β′) ⟩ ⟦ e [ ext Term.id e′ ] ⟧ ∎ soundness (eta/=> e) = begin ⟦ abs (app (e [ weaken ]) var) ⟧ ≈˘⟨ λ-cong (∘-resp-≈ʳ (⟨⟩-cong₂ Equiv.refl identityˡ)) ⟩ λg (eval′ ∘ ⟨ ⟦ e ⟧ ∘ π₁ , Category.id 𝒞 ∘ π₂ ⟩) ≈˘⟨ λ-cong (∘-resp-≈ʳ ⁂∘⟨⟩) ⟩ λg (eval′ ∘ (⟦ e ⟧ ⁂ Category.id 𝒞) ∘ ⟨ π₁ , π₂ ⟩) ≈⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ η)) ⟩ λg (eval′ ∘ (⟦ e ⟧ ⁂ Category.id 𝒞) ∘ Category.id 𝒞) ≈⟨ λ-cong (∘-resp-≈ʳ identityʳ) ⟩ λg (eval′ ∘ (⟦ e ⟧ ⁂ Category.id 𝒞)) ≈⟨ η-exp′ ⟩ ⟦ e ⟧ ∎ soundness (comm/func _ Γ′ γ f e) = assoc soundness (comm/unit _ Γ′ γ) = Equiv.sym (T.!-unique (T.! ∘ ⟦ γ ⟧S)) soundness comm/pair = Product.∘-distribʳ-⟨⟩ product soundness comm/fst = assoc soundness comm/snd = assoc soundness (comm/abs {γ = γ} {e = e}) = begin λg ⟦ e ⟧ ∘ ⟦ γ ⟧S ≈⟨ exp.subst product product ⟩ λg (⟦ e ⟧ ∘ (⟦ γ ⟧S ⁂ Category.id 𝒞)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (Equiv.trans (∘-resp-≈ʳ η) identityʳ)) ⟩ λg (⟦ e ⟧ ∘ (⟦ γ ⟧S ⁂ Category.id 𝒞) ∘ ⟨ π₁ , π₂ ⟩) ≈⟨ λ-cong (∘-resp-≈ʳ (⁂∘⟨⟩)) ⟩ λg (⟦ e ⟧ ∘ ⟨ ⟦ γ ⟧S ∘ π₁ , Category.id 𝒞 ∘ π₂ ⟩) ≈⟨ λ-cong (∘-resp-≈ʳ (⟨⟩-cong₂ Equiv.refl identityˡ)) ⟩ λg (⟦ e ⟧ ∘ ⟨ ⟦ γ ⟧S ∘ π₁ , π₂ ⟩ ) ∎ soundness comm/app = Equiv.trans assoc (∘-resp-≈ʳ ⟨⟩∘) soundness (var/ext γ _) = project₂ soundness (cong/sub D D′) = ∘-resp-≈ (soundness D′) (soundness-sub D) soundness (cong/pair D D₁) = ⟨⟩-cong₂ (soundness D) (soundness D₁) soundness (cong/fst D) = ∘-resp-≈ʳ (soundness D) soundness (cong/snd D) = ∘-resp-≈ʳ (soundness D) soundness (cong/app D D₁) = ∘-resp-≈ʳ (⟨⟩-cong₂ (soundness D) (soundness D₁)) soundness (cong/abs D) = λ-cong (soundness D) soundness (cong/func D) = ∘-resp-≈ Equiv.refl (soundness D) soundness-sub refl = Equiv.refl soundness-sub (sym D) = Equiv.sym (soundness-sub D) soundness-sub (trans D D₁) = Equiv.trans (soundness-sub D) (soundness-sub D₁) soundness-sub (!-unique {γ = γ}) = T.!-unique ⟦ γ ⟧S soundness-sub η-pair = begin ⟨ π₁ , π₂ ⟩ ≈⟨ Product.η product ⟩ Category.id 𝒞 ∎ soundness-sub ext∙ = ⟨⟩∘ soundness-sub (cong/ext D D′) = ⟨⟩-cong₂ (soundness-sub D) (soundness D′) soundness-sub weaken/ext = project₁ soundness-sub (cong/∙ D D₁) = ∘-resp-≈ (soundness-sub D) (soundness-sub D₁) soundness-sub id∙ˡ = identityˡ soundness-sub id∙ʳ = identityʳ soundness-sub assoc∙ = assoc
{ "alphanum_fraction": 0.5628272251, "avg_line_length": 35.9145299145, "ext": "agda", "hexsha": "7aa67eff992ab895223b96304fcbc7ed17888fab", "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": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "elpinal/exsub-ccc", "max_forks_repo_path": "Soundness.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "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/exsub-ccc", "max_issues_repo_path": "Soundness.agda", "max_line_length": 81, "max_stars_count": 3, "max_stars_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "elpinal/exsub-ccc", "max_stars_repo_path": "Soundness.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T13:30:48.000Z", "max_stars_repo_stars_event_min_datetime": "2022-02-05T06:16:32.000Z", "num_tokens": 1811, "size": 4202 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics module lib.types.TwoSemiCategory where module _ {i j} {El : Type i} (Arr : El → El → Type j) (_ : ∀ x y → has-level 1 (Arr x y)) where record TwoSemiCategoryStructure : Type (lmax i j) where field comp : ∀ {x y z} → Arr x y → Arr y z → Arr x z assoc : ∀ {x y z w} (a : Arr x y) (b : Arr y z) (c : Arr z w) → comp (comp a b) c == comp a (comp b c) {- coherence -} pentagon-identity : ∀ {v w x y z} (a : Arr v w) (b : Arr w x) (c : Arr x y) (d : Arr y z) → assoc (comp a b) c d ◃∙ assoc a b (comp c d) ◃∎ =ₛ ap (λ s → comp s d) (assoc a b c) ◃∙ assoc a (comp b c) d ◃∙ ap (comp a) (assoc b c d) ◃∎ record TwoSemiCategory i j : Type (lsucc (lmax i j)) where constructor two-semi-category field El : Type i Arr : El → El → Type j Arr-level : ∀ x y → has-level 1 (Arr x y) two-semi-cat-struct : TwoSemiCategoryStructure Arr Arr-level open TwoSemiCategoryStructure two-semi-cat-struct public
{ "alphanum_fraction": 0.551627907, "avg_line_length": 32.5757575758, "ext": "agda", "hexsha": "bc51dbce90abc30cd06e1a5e725fb7a01efac5d9", "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": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "core/lib/types/TwoSemiCategory.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "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": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "core/lib/types/TwoSemiCategory.agda", "max_line_length": 95, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "core/lib/types/TwoSemiCategory.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": 383, "size": 1075 }
open import Categories open import Functors open import RMonads module RMonads.REM.Adjunction {a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}} {J : Fun C D}(M : RMonad J) where open import Library open import RAdjunctions open import RMonads.REM M open import RMonads.REM.Functors J M open Fun open RAdj open RAlg open RAlgMorph open RMonad M open Cat D REMAdj : RAdj J EM REMAdj = record { L = REML; R = REMR; left = λ f → comp (amor f) η; right = λ{_ B} f → record{ amor = astr B f; ahom = sym (alaw2 B)}; lawa = λ {_ Y} f → RAlgMorphEq ( proof astr Y (comp (amor f) η) ≅⟨ sym (ahom f) ⟩ comp (amor f) (bind η) ≅⟨ cong (comp (amor f)) law1 ⟩ comp (amor f) iden ≅⟨ idr ⟩ amor f ∎); lawb = λ {_ B} f → sym (alaw1 B); natleft = λ f g h → proof comp (amor g) (comp (comp (amor h) η) (HMap J f)) ≅⟨ cong (comp (amor g)) ass ⟩ comp (amor g) (comp (amor h) (comp η (HMap J f))) ≅⟨ cong (comp (amor g) ∘ comp (amor h)) (sym law2) ⟩ comp (amor g) (comp (amor h) (comp (bind (comp η (HMap J f))) η)) ≅⟨ cong (comp (amor g)) (sym ass) ⟩ comp (amor g) (comp (comp (amor h) (bind (comp η (HMap J f)))) η) ≅⟨ sym ass ⟩ comp (comp (amor g) (comp (amor h) (bind (comp η (HMap J f))))) η ∎; natright = λ{W}{X}{Y}{Z} f g h → RAlgMorphEq ( proof astr Z (comp (amor g) (comp h (HMap J f))) ≅⟨ sym (ahom g) ⟩ comp (amor g) (astr Y (comp h (HMap J f))) ≅⟨ cong (λ h₁ → comp (amor g) (astr Y (comp h₁ (HMap J f)))) (alaw1 Y) ⟩ comp (amor g) (astr Y (comp (comp (astr Y h) η) (HMap J f))) ≅⟨ cong (comp (amor g) ∘ astr Y) ass ⟩ comp (amor g) (astr Y (comp (astr Y h) (comp η (HMap J f)))) ≅⟨ cong (comp (amor g)) (alaw2 Y) ⟩ comp (amor g) (comp (astr Y h) (bind (comp η (HMap J f)))) ∎)}
{ "alphanum_fraction": 0.5239096164, "avg_line_length": 29.734375, "ext": "agda", "hexsha": "ab8f30555aaad71053fe58ff2e1d1f928a6f19e6", "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": "RMonads/REM/Adjunction.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": "RMonads/REM/Adjunction.agda", "max_line_length": 78, "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": "RMonads/REM/Adjunction.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": 804, "size": 1903 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Setoids.Setoids open import Sets.EquivalenceRelations open import Rings.Definition open import Rings.Homomorphisms.Definition open import Rings.Ideals.Definition module Rings.Homomorphisms.Kernel {a b c d : _} {A : Set a} {B : Set c} {S : Setoid {a} {b} A} {T : Setoid {c} {d} B} {_+1_ _*1_ : A → A → A} {_+2_ _*2_ : B → B → B} {R1 : Ring S _+1_ _*1_} {R2 : Ring T _+2_ _*2_} {f : A → B} (fHom : RingHom R1 R2 f) where open import Groups.Homomorphisms.Kernel (RingHom.groupHom fHom) ringKernelIsIdeal : Ideal R1 groupKernelPred Ideal.isSubgroup ringKernelIsIdeal = groupKernelIsSubgroup Ideal.accumulatesTimes ringKernelIsIdeal {x} {y} fx=0 = transitive (RingHom.ringHom fHom) (transitive (Ring.*WellDefined R2 fx=0 reflexive) (transitive (Ring.*Commutative R2) (Ring.timesZero R2))) where open Setoid T open Equivalence eq
{ "alphanum_fraction": 0.7172949002, "avg_line_length": 45.1, "ext": "agda", "hexsha": "4d4cff1940892bd55677b7e4cd24606e6e76d057", "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": "Rings/Homomorphisms/Kernel.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": "Rings/Homomorphisms/Kernel.agda", "max_line_length": 256, "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": "Rings/Homomorphisms/Kernel.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": 314, "size": 902 }
-- Andreas, 2017-07-28, issue #776 reported by p.giarusso on 30 Dec 2012 open import Agda.Primitive -- Note Set₁ instead of Set (suc l) data _:=:_ {l : Level} (A : Set l) (B : Set l) : Set₁ where proof : {F : Set l → Set l} → F A → F B → A :=: B -- WAS: no error message -- Expected: -- The type of the constructor does not fit in the sort of the -- datatype, since Set (lsuc l) is not less or equal than Set₁ -- when checking the constructor proof in the declaration of _:=:_
{ "alphanum_fraction": 0.6604554865, "avg_line_length": 32.2, "ext": "agda", "hexsha": "164534fe4b3b52688de88a05dafcb622bc3e5a42", "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/Issue776.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/Issue776.agda", "max_line_length": 72, "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/Issue776.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": 156, "size": 483 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Sn.Base where open import Cubical.HITs.Susp open import Cubical.Data.Nat open import Cubical.Data.NatMinusOne open import Cubical.Data.Empty open import Cubical.Foundations.Prelude S₊ : ℕ₋₁ → Type₀ S₊ neg1 = ⊥ S₊ (suc n) = Susp (S₊ n) S : ℕ → Type₀ S n = S₊ (ℕ→ℕ₋₁ n)
{ "alphanum_fraction": 0.6975308642, "avg_line_length": 20.25, "ext": "agda", "hexsha": "88c3ac66da7d0d0c73fe49c15a5473a5ea137442", "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/HITs/Sn/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/HITs/Sn/Base.agda", "max_line_length": 39, "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/HITs/Sn/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 125, "size": 324 }
{-# OPTIONS -v treeless:20 #-} module _ where data N : Set where zero : N suc : N → N _+_ : N → N → N zero + n = n suc m + n = suc (m + n) record P A B : Set where constructor _,_ field fst : A snd : B open P {-# INLINE fst #-} {-# INLINE snd #-} -- Without handling repeated cases: -- g = λ a → case a of b , c → b (case a of d , e → e) -- Should be -- g = λ a → case a of b , c → b c g : P (N → N) N → N g z = fst z (snd z)
{ "alphanum_fraction": 0.5111607143, "avg_line_length": 16, "ext": "agda", "hexsha": "7fe391ef18e355b7e1318bebc1f4a7015d83a27a", "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": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/eagda", "max_forks_repo_path": "test/Succeed/RepeatedCase.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "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": "asr/eagda", "max_issues_repo_path": "test/Succeed/RepeatedCase.agda", "max_line_length": 54, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/eagda", "max_stars_repo_path": "test/Succeed/RepeatedCase.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 163, "size": 448 }
import Structure.Logic.Classical.NaturalDeduction -- TODO: MAybe rename to SetBoundedQuantification module Structure.Logic.Classical.SetTheory.SetBoundedQuantification {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic : _ ⦄ (_∈_ : Domain → Domain → Formula) where open Structure.Logic.Classical.NaturalDeduction.ClassicalLogic {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} (classicLogic) open import Functional hiding (Domain) open import Lang.Instance import Lvl open import Type.Dependent open import Structure.Logic.Classical.PredicateBoundedQuantification {ℓₗ} {Formula} {ℓₘₗ} {Proof} {ℓₒ} {Domain} ⦃ classicLogic ⦄ -- Bounded universal quantifier ∀ₛ : Domain → (Domain → Formula) → Formula ∀ₛ(S)(P) = ∀ₚ(_∈ S)(P) [∀ₛ]-intro : ∀{S}{P} → (∀{x} → Proof(x ∈ S) → Proof(P(x))) → Proof(∀ₛ(S)(P)) [∀ₛ]-intro = [∀ₚ]-intro [∀ₛ]-elim : ∀{S}{P} → Proof(∀ₛ(S)(P)) → ∀{x} → Proof(x ∈ S) → Proof(P(x)) [∀ₛ]-elim = [∀ₚ]-elim -- Bounded existential quantifier ∃ₛ : Domain → (Domain → Formula) → Formula ∃ₛ(S)(P) = ∃ₚ(_∈ S)(P) [∃ₛ]-intro : ∀{S}{P}{x} → Proof(x ∈ S) → Proof(P(x)) → Proof(∃ₛ(S)(P)) [∃ₛ]-intro = [∃ₚ]-intro [∃ₛ]-elim : ∀{S}{P}{Q} → (∀{x} → Proof(x ∈ S) → Proof(P(x)) → Proof(Q)) → Proof(∃ₛ(S)(P)) → Proof(Q) [∃ₛ]-elim = [∃ₚ]-elim [∃ₛ]-witness : ∀{S : Domain}{P : Domain → Formula} → ⦃ _ : Proof(∃ₛ S P) ⦄ → Domain [∃ₛ]-witness = [∃ₚ]-witness [∃ₛ]-domain : ∀{S : Domain}{P : Domain → Formula} → ⦃ p : Proof(∃ₛ S P) ⦄ → Proof([∃ₛ]-witness{S}{P} ⦃ p ⦄ ∈ S) [∃ₛ]-domain = [∃ₚ]-bound [∃ₛ]-proof : ∀{S : Domain}{P : Domain → Formula} → ⦃ p : Proof(∃ₛ S P) ⦄ → Proof(P([∃ₛ]-witness{S}{P} ⦃ p ⦄)) [∃ₛ]-proof = [∃ₚ]-proof Uniqueₛ : Domain → (Domain → Formula) → Formula Uniqueₛ(S)(P) = Uniqueₚ(_∈ S)(P) -- Bounded unique existential quantifier ∃ₛ! : Domain → (Domain → Formula) → Formula ∃ₛ!(S)(P) = ∃ₚ!(_∈ S)(P) [∃ₛ!]-witness : ∀{S : Domain}{P : Domain → Formula} → ⦃ _ : Proof(∃ₛ! S P) ⦄ → Domain [∃ₛ!]-witness = [∃ₚ!]-witness [∃ₛ!]-domain : ∀{S : Domain}{P : Domain → Formula} → ⦃ p : Proof(∃ₛ! S P) ⦄ → Proof([∃ₛ!]-witness{S}{P} ⦃ p ⦄ ∈ S) [∃ₛ!]-domain = [∃ₚ!]-bound [∃ₛ!]-proof : ∀{S : Domain}{P : Domain → Formula} → ⦃ p : Proof(∃ₛ! S P) ⦄ → Proof(P([∃ₛ!]-witness{S}{P} ⦃ p ⦄)) [∃ₛ!]-proof = [∃ₚ!]-proof [∃ₛ!]-unique : ∀{S : Domain}{P : Domain → Formula} → ⦃ p : Proof(∃ₛ! S P) ⦄ → Proof(∀ₗ(x ↦ P(x) ⟶ (x ≡ [∃ₛ!]-witness{S}{P} ⦃ p ⦄))) [∃ₛ!]-unique = [∃ₚ!]-unique
{ "alphanum_fraction": 0.5725637808, "avg_line_length": 39.85, "ext": "agda", "hexsha": "b2c94e278dbf6147d40cf5e6422879e6eefc5e03", "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": "old/Structure/Logic/Classical/SetTheory/SetBoundedQuantification.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": "old/Structure/Logic/Classical/SetTheory/SetBoundedQuantification.agda", "max_line_length": 171, "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": "old/Structure/Logic/Classical/SetTheory/SetBoundedQuantification.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": 1153, "size": 2391 }
-- Andreas, AIM XXIII 2016-04-21 Overloaded projections -- Milestone 1: Check overloaded projections on rhs (without postponing). module _ (A : Set) (a : A) where module RecDefs where record R B : Set where field f : B open R public record S B : Set where field f : B open S public record T B : Set where field f : B → B open T public open RecDefs public r : R A R.f r = a s : S A S.f s = f r t : R A → S A S.f (t r) = f r u : _ u = f s v = f s w : ∀{A} → T A → A → A w t x = f t x
{ "alphanum_fraction": 0.5857418112, "avg_line_length": 13.3076923077, "ext": "agda", "hexsha": "342e0dffa82548de24ce8323a588fc656b558816", "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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_path": "test/Succeed/Issue1944-1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "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": "pthariensflame/agda", "max_issues_repo_path": "test/Succeed/Issue1944-1.agda", "max_line_length": 73, "max_stars_count": 3, "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_path": "test/Succeed/Issue1944-1.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": 192, "size": 519 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Non-empty lists ------------------------------------------------------------------------ module Data.List.NonEmpty where open import Category.Monad open import Data.Bool open import Data.Bool.Properties open import Data.List as List using (List; []; _∷_) open import Data.Maybe using (nothing; just) open import Data.Nat as Nat open import Data.Product using (∃; proj₁; proj₂; _,_; ,_) open import Data.Sum as Sum using (_⊎_; inj₁; inj₂) open import Data.Unit open import Data.Vec as Vec using (Vec; []; _∷_) open import Function open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence using () renaming (module Equivalence to Eq) open import Relation.Binary.PropositionalEquality as P using (_≡_; refl) open import Relation.Nullary.Decidable using (⌊_⌋) ------------------------------------------------------------------------ -- Non-empty lists infixr 5 _∷_ record List⁺ {a} (A : Set a) : Set a where constructor _∷_ field head : A tail : List A open List⁺ public [_] : ∀ {a} {A : Set a} → A → List⁺ A [ x ] = x ∷ [] infixr 5 _∷⁺_ _∷⁺_ : ∀ {a} {A : Set a} → A → List⁺ A → List⁺ A x ∷⁺ y ∷ xs = x ∷ y ∷ xs length : ∀ {a} {A : Set a} → List⁺ A → ℕ length (x ∷ xs) = suc (List.length xs) ------------------------------------------------------------------------ -- Conversion toList : ∀ {a} {A : Set a} → List⁺ A → List A toList (x ∷ xs) = x ∷ xs fromVec : ∀ {n a} {A : Set a} → Vec A (suc n) → List⁺ A fromVec (x ∷ xs) = x ∷ Vec.toList xs toVec : ∀ {a} {A : Set a} (xs : List⁺ A) → Vec A (length xs) toVec (x ∷ xs) = x ∷ Vec.fromList xs lift : ∀ {a b} {A : Set a} {B : Set b} → (∀ {m} → Vec A (suc m) → ∃ λ n → Vec B (suc n)) → List⁺ A → List⁺ B lift f xs = fromVec (proj₂ (f (toVec xs))) ------------------------------------------------------------------------ -- Other operations map : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → List⁺ A → List⁺ B map f (x ∷ xs) = (f x ∷ List.map f xs) -- Right fold. Note that s is only applied to the last element (see -- the examples below). foldr : ∀ {a b} {A : Set a} {B : Set b} → (A → B → B) → (A → B) → List⁺ A → B foldr {A = A} {B} c s (x ∷ xs) = foldr′ x xs where foldr′ : A → List A → B foldr′ x [] = s x foldr′ x (y ∷ xs) = c x (foldr′ y xs) -- Left fold. Note that s is only applied to the first element (see -- the examples below). foldl : ∀ {a b} {A : Set a} {B : Set b} → (B → A → B) → (A → B) → List⁺ A → B foldl c s (x ∷ xs) = List.foldl c (s x) xs -- Append (several variants). infixr 5 _⁺++⁺_ _++⁺_ _⁺++_ _⁺++⁺_ : ∀ {a} {A : Set a} → List⁺ A → List⁺ A → List⁺ A (x ∷ xs) ⁺++⁺ (y ∷ ys) = x ∷ (xs List.++ y ∷ ys) _⁺++_ : ∀ {a} {A : Set a} → List⁺ A → List A → List⁺ A (x ∷ xs) ⁺++ ys = x ∷ (xs List.++ ys) _++⁺_ : ∀ {a} {A : Set a} → List A → List⁺ A → List⁺ A xs ++⁺ ys = List.foldr _∷⁺_ ys xs concat : ∀ {a} {A : Set a} → List⁺ (List⁺ A) → List⁺ A concat (xs ∷ xss) = xs ⁺++ List.concat (List.map toList xss) monad : ∀ {f} → RawMonad (List⁺ {a = f}) monad = record { return = [_] ; _>>=_ = λ xs f → concat (map f xs) } reverse : ∀ {a} {A : Set a} → List⁺ A → List⁺ A reverse = lift (,_ ∘′ Vec.reverse) -- Snoc. infixl 5 _∷ʳ_ _⁺∷ʳ_ _∷ʳ_ : ∀ {a} {A : Set a} → List A → A → List⁺ A [] ∷ʳ y = [ y ] (x ∷ xs) ∷ʳ y = x ∷ (xs List.∷ʳ y) _⁺∷ʳ_ : ∀ {a} {A : Set a} → List⁺ A → A → List⁺ A xs ⁺∷ʳ x = toList xs ∷ʳ x -- A snoc-view of non-empty lists. infixl 5 _∷ʳ′_ data SnocView {a} {A : Set a} : List⁺ A → Set a where _∷ʳ′_ : (xs : List A) (x : A) → SnocView (xs ∷ʳ x) snocView : ∀ {a} {A : Set a} (xs : List⁺ A) → SnocView xs snocView (x ∷ xs) with List.initLast xs snocView (x ∷ .[]) | [] = [] ∷ʳ′ x snocView (x ∷ .(xs List.∷ʳ y)) | xs List.∷ʳ' y = (x ∷ xs) ∷ʳ′ y -- The last element in the list. last : ∀ {a} {A : Set a} → List⁺ A → A last xs with snocView xs last .(ys ∷ʳ y) | ys ∷ʳ′ y = y -- Groups all contiguous elements for which the predicate returns the -- same result into lists. split : ∀ {a} {A : Set a} (p : A → Bool) → List A → List (List⁺ (∃ (T ∘ p)) ⊎ List⁺ (∃ (T ∘ not ∘ p))) split p [] = [] split p (x ∷ xs) with p x | P.inspect p x | split p xs ... | true | P.[ px≡t ] | inj₁ xs′ ∷ xss = inj₁ ((x , Eq.from T-≡ ⟨$⟩ px≡t) ∷⁺ xs′) ∷ xss ... | true | P.[ px≡t ] | xss = inj₁ [ x , Eq.from T-≡ ⟨$⟩ px≡t ] ∷ xss ... | false | P.[ px≡f ] | inj₂ xs′ ∷ xss = inj₂ ((x , Eq.from T-not-≡ ⟨$⟩ px≡f) ∷⁺ xs′) ∷ xss ... | false | P.[ px≡f ] | xss = inj₂ [ x , Eq.from T-not-≡ ⟨$⟩ px≡f ] ∷ xss -- If we flatten the list returned by split, then we get the list we -- started with. flatten : ∀ {a p q} {A : Set a} {P : A → Set p} {Q : A → Set q} → List (List⁺ (∃ P) ⊎ List⁺ (∃ Q)) → List A flatten = List.concat ∘ List.map Sum.[ toList ∘ map proj₁ , toList ∘ map proj₁ ] flatten-split : ∀ {a} {A : Set a} (p : A → Bool) (xs : List A) → flatten (split p xs) ≡ xs flatten-split p [] = refl flatten-split p (x ∷ xs) with p x | P.inspect p x | split p xs | flatten-split p xs ... | true | P.[ _ ] | [] | hyp = P.cong (_∷_ x) hyp ... | true | P.[ _ ] | inj₁ _ ∷ _ | hyp = P.cong (_∷_ x) hyp ... | true | P.[ _ ] | inj₂ _ ∷ _ | hyp = P.cong (_∷_ x) hyp ... | false | P.[ _ ] | [] | hyp = P.cong (_∷_ x) hyp ... | false | P.[ _ ] | inj₁ _ ∷ _ | hyp = P.cong (_∷_ x) hyp ... | false | P.[ _ ] | inj₂ _ ∷ _ | hyp = P.cong (_∷_ x) hyp -- Groups all contiguous elements /not/ satisfying the predicate into -- lists. Elements satisfying the predicate are dropped. wordsBy : ∀ {a} {A : Set a} → (A → Bool) → List A → List (List⁺ A) wordsBy p = List.gfilter Sum.[ const nothing , just ∘′ map proj₁ ] ∘ split p ------------------------------------------------------------------------ -- Examples -- Note that these examples are simple unit tests, because the type -- checker verifies them. private module Examples {A B : Set} (_⊕_ : A → B → B) (_⊗_ : B → A → B) (f : A → B) (a b c : A) where hd : head (a ∷⁺ b ∷⁺ [ c ]) ≡ a hd = refl tl : tail (a ∷⁺ b ∷⁺ [ c ]) ≡ b ∷ c ∷ [] tl = refl mp : map f (a ∷⁺ b ∷⁺ [ c ]) ≡ f a ∷⁺ f b ∷⁺ [ f c ] mp = refl right : foldr _⊕_ f (a ∷⁺ b ∷⁺ [ c ]) ≡ a ⊕ (b ⊕ f c) right = refl left : foldl _⊗_ f (a ∷⁺ b ∷⁺ [ c ]) ≡ (f a ⊗ b) ⊗ c left = refl ⁺app⁺ : (a ∷⁺ b ∷⁺ [ c ]) ⁺++⁺ (b ∷⁺ [ c ]) ≡ a ∷⁺ b ∷⁺ c ∷⁺ b ∷⁺ [ c ] ⁺app⁺ = refl ⁺app : (a ∷⁺ b ∷⁺ [ c ]) ⁺++ (b ∷ c ∷ []) ≡ a ∷⁺ b ∷⁺ c ∷⁺ b ∷⁺ [ c ] ⁺app = refl app⁺ : (a ∷ b ∷ c ∷ []) ++⁺ (b ∷⁺ [ c ]) ≡ a ∷⁺ b ∷⁺ c ∷⁺ b ∷⁺ [ c ] app⁺ = refl conc : concat ((a ∷⁺ b ∷⁺ [ c ]) ∷⁺ [ b ∷⁺ [ c ] ]) ≡ a ∷⁺ b ∷⁺ c ∷⁺ b ∷⁺ [ c ] conc = refl rev : reverse (a ∷⁺ b ∷⁺ [ c ]) ≡ c ∷⁺ b ∷⁺ [ a ] rev = refl snoc : (a ∷ b ∷ c ∷ []) ∷ʳ a ≡ a ∷⁺ b ∷⁺ c ∷⁺ [ a ] snoc = refl snoc⁺ : (a ∷⁺ b ∷⁺ [ c ]) ⁺∷ʳ a ≡ a ∷⁺ b ∷⁺ c ∷⁺ [ a ] snoc⁺ = refl split-true : split (const true) (a ∷ b ∷ c ∷ []) ≡ inj₁ ((a , tt) ∷⁺ (b , tt) ∷⁺ [ c , tt ]) ∷ [] split-true = refl split-false : split (const false) (a ∷ b ∷ c ∷ []) ≡ inj₂ ((a , tt) ∷⁺ (b , tt) ∷⁺ [ c , tt ]) ∷ [] split-false = refl split-≡1 : split (λ n → ⌊ n Nat.≟ 1 ⌋) (1 ∷ 2 ∷ 3 ∷ 1 ∷ 1 ∷ 2 ∷ 1 ∷ []) ≡ inj₁ [ 1 , tt ] ∷ inj₂ ((2 , tt) ∷⁺ [ 3 , tt ]) ∷ inj₁ ((1 , tt) ∷⁺ [ 1 , tt ]) ∷ inj₂ [ 2 , tt ] ∷ inj₁ [ 1 , tt ] ∷ [] split-≡1 = refl wordsBy-true : wordsBy (const true) (a ∷ b ∷ c ∷ []) ≡ [] wordsBy-true = refl wordsBy-false : wordsBy (const false) (a ∷ b ∷ c ∷ []) ≡ (a ∷⁺ b ∷⁺ [ c ]) ∷ [] wordsBy-false = refl wordsBy-≡1 : wordsBy (λ n → ⌊ n Nat.≟ 1 ⌋) (1 ∷ 2 ∷ 3 ∷ 1 ∷ 1 ∷ 2 ∷ 1 ∷ []) ≡ (2 ∷⁺ [ 3 ]) ∷ [ 2 ] ∷ [] wordsBy-≡1 = refl
{ "alphanum_fraction": 0.4497936726, "avg_line_length": 30.0639097744, "ext": "agda", "hexsha": "542a04157abf2d0fc707d4347f2cb3495a3a886c", "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/List/NonEmpty.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/List/NonEmpty.agda", "max_line_length": 94, "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/List/NonEmpty.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": 3398, "size": 7997 }
open import Relation.Binary using (IsDecEquivalence) open import Agda.Builtin.Equality module UnifyWith (FunctionName : Set) ⦃ isDecEquivalenceA : IsDecEquivalence (_≡_ {A = FunctionName}) ⦄ where open import UnifyTermF FunctionName open import UnifyMguF FunctionName open import UnifyMguCorrectF FunctionName open import Data.Fin using (Fin; suc; zero) open import Data.Nat hiding (_≤_) open import Relation.Binary.PropositionalEquality renaming ([_] to [[_]]) open import Function using (_∘_; id; case_of_; _$_; flip) open import Relation.Nullary open import Data.Product renaming (map to _***_) open import Data.Empty open import Data.Maybe open import Category.Functor open import Category.Monad import Level open RawMonad (Data.Maybe.monad {Level.zero}) open import Data.Sum open import Data.Maybe using (maybe; maybe′; nothing; just; monad; Maybe) open import Data.List renaming (_++_ to _++L_) open ≡-Reasoning open import Data.Vec using (Vec; []; _∷_) renaming (_++_ to _++V_; map to mapV) open import Data.Unit -- moved to UnifyMguCorrectF
{ "alphanum_fraction": 0.7727272727, "avg_line_length": 32, "ext": "agda", "hexsha": "1c58da252d9a77f4466f73dd7e267d381f423a76", "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-1/UnifyWith.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-1/UnifyWith.agda", "max_line_length": 109, "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-1/UnifyWith.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 286, "size": 1056 }
{-# OPTIONS --without-K --safe #-} module Data.Quiver.Morphism where -- Morphism of Quivers, as well as some useful kit (identity, composition, equivalence) -- also define map on paths, and that it behaves well wrt morphisms and morphism equivalence. -- See the further comments around the definition of equivalence, as that is quite the -- mine field. open import Level open import Function using () renaming (id to idFun; _∘_ to _⊚_) open import Data.Quiver open import Data.Quiver.Paths using (module Paths) open import Relation.Binary using (IsEquivalence; Reflexive; Symmetric; Transitive) open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (Star; gmap; ε; _◅_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; naturality) open import Relation.Binary.PropositionalEquality.Properties using (trans-symʳ; trans-symˡ) open import Relation.Binary.PropositionalEquality.Subst.Properties using (module Shorthands; module Transport; module TransportOverQ; module TransportMor; module TransportStar) infix 4 _≃_ private variable o o′ ℓ ℓ′ e e′ : Level -- A Morphism of Quivers. As this is meant to be used as the underlying part of a -- Category, the fields should be named the same as for Functor. record Morphism (G : Quiver o ℓ e) (G′ : Quiver o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where private module G = Quiver G module G′ = Quiver G′ field F₀ : G.Obj → G′.Obj F₁ : ∀ {A B} → A G.⇒ B → F₀ A G′.⇒ F₀ B F-resp-≈ : ∀ {A B} {f g : A G.⇒ B} → f G.≈ g → F₁ f G′.≈ F₁ g id : {G : Quiver o ℓ e} → Morphism G G id = record { F₀ = idFun ; F₁ = idFun ; F-resp-≈ = idFun } _∘_ : {G₁ G₂ G₃ : Quiver o ℓ e} (m₁ : Morphism G₂ G₃) (m₂ : Morphism G₁ G₂) → Morphism G₁ G₃ m₁ ∘ m₂ = record { F₀ = F₀ m₁ ⊚ F₀ m₂ ; F₁ = F₁ m₁ ⊚ F₁ m₂ ; F-resp-≈ = F-resp-≈ m₁ ⊚ F-resp-≈ m₂ } where open Morphism -- Morphism equivalence. Note how it is mixed, with -- propositional equivalence mixed with edge-setoid equivalence. -- Ideally, we'd like something weaker, aking to natural isomorphism here. -- However, there is no notion of composition (nor identity) for edges, so that -- doesn't work (no commuting squares in quivers, so the naturality condition cannot -- be written down). So one choice that works is to be strict. Note that introducing -- node equality might work too, but that would be even further from the notion of -- category used here, so that we could not reasonably end up with an adjoint. record _≃_ {G : Quiver o ℓ e} {G′ : Quiver o′ ℓ′ e′} (M M′ : Morphism G G′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where open Quiver G using (_⇒_) open Quiver G′ using (_≈_) private module M = Morphism M module M′ = Morphism M′ open Shorthands (Quiver._⇒_ G′) -- Pick a presentation of equivalence for graph morphisms that works -- well with functor equality. field F₀≡ : ∀ {X} → M.F₀ X ≡ M′.F₀ X F₁≡ : ∀ {A B} {f : A ⇒ B} → M.F₁ f ▸ F₀≡ ≈ F₀≡ ◂ M′.F₁ f -- Prove that ≃ is an equivalence relation module _ {G : Quiver o ℓ e} {G′ : Quiver o′ ℓ′ e′} where open Quiver open Morphism open _≃_ private ≃-refl : Reflexive {A = Morphism G G′} _≃_ ≃-refl = record { F₀≡ = refl ; F₁≡ = Equiv.refl G′} ≃-sym : Symmetric {A = Morphism G G′} _≃_ ≃-sym {i} {j} eq = record { F₀≡ = sym (F₀≡ eq) ; F₁≡ = λ {_ _ f} → let open EdgeReasoning G′ open Transport (_⇒_ G′) open TransportOverQ (_⇒_ G′) (_≈_ G′) e₁ = F₀≡ eq in begin F₁ j f ▸ sym e₁ ≡˘⟨ cong (_◂ (F₁ j f ▸ _)) (trans-symˡ e₁) ⟩ trans (sym e₁) e₁ ◂ (F₁ j f ▸ sym e₁) ≡˘⟨ ◂-assocˡ (sym e₁) (F₁ j f ▸ sym e₁) ⟩ sym e₁ ◂ e₁ ◂ (F₁ j f ▸ sym e₁) ≡⟨ cong (sym e₁ ◂_) (◂-▸-comm e₁ (F₁ j f) (sym e₁)) ⟩ sym e₁ ◂ ((e₁ ◂ F₁ j f) ▸ sym e₁) ≈˘⟨ ◂-resp-≈ (sym e₁) (▸-resp-≈ (F₁≡ eq) (sym e₁)) ⟩ sym e₁ ◂ (F₁ i f ▸ e₁ ▸ sym e₁) ≡⟨ cong (sym e₁ ◂_) (▸-assocʳ (F₁ i f) (sym e₁)) ⟩ sym e₁ ◂ (F₁ i f ▸ trans e₁ (sym e₁)) ≡⟨ cong (λ p → sym e₁ ◂ (F₁ i f ▸ p)) (trans-symʳ e₁) ⟩ sym e₁ ◂ F₁ i f ∎ } ≃-trans : Transitive {A = Morphism G G′} _≃_ ≃-trans {i} {j} {k} eq eq′ = record { F₀≡ = trans (F₀≡ eq) (F₀≡ eq′) ; F₁≡ = λ {_ _ f} → let open EdgeReasoning G′ open Transport (_⇒_ G′) open TransportOverQ (_⇒_ G′) (_≈_ G′) in begin F₁ i f ▸ trans (F₀≡ eq) (F₀≡ eq′) ≡˘⟨ ▸-assocʳ (F₁ i f) (F₀≡ eq′) ⟩ (F₁ i f ▸ F₀≡ eq) ▸ F₀≡ eq′ ≈⟨ ▸-resp-≈ (F₁≡ eq) (F₀≡ eq′) ⟩ (F₀≡ eq ◂ F₁ j f) ▸ F₀≡ eq′ ≡˘⟨ ◂-▸-comm (F₀≡ eq) (F₁ j f) (F₀≡ eq′) ⟩ F₀≡ eq ◂ (F₁ j f ▸ F₀≡ eq′) ≈⟨ ◂-resp-≈ (F₀≡ eq) (F₁≡ eq′) ⟩ F₀≡ eq ◂ (F₀≡ eq′ ◂ F₁ k f) ≡⟨ ◂-assocˡ (F₀≡ eq) (F₁ k f) ⟩ trans (F₀≡ eq) (F₀≡ eq′) ◂ F₁ k f ∎ } ≃-Equivalence : IsEquivalence _≃_ ≃-Equivalence = record { refl = ≃-refl ; sym = ≃-sym ; trans = ≃-trans {- λ {G i j k} eq eq′ → -} } -- Furthermore, it respects morphism composition ≃-resp-∘ : {A B C : Quiver o ℓ e} {f g : Morphism B C} {h i : Morphism A B} → f ≃ g → h ≃ i → (f ∘ h) ≃ (g ∘ i) ≃-resp-∘ {B = G} {H} {f} {g} {h} {i} eq eq′ = record { F₀≡ = trans (cong (F₀ f) (F₀≡ eq′)) (F₀≡ eq) ; F₁≡ = λ {_ _ j} → let open EdgeReasoning H open Transport (_⇒_ H) open TransportOverQ (_⇒_ H) (_≈_ H) open Transport (_⇒_ G) using () renaming (_▸_ to _▹_; _◂_ to _◃_) open TransportMor (_⇒_ G) (_⇒_ H) e₁ = F₀≡ eq e₂ = F₀≡ eq′ in begin F₁ (f ∘ h) j ▸ trans (cong (F₀ f) e₂) e₁ ≡˘⟨ ▸-assocʳ (F₁ f (F₁ h j)) e₁ ⟩ F₁ f (F₁ h j) ▸ cong (F₀ f) e₂ ▸ e₁ ≡˘⟨ cong (_▸ e₁) ( M-resp-▸ (F₀ f) (F₁ f) (F₁ h j) e₂) ⟩ F₁ f (F₁ h j ▹ e₂) ▸ e₁ ≈⟨ F₁≡ eq ⟩ e₁ ◂ F₁ g (F₁ h j ▹ e₂) ≈⟨ ◂-resp-≈ e₁ (F-resp-≈ g (F₁≡ eq′)) ⟩ e₁ ◂ F₁ g (e₂ ◃ F₁ i j) ≡⟨ cong (e₁ ◂_) (M-resp-◂ (F₀ g) (F₁ g) e₂ (F₁ i j) ) ⟩ e₁ ◂ cong (F₀ g) e₂ ◂ F₁ g (F₁ i j) ≡⟨ ◂-assocˡ e₁ (F₁ g (F₁ i j)) ⟩ trans e₁ (cong (F₀ g) e₂) ◂ F₁ g (F₁ i j) ≡˘⟨ cong (_◂ F₁ g (F₁ i j)) (naturality (λ _ → e₁)) ⟩ trans (cong (F₀ f) e₂) e₁ ◂ F₁ g (F₁ i j) ∎ } where open Quiver using (_⇒_; _≈_; module EdgeReasoning) open Morphism open _≃_ -- We can induce a map from paths in on quiver to the in the target module _ {G₁ G₂ : Quiver o ℓ e} (G⇒ : Morphism G₁ G₂) where open Quiver G₁ renaming (_⇒_ to _⇒₁_; Obj to Obj₁) open Quiver G₂ renaming (_⇒_ to _⇒₂_; Obj to Obj₂; module Equiv to Equiv₂) open Morphism G⇒ using (F₀; F₁; F-resp-≈) open Paths renaming (_≈*_ to [_]_≈*_) qmap : {A B : Obj₁} → Star _⇒₁_ A B → Star _⇒₂_ (F₀ A) (F₀ B) qmap = gmap F₀ F₁ -- this is needed, because this uses F-resp-≈ and not ≡ -- unlike gmap-cong map-resp : {A B : Obj₁} (f : Star _⇒₁_ A B) {g : Star _⇒₁_ A B} → [ G₁ ] f ≈* g → [ G₂ ] qmap f ≈* qmap g map-resp ε ε = ε map-resp (x ◅ f) (f≈* ◅ eq) = F-resp-≈ f≈* ◅ map-resp f eq module _ {G H : Quiver o ℓ e} {f g : Morphism G H} (f≈g : f ≃ g) where open Quiver G open Paths H using (_≈*_; _◅_) open Morphism open _≃_ f≈g open Transport (Quiver._⇒_ H) open TransportStar (Quiver._⇒_ H) map-F₁≡ : {A B : Obj} (hs : Star _⇒_ A B) → qmap f hs ▸* F₀≡ ≈* F₀≡ ◂* qmap g hs map-F₁≡ ε = Paths.≡⇒≈* H (◂*-▸*-ε F₀≡) map-F₁≡ (hs ◅ h) = begin (F₁ f hs ◅ qmap f h) ▸* F₀≡ ≡⟨ ◅-▸* (F₁ f hs) _ F₀≡ ⟩ F₁ f hs ◅ (qmap f h ▸* F₀≡) ≈⟨ Quiver.Equiv.refl H ◅ map-F₁≡ h ⟩ F₁ f hs ◅ (F₀≡ ◂* qmap g h) ≡⟨ ◅-◂*-▸ (F₁ f hs) F₀≡ _ ⟩ (F₁ f hs ▸ F₀≡) ◅ qmap g h ≈⟨ F₁≡ ◅ (Paths.refl H) ⟩ (F₀≡ ◂ F₁ g hs) ◅ qmap g h ≡˘⟨ ◂*-◅ F₀≡ (F₁ g hs) _ ⟩ F₀≡ ◂* (F₁ g hs ◅ qmap g h) ∎ where open Paths.PathEqualityReasoning H
{ "alphanum_fraction": 0.5409239267, "avg_line_length": 40.6428571429, "ext": "agda", "hexsha": "f73a66fb0597ec7c91c24f5c8542792b4473af90", "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/Morphism.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/Morphism.agda", "max_line_length": 111, "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/Morphism.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": 3563, "size": 7966 }
module Highlighting where Set-one : Set₂ Set-one = Set₁ record R (A : Set) : Set-one where constructor con field X : Set F : Set → Set → Set F A B = B field P : F A X → Set -- Note: we cannot check highlighting of non-termination -- any more (Andreas, 2014-09-05), since termination failure -- is a type error now. {-# NON_TERMINATING #-} Q : F A X → Set Q = Q postulate P : _ open import Highlighting.M data D (A : Set) : Set-one where d : let X = D in X A
{ "alphanum_fraction": 0.6252545825, "avg_line_length": 16.9310344828, "ext": "agda", "hexsha": "ae24905e6c3a556264e8ef57a12641ce74c4f3e9", "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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/interaction/Highlighting.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "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": "redfish64/autonomic-agda", "max_issues_repo_path": "test/interaction/Highlighting.agda", "max_line_length": 62, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/interaction/Highlighting.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 161, "size": 491 }
module SecondOrder.MContext {ℓ} (arity : Set ℓ) (sort : Set ℓ) where data MContext : Set ℓ where ctx-empty : MContext ctx-slot : arity → sort → MContext _,,_ : MContext → MContext → MContext infixl 5 _,,_ infix 4 [_,_]∈_ -- the meta-variables of a given type in a context data [_,_]∈_ (Λ : arity) (A : sort) : MContext → Set ℓ where var-slot : [ Λ , A ]∈ ctx-slot Λ A var-inl : ∀ {Θ ψ} (x : [ Λ , A ]∈ Θ) → [ Λ , A ]∈ Θ ,, ψ var-inr : ∀ {Θ ψ} (y : [ Λ , A ]∈ ψ) → [ Λ , A ]∈ Θ ,, ψ
{ "alphanum_fraction": 0.5297504798, "avg_line_length": 30.6470588235, "ext": "agda", "hexsha": "e2cf4544465a2955a08a0c096bcedd2949783273", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2021-05-24T02:51:43.000Z", "max_forks_repo_forks_event_min_datetime": "2021-02-16T13:43:07.000Z", "max_forks_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/formaltt", "max_forks_repo_path": "src/SecondOrder/MContext.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "2aaf850bb1a262681c5a232cdefae312f921b9d4", "max_issues_repo_issues_event_max_datetime": "2021-05-14T16:15:17.000Z", "max_issues_repo_issues_event_min_datetime": "2021-04-30T14:18:25.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/formaltt", "max_issues_repo_path": "src/SecondOrder/MContext.agda", "max_line_length": 69, "max_stars_count": 21, "max_stars_repo_head_hexsha": "0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cilinder/formaltt", "max_stars_repo_path": "src/SecondOrder/MContext.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-19T15:50:08.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-16T14:07:06.000Z", "num_tokens": 227, "size": 521 }
module _ where open import Common.Prelude hiding (_>>=_) open import Common.Reflection open import Common.Equality module _ (A : Set) where record R : Set where `R₀ : Type `R₀ = def (quote R) [] `R₁ : Term → Type `R₁ a = def (quote R) (vArg a ∷ []) `Nat : Type `Nat = def (quote Nat) [] _`→_ : Type → Type → Type a `→ b = pi (vArg a) (abs "x" b) helper-type₀ : Type helper-type₀ = `R₀ `→ `R₀ helper-type₁ : Type helper-type₁ = `R₁ `Nat `→ `R₁ `Nat helper-term : Term helper-term = var 0 [] helper-patterns : List (Arg Pattern) helper-patterns = vArg (var "_") ∷ [] defineHelper : Type → TC ⊤ defineHelper t = freshName "n" >>= λ n → declareDef (vArg n) t >>= λ _ → defineFun n (clause helper-patterns helper-term ∷ []) noFail : TC ⊤ → TC Bool noFail m = catchTC (bindTC m λ _ → returnTC true) (returnTC false) mac : Type → Tactic mac t hole = noFail (defineHelper t) >>= λ b → quoteTC b >>= unify hole macro mac₀ : Tactic mac₀ = mac helper-type₀ mac₁ : Tactic mac₁ = mac helper-type₁ within-module-succeeds₀ : mac₀ ≡ true within-module-succeeds₀ = refl within-module-fails₁ : mac₁ ≡ false within-module-fails₁ = refl outside-module-fails₀ : mac₀ Nat ≡ false outside-module-fails₀ = refl outside-module-succeeds₁ : mac₁ Nat ≡ true outside-module-succeeds₁ = refl
{ "alphanum_fraction": 0.6173725772, "avg_line_length": 20.7910447761, "ext": "agda", "hexsha": "fdb8b2597bb322eea22ed89d3fd849b646aff088", "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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Succeed/Issue1890b.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "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": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Succeed/Issue1890b.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/Issue1890b.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 466, "size": 1393 }
------------------------------------------------------------------------ -- Well-typed substitutions ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module Data.Fin.Substitution.Typed where open import Data.Context as Ctx hiding (map) open import Data.Context.WellFormed open import Data.Context.Properties using (module ContextFormationLemmas) open import Data.Fin using (Fin; zero; suc) open import Data.Fin.Substitution open import Data.Fin.Substitution.Lemmas open import Data.Fin.Substitution.ExtraLemmas open import Data.Nat using (ℕ; suc) open import Data.Vec as Vec using (Vec; []; _∷_; map) open import Data.Vec.Properties using (map-cong; map-∘; lookup-map) open import Data.Vec.Relation.Binary.Pointwise.Inductive as PW using (Pointwise; []; _∷_) open import Function as Fun using (_∘_) open import Level using (_⊔_) renaming (zero to lzero; suc to lsuc) open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Relation.Unary using (Pred) ------------------------------------------------------------------------ -- Abstract typing -- -- Well-typed substitutions are defined over an abstract "type -- system", i.e. a pair of formation and typing judgments and -- substitution lemmas for raw terms and types. -- An abtract typing judgment _⊢_∈_ : Typing Bnd Term Type is a -- ternary relation which, in a given Bnd-context, relates Term-terms -- to their Type-types. Typing : ∀ {t₁ t₂ t₃} → Pred ℕ t₁ → Pred ℕ t₂ → Pred ℕ t₃ → ∀ ℓ → Set (t₁ ⊔ t₂ ⊔ t₃ ⊔ lsuc ℓ) Typing Bnd Term Type ℓ = ∀ {n} → Ctx Bnd n → Term n → Type n → Set ℓ ------------------------------------------------------------------------ -- Abstract well-typed substitutions (aka context morphisms) record TypedSub {t} (Type : Pred ℕ t) -- Type syntax (Term : Pred ℕ lzero) -- Term syntax ℓ : Set (lsuc (t ⊔ ℓ)) where -- The underlying type assignment system infix 4 _⊢_∈_ _⊢_wf field _⊢_wf : Wf Type Type ℓ -- Type formation judgment _⊢_∈_ : Typing Type Term Type ℓ -- Typing judgment -- Weakening and term substitutions in types. field typeExtension : Extension Type -- weakening of types typeTermApplication : Application Type Term -- app. of term subst. termSimple : Simple Term -- simple term subst. open ContextFormation _⊢_wf using (_wf) open Application typeTermApplication using (_/_) infix 4 _⊢/_∈_ infixr 5 _∷_ -- Typed substitutions. -- -- A typed substitution Δ ⊢/ σ ∈ Γ is a substitution σ which, when -- applied to a well-typed term Γ ⊢ t ∈ a in a source context Γ, -- yields a well-typed term Δ ⊢ t / σ ∈ a / σ in a well-formed -- target context Δ. data _⊢/_∈_ {n} (Δ : Ctx Type n) : ∀ {m} → Sub Term m n → Ctx Type m → Set (t ⊔ ℓ) where [] : Δ wf → Δ ⊢/ [] ∈ [] _∷_ : ∀ {m t} {a : Type m} {σ : Sub Term m n} {Γ} → Δ ⊢ t ∈ a / σ → Δ ⊢/ σ ∈ Γ → Δ ⊢/ t ∷ σ ∈ a ∷ Γ -- The domains of well-typed substitutions are well-formed. /∈-wf : ∀ {m n Δ} {σ : Sub Term m n} {Γ} → Δ ⊢/ σ ∈ Γ → Δ wf /∈-wf ([] Δ-wf) = Δ-wf /∈-wf (_ ∷ σ∈Γ) = /∈-wf σ∈Γ ------------------------------------------------------------------------ -- Operations on abstract well-typed substitutions -- Operations on abstract typed substitutions that require weakening -- of well-typed terms record TypedWeakenOps {t ℓ} {Type : Pred ℕ t} {Term : Pred ℕ lzero} (typedSub : TypedSub Type Term ℓ) : Set (lsuc (t ⊔ ℓ)) where open TypedSub typedSub -- Operations on contexts and raw terms that require weakening private termExtension : Extension Term termExtension = record { weaken = Simple.weaken termSimple } module E = Extension termExtension module C = WeakenOps typeExtension open Simple termSimple using (wk) open Application typeTermApplication using (_/_; _⊙_) open ContextFormation _⊢_wf using (_wf; _∷_; wf-∷₁) field -- Weakening preserves well-typed terms. ∈-weaken : ∀ {n} {Δ : Ctx Type n} {t a b} → Δ ⊢ a wf → Δ ⊢ t ∈ b → (a ∷ Δ) ⊢ E.weaken t ∈ C.weaken b -- Well-typedness implies well-formedness of contexts. ∈-wf : ∀ {n} {Δ : Ctx Type n} {t a} → Δ ⊢ t ∈ a → Δ wf -- Lemmas relating type weakening to term substitutions /-wk : ∀ {n} {a : Type n} → a / wk ≡ C.weaken a /-weaken : ∀ {m n} {σ : Sub Term m n} a → a / map E.weaken σ ≡ a / σ / wk weaken-/-∷ : ∀ {n m} {t} {σ : Sub Term m n} (a : Type m) → C.weaken a / (t ∷ σ) ≡ a / σ -- Some helper lemmas /-map-weaken : ∀ {m n} a (ρ : Sub Term m n) → C.weaken (a / ρ) ≡ a / map E.weaken ρ /-map-weaken a ρ = begin C.weaken (a / ρ) ≡⟨ sym /-wk ⟩ a / ρ / wk ≡⟨ sym (/-weaken a) ⟩ a / map E.weaken ρ ∎ map-weaken-⊙-∷ : ∀ {m n} (σ : Sub Type m m) t (ρ : Sub Term m n) → σ ⊙ ρ ≡ map C.weaken σ ⊙ (t ∷ ρ) map-weaken-⊙-∷ σ t ρ = sym (begin map C.weaken σ ⊙ (t ∷ ρ) ≡⟨ sym (map-∘ _ C.weaken σ) ⟩ map ((_/ (t ∷ ρ)) ∘ C.weaken) σ ≡⟨ map-cong weaken-/-∷ σ ⟩ map (_/ ρ) σ ≡⟨⟩ σ ⊙ ρ ∎) -- Weakening preserves well-typed substitutions. /∈-weaken : ∀ {m n Δ a} {σ : Sub Term m n} {Γ} → Δ ⊢ a wf → Δ ⊢/ σ ∈ Γ → (a ∷ Δ) ⊢/ map E.weaken σ ∈ Γ /∈-weaken a-wf ([] Δ-wf) = [] (a-wf ∷ Δ-wf) /∈-weaken {_} {_} {Δ} {a} {t ∷ σ} a-wf (t∈b/σ ∷ σ∈Γ) = subst (a ∷ Δ ⊢ _ ∈_) (/-map-weaken _ σ) (∈-weaken a-wf t∈b/σ) ∷ (/∈-weaken a-wf σ∈Γ) -- A typed substitution consists of pointwise-typed terms. toPointwise : ∀ {m n Δ} {σ : Sub Term m n} {Γ} → Δ ⊢/ σ ∈ Γ → Pointwise (Δ ⊢_∈_) σ (C.toVec Γ ⊙ σ) toPointwise ([] Δ-wf) = [] toPointwise {_} {_} {Δ} {t ∷ σ} (t∈a/σ ∷ σ∈Γ) = subst (Δ ⊢ t ∈_) (sym (weaken-/-∷ _)) t∈a/σ ∷ subst (Pointwise (_⊢_∈_ Δ) σ) (map-weaken-⊙-∷ _ t σ) (toPointwise σ∈Γ) -- Look up an entry in a typed substitution. lookup : ∀ {m n Δ} {σ : Sub Term m n} {Γ} → Δ ⊢/ σ ∈ Γ → (x : Fin m) → Δ ⊢ Vec.lookup σ x ∈ C.lookup Γ x / σ lookup {_} {_} {Δ} {σ} {Γ} σ∈Γ x = subst (Δ ⊢ _ ∈_) (lookup-map x _ (C.toVec Γ)) (PW.lookup (toPointwise σ∈Γ) x) -- Extension by a typed term. ∈-/∷ : ∀ {m n Δ} {σ : Sub Term m n} {Γ t a b} → (b ∷ Δ) ⊢ t ∈ C.weaken (a / σ) → Δ ⊢/ σ ∈ Γ → b ∷ Δ ⊢/ t E./∷ σ ∈ a ∷ Γ ∈-/∷ t∈a/σ σ∈Γ = subst (_⊢_∈_ _ _) (/-map-weaken _ _) t∈a/σ ∷ /∈-weaken b-wf σ∈Γ where b∷Δ-wf = ∈-wf t∈a/σ b-wf = wf-∷₁ b∷Δ-wf -- Operations on abstract typed substitutions that require simple term -- substitutions record TypedSimple {t ℓ} {Type : Pred ℕ t} {Term : Pred ℕ lzero} (typedSub : TypedSub Type Term ℓ) : Set (lsuc (t ⊔ ℓ)) where -- Operations on abstract typed substitutions that require weakening -- of terms field typedWeakenOps : TypedWeakenOps typedSub open TypedWeakenOps typedWeakenOps public open TypedSub typedSub open ContextFormation _⊢_wf using (_wf; _⊢_wfExt; []; _∷_; wf-∷₂) open Application typeTermApplication using (_/_) private module S = Simple termSimple module C = WeakenOps typeExtension open S using (_↑; _↑⋆_; id; wk; sub) -- Context operations that require term substitutions in types. open SubstOps typeTermApplication termSimple using (_E/_) field -- Takes variables to well-typed Tms. ∈-var : ∀ {n} {Γ : Ctx Type n} → ∀ x → Γ wf → Γ ⊢ S.var x ∈ C.lookup Γ x -- Well-formedness of types implies well-formedness of contexts. wf-wf : ∀ {n} {Γ : Ctx Type n} {a} → Γ ⊢ a wf → Γ wf -- The identity substitution is an identity id-vanishes : ∀ {n} (a : Type n) → a / id ≡ a -- Lifting. ∈-↑ : ∀ {m n Δ} {σ : Sub Term m n} {a Γ} → Δ ⊢ a / σ wf → Δ ⊢/ σ ∈ Γ → a / σ ∷ Δ ⊢/ σ ↑ ∈ a ∷ Γ ∈-↑ a/σ-wf σ∈Γ = ∈-/∷ (∈-var zero (a/σ-wf ∷ (wf-wf a/σ-wf))) σ∈Γ ∈-↑⋆ : ∀ {k m n Δ} {E : CtxExt Type m k} {σ : Sub Term m n} {Γ} → Δ ⊢ (E E/ σ) wfExt → Δ ⊢/ σ ∈ Γ → (E E/ σ) ++ Δ ⊢/ σ ↑⋆ k ∈ (E ++ Γ) ∈-↑⋆ {E = []} [] σ∈Γ = σ∈Γ ∈-↑⋆ {E = a ∷ E} {Δ} {Γ} (a/σ↑⋆1+k-wf ∷ E/σ-wfExt) σ∈Γ = ∈-↑ {Γ = E ++ Γ} a/σ↑⋆1+k-wf (∈-↑⋆ {E = E} E/σ-wfExt σ∈Γ) -- The identity substitution. ∈-id : ∀ {n} {Γ : Ctx Type n} → Γ wf → Γ ⊢/ id ∈ Γ ∈-id [] = [] [] ∈-id (a-wf ∷ Γ-wf) = ∈-/∷ (subst (_ ⊢ S.var zero ∈_) (sym (cong C.weaken (id-vanishes _))) (∈-var zero (a-wf ∷ Γ-wf))) (∈-id Γ-wf) -- Weakening. ∈-wk : ∀ {n} {Γ : Ctx Type n} {a} → Γ ⊢ a wf → a ∷ Γ ⊢/ wk ∈ Γ ∈-wk a-wf = /∈-weaken a-wf (∈-id (wf-wf a-wf)) -- A substitution which only replaces the first variable. ∈-sub : ∀ {n} {Γ : Ctx Type n} {t a} → Γ ⊢ t ∈ a → Γ ⊢/ sub t ∈ a ∷ Γ ∈-sub t∈a = (subst (_ ⊢ _ ∈_) (sym (id-vanishes _)) t∈a) ∷ (∈-id (∈-wf t∈a)) -- A substitution which only changes the type of the first variable. ∈-tsub : ∀ {n} {Γ : Ctx Type n} {a b} → b ∷ Γ ⊢ S.var zero ∈ C.weaken a → b ∷ Γ ⊢/ id ∈ a ∷ Γ ∈-tsub z∈a = ∈-/∷ (subst (_ ⊢ _ ∈_) (cong C.weaken (sym (id-vanishes _))) z∈a) (∈-id (wf-∷₂ (∈-wf z∈a))) -- Application of typed substitutions to typed terms. record TypedApplication {t ℓ} {Type : Pred ℕ t} {Term : Pred ℕ lzero} (typedSub : TypedSub Type Term ℓ) : Set (lsuc (t ⊔ ℓ)) where open TypedSub typedSub open Application typeTermApplication using (_/_) -- Applications of term substitutions to terms field termTermApplication : Application Term Term private module C = WeakenOps typeExtension module A = Application termTermApplication open A using (_⊙_) field -- Post-application of substitutions to things. ∈-/ : ∀ {m n Δ} {σ : Sub Term m n} {Γ t a} → Γ ⊢ t ∈ a → Δ ⊢/ σ ∈ Γ → Δ ⊢ t A./ σ ∈ a / σ -- Application of composed substitutions is repeated application. /-⊙ : ∀ {m n k} {σ : Sub Term m n} {ρ : Sub Term n k} a → a / σ ⊙ ρ ≡ a / σ / ρ -- Reverse composition. (Fits well with post-application.) ∈-⊙ : ∀ {m n k Δ Γ E} {σ : Sub Term m n} {ρ : Sub Term n k} → Δ ⊢/ σ ∈ Γ → E ⊢/ ρ ∈ Δ → E ⊢/ σ ⊙ ρ ∈ Γ ∈-⊙ ([] Δ-wf) ρ∈Δ = [] (/∈-wf ρ∈Δ) ∈-⊙ (t∈a/σ ∷ σ∈Γ) ρ∈Δ = (subst (_ ⊢ _ ∈_) (sym (/-⊙ _)) (∈-/ t∈a/σ ρ∈Δ)) ∷ (∈-⊙ σ∈Γ ρ∈Δ) ------------------------------------------------------------------------ -- Instantiations and code for facilitating instantiations -- Abstract typed liftings from Term₁ to Term₂ terms record LiftTyped {t ℓ₁ ℓ₂} {Type : Pred ℕ t} {Term₁ Term₂ : Pred ℕ lzero} (typeTermSubst : TermLikeSubst Type Term₂) (_⊢_wf : Wf Type Type ℓ₁) (_⊢₁_∈_ : Typing Type Term₁ Type ℓ₁) (_⊢₂_∈_ : Typing Type Term₂ Type ℓ₂) : Set (lsuc (t ⊔ ℓ₁ ⊔ ℓ₂)) where field rawLift : Lift Term₁ Term₂ -- Lifting between raw terms open TermLikeSubst typeTermSubst using (app; weaken; termSubst) private module S₂ = TermSubst termSubst typedSub : TypedSub Type Term₁ ℓ₁ typedSub = record { _⊢_wf = _⊢_wf ; _⊢_∈_ = _⊢₁_∈_ ; typeExtension = record { weaken = weaken } ; typeTermApplication = record { _/_ = app rawLift } ; termSimple = Lift.simple rawLift } open TypedSub typedSub public hiding (_⊢_wf; _⊢_∈_; typeExtension) -- Simple typed Term₁ substitutions. field typedSimple : TypedSimple typedSub open Lift rawLift public open Application typeTermApplication public open TypedSimple typedSimple public hiding (_⊢_∈_) field -- Lifts well-typed Term₁-terms to well-typed Term₂-terms. ∈-lift : ∀ {n} {Γ : Ctx Type n} {t a} → Γ ⊢₁ t ∈ a → Γ ⊢₂ (lift t) ∈ a -- A usefule lemma: lifting preserves variables. lift-var : ∀ {n} (x : Fin n) → lift (var x) ≡ S₂.var x -- Abstract variable typings. module VarTyping {t ℓ} {Type : Pred ℕ t} (_⊢_wf : Wf Type Type (t ⊔ ℓ)) (typeExtension : Extension Type) where open ContextFormation _⊢_wf open WeakenOps typeExtension infix 4 _⊢Var_∈_ -- Abstract reflexive variable typings. data _⊢Var_∈_ {n} (Γ : Ctx Type n) : Fin n → Type n → Set (t ⊔ ℓ) where ∈-var : ∀ x → Γ wf → Γ ⊢Var x ∈ lookup Γ x -- Variable typing together with type formation forms -- a type assignment system. -- Abstract typed variable substitutions (renamings). record TypedVarSubst {t} (Type : Pred ℕ t) ℓ : Set (lsuc (t ⊔ ℓ)) where infix 4 _⊢_wf field _⊢_wf : Wf Type Type (t ⊔ ℓ) -- Type formation judgment -- Generic application of renamings to raw types typeExtension : Extension Type typeVarApplication : Application Type Fin open VarTyping {t} {t ⊔ ℓ} _⊢_wf typeExtension public open WeakenOps typeExtension using (weaken; toVec) open Application typeVarApplication using (_/_) open ContextFormation _⊢_wf using (_wf; _∷_) open VarSubst using (id; wk; _⊙_) field -- Context validity of type formation. wf-wf : ∀ {n} {Γ : Ctx Type n} {a} → Γ ⊢ a wf → Γ wf -- Lemmas about renamings in types /-wk : ∀ {n} {a : Type n} → a / wk ≡ weaken a id-vanishes : ∀ {n} (a : Type n) → a / id ≡ a /-⊙ : ∀ {m n k} {ρ₁ : Sub Fin m n} {ρ₂ : Sub Fin n k} a → a / ρ₁ ⊙ ρ₂ ≡ a / ρ₁ / ρ₂ -- Typed renamings and associated lemmas. typedRenaming : TypedSub Type Fin (t ⊔ ℓ) typedRenaming = record { _⊢_wf = _⊢_wf ; _⊢_∈_ = _⊢Var_∈_ ; typeExtension = typeExtension ; typeTermApplication = typeVarApplication ; termSimple = VarSubst.simple } appLemmas : AppLemmas Type Fin appLemmas = record { application = typeVarApplication ; lemmas₄ = VarLemmas.lemmas₄ ; id-vanishes = id-vanishes ; /-⊙ = /-⊙ } weakenLemmas : WeakenLemmas Type Fin weakenLemmas = record { appLemmas = appLemmas ; /-wk = /-wk } open AppLemmas appLemmas using (/-weaken) open WeakenLemmas weakenLemmas using (weaken-/-∷) -- Simple typed renamings. typedSimple : TypedSimple typedRenaming typedSimple = record { typedWeakenOps = record { ∈-weaken = ∈-weaken ; ∈-wf = ∈-wf ; /-wk = /-wk ; /-weaken = /-weaken ; weaken-/-∷ = weaken-/-∷ } ; ∈-var = ∈-var ; wf-wf = wf-wf ; id-vanishes = id-vanishes } where ∈-weaken : ∀ {n} {Γ : Ctx Type n} {x a b} → Γ ⊢ a wf → Γ ⊢Var x ∈ b → a ∷ Γ ⊢Var suc x ∈ weaken b ∈-weaken {_} {Γ} a-wf (∈-var x Γ-wf) = subst (_ ∷ Γ ⊢Var _ ∈_) (lookup-map x weaken (toVec Γ)) (∈-var (suc x) (a-wf ∷ Γ-wf)) ∈-wf : ∀ {n} {Γ : Ctx Type n} {x a} → Γ ⊢Var x ∈ a → Γ wf ∈-wf (∈-var x Γ-wf) = Γ-wf open TypedSub typedRenaming public renaming (_⊢/_∈_ to _⊢/Var_∈_) hiding (_⊢_wf; _/_) open TypedSimple typedSimple public hiding (typeExtension; _/_; _⊢_∈_; ∈-var; _⊢_wf; wf-wf; /-wk; id-vanishes) -- Applications of typed renamings to typed variables typedApplication : TypedApplication typedRenaming typedApplication = record { termTermApplication = VarSubst.application ; ∈-/ = ∈-/ ; /-⊙ = /-⊙ } where ∈-/ : ∀ {m n Δ} {ρ : Sub Fin m n} {Γ x a} → Γ ⊢Var x ∈ a → Δ ⊢/Var ρ ∈ Γ → Δ ⊢Var Vec.lookup ρ x ∈ a / ρ ∈-/ (∈-var x Γ-wf) ρ∈Γ = lookup ρ∈Γ x open TypedApplication typedApplication public using (_/_; ∈-/; ∈-⊙) -- Abstract typed term substitutions. record TypedTermSubst {t h} (Type : Pred ℕ t) (Term : Pred ℕ lzero) ℓ (Helpers : ∀ {T} → Lift T Term → Set h) : Set (lsuc (t ⊔ ℓ) ⊔ h) where infix 4 _⊢_∈_ _⊢_wf field _⊢_wf : Wf Type Type (t ⊔ ℓ) -- Type formation judgment _⊢_∈_ : Typing Type Term Type (t ⊔ ℓ) -- Typing judgment -- Lemmas about term substitutions in Types termLikeLemmas : TermLikeLemmas Type Term private module Tp = TermLikeLemmas termLikeLemmas module Tm = TermLemmas Tp.termLemmas module S = TermSubst Tm.termSubst typeExtension : Extension Type typeExtension = record { weaken = Tp.weaken } private module C = WeakenOps typeExtension typedSub : TypedSub Type Term (t ⊔ ℓ) typedSub = record { _⊢_wf = _⊢_wf ; _⊢_∈_ = _⊢_∈_ ; typeExtension = typeExtension ; termSimple = S.simple ; typeTermApplication = Tp.termApplication } open ContextFormation _⊢_wf using (_wf) field -- Custom helper lemmas used to implement application of typed -- substitutions varHelpers : Helpers S.varLift -- lemmas about renamings termHelpers : Helpers S.termLift -- lemmas about substitutions -- Context validity of type formation and typing. wf-wf : ∀ {n} {Γ : Ctx Type n} {a} → Γ ⊢ a wf → Γ wf ∈-wf : ∀ {n} {Γ : Ctx Type n} {t a} → Γ ⊢ t ∈ a → Γ wf -- Takes variables to well-typed Tms. ∈-var : ∀ {n} {Γ : Ctx Type n} → ∀ x → Γ wf → Γ ⊢ S.var x ∈ C.lookup Γ x -- Generic application of typed Term′ substitutions to typed Terms. typedApp : ∀ {Term′ : Pred ℕ lzero} (_⊢′_∈_ : Typing Type Term′ Type (t ⊔ ℓ)) (liftTyped : LiftTyped Tp.termLikeSubst _⊢_wf _⊢′_∈_ _⊢_∈_) → let open LiftTyped liftTyped using (rawLift; _⊢/_∈_; _/_) in (helpers : Helpers rawLift) → ∀ {m n Γ Δ t a} {σ : Sub Term′ m n} → Γ ⊢ t ∈ a → Δ ⊢/ σ ∈ Γ → Δ ⊢ S.app rawLift t σ ∈ a / σ typedVarSubst : TypedVarSubst Type (t ⊔ ℓ) typedVarSubst = record { _⊢_wf = _⊢_wf ; typeVarApplication = Tp.varApplication ; typeExtension = typeExtension ; wf-wf = wf-wf ; /-wk = refl ; id-vanishes = id-vanishes ; /-⊙ = /-⊙ } where open LiftSubLemmas Tp.varLiftSubLemmas using (liftAppLemmas) open LiftAppLemmas liftAppLemmas using (id-vanishes; /-⊙) open TypedVarSubst typedVarSubst public using (_⊢Var_∈_; _⊢/Var_∈_; typedRenaming) renaming ( typedSimple to varTypedSimple ; ∈-var to Var∈-var ; ∈-↑ to Var∈-↑ ; ∈-id to Var∈-id ; ∈-wk to Var∈-wk ; ∈-sub to Var∈-sub ; ∈-tsub to Var∈-tsub ) varLiftTyped : LiftTyped Tp.termLikeSubst _⊢_wf _⊢Var_∈_ _⊢_∈_ varLiftTyped = record { rawLift = S.varLift ; typedSimple = varTypedSimple ; ∈-lift = ∈-lift ; lift-var = λ _ → refl } where ∈-lift : ∀ {n Γ x} {a : Type n} → Γ ⊢Var x ∈ a → Γ ⊢ S.var x ∈ a ∈-lift (Var∈-var x Γ-wf) = ∈-var x Γ-wf ∈-/Var : ∀ {m n} {Γ t a} {ρ : Sub Fin m n} {Δ} → Δ ⊢ t ∈ a → Γ ⊢/Var ρ ∈ Δ → Γ ⊢ t S./Var ρ ∈ a Tp./Var ρ ∈-/Var = typedApp _⊢Var_∈_ varLiftTyped varHelpers -- Operations on well-formed contexts that require weakening of -- well-formedness judgments. -- Simple typed substitutions. typedSimple : TypedSimple typedSub typedSimple = record { typedWeakenOps = record { ∈-weaken = λ a-wf t∈b → ∈-/Var t∈b (Var∈-wk a-wf) ; ∈-wf = ∈-wf ; /-wk = Tp./-wk ; /-weaken = Tp./-weaken ; weaken-/-∷ = Tp.weaken-/-∷ } ; ∈-var = ∈-var ; wf-wf = wf-wf ; id-vanishes = Tp.id-vanishes } termLiftTyped : LiftTyped Tp.termLikeSubst _⊢_wf _⊢_∈_ _⊢_∈_ termLiftTyped = record { rawLift = S.termLift ; typedSimple = typedSimple ; ∈-lift = Fun.id ; lift-var = λ _ → refl } -- Applications of typed term substitutions to typed terms typedApplication : TypedApplication typedSub typedApplication = record { termTermApplication = S.application ; ∈-/ = typedApp _⊢_∈_ termLiftTyped termHelpers ; /-⊙ = Tp./-⊙ } open TypedSub typedSub public hiding (typeExtension) open TypedSimple typedSimple public hiding ( typeExtension; ∈-weaken; ∈-wf; ∈-var; wf-wf ; /-wk; /-weaken; weaken-/-∷; id-vanishes ) open TypedApplication typedApplication public hiding (/-⊙)
{ "alphanum_fraction": 0.5370818024, "avg_line_length": 32.1180124224, "ext": "agda", "hexsha": "45d8c37f0c97be1135d1e6cca438e3c5a2d51057", "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": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Blaisorblade/f-omega-int-agda", "max_forks_repo_path": "src/Data/Fin/Substitution/Typed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "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": "Blaisorblade/f-omega-int-agda", "max_issues_repo_path": "src/Data/Fin/Substitution/Typed.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Blaisorblade/f-omega-int-agda", "max_stars_repo_path": "src/Data/Fin/Substitution/Typed.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 7454, "size": 20684 }
-- {-# OPTIONS --verbose tc.records.ifs:15 #-} -- {-# OPTIONS --verbose tc.constr.findInScope:15 #-} -- {-# OPTIONS --verbose tc.term.args.ifs:15 #-} -- {-# OPTIONS --verbose cta.record.ifs:15 #-} -- {-# OPTIONS --verbose tc.section.apply:25 #-} -- {-# OPTIONS --verbose tc.mod.apply:100 #-} -- {-# OPTIONS --verbose scope.rec:15 #-} -- {-# OPTIONS --verbose tc.rec.def:15 #-} module 07-subclasses where module Imports where module L where open import Agda.Primitive public using (Level; _⊔_) renaming (lzero to zero; lsuc to suc) -- extract from Function id : ∀ {a} {A : Set a} → A → A id x = x _$_ : ∀ {a b} {A : Set a} {B : A → Set b} → ((x : A) → B x) → ((x : A) → B x) f $ x = f x _∘_ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} → (∀ {x} (y : B x) → C y) → (g : (x : A) → B x) → ((x : A) → C (g x)) f ∘ g = λ x → f (g x) -- extract from Data.Bool infixr 5 _∨_ data Bool : Set where true : Bool false : Bool not : Bool → Bool not true = false not false = true _∨_ : Bool → Bool → Bool true ∨ b = true false ∨ b = b -- extract from Relation.Nullary.Decidable and friends infix 3 ¬_ data ⊥ : Set where ¬_ : ∀ {ℓ} → Set ℓ → Set ℓ ¬ P = P → ⊥ data Dec {p} (P : Set p) : Set p where yes : ( p : P) → Dec P no : (¬p : ¬ P) → Dec P ⌊_⌋ : ∀ {p} {P : Set p} → Dec P → Bool ⌊ yes _ ⌋ = true ⌊ no _ ⌋ = false -- extract from Relation.Binary.PropositionalEquality data _≡_ {a} {A : Set a} (x : A) : A → Set a where refl : x ≡ x cong : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {x y} → x ≡ y → f x ≡ f y cong f refl = refl -- extract from Data.Nat data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} pred : ℕ → ℕ pred zero = zero pred (suc n) = n _≟_ : (x y : ℕ) → Dec (x ≡ y) zero ≟ zero = yes refl suc m ≟ suc n with m ≟ n suc m ≟ suc .m | yes refl = yes refl suc m ≟ suc n | no prf = no (prf ∘ cong pred) zero ≟ suc n = no λ() suc m ≟ zero = no λ() open Imports -- Begin of actual example! record Eq (A : Set) : Set where field eq : A → A → Bool primEqBool : Bool → Bool → Bool primEqBool true = id primEqBool false = not eqBool : Eq Bool eqBool = record { eq = primEqBool } primEqNat : ℕ → ℕ → Bool primEqNat a b = ⌊ a ≟ b ⌋ primLtNat : ℕ → ℕ → Bool primLtNat 0 _ = true primLtNat (suc a) (suc b) = primLtNat a b primLtNat _ _ = false neq : {t : Set} → {{eqT : Eq t}} → t → t → Bool neq a b = not $ eq a b where open Eq {{...}} record Ord₁ (A : Set) : Set where field _<_ : A → A → Bool eqA : Eq A ord₁Nat : Ord₁ ℕ ord₁Nat = record { _<_ = primLtNat; eqA = eqNat } where eqNat : Eq ℕ eqNat = record { eq = primEqNat } record Ord₂ {A : Set} (eqA : Eq A) : Set where field _<_ : A → A → Bool ord₂Nat : Ord₂ (record { eq = primEqNat }) ord₂Nat = record { _<_ = primLtNat } record Ord₃ (A : Set) : Set where field _<_ : A → A → Bool eqA : Eq A open Eq eqA public ord₃Nat : Ord₃ ℕ ord₃Nat = record { _<_ = primLtNat; eqA = eqNat } where eqNat : Eq ℕ eqNat = record { eq = primEqNat } record Ord₄ {A : Set} (eqA : Eq A) : Set where field _<_ : A → A → Bool open Eq eqA public ord₄Nat : Ord₄ (record { eq = primEqNat }) ord₄Nat = record { _<_ = primLtNat } module test₁ where open Ord₁ {{...}} open Eq {{...}} eqNat : Eq _ eqNat = eqA test₁ = 5 < 3 test₂ = eq 5 3 test₃ = eq true false test₄ : {A : Set} → {{ ordA : Ord₁ A }} → A → A → Bool test₄ a b = a < b ∨ eq a b where eqA' : Eq _ eqA' = eqA module test₂ where open Ord₂ {{...}} open Eq {{...}} eqNat : Eq ℕ eqNat = record { eq = primEqNat } test₁ = 5 < 3 test₂ = eq 5 3 test₃ = eq true false test₄ : {A : Set} → {eqA : Eq A} → {{ ordA : Ord₂ eqA }} → A → A → Bool test₄ {eqA = _} a b = a < b ∨ eq a b module test₃ where open Ord₃ {{...}} open Eq {{...}} renaming (eq to eq') test₁ = 5 < 3 test₂ = eq 5 3 test₃ = eq' true false test₄ : {A : Set} → {{ ordA : Ord₃ A }} → A → A → Bool test₄ a b = a < b ∨ eq a b module test₄ where open Ord₄ {{...}} open Eq {{...}} renaming (eq to eq') test₁ = 5 < 3 test₂ = eq 5 3 test₃ = eq' true false test₄ : {A : Set} → {eqA : Eq A} → {{ ordA : Ord₄ eqA }} → A → A → Bool test₄ a b = a < b ∨ eq a b module test₄′ where open Ord₄ {{...}} hiding (eq) open Eq {{...}} eqNat : Eq ℕ eqNat = record { eq = primEqNat } test₁ = 5 < 3 test₂ = eq 5 3 test₃ = eq true false test₄ : {A : Set} → {eqA : Eq A} → {{ ordA : Ord₄ eqA }} → A → A → Bool test₄ {eqA = _} a b = a < b ∨ eq a b
{ "alphanum_fraction": 0.5217391304, "avg_line_length": 22.1320754717, "ext": "agda", "hexsha": "6474f6c404607a6b2f486a6e58fd8e5ae0722fbf", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/instance-arguments/07-subclasses.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": "examples/instance-arguments/07-subclasses.agda", "max_line_length": 73, "max_stars_count": 1, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "examples/instance-arguments/07-subclasses.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 1894, "size": 4692 }
{-# OPTIONS --safe #-} module Cubical.Algebra.Field.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.SIP open import Cubical.Relation.Nullary open import Cubical.Data.Sigma open import Cubical.Data.Unit open import Cubical.Data.Empty open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Ring hiding (_$_) open import Cubical.Algebra.CommRing open import Cubical.Displayed.Base open import Cubical.Displayed.Auto open import Cubical.Displayed.Record open import Cubical.Displayed.Universe open import Cubical.Reflection.RecordEquiv open Iso private variable ℓ ℓ' : Level record IsField {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) : Type ℓ where constructor isfield field isCommRing : IsCommRing 0r 1r _+_ _·_ -_ hasInverse : (x : R) → ¬ x ≡ 0r → Σ[ y ∈ R ] x · y ≡ 1r 0≢1 : ¬ 0r ≡ 1r open IsCommRing isCommRing public _[_]⁻¹ : (x : R) → ¬ x ≡ 0r → R x [ ¬x≡0 ]⁻¹ = hasInverse x ¬x≡0 .fst ·⁻¹≡1 : (x : R) (≢0 : ¬ x ≡ 0r) → x · (x [ ≢0 ]⁻¹) ≡ 1r ·⁻¹≡1 x ¬x≡0 = hasInverse x ¬x≡0 .snd record FieldStr (A : Type ℓ) : Type (ℓ-suc ℓ) where constructor fieldstr field 0r : A 1r : A _+_ : A → A → A _·_ : A → A → A -_ : A → A isField : IsField 0r 1r _+_ _·_ -_ infix 8 -_ infixl 7 _·_ infixl 6 _+_ open IsField isField public Field : ∀ ℓ → Type (ℓ-suc ℓ) Field ℓ = TypeWithStr ℓ FieldStr isSetField : (R : Field ℓ) → isSet ⟨ R ⟩ isSetField R = R .snd .FieldStr.isField .IsField.·IsMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set makeIsField : {R : Type ℓ} {0r 1r : R} {_+_ _·_ : R → R → R} { -_ : R → R} {_[_]⁻¹ : (x : R) → ¬ (x ≡ 0r) → R} (is-setR : isSet R) (+-assoc : (x y z : R) → x + (y + z) ≡ (x + y) + z) (+-rid : (x : R) → x + 0r ≡ x) (+-rinv : (x : R) → x + (- x) ≡ 0r) (+-comm : (x y : R) → x + y ≡ y + x) (·-assoc : (x y z : R) → x · (y · z) ≡ (x · y) · z) (·-rid : (x : R) → x · 1r ≡ x) (·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z)) (·-comm : (x y : R) → x · y ≡ y · x) (·⁻¹≡1 : (x : R) (≢0 : ¬ (x ≡ 0r)) → x · (x [ ≢0 ]⁻¹) ≡ 1r) (0≢1 : ¬ (0r ≡ 1r)) → IsField 0r 1r _+_ _·_ -_ makeIsField {R = R} {0r = 0r} {1r = 1r} {_+_ = _+_} {_·_ = _·_} {_[_]⁻¹ = _[_]⁻¹} is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-rdist-+ ·-comm ·⁻¹≡1 0≢1 = isfield (makeIsCommRing is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-rdist-+ ·-comm) ·-inv 0≢1 where ·-inv : (x : R) → ¬ x ≡ 0r → Σ[ y ∈ R ] x · y ≡ 1r ·-inv x ¬x≡0 = x [ ¬x≡0 ]⁻¹ , ·⁻¹≡1 x ¬x≡0 makeField : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) (_[_]⁻¹ : (x : R) → ¬ (x ≡ 0r) → R) (is-setR : isSet R) (+-assoc : (x y z : R) → x + (y + z) ≡ (x + y) + z) (+-rid : (x : R) → x + 0r ≡ x) (+-rinv : (x : R) → x + (- x) ≡ 0r) (+-comm : (x y : R) → x + y ≡ y + x) (·-assoc : (x y z : R) → x · (y · z) ≡ (x · y) · z) (·-rid : (x : R) → x · 1r ≡ x) (·-rdist-+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z)) (·-comm : (x y : R) → x · y ≡ y · x) (·⁻¹≡1 : (x : R) (≢0 : ¬ (x ≡ 0r)) → x · (x [ ≢0 ]⁻¹) ≡ 1r) (0≢1 : ¬ (0r ≡ 1r)) → Field ℓ makeField 0r 1r _+_ _·_ -_ _[_]⁻¹ is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-rdist-+ ·-comm ·⁻¹≡1 0≢1 = _ , fieldstr _ _ _ _ _ (makeIsField is-setR +-assoc +-rid +-rinv +-comm ·-assoc ·-rid ·-rdist-+ ·-comm ·⁻¹≡1 0≢1) module _ (R : CommRing ℓ) where open CommRingStr (R .snd) makeFieldFromCommRing : (hasInv : (x : R .fst) → ¬ x ≡ 0r → Σ[ y ∈ R .fst ] x · y ≡ 1r) (0≢1 : ¬ 0r ≡ 1r) → Field ℓ makeFieldFromCommRing hasInv 0≢1 .fst = R .fst makeFieldFromCommRing hasInv 0≢1 .snd = fieldstr _ _ _ _ _ (isfield isCommRing hasInv 0≢1) FieldStr→CommRingStr : {A : Type ℓ} → FieldStr A → CommRingStr A FieldStr→CommRingStr (fieldstr _ _ _ _ _ H) = commringstr _ _ _ _ _ (IsField.isCommRing H) Field→CommRing : Field ℓ → CommRing ℓ Field→CommRing (_ , fieldstr _ _ _ _ _ H) = _ , commringstr _ _ _ _ _ (IsField.isCommRing H) record IsFieldHom {A : Type ℓ} {B : Type ℓ'} (R : FieldStr A) (f : A → B) (S : FieldStr B) : Type (ℓ-max ℓ ℓ') where -- Shorter qualified names private module R = FieldStr R module S = FieldStr S field pres0 : f R.0r ≡ S.0r pres1 : f R.1r ≡ S.1r pres+ : (x y : A) → f (x R.+ y) ≡ f x S.+ f y pres· : (x y : A) → f (x R.· y) ≡ f x S.· f y pres- : (x : A) → f (R.- x) ≡ S.- (f x) unquoteDecl IsFieldHomIsoΣ = declareRecordIsoΣ IsFieldHomIsoΣ (quote IsFieldHom) FieldHom : (R : Field ℓ) (S : Field ℓ') → Type (ℓ-max ℓ ℓ') FieldHom R S = Σ[ f ∈ (⟨ R ⟩ → ⟨ S ⟩) ] IsFieldHom (R .snd) f (S .snd) IsFieldEquiv : {A : Type ℓ} {B : Type ℓ'} (R : FieldStr A) (e : A ≃ B) (S : FieldStr B) → Type (ℓ-max ℓ ℓ') IsFieldEquiv R e S = IsFieldHom R (e .fst) S FieldEquiv : (R : Field ℓ) (S : Field ℓ') → Type (ℓ-max ℓ ℓ') FieldEquiv R S = Σ[ e ∈ (R .fst ≃ S .fst) ] IsFieldEquiv (R .snd) e (S .snd) _$_ : {R S : Field ℓ} → (φ : FieldHom R S) → (x : ⟨ R ⟩) → ⟨ S ⟩ φ $ x = φ .fst x FieldEquiv→FieldHom : {A B : Field ℓ} → FieldEquiv A B → FieldHom A B FieldEquiv→FieldHom (e , eIsHom) = e .fst , eIsHom isPropIsField : {R : Type ℓ} (0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) → isProp (IsField 0r 1r _+_ _·_ -_) isPropIsField {R = R} 0r 1r _+_ _·_ -_ H@(isfield RR RC RD) (isfield SR SC SD) = λ i → isfield (isPropIsCommRing _ _ _ _ _ RR SR i) (isPropInv RC SC i) (isProp¬ _ RD SD i) where isSetR : isSet _ isSetR = RR .IsCommRing.·IsMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set isPropInv : isProp ((x : _) → ¬ x ≡ 0r → Σ[ y ∈ R ] x · y ≡ 1r) isPropInv = isPropΠ2 (λ x _ → Units.inverseUniqueness (Field→CommRing (_ , fieldstr _ _ _ _ _ H)) x) 𝒮ᴰ-Field : DUARel (𝒮-Univ ℓ) FieldStr ℓ 𝒮ᴰ-Field = 𝒮ᴰ-Record (𝒮-Univ _) IsFieldEquiv (fields: data[ 0r ∣ null ∣ pres0 ] data[ 1r ∣ null ∣ pres1 ] data[ _+_ ∣ bin ∣ pres+ ] data[ _·_ ∣ bin ∣ pres· ] data[ -_ ∣ autoDUARel _ _ ∣ pres- ] prop[ isField ∣ (λ _ _ → isPropIsField _ _ _ _ _) ]) where open FieldStr open IsFieldHom -- faster with some sharing null = autoDUARel (𝒮-Univ _) (λ A → A) bin = autoDUARel (𝒮-Univ _) (λ A → A → A → A) FieldPath : (R S : Field ℓ) → FieldEquiv R S ≃ (R ≡ S) FieldPath = ∫ 𝒮ᴰ-Field .UARel.ua uaField : {A B : Field ℓ} → FieldEquiv A B → A ≡ B uaField {A = A} {B = B} = equivFun (FieldPath A B)
{ "alphanum_fraction": 0.5152327221, "avg_line_length": 33.2863849765, "ext": "agda", "hexsha": "21b9cbeca30d2fbbe6057316928e4c26f5997a39", "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/Field/Base.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/Field/Base.agda", "max_line_length": 115, "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/Field/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3060, "size": 7090 }
{-# OPTIONS --without-K --safe #-} open import Agda.Builtin.Bool open import Data.Maybe.Base using (Maybe; just; nothing) open import Relation.Nullary open import Data.Rational.Unnormalised.Base using (ℚᵘ; 0ℚᵘ; _≃_) open import Data.Rational.Unnormalised.Properties using (+-*-commutativeRing; _≃?_) isZero? : ∀ (p : ℚᵘ) -> Maybe (0ℚᵘ ≃ p) isZero? p with 0ℚᵘ ≃? p ... | .true because ofʸ p₁ = just p₁ ... | .false because ofⁿ ¬p = nothing open import Tactic.RingSolver.Core.AlmostCommutativeRing using (fromCommutativeRing) open import Tactic.RingSolver.NonReflective (fromCommutativeRing +-*-commutativeRing isZero?) public
{ "alphanum_fraction": 0.7436305732, "avg_line_length": 39.25, "ext": "agda", "hexsha": "7c7105b9f9dd9d53b6edb027eedcb201d67bc38c", "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": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "z-murray/AnalysisAgda", "max_forks_repo_path": "NonReflectiveQ.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "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": "z-murray/AnalysisAgda", "max_issues_repo_path": "NonReflectiveQ.agda", "max_line_length": 100, "max_stars_count": null, "max_stars_repo_head_hexsha": "6fbaca08b1d63b5765d184f6284fb0e58c9f5e52", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "z-murray/AnalysisAgda", "max_stars_repo_path": "NonReflectiveQ.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 208, "size": 628 }
------------------------------------------------------------------------ -- Conatural numbers ------------------------------------------------------------------------ {-# OPTIONS --without-K --sized-types #-} open import Equality module Conat {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where open Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude hiding (_+_; _∸_; _*_) open import Prelude.Size open import Function-universe eq hiding (_∘_) open import Nat eq as Nat using (_≤_) ------------------------------------------------------------------------ -- The type -- Conats. mutual data Conat (i : Size) : Type where zero : Conat i suc : Conat′ i → Conat i record Conat′ (i : Size) : Type where coinductive field force : {j : Size< i} → Conat j open Conat′ public ------------------------------------------------------------------------ -- Bisimilarity -- Bisimilarity is only defined for fully defined conatural numbers -- (of size ∞). mutual infix 4 [_]_∼_ [_]_∼′_ data [_]_∼_ (i : Size) : Conat ∞ → Conat ∞ → Type where zero : [ i ] zero ∼ zero suc : ∀ {m n} → [ i ] force m ∼′ force n → [ i ] suc m ∼ suc n record [_]_∼′_ (i : Size) (m n : Conat ∞) : Type where coinductive field force : {j : Size< i} → [ j ] m ∼ n open [_]_∼′_ public -- Bisimilarity is an equivalence relation. reflexive-∼ : ∀ {i} n → [ i ] n ∼ n reflexive-∼ zero = zero reflexive-∼ (suc n) = suc λ { .force → reflexive-∼ (force n) } symmetric-∼ : ∀ {i m n} → [ i ] m ∼ n → [ i ] n ∼ m symmetric-∼ zero = zero symmetric-∼ (suc p) = suc λ { .force → symmetric-∼ (force p) } transitive-∼ : ∀ {i m n o} → [ i ] m ∼ n → [ i ] n ∼ o → [ i ] m ∼ o transitive-∼ zero zero = zero transitive-∼ (suc p) (suc q) = suc λ { .force → transitive-∼ (force p) (force q) } -- Equational reasoning combinators. infix -1 finally-∼ _∎∼ infixr -2 step-∼ step-≡∼ _≡⟨⟩∼_ _∎∼ : ∀ {i} n → [ i ] n ∼ n _∎∼ = reflexive-∼ -- For an explanation of why step-∼ is defined in this way, see -- Equality.step-≡. step-∼ : ∀ {i} m {n o} → [ i ] n ∼ o → [ i ] m ∼ n → [ i ] m ∼ o step-∼ _ n∼o m∼n = transitive-∼ m∼n n∼o syntax step-∼ m n∼o m∼n = m ∼⟨ m∼n ⟩ n∼o step-≡∼ : ∀ {i} m {n o} → [ i ] n ∼ o → m ≡ n → [ i ] m ∼ o step-≡∼ {i} _ n∼o m≡n = subst ([ i ]_∼ _) (sym m≡n) n∼o syntax step-≡∼ m n∼o m≡n = m ≡⟨ m≡n ⟩∼ n∼o _≡⟨⟩∼_ : ∀ {i} m {n} → [ i ] m ∼ n → [ i ] m ∼ n _ ≡⟨⟩∼ m∼n = m∼n finally-∼ : ∀ {i} m n → [ i ] m ∼ n → [ i ] m ∼ n finally-∼ _ _ m∼n = m∼n syntax finally-∼ m n m∼n = m ∼⟨ m∼n ⟩∎ n ∎∼ ------------------------------------------------------------------------ -- Some operations -- The largest conatural number. infinity : ∀ {i} → Conat i infinity = suc λ { .force → infinity } mutual -- Turns natural numbers into conatural numbers. ⌜_⌝ : ∀ {i} → ℕ → Conat i ⌜ zero ⌝ = zero ⌜ suc n ⌝ = suc ⌜ n ⌝′ ⌜_⌝′ : ∀ {i} → ℕ → Conat′ i force ⌜ n ⌝′ = ⌜ n ⌝ -- ⌜_⌝ maps equal numbers to bisimilar numbers. ⌜⌝-cong : ∀ {i m n} → m ≡ n → [ i ] ⌜ m ⌝ ∼ ⌜ n ⌝ ⌜⌝-cong {m = m} {n} m≡n = ⌜ m ⌝ ≡⟨ cong ⌜_⌝ m≡n ⟩∼ ⌜ n ⌝ ∎∼ -- Truncated predecessor. pred : ∀ {i} {j : Size< i} → Conat i → Conat j pred zero = zero pred (suc n) = force n -- The pred function preserves bisimilarity. pred-cong : ∀ {n₁ n₂ i} {j : Size< i} → [ i ] n₁ ∼ n₂ → [ j ] pred n₁ ∼ pred n₂ pred-cong zero = zero pred-cong (suc p) = force p -- ⌜_⌝ is homomorphic with respect to pred. ⌜⌝-pred : ∀ n {i} → [ i ] ⌜ Nat.pred n ⌝ ∼ pred ⌜ n ⌝ ⌜⌝-pred zero = zero ∎∼ ⌜⌝-pred (suc n) = ⌜ n ⌝ ∎∼ -- Addition. infixl 6 _+_ _+_ : ∀ {i} → Conat i → Conat i → Conat i zero + n = n suc m + n = suc λ { .force → force m + n } -- Zero is a left and right identity of addition (up to bisimilarity). +-left-identity : ∀ {i} n → [ i ] zero + n ∼ n +-left-identity = reflexive-∼ +-right-identity : ∀ {i} n → [ i ] n + zero ∼ n +-right-identity zero = zero +-right-identity (suc n) = suc λ { .force → +-right-identity (force n) } -- Infinity is a left and right zero of addition (up to bisimilarity). +-left-zero : ∀ {i n} → [ i ] infinity + n ∼ infinity +-left-zero = suc λ { .force → +-left-zero } +-right-zero : ∀ {i} n → [ i ] n + infinity ∼ infinity +-right-zero zero = reflexive-∼ _ +-right-zero (suc n) = suc λ { .force → +-right-zero (force n) } -- Addition is associative. +-assoc : ∀ m {n o i} → [ i ] m + (n + o) ∼ (m + n) + o +-assoc zero = reflexive-∼ _ +-assoc (suc m) = suc λ { .force → +-assoc (force m) } mutual -- The successor constructor can be moved from one side of _+_ to the -- other. suc+∼+suc : ∀ {m n i} → [ i ] suc m + force n ∼ force m + suc n suc+∼+suc {m} {n} = suc m + force n ∼⟨ (suc λ { .force → reflexive-∼ _ }) ⟩ ⌜ 1 ⌝ + force m + force n ∼⟨ 1++∼+suc _ ⟩∎ force m + suc n ∎∼ 1++∼+suc : ∀ m {n i} → [ i ] ⌜ 1 ⌝ + m + force n ∼ m + suc n 1++∼+suc zero = suc λ { .force → reflexive-∼ _ } 1++∼+suc (suc _) = suc λ { .force → suc+∼+suc } -- Addition is commutative. +-comm : ∀ m {n i} → [ i ] m + n ∼ n + m +-comm zero {n} = zero + n ∼⟨ symmetric-∼ (+-right-identity _) ⟩∎ n + zero ∎∼ +-comm (suc m) {n} = suc m + n ∼⟨ (suc λ { .force → +-comm (force m) }) ⟩ ⌜ 1 ⌝ + n + force m ∼⟨ 1++∼+suc _ ⟩∎ n + suc m ∎∼ -- Addition preserves bisimilarity. infixl 6 _+-cong_ _+-cong_ : ∀ {i m₁ m₂ n₁ n₂} → [ i ] m₁ ∼ m₂ → [ i ] n₁ ∼ n₂ → [ i ] m₁ + n₁ ∼ m₂ + n₂ zero +-cong q = q suc p +-cong q = suc λ { .force → force p +-cong q } -- ⌜_⌝ is homomorphic with respect to addition. ⌜⌝-+ : ∀ m {n i} → [ i ] ⌜ m Prelude.+ n ⌝ ∼ ⌜ m ⌝ + ⌜ n ⌝ ⌜⌝-+ zero = reflexive-∼ _ ⌜⌝-+ (suc m) = suc λ { .force → ⌜⌝-+ m } -- Truncated subtraction of a natural number. infixl 6 _∸_ _∸_ : Conat ∞ → ℕ → Conat ∞ m ∸ zero = m zero ∸ suc n = zero suc m ∸ suc n = force m ∸ n -- Infinity is a left zero of _∸_ (up to bisimilarity). ∸-left-zero-infinity : ∀ {i} n → [ i ] infinity ∸ n ∼ infinity ∸-left-zero-infinity zero = reflexive-∼ _ ∸-left-zero-infinity (suc n) = ∸-left-zero-infinity n -- Zero is a left zero of _∸_ (up to bisimilarity). ∸-left-zero-zero : ∀ {i} n → [ i ] zero ∸ n ∼ zero ∸-left-zero-zero zero = reflexive-∼ _ ∸-left-zero-zero (suc n) = reflexive-∼ _ -- Zero is a right identity of subtraction (up to bisimilarity). ∸-right-identity : ∀ {i} n → [ i ] n ∸ zero ∼ n ∸-right-identity = reflexive-∼ -- Subtraction preserves bisimilarity and equality. infixl 6 _∸-cong_ _∸-cong_ : ∀ {i m₁ m₂ n₁ n₂} → [ ∞ ] m₁ ∼ m₂ → n₁ ≡ n₂ → [ i ] m₁ ∸ n₁ ∼ m₂ ∸ n₂ _∸-cong_ {m₁ = m₁} {m₂} {zero} {n₂} p eq = m₁ ∼⟨ p ⟩ m₂ ≡⟨⟩∼ m₂ ∸ zero ≡⟨ cong (_ ∸_) eq ⟩∼ m₂ ∸ n₂ ∎∼ _∸-cong_ {n₁ = suc n₁} {n₂} zero eq = zero ≡⟨⟩∼ zero ∸ suc n₁ ≡⟨ cong (_ ∸_) eq ⟩∼ zero ∸ n₂ ∎∼ _∸-cong_ {n₁ = suc n₁} {n₂} (suc {m = m₁} {n = m₂} p) eq = force m₁ ∸ n₁ ∼⟨ force p ∸-cong refl n₁ ⟩ force m₂ ∸ n₁ ≡⟨⟩∼ suc m₂ ∸ suc n₁ ≡⟨ cong (_ ∸_) eq ⟩∼ suc m₂ ∸ n₂ ∎∼ -- ⌜_⌝ is homomorphic with respect to subtraction. ⌜⌝-∸ : ∀ m n {i} → [ i ] ⌜ m Prelude.∸ n ⌝ ∼ ⌜ m ⌝ ∸ n ⌜⌝-∸ m zero = reflexive-∼ _ ⌜⌝-∸ zero (suc n) = reflexive-∼ _ ⌜⌝-∸ (suc m) (suc n) = ⌜⌝-∸ m n -- Multiplication. infixl 7 _*_ _*_ : ∀ {i} → Conat i → Conat i → Conat i zero * n = zero m * zero = zero suc m * suc n = suc λ { .force → n .force + m .force * suc n } -- One is a left and right identity of multiplication (up to -- bisimilarity). *-left-identity : ∀ {i} n → [ i ] ⌜ 1 ⌝ * n ∼ n *-left-identity zero = reflexive-∼ _ *-left-identity (suc n) = suc λ { .force → n .force + zero ∼⟨ +-right-identity _ ⟩ n .force ∎∼ } *-right-identity : ∀ {i} n → [ i ] n * ⌜ 1 ⌝ ∼ n *-right-identity zero = reflexive-∼ _ *-right-identity (suc n) = suc λ { .force → *-right-identity _ } -- Zero is a left and right zero of multiplication (up to -- bisimilarity). *-left-zero : ∀ {i n} → [ i ] zero * n ∼ zero *-left-zero = reflexive-∼ _ *-right-zero : ∀ {i n} → [ i ] n * zero ∼ zero *-right-zero {n = zero} = reflexive-∼ _ *-right-zero {n = suc n} = reflexive-∼ _ -- An unfolding lemma for multiplication. suc*∼+* : ∀ {m n i} → [ i ] suc m * n ∼ n + m .force * n suc*∼+* {m} {zero} = zero ∼⟨ symmetric-∼ *-right-zero ⟩ m .force * zero ∎∼ suc*∼+* {m} {suc n} = suc λ { .force → reflexive-∼ _ } -- Multiplication distributes over addition. *-+-distribˡ : ∀ m {n o i} → [ i ] m * (n + o) ∼ m * n + m * o *-+-distribˡ zero = reflexive-∼ _ *-+-distribˡ (suc m) {zero} {o} = reflexive-∼ _ *-+-distribˡ (suc m) {suc n} {o} = suc λ { .force → n .force + o + m .force * (suc n + o) ∼⟨ (_ ∎∼) +-cong *-+-distribˡ (m .force) ⟩ n .force + o + (m .force * suc n + m .force * o) ∼⟨ symmetric-∼ (+-assoc (n .force)) ⟩ n .force + (o + (m .force * suc n + m .force * o)) ∼⟨ (n .force ∎∼) +-cong +-assoc o ⟩ n .force + ((o + m .force * suc n) + m .force * o) ∼⟨ (n .force ∎∼) +-cong (+-comm o +-cong (_ ∎∼)) ⟩ n .force + ((m .force * suc n + o) + m .force * o) ∼⟨ (n .force ∎∼) +-cong symmetric-∼ (+-assoc (m .force * _)) ⟩ n .force + (m .force * suc n + (o + m .force * o)) ∼⟨ +-assoc (n .force) ⟩ n .force + m .force * suc n + (o + m .force * o) ∼⟨ (n .force + _ ∎∼) +-cong symmetric-∼ suc*∼+* ⟩ n .force + m .force * suc n + suc m * o ∎∼ } *-+-distribʳ : ∀ m {n o i} → [ i ] (m + n) * o ∼ m * o + n * o *-+-distribʳ zero = reflexive-∼ _ *-+-distribʳ (suc m) {n} {zero} = zero ∼⟨ symmetric-∼ *-right-zero ⟩ n * zero ∎∼ *-+-distribʳ (suc m) {n} {suc o} = suc λ { .force → o .force + (m .force + n) * suc o ∼⟨ (_ ∎∼) +-cong *-+-distribʳ (m .force) ⟩ o .force + (m .force * suc o + n * suc o) ∼⟨ +-assoc (o .force) ⟩ o .force + m .force * suc o + n * suc o ∎∼ } -- Multiplication is associative. *-assoc : ∀ m {n o i} → [ i ] m * (n * o) ∼ (m * n) * o *-assoc zero = reflexive-∼ _ *-assoc (suc m) {zero} = reflexive-∼ _ *-assoc (suc m) {suc n} {zero} = reflexive-∼ _ *-assoc (suc m) {suc n} {suc o} = suc λ { .force → o .force + n .force * suc o + m .force * (suc n * suc o) ∼⟨ symmetric-∼ (+-assoc (o .force)) ⟩ o .force + (n .force * suc o + m .force * (suc n * suc o)) ∼⟨ (o .force ∎∼) +-cong ((_ ∎∼) +-cong *-assoc (m .force)) ⟩ o .force + (n .force * suc o + (m .force * suc n) * suc o) ∼⟨ (o .force ∎∼) +-cong symmetric-∼ (*-+-distribʳ (n .force)) ⟩ o .force + (n .force + m .force * suc n) * suc o ∎∼ } -- Multiplication is commutative. *-comm : ∀ m {n i} → [ i ] m * n ∼ n * m *-comm zero {n} = zero ∼⟨ symmetric-∼ *-right-zero ⟩ n * zero ∎∼ *-comm (suc m) {zero} = reflexive-∼ _ *-comm (suc m) {suc n} = suc λ { .force → n .force + m .force * suc n ∼⟨ (_ ∎∼) +-cong *-comm (m .force) ⟩ n .force + suc n * m .force ∼⟨ (n .force ∎∼) +-cong suc*∼+* ⟩ n .force + (m .force + n .force * m .force) ∼⟨ +-assoc (n .force) ⟩ (n .force + m .force) + n .force * m .force ∼⟨ +-comm (n .force) +-cong *-comm _ ⟩ (m .force + n .force) + m .force * n .force ∼⟨ symmetric-∼ (+-assoc (m .force)) ⟩ m .force + (n .force + m .force * n .force) ∼⟨ (m .force ∎∼) +-cong symmetric-∼ suc*∼+* ⟩ m .force + suc m * n .force ∼⟨ (m .force ∎∼) +-cong *-comm (suc m) ⟩ m .force + n .force * suc m ∎∼ } -- An unfolding lemma for multiplication. *suc∼+* : ∀ {m n i} → [ i ] m * suc n ∼ m + m * n .force *suc∼+* {m} {n} = m * suc n ∼⟨ *-comm _ ⟩ suc n * m ∼⟨ suc*∼+* ⟩ m + n .force * m ∼⟨ (_ ∎∼) +-cong *-comm (n .force) ⟩ m + m * n .force ∎∼ -- Multiplication preserves bisimilarity. infixl 7 _*-cong_ _*-cong_ : ∀ {i m₁ m₂ n₁ n₂} → [ i ] m₁ ∼ m₂ → [ i ] n₁ ∼ n₂ → [ i ] m₁ * n₁ ∼ m₂ * n₂ zero *-cong _ = zero suc p *-cong zero = zero suc p *-cong suc q = suc λ { .force → q .force +-cong p .force *-cong suc q } -- ⌜_⌝ is homomorphic with respect to multiplication. ⌜⌝-* : ∀ m {n i} → [ i ] ⌜ m Prelude.* n ⌝ ∼ ⌜ m ⌝ * ⌜ n ⌝ ⌜⌝-* zero = reflexive-∼ _ ⌜⌝-* (suc m) {n} = ⌜ n Prelude.+ m Prelude.* n ⌝ ∼⟨ ⌜⌝-+ n ⟩ ⌜ n ⌝ + ⌜ m Prelude.* n ⌝ ∼⟨ reflexive-∼ _ +-cong ⌜⌝-* m ⟩ ⌜ n ⌝ + ⌜ m ⌝ * ⌜ n ⌝ ∼⟨ symmetric-∼ suc*∼+* ⟩ ⌜ suc m ⌝ * ⌜ n ⌝ ∎∼ ------------------------------------------------------------------------ -- Ordering -- [ ∞ ] m ≤ n means that m is less than or equal to n. mutual infix 4 [_]_≤_ [_]_≤′_ data [_]_≤_ (i : Size) : Conat ∞ → Conat ∞ → Type where zero : ∀ {n} → [ i ] zero ≤ n suc : ∀ {m n} → [ i ] force m ≤′ force n → [ i ] suc m ≤ suc n record [_]_≤′_ (i : Size) (m n : Conat ∞) : Type where coinductive field force : {j : Size< i} → [ j ] m ≤ n open [_]_≤′_ public -- [ ∞ ] m < n means that m is less than n (if n is finite). infix 4 [_]_<_ [_]_<_ : Size → Conat′ ∞ → Conat ∞ → Type [ i ] m < n = [ i ] suc m ≤ n -- Every conatural number is less than or equal to infinity. infix 4 _≤infinity _≤infinity : ∀ {i} n → [ i ] n ≤ infinity zero ≤infinity = zero suc n ≤infinity = suc λ { .force → force n ≤infinity } -- No natural number is greater than or equal to infinity. infinity≰⌜⌝ : ∀ n → ¬ [ ∞ ] infinity ≤ ⌜ n ⌝ infinity≰⌜⌝ zero () infinity≰⌜⌝ (suc n) (suc p) = infinity≰⌜⌝ n (force p) -- No number is less than zero. ≮0 : ∀ {n i} → ¬ [ i ] n < zero ≮0 () -- If a number is not bounded from above by any natural number, then -- it is bisimilar to infinity. ¬≤⌜⌝→∼∞ : ∀ {i} m → (∀ n → ¬ [ ∞ ] m ≤ ⌜ n ⌝) → [ i ] m ∼ infinity ¬≤⌜⌝→∼∞ zero zero≰ = ⊥-elim (zero≰ 0 zero) ¬≤⌜⌝→∼∞ (suc m) hyp = suc λ { .force → ¬≤⌜⌝→∼∞ (force m) λ n → [ ∞ ] force m ≤ ⌜ n ⌝ ↝⟨ (λ p → suc λ { .force → p }) ⟩ [ ∞ ] suc m ≤ ⌜ suc n ⌝ ↝⟨ hyp (suc n) ⟩□ ⊥ □ } -- The ordering relation is a partial order (with respect to -- bisimilarity). reflexive-≤ : ∀ {i} n → [ i ] n ≤ n reflexive-≤ zero = zero reflexive-≤ (suc n) = suc λ { .force → reflexive-≤ (force n) } transitive-≤ : ∀ {i m n o} → [ i ] m ≤ n → [ i ] n ≤ o → [ i ] m ≤ o transitive-≤ zero _ = zero transitive-≤ (suc p) (suc q) = suc λ { .force → transitive-≤ (force p) (force q) } antisymmetric-≤ : ∀ {i m n} → [ i ] m ≤ n → [ i ] n ≤ m → [ i ] m ∼ n antisymmetric-≤ zero zero = zero antisymmetric-≤ (suc p) (suc q) = suc λ { .force → antisymmetric-≤ (force p) (force q) } -- Bisimilarity is contained in the ordering relation. ∼→≤ : ∀ {i m n} → [ i ] m ∼ n → [ i ] m ≤ n ∼→≤ zero = zero ∼→≤ (suc p) = suc λ { .force → ∼→≤ (force p) } -- "Equational" reasoning combinators. infix -1 finally-≤ _∎≤ infixr -2 step-≤ step-∼≤ _≡⟨⟩≤_ _∎≤ : ∀ {i} n → [ i ] n ≤ n _∎≤ = reflexive-≤ step-≤ : ∀ {i} m {n o} → [ i ] n ≤ o → [ i ] m ≤ n → [ i ] m ≤ o step-≤ _ n≤o m≤n = transitive-≤ m≤n n≤o syntax step-≤ m n≤o m≤n = m ≤⟨ m≤n ⟩ n≤o step-∼≤ : ∀ {i} m {n o} → [ i ] n ≤ o → [ i ] m ∼ n → [ i ] m ≤ o step-∼≤ _ n≤o m∼n = step-≤ _ n≤o (∼→≤ m∼n) syntax step-∼≤ m n≤o m∼n = m ∼⟨ m∼n ⟩≤ n≤o _≡⟨⟩≤_ : ∀ {i} m {n} → [ i ] m ≤ n → [ i ] m ≤ n _ ≡⟨⟩≤ m≤n = m≤n finally-≤ : ∀ {i} m n → [ i ] m ≤ n → [ i ] m ≤ n finally-≤ _ _ m≤n = m≤n syntax finally-≤ m n m≤n = m ≤⟨ m≤n ⟩∎ n ∎≤ -- The ordering relation respects the ordering relation -- (contravariantly in the first argument). infix 4 _≤-cong-≤_ _≤-cong-≤_ : ∀ {m m′ n n′ i} → [ i ] m′ ≤ m → [ i ] n ≤ n′ → [ i ] m ≤ n → [ i ] m′ ≤ n′ _≤-cong-≤_ {m} {m′} {n} {n′} m≥m′ n≤n′ m≤n = m′ ≤⟨ m≥m′ ⟩ m ≤⟨ m≤n ⟩ n ≤⟨ n≤n′ ⟩ n′ ∎≤ -- A kind of preservation result for bisimilarity, ordering and -- logical equivalence. infix 4 _≤-cong-∼_ _≤-cong-∼_ : ∀ {m m′ n n′ i} → [ i ] m ∼ m′ → [ i ] n ∼ n′ → [ i ] m ≤ n ⇔ [ i ] m′ ≤ n′ m∼m′ ≤-cong-∼ n∼n′ = record { to = ∼→≤ (symmetric-∼ m∼m′) ≤-cong-≤ ∼→≤ n∼n′ ; from = ∼→≤ m∼m′ ≤-cong-≤ ∼→≤ (symmetric-∼ n∼n′) } -- Some inversion lemmas. cancel-suc-≤ : ∀ {i m n} → [ i ] suc m ≤ suc n → [ i ] force m ≤′ force n cancel-suc-≤ (suc p) = p cancel-pred-≤ : ∀ {m n i} → [ i ] ⌜ 1 ⌝ ≤ n → [ i ] pred m ≤′ pred n → [ i ] m ≤ n cancel-pred-≤ {zero} (suc _) = λ _ → zero cancel-pred-≤ {suc _} (suc _) = suc cancel-∸-suc-≤ : ∀ {m n o i} → [ ∞ ] ⌜ o ⌝′ < n → [ i ] m ∸ suc o ≤′ n ∸ suc o → [ i ] m ∸ o ≤ n ∸ o cancel-∸-suc-≤ {zero} {n} {o} _ _ = zero ∸ o ∼⟨ ∸-left-zero-zero o ⟩≤ zero ≤⟨ zero ⟩∎ n ∸ o ∎≤ cancel-∸-suc-≤ {suc _} {_} {zero} (suc _) = suc cancel-∸-suc-≤ {suc m} {suc n} {suc o} (suc o<n) = cancel-∸-suc-≤ (force o<n) -- The successor of a number is greater than or equal to the number. ≤suc : ∀ {i n} → [ i ] force n ≤ suc n ≤suc = helper _ (refl _) where helper : ∀ {i} m {n} → m ≡ force n → [ i ] m ≤ suc n helper zero _ = zero helper (suc m) 1+m≡ = suc λ { .force {j = j} → subst ([ j ] _ ≤_) 1+m≡ ≤suc } -- If a number is less than or equal to another, then it is also less -- than or equal to the other's successor. ≤-step : ∀ {m n i} → [ i ] m ≤′ force n → [ i ] m ≤ suc n ≤-step {zero} _ = zero ≤-step {suc m} {n} p = suc λ { .force → force m ≤⟨ ≤suc ⟩ suc m ≤⟨ force p ⟩∎ force n ∎≤ } -- If m is less than n, then m is less than or equal to n. <→≤ : ∀ {i m n} → [ i ] m < n → [ i ] force m ≤ n <→≤ (suc p) = ≤-step p -- If you add something to a number, then you get something that is -- greater than or equal to what you started with. m≤n+m : ∀ {i m n} → [ i ] m ≤ n + m m≤n+m {n = zero} = reflexive-≤ _ m≤n+m {n = suc n} = ≤-step λ { .force → m≤n+m } m≤m+n : ∀ {m n i} → [ i ] m ≤ m + n m≤m+n {m} {n} = m ≤⟨ m≤n+m ⟩ n + m ≤⟨ ∼→≤ (+-comm n) ⟩∎ m + n ∎≤ -- A form of associativity for _∸_. ∸-∸-assoc : ∀ {m} n {k i} → [ i ] (m ∸ n) ∸ k ∼ m ∸ (n Prelude.+ k) ∸-∸-assoc zero = _ ∎∼ ∸-∸-assoc {zero} (suc _) {zero} = _ ∎∼ ∸-∸-assoc {zero} (suc _) {suc _} = _ ∎∼ ∸-∸-assoc {suc _} (suc n) = ∸-∸-assoc n -- A limited form of associativity for _+_ and _∸_. +-∸-assoc : ∀ {m n k i} → [ ∞ ] ⌜ k ⌝ ≤ n → [ i ] (m + n) ∸ k ∼ m + (n ∸ k) +-∸-assoc {m} {n} {zero} zero = m + n ∸ 0 ≡⟨⟩∼ m + n ≡⟨⟩∼ m + (n ∸ 0) ∎∼ +-∸-assoc {m} {suc n} {suc k} (suc k≤n) = m + suc n ∸ suc k ∼⟨ symmetric-∼ (1++∼+suc m) ∸-cong refl (suc k) ⟩ ⌜ 1 ⌝ + m + force n ∸ suc k ≡⟨⟩∼ m + force n ∸ k ∼⟨ +-∸-assoc (force k≤n) ⟩ m + (force n ∸ k) ≡⟨⟩∼ m + (suc n ∸ suc k) ∎∼ -- If you subtract a number and then add it again, then you get back -- what you started with if the number is less than or equal to the -- number that you started with. ∸+≡ : ∀ {m n i} → [ i ] ⌜ n ⌝ ≤ m → [ i ] (m ∸ n) + ⌜ n ⌝ ∼ m ∸+≡ {m} {zero} zero = m + zero ∼⟨ +-right-identity _ ⟩∎ m ∎∼ ∸+≡ {.suc m} {suc n} (suc p) = force m ∸ n + ⌜ suc n ⌝ ∼⟨ symmetric-∼ (1++∼+suc _) ⟩ ⌜ 1 ⌝ + (force m ∸ n) + ⌜ n ⌝ ∼⟨ symmetric-∼ (+-assoc ⌜ 1 ⌝) ⟩ ⌜ 1 ⌝ + (force m ∸ n + ⌜ n ⌝) ∼⟨ (suc λ { .force → ∸+≡ (force p) }) ⟩ ⌜ 1 ⌝ + force m ∼⟨ (suc λ { .force → _ ∎∼ }) ⟩∎ suc m ∎∼ -- If you subtract a natural number and then add it again, then you -- get something that is greater than or equal to what you started -- with. ≤∸+ : ∀ m n {i} → [ i ] m ≤ (m ∸ n) + ⌜ n ⌝ ≤∸+ m zero = m ∼⟨ symmetric-∼ (+-right-identity _) ⟩≤ m + ⌜ 0 ⌝ ∎≤ ≤∸+ zero (suc n) = zero ≤∸+ (suc m) (suc n) = suc m ≤⟨ (suc λ { .force → ≤∸+ (force m) n }) ⟩ ⌜ 1 ⌝ + (force m ∸ n + ⌜ n ⌝) ∼⟨ +-assoc ⌜ 1 ⌝ ⟩≤ ⌜ 1 ⌝ + (force m ∸ n) + ⌜ n ⌝ ∼⟨ 1++∼+suc _ ⟩≤ force m ∸ n + ⌜ suc n ⌝ ≡⟨⟩≤ suc m ∸ suc n + ⌜ suc n ⌝ ∎≤ -- If you subtract something from a number you get a number that is -- less than or equal to the one you started with. ∸≤ : ∀ {m} n {i} → [ i ] m ∸ n ≤ m ∸≤ zero = _ ∎≤ ∸≤ {zero} (suc _) = _ ∎≤ ∸≤ {suc m} (suc n) = ≤-step λ { .force → ∸≤ n } -- Lemmas relating the ordering relation, subtraction and the -- successor function. ∸suc≤→∸≤suc : ∀ {i} m n {o} → [ i ] m ∸ suc n ≤ force o → [ ssuc i ] m ∸ n ≤ suc o ∸suc≤→∸≤suc zero zero p = zero ∸suc≤→∸≤suc zero (suc n) p = zero ∸suc≤→∸≤suc (suc m) zero p = suc λ { .force → p } ∸suc≤→∸≤suc (suc m) (suc n) p = ∸suc≤→∸≤suc (force m) n p ∸≤suc→∸suc≤ : ∀ {i} {j : Size< i} m n {o} → [ i ] m ∸ n ≤ suc o → [ j ] m ∸ suc n ≤ force o ∸≤suc→∸suc≤ zero zero p = zero ∸≤suc→∸suc≤ zero (suc n) p = zero ∸≤suc→∸suc≤ (suc m) zero (suc p) = force p ∸≤suc→∸suc≤ (suc m) (suc n) p = ∸≤suc→∸suc≤ (force m) n p -- One can decide whether a natural number is greater than or equal -- to, or less than, any number. ≤⌜⌝⊎>⌜⌝ : ∀ {i} m n → [ i ] m ≤ ⌜ n ⌝ ⊎ [ i ] ⌜ n ⌝′ < m ≤⌜⌝⊎>⌜⌝ zero _ = inj₁ zero ≤⌜⌝⊎>⌜⌝ (suc m) zero = inj₂ (suc λ { .force → zero }) ≤⌜⌝⊎>⌜⌝ (suc m) (suc n) = ⊎-map (λ (p : [ _ ] _ ≤ _) → suc λ { .force → p }) (λ (p : [ _ ] _ < _) → suc λ { .force → p }) (≤⌜⌝⊎>⌜⌝ (force m) n) -- One can decide whether a natural number is less than or equal to, -- or greater than, any number. ⌜⌝≤⊎⌜⌝> : ∀ {i} m n → [ i ] ⌜ m ⌝ ≤ n ⊎ [ i ] ⌜ 1 ⌝ + n ≤ ⌜ m ⌝ ⌜⌝≤⊎⌜⌝> zero _ = inj₁ zero ⌜⌝≤⊎⌜⌝> (suc m) zero = inj₂ (suc λ { .force → zero }) ⌜⌝≤⊎⌜⌝> (suc m) (suc n) = ⊎-map (λ (p : [ _ ] _ ≤ _) → suc λ { .force → p }) (λ p → suc λ { .force → suc n ≤⟨ (suc λ { .force → _ ∎≤ }) ⟩ ⌜ 1 ⌝ + force n ≤⟨ p ⟩∎ ⌜ m ⌝ ∎≤ }) (⌜⌝≤⊎⌜⌝> m (force n)) -- ⌜_⌝ is monotone. ⌜⌝-mono : ∀ {m n i} → m ≤ n → [ i ] ⌜ m ⌝ ≤ ⌜ n ⌝ ⌜⌝-mono {zero} m≤n = zero ⌜⌝-mono {suc _} {zero} m≤n = ⊥-elim (Nat.≮0 _ m≤n) ⌜⌝-mono {suc _} {suc _} m≤n = suc λ { .force → ⌜⌝-mono (Nat.suc≤suc⁻¹ m≤n) } -- If two natural numbers are related by [ ∞ ]_≤_, then they are also -- related by _≤_. ⌜⌝-mono⁻¹ : ∀ {m n} → [ ∞ ] ⌜ m ⌝ ≤ ⌜ n ⌝ → m ≤ n ⌜⌝-mono⁻¹ {zero} zero = Nat.zero≤ _ ⌜⌝-mono⁻¹ {suc _} {zero} () ⌜⌝-mono⁻¹ {suc _} {suc _} (suc m≤n) = Nat.suc≤suc (⌜⌝-mono⁻¹ (force m≤n)) -- The pred function is monotone. pred-mono : ∀ {m n} → [ ∞ ] m ≤ n → [ ∞ ] pred m ≤ pred n pred-mono zero = zero pred-mono (suc p) = force p -- Addition is monotone. infixl 6 _+-mono_ _+-mono_ : ∀ {i m₁ m₂ n₁ n₂} → [ i ] m₁ ≤ m₂ → [ i ] n₁ ≤ n₂ → [ i ] m₁ + n₁ ≤ m₂ + n₂ _+-mono_ {m₁ = m₁} {m₂} {n₁} {n₂} zero q = zero + n₁ ≡⟨⟩≤ n₁ ≤⟨ q ⟩ n₂ ≤⟨ m≤n+m ⟩∎ m₂ + n₂ ∎≤ suc p +-mono q = suc λ { .force → force p +-mono q } -- Subtraction is monotone in its first argument and antitone in its -- second argument. infixl 6 _∸-mono_ _∸-mono_ : ∀ {m₁ m₂ n₁ n₂ i} → [ ∞ ] m₁ ≤ m₂ → n₂ ≤ n₁ → [ i ] m₁ ∸ n₁ ≤ m₂ ∸ n₂ _∸-mono_ {n₁ = zero} {zero} p _ = p _∸-mono_ {n₁ = zero} {suc _} _ q = ⊥-elim (Nat.≮0 _ q) _∸-mono_ {zero} {n₁ = suc n₁} _ _ = zero _∸-mono_ {suc _} {zero} {suc _} () _ _∸-mono_ {suc m₁} {suc m₂} {suc n₁} {zero} p _ = force m₁ ∸ n₁ ≤⟨ ∸≤ n₁ ⟩ force m₁ ≤⟨ ≤suc ⟩ suc m₁ ≤⟨ p ⟩∎ suc m₂ ∎≤ _∸-mono_ {suc _} {suc _} {suc _} {suc _} p q = force (cancel-suc-≤ p) ∸-mono Nat.suc≤suc⁻¹ q -- Multiplication is monotone. infixl 7 _*-mono_ _*-mono_ : ∀ {i m₁ m₂ n₁ n₂} → [ i ] m₁ ≤ m₂ → [ i ] n₁ ≤ n₂ → [ i ] m₁ * n₁ ≤ m₂ * n₂ zero *-mono _ = zero suc _ *-mono zero = zero suc p *-mono suc q = suc λ { .force → q .force +-mono p .force *-mono suc q } ------------------------------------------------------------------------ -- Minimum and maximum -- The smallest number. min : ∀ {i} → Conat i → Conat i → Conat i min zero n = zero min m zero = zero min (suc m) (suc n) = suc λ { .force → min (force m) (force n) } -- The largest number. max : ∀ {i} → Conat i → Conat i → Conat i max zero n = n max (suc m) n = suc λ { .force → max (force m) (pred n) } -- The minimum of two numbers is less than or equal to both of them. min≤ˡ : ∀ {i} m n → [ i ] min m n ≤ m min≤ˡ zero _ = zero min≤ˡ (suc _) zero = zero min≤ˡ (suc m) (suc n) = suc λ { .force → min≤ˡ (force m) (force n) } min≤ʳ : ∀ {i} m n → [ i ] min m n ≤ n min≤ʳ zero _ = zero min≤ʳ (suc _) zero = zero min≤ʳ (suc m) (suc n) = suc λ { .force → min≤ʳ (force m) (force n) } -- The maximum of two numbers is greater than or equal to both of -- them. ˡ≤max : ∀ {i} m n → [ i ] m ≤ max m n ˡ≤max zero _ = zero ˡ≤max (suc m) n = suc λ { .force → ˡ≤max (force m) (pred n) } ʳ≤max : ∀ {i} m n → [ i ] n ≤ max m n ʳ≤max zero _ = reflexive-≤ _ ʳ≤max (suc _) zero = zero ʳ≤max (suc m) (suc n) = suc λ { .force → ʳ≤max (force m) (force n) } -- The min and max functions preserve bisimilarity. min-cong : ∀ {i m₁ m₂ n₁ n₂} → [ i ] m₁ ∼ m₂ → [ i ] n₁ ∼ n₂ → [ i ] min m₁ n₁ ∼ min m₂ n₂ min-cong zero q = zero min-cong (suc p) zero = zero min-cong (suc p) (suc q) = suc λ { .force → min-cong (force p) (force q) } max-cong : ∀ {i m₁ m₂ n₁ n₂} → [ i ] m₁ ∼ m₂ → [ i ] n₁ ∼ n₂ → [ i ] max m₁ n₁ ∼ max m₂ n₂ max-cong zero q = q max-cong (suc p) q = suc λ { .force → max-cong (force p) (pred-cong q) } ------------------------------------------------------------------------ -- Finite and infinite numbers -- A number is finite if it is bisimilar to a natural number. Finite : Conat ∞ → Type Finite m = ∃ λ n → [ ∞ ] m ∼ ⌜ n ⌝ -- Numbers that are not finite are infinite. Infinite : Conat ∞ → Type Infinite n = ¬ Finite n -- The value infinity is infinite. Infinite-infinity : Infinite infinity Infinite-infinity = uncurry λ n → [ ∞ ] infinity ∼ ⌜ n ⌝ ↝⟨ ∼→≤ ⟩ [ ∞ ] infinity ≤ ⌜ n ⌝ ↝⟨ infinity≰⌜⌝ _ ⟩ ⊥ □ -- Infinite numbers are bisimilar to infinity. Infinite→∼infinity : ∀ {n i} → Infinite n → [ i ] n ∼ infinity Infinite→∼infinity {zero} inf = ⊥-elim (inf (_ , zero)) Infinite→∼infinity {suc n} inf = suc λ { .force → Infinite→∼infinity (inf ∘ Σ-map suc suc′) } where suc′ : ∀ {m} → [ ∞ ] force n ∼ ⌜ m ⌝ → [ ∞ ] suc n ∼ ⌜ suc m ⌝ suc′ p = suc λ { .force → p } -- If m is bounded from above by some natural number, then m is -- finite. ≤⌜⌝→Finite : ∀ {m n} → [ ∞ ] m ≤ ⌜ n ⌝ → Finite m ≤⌜⌝→Finite {.zero} {zero} zero = zero , zero ≤⌜⌝→Finite {.zero} {suc n} zero = zero , zero ≤⌜⌝→Finite {.suc m} {suc n} (suc m≤n) = Σ-map suc (λ (hyp : [ _ ] _ ∼ _) → suc λ { .force → hyp }) (≤⌜⌝→Finite (force m≤n)) ------------------------------------------------------------------------ -- Functions and proofs related to addition of strictly positive -- numbers -- The function _⁺+_ adds two numbers, given that the first one is -- positive. This fact allows the second number to have type Conat′ i, -- rather than Conat i. This can be convenient in corecursive -- definitions. infixl 6 _⁺+_ _⁺+_ : ∀ {m i} → [ i ] ⌜ 1 ⌝ ≤ m → Conat′ i → Conat i _⁺+_ {zero} () _ _⁺+_ {suc m} _ n = suc λ { .force → force m + force n } -- The definition of _⁺+_ is correct. ⁺+∼+ : ∀ {m i} (1≤m : [ ∞ ] ⌜ 1 ⌝ ≤ m) n → [ i ] 1≤m ⁺+ n ∼ m + force n ⁺+∼+ {zero} () _ ⁺+∼+ {suc _} _ _ = suc λ { .force → _ ∎∼ } -- _⁺+_ preserves bisimilarity. ⁺+-cong : ∀ {m₁ m₂ n₁ n₂ i} (1≤m₁ : [ ∞ ] ⌜ 1 ⌝ ≤ m₁) (1≤m₂ : [ ∞ ] ⌜ 1 ⌝ ≤ m₂) → [ i ] m₁ ∼ m₂ → [ i ] force n₁ ∼′ force n₂ → [ i ] 1≤m₁ ⁺+ n₁ ∼ 1≤m₂ ⁺+ n₂ ⁺+-cong {zero} () _ _ _ ⁺+-cong {suc _} {zero} _ () _ _ ⁺+-cong {suc _} {suc _} _ _ (suc m₁∼m₂) n₁∼n₂ = suc λ { .force → force m₁∼m₂ +-cong force n₁∼n₂ } -- _⁺+_ is monotone. ⁺+-mono : ∀ {m₁ m₂ n₁ n₂ i} (1≤m₁ : [ ∞ ] ⌜ 1 ⌝ ≤ m₁) (1≤m₂ : [ ∞ ] ⌜ 1 ⌝ ≤ m₂) → [ i ] m₁ ≤ m₂ → [ i ] force n₁ ≤′ force n₂ → [ i ] 1≤m₁ ⁺+ n₁ ≤ 1≤m₂ ⁺+ n₂ ⁺+-mono {zero} () _ _ _ ⁺+-mono {suc _} {zero} _ () _ _ ⁺+-mono {suc _} {suc _} _ _ (suc m₁∼m₂) n₁∼n₂ = suc λ { .force → force m₁∼m₂ +-mono force n₁∼n₂ } -- Variants of _+-cong_ that can be used when one or more of the -- numbers are known to be positive. With this information at hand it -- suffices for some of the proofs to be "primed". 1≤+-cong : ∀ {m₁ m₂ n₁ n₂ i} → [ i ] ⌜ 1 ⌝ ≤ m₁ → [ i ] m₁ ∼ m₂ → [ i ] n₁ ∼′ n₂ → [ i ] m₁ + n₁ ∼ m₂ + n₂ 1≤+-cong {zero} () _ _ 1≤+-cong {suc _} {zero} _ () _ 1≤+-cong {suc _} {suc _} _ (suc m₁∼m₂) n₁∼n₂ = suc λ { .force → force m₁∼m₂ +-cong force n₁∼n₂ } +1≤-cong : ∀ {m₁ m₂ n₁ n₂ i} → [ i ] ⌜ 1 ⌝ ≤ n₁ → [ i ] m₁ ∼′ m₂ → [ i ] n₁ ∼ n₂ → [ i ] m₁ + n₁ ∼ m₂ + n₂ +1≤-cong {m₁} {m₂} {n₁} {n₂} 1≤n₁ m₁∼m₂ n₁∼n₂ = m₁ + n₁ ∼⟨ +-comm m₁ ⟩ n₁ + m₁ ∼⟨ 1≤+-cong 1≤n₁ n₁∼n₂ m₁∼m₂ ⟩ n₂ + m₂ ∼⟨ +-comm n₂ ⟩∎ m₂ + n₂ ∎∼ 1≤+1≤-cong : ∀ {m₁ m₂ n₁ n₂ i} → [ i ] ⌜ 1 ⌝ ≤ m₁ → [ i ] ⌜ 1 ⌝ ≤ n₂ → [ i ] m₁ ∼′ m₂ → [ i ] n₁ ∼′ n₂ → [ i ] m₁ + n₁ ∼ m₂ + n₂ 1≤+1≤-cong {m₁} {m₂} {n₁} {n₂} 1≤m₁ 1≤n₂ m₁∼m₂ n₁∼n₂ = m₁ + n₁ ∼⟨ 1≤+-cong 1≤m₁ (_ ∎∼) n₁∼n₂ ⟩ m₁ + n₂ ∼⟨ +1≤-cong 1≤n₂ m₁∼m₂ (_ ∎∼) ⟩∎ m₂ + n₂ ∎∼ -- Variants of _+-mono_ that can be used when one or more of the -- numbers are known to be positive. With this information at hand it -- suffices for some of the proofs to be "primed". 1≤+-mono : ∀ {m₁ m₂ n₁ n₂ i} → [ i ] ⌜ 1 ⌝ ≤ m₁ → [ i ] m₁ ≤ m₂ → [ i ] n₁ ≤′ n₂ → [ i ] m₁ + n₁ ≤ m₂ + n₂ 1≤+-mono {zero} () _ _ 1≤+-mono {suc _} {zero} _ () _ 1≤+-mono {suc _} {suc _} _ (suc m₁≤m₂) n₁≤n₂ = suc λ { .force → force m₁≤m₂ +-mono force n₁≤n₂ } +1≤-mono : ∀ {m₁ m₂ n₁ n₂ i} → [ i ] ⌜ 1 ⌝ ≤ n₁ → [ i ] m₁ ≤′ m₂ → [ i ] n₁ ≤ n₂ → [ i ] m₁ + n₁ ≤ m₂ + n₂ +1≤-mono {m₁} {m₂} {n₁} {n₂} 1≤n₁ m₁≤m₂ n₁≤n₂ = m₁ + n₁ ∼⟨ +-comm m₁ ⟩≤ n₁ + m₁ ≤⟨ 1≤+-mono 1≤n₁ n₁≤n₂ m₁≤m₂ ⟩ n₂ + m₂ ∼⟨ +-comm n₂ ⟩≤ m₂ + n₂ ∎≤ 1≤+1≤-mono : ∀ {m₁ m₂ n₁ n₂ i} → [ i ] ⌜ 1 ⌝ ≤ m₁ → [ i ] ⌜ 1 ⌝ ≤ n₂ → [ i ] m₁ ≤′ m₂ → [ i ] n₁ ≤′ n₂ → [ i ] m₁ + n₁ ≤ m₂ + n₂ 1≤+1≤-mono {m₁} {m₂} {n₁} {n₂} 1≤m₁ 1≤n₂ m₁≤m₂ n₁≤n₂ = m₁ + n₁ ≤⟨ 1≤+-mono 1≤m₁ (_ ∎≤) n₁≤n₂ ⟩ m₁ + n₂ ≤⟨ +1≤-mono 1≤n₂ m₁≤m₂ (_ ∎≤) ⟩∎ m₂ + n₂ ∎≤ ------------------------------------------------------------------------ -- Some negative results -- It is impossible to define a strengthening function that, for any -- size i, takes strong bisimilarity of size i between 2 and 1 into -- ordering of size ssuc i between 2 and 1. no-strengthening-21 : ¬ (∀ {i} → [ i ] ⌜ 2 ⌝ ∼ ⌜ 1 ⌝ → [ ssuc i ] ⌜ 2 ⌝ ≤ ⌜ 1 ⌝) no-strengthening-21 strengthen = contradiction ∞ where 2≁1 : ∀ i → ¬ [ i ] ⌜ 2 ⌝ ∼ ⌜ 1 ⌝ 2≁1 i = [ i ] ⌜ 2 ⌝ ∼ ⌜ 1 ⌝ ↝⟨ strengthen ⟩ [ ssuc i ] ⌜ 2 ⌝ ≤ ⌜ 1 ⌝ ↝⟨ (λ hyp → cancel-suc-≤ hyp .force) ⟩ [ i ] ⌜ 1 ⌝ ≤ ⌜ 0 ⌝ ↝⟨ ≮0 ⟩□ ⊥ □ mutual 2∼1 : ∀ i → [ i ] ⌜ 2 ⌝ ∼ ⌜ 1 ⌝ 2∼1 i = suc λ { .force {j} → ⊥-elim (contradiction j) } contradiction : Size → ⊥ contradiction i = 2≁1 i (2∼1 i) -- It is impossible to define a strengthening function that, for any -- size i, takes strong bisimilarity of size i between 2 and 1 into -- strong bisimilarity of size ssuc i between 2 and 1. no-strengthening-∼-21 : ¬ (∀ {i} → [ i ] ⌜ 2 ⌝ ∼ ⌜ 1 ⌝ → [ ssuc i ] ⌜ 2 ⌝ ∼ ⌜ 1 ⌝) no-strengthening-∼-21 = (∀ {i} → [ i ] ⌜ 2 ⌝ ∼ ⌜ 1 ⌝ → [ ssuc i ] ⌜ 2 ⌝ ∼ ⌜ 1 ⌝) ↝⟨ ∼→≤ ∘_ ⟩ (∀ {i} → [ i ] ⌜ 2 ⌝ ∼ ⌜ 1 ⌝ → [ ssuc i ] ⌜ 2 ⌝ ≤ ⌜ 1 ⌝) ↝⟨ no-strengthening-21 ⟩□ ⊥ □ -- It is impossible to define a strengthening function that, for any -- size i, takes ordering of size i between 2 and 1 into ordering of -- size ssuc i between 2 and 1. no-strengthening-≤-21 : ¬ (∀ {i} → [ i ] ⌜ 2 ⌝ ≤ ⌜ 1 ⌝ → [ ssuc i ] ⌜ 2 ⌝ ≤ ⌜ 1 ⌝) no-strengthening-≤-21 = (∀ {i} → [ i ] ⌜ 2 ⌝ ≤ ⌜ 1 ⌝ → [ ssuc i ] ⌜ 2 ⌝ ≤ ⌜ 1 ⌝) ↝⟨ _∘ ∼→≤ ⟩ (∀ {i} → [ i ] ⌜ 2 ⌝ ∼ ⌜ 1 ⌝ → [ ssuc i ] ⌜ 2 ⌝ ≤ ⌜ 1 ⌝) ↝⟨ no-strengthening-21 ⟩□ ⊥ □
{ "alphanum_fraction": 0.4647725508, "avg_line_length": 30.7593123209, "ext": "agda", "hexsha": "e0f0dd7b46f28533dbbb085ab40180faee20908c", "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/Conat.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/Conat.agda", "max_line_length": 125, "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/Conat.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": 15495, "size": 32205 }
open import Data.Product using ( ∃ ; _×_ ; _,_ ; proj₁ ; proj₂ ) open import Relation.Unary using ( _∈_ ) open import Web.Semantic.DL.ABox using ( ABox ) open import Web.Semantic.DL.ABox.Model using ( _⊨a_ ; _⊨b_ ; ⊨a-resp-≲ ; ⊨b-resp-≲ ) open import Web.Semantic.DL.ABox.Interp using ( Interp ; ⌊_⌋ ; _*_ ) open import Web.Semantic.DL.ABox.Interp.Morphism using ( _≲_ ; ≲-refl ) open import Web.Semantic.DL.KB using ( _,_ ) open import Web.Semantic.DL.KB.Model using ( _⊨_ ) open import Web.Semantic.DL.Integrity using ( Initial ; _⊕_⊨_ ; extension ; ext-init ; ext-⊨ ; ext✓ ; init-≲ ; init-⊨ ; init-med ; med-≲ ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ; _,_ ) open import Web.Semantic.DL.TBox.Model using ( _⊨t_ ) open import Web.Semantic.DL.Category.Object using ( Object ; _,_ ; IN ; iface ) open import Web.Semantic.Util using ( _⊕_⊕_ ; inode ; enode ) module Web.Semantic.DL.Category.Morphism {Σ : Signature} {S T : TBox Σ} where infixr 4 _,_ -- A morphism A ⇒ B is an abox F such that for every I ⊨ S , T , A -- there is a J which is the initial extension of I satisfying (S , F), -- and moreover J satisfies (T , B). data _⇒_w/_ (A B : Object S T) (V : Set) : Set₁ where _,_ : (F : ABox Σ (IN A ⊕ V ⊕ IN B)) → (∀ I → (I ⊨ (S , T) , iface A) → (I ⊕ (S , F) ⊨ (T , iface B))) → (A ⇒ B w/ V) data _⇒_ (A B : Object S T) : Set₁ where _,_ : ∀ V → (A ⇒ B w/ V) → (A ⇒ B) BN : ∀ {A B} → (F : A ⇒ B) → Set BN (V , F,F✓) = V impl : ∀ {A B} → (F : A ⇒ B) → ABox Σ (IN A ⊕ BN F ⊕ IN B) impl (V , F , F✓) = F impl✓ : ∀ {A B} → (F : A ⇒ B) → ∀ I → (I ⊨ (S , T) , iface A) → (I ⊕ (S , impl F) ⊨ (T , iface B)) impl✓ (V , F , F✓) = F✓ apply : ∀ {A B} (F : A ⇒ B) I → (I ⊨ (S , T) , iface A) → Interp Σ (IN A ⊕ BN F ⊕ IN B) apply F I I⊨STA = extension (impl✓ F I I⊨STA) apply-init : ∀ {A B} (F : A ⇒ B) I I⊨STA → (apply F I I⊨STA ∈ Initial I (S , impl F)) apply-init F I I⊨STA = ext-init (impl✓ F I I⊨STA) apply-⊨ : ∀ {A B} (F : A ⇒ B) I I⊨STA → (enode * (apply F I I⊨STA) ⊨ (T , iface B)) apply-⊨ F I I⊨STA = ext-⊨ (impl✓ F I I⊨STA) apply-≲ : ∀ {A B} (F : A ⇒ B) I I⊨STA → (I ⊨a impl F) → (apply F (inode * I) I⊨STA ≲ I) apply-≲ F I ((I⊨S , I⊨T) , I⊨A) I⊨F = med-≲ (init-med (apply-init F (inode * I) ((I⊨S , I⊨T) , I⊨A)) I (≲-refl (inode * I)) (I⊨S , I⊨F)) apply✓ : ∀ {A B} (F : A ⇒ B) I I⊨STA → (enode * apply F I I⊨STA ⊨ (S , T) , iface B) apply✓ F I I⊨STA = ext✓ (impl✓ F I I⊨STA) -- Morphisms F and G are equivalent whenever -- in any interpretation I ⊨ S,T -- we have I ⊨ F iff I ⊨ G. infix 2 _⊑_ _⊑′_ _≣_ _⊑_ : ∀ {A B : Object S T} → (A ⇒ B) → (A ⇒ B) → Set₁ _⊑_ {A} F G = ∀ I → (inode * I ⊨ (S , T) , iface A) → (I ⊨a impl F) → (I ⊨b impl G) data _≣_ {A B : Object S T} (F G : A ⇒ B) : Set₁ where _,_ : (F ⊑ G) → (G ⊑ F) → (F ≣ G) -- An alternative characterization, which may be easier -- to work with. _⊑′_ : ∀ {A B : Object S T} → (A ⇒ B) → (A ⇒ B) → Set₁ F ⊑′ G = ∀ I I⊨STA → (apply F I I⊨STA) ⊨b (impl G) ⊑′-impl-⊑ : ∀ {A B : Object S T} → (F G : A ⇒ B) → (F ⊑′ G) → (F ⊑ G) ⊑′-impl-⊑ F G F⊑′G I I⊨STA I⊨F = ⊨b-resp-≲ (apply-≲ F I I⊨STA I⊨F) (impl G) (F⊑′G (inode * I) I⊨STA) ⊑-impl-⊑′ : ∀ {A B : Object S T} → (F G : A ⇒ B) → (F ⊑ G) → (F ⊑′ G) ⊑-impl-⊑′ {A} {B} F G F⊑G I (I⊨ST , I⊨A) = J⊨G where J : Interp Σ (IN A ⊕ BN F ⊕ IN B) J = apply F I (I⊨ST , I⊨A) J⊨S : ⌊ J ⌋ ⊨t S J⊨S = proj₁ (init-⊨ (apply-init F I (I⊨ST , I⊨A))) J⊨T : ⌊ J ⌋ ⊨t T J⊨T = proj₁ (apply-⊨ F I (I⊨ST , I⊨A)) J⊨A : inode * J ⊨a iface A J⊨A = ⊨a-resp-≲ (init-≲ (apply-init F I (I⊨ST , I⊨A))) (iface A) I⊨A J⊨F : J ⊨a impl F J⊨F = proj₂ (init-⊨ (apply-init F I (I⊨ST , I⊨A))) J⊨G : J ⊨b impl G J⊨G = F⊑G J ((J⊨S , J⊨T) , J⊨A) J⊨F
{ "alphanum_fraction": 0.5179704017, "avg_line_length": 34.4, "ext": "agda", "hexsha": "0a7809a1d4b0fe2cd701e1484b053c029517c84d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/Category/Morphism.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/Category/Morphism.agda", "max_line_length": 138, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/Category/Morphism.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 1928, "size": 3784 }
module x03-842Relations-hc where -- Library import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; sym) -- added sym open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Nat.Properties using (+-comm) -- The less-than-or-equal-to relation. data _≤_ : ℕ → ℕ → Set where z≤n : ∀ {n : ℕ} -------- → zero ≤ n s≤s : ∀ {m n : ℕ} → m ≤ n ------------- → suc m ≤ suc n -- Some examples. _ : 2 ≤ 4 -- can do just by refine _ = s≤s (s≤s z≤n) _ : 2 ≤ 4 -- with implicit args _ = s≤s {1} {3} (s≤s {0} {2} z≤n) _ : 2 ≤ 4 -- with named implicit args _ = s≤s {m = 1} {n = 3} (s≤s {m = 0} {n = 2} z≤n) _ : 2 ≤ 4 -- with some implicit named args _ = s≤s {n = 3} (s≤s {m = 0} z≤n) infix 4 _≤_ -- Inversion. inv-s≤s : ∀ {m n : ℕ} → suc m ≤ suc n ------------- → m ≤ n inv-s≤s (s≤s x) = x inv-z≤n : ∀ {m : ℕ} → m ≤ zero -------- → m ≡ zero inv-z≤n z≤n = refl -- Properties. -- Reflexivity. ≤-refl : ∀ {n : ℕ} ----- → n ≤ n ≤-refl {zero} = z≤n ≤-refl {suc n} = s≤s (≤-refl {n}) -- Transitivity. ≤-trans : ∀ {m n p : ℕ} -- note implicit arguments → m ≤ n → n ≤ p ----- → m ≤ p ≤-trans z≤n n≤p = z≤n ≤-trans (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans m≤n n≤p) ≤-trans′ : ∀ (m n p : ℕ) -- without implicit arguments → m ≤ n → n ≤ p ----- → m ≤ p ≤-trans′ .0 _ _ z≤n n≤p = z≤n ≤-trans′ (suc m) (suc n) (suc p) (s≤s m≤n) (s≤s n≤p) = s≤s (≤-trans′ m n p m≤n n≤p) -- Antisymmetry. ≤-antisym : ∀ {m n : ℕ} → m ≤ n → n ≤ m ----- → m ≡ n ≤-antisym z≤n z≤n = refl ≤-antisym (s≤s m≤n) (s≤s n≤m) rewrite ≤-antisym m≤n n≤m = refl -- Total ordering. -- A definition with parameters. data Total (m n : ℕ) : Set where forward : m ≤ n --------- → Total m n flipped : n ≤ m --------- → Total m n -- An equivalent definition without parameters. data Total′ : ℕ → ℕ → Set where forward′ : ∀ {m n : ℕ} → m ≤ n ---------- → Total′ m n flipped′ : ∀ {m n : ℕ} → n ≤ m ---------- → Total′ m n -- Showing that ≤ is a total order. ≤-total : ∀ (m n : ℕ) → Total m n -- introducing with clause ≤-total zero n = forward z≤n ≤-total (suc m) zero = flipped z≤n ≤-total (suc m) (suc n) with ≤-total m n ... | forward x = forward (s≤s x) ... | flipped x = flipped (s≤s x) ≤-total′ : ∀ (m n : ℕ) → Total m n -- with helper function and where ≤-total′ zero n = forward z≤n ≤-total′ (suc m) zero = flipped z≤n ≤-total′ (suc m) (suc n) = helper (≤-total m n) where helper : Total m n → Total (suc m) (suc n) helper (forward x) = forward (s≤s x) helper (flipped x) = flipped (s≤s x) -- Splitting on n first gives different code (see PLFA or try it yourself). -- Monotonicity. +-monoʳ-≤ : ∀ (m p q : ℕ) → p ≤ q ------------- → m + p ≤ m + q +-monoʳ-≤ zero p q p≤q = p≤q -- split on m +-monoʳ-≤ (suc m) p q p≤q = s≤s (+-monoʳ-≤ m p q p≤q) -- refine, recurse +-monoˡ-≤ : ∀ (m n p : ℕ) → m ≤ n ------------- → m + p ≤ n + p +-monoˡ-≤ m n p m≤n rewrite +-comm m p | +-comm n p = +-monoʳ-≤ p m n m≤n -- use commutativity +-mono-≤ : ∀ (m n p q : ℕ) -- combine above → m ≤ n → p ≤ q ------------- → m + p ≤ n + q +-mono-≤ m n p q m≤n p≤q = ≤-trans (+-monoʳ-≤ m p q p≤q ) (+-monoˡ-≤ m n q m≤n) -- PLFA exercise: show *-mono-≤. -- Strict inequality. infix 4 _<_ data _<_ : ℕ → ℕ → Set where z<s : ∀ {n : ℕ} ------------ → zero < suc n s<s : ∀ {m n : ℕ} → m < n ------------- → suc m < suc n -- 842 exercise: LTTrans (1 point) -- Prove that < is transitive. -- Order of arguments changed from PLFA, to match ≤-trans. <-trans : ∀ {m n p : ℕ} → m < n → n < p → m < p -- TODO <-trans m<n n<p = {!!} -- 842 exercise: Trichotomy (2 points) -- Prove that either m < n, m ≡ n, or m > n for all m and n. data Trichotomy (m n : ℕ) : Set where is-< : m < n → Trichotomy m n is-≡ : m ≡ n → Trichotomy m n is-> : n < m → Trichotomy m n <-trichotomy : ∀ (m n : ℕ) → Trichotomy m n -- TODO <-trichotomy m n = {!!} -- PLFA exercise: show +-mono-<. -- Prove that suc m ≤ n implies m < n, and conversely, -- and do the same for (m ≤ n) and (m < suc n). -- Hint: if you do the proofs in the order below, you can avoid induction -- for two of the four proofs. -- 842 exercise: LEtoLTS (1 point) ≤-<-to : ∀ {m n : ℕ} → m ≤ n → m < suc n -- TODO ≤-<-to m≤n = {!!} -- 842 exercise: LEStoLT (1 point) ≤-<--to′ : ∀ {m n : ℕ} → suc m ≤ n → m < n -- TODO ≤-<--to′ sm≤n = {!!} -- 842 exercise: LTtoSLE (1 point) ≤-<-from : ∀ {m n : ℕ} → m < n → suc m ≤ n -- TODO ≤-<-from m<n = {!!} -- 842 exercise: LTStoLE (1 point) ≤-<-from′ : ∀ {m n : ℕ} → m < suc n → m ≤ n -- TODO ≤-<-from′ m<sn = {!!} -- PLFA exercise: use the above to give a proof of <-trans that uses ≤-trans. -- TODO -- Mutually recursive datatypes. -- Specify the types first, then give the definitions. data even : ℕ → Set data odd : ℕ → Set data even where zero : --------- even zero suc : ∀ {n : ℕ} → odd n ------------ → even (suc n) data odd where suc : ∀ {n : ℕ} → even n ----------- → odd (suc n) -- Theorems about these datatypes. -- The proofs are also mutually recursive. -- So we give the types first, then the implementations. e+e≡e : ∀ {m n : ℕ} → even m → even n ------------ → even (m + n) o+e≡o : ∀ {m n : ℕ} → odd m → even n ----------- → odd (m + n) e+e≡e zero en = en e+e≡e (suc x) en = suc (o+e≡o x en) o+e≡o (suc x) en = suc (e+e≡e x en) -- 842 exercise: OPOE (2 points) -- Prove that the sum of two odds is even. -- Hint: You will need to define another theorem and prove both -- by mutual induction, as with the theorems above. o+o≡e : ∀ {m n : ℕ} → odd m → odd n → even (m + n) -- TODO o+o≡e om on = {!!} -- For remarks on which of these definitions are in the standard library, see PLFA. -- Here is the new Unicode used in this file. {- ≤ U+2264 LESS-THAN OR EQUAL TO (\<=, \le) ≥ U+2265 GREATER-THAN OR EQUAL TO (\>=, \ge) ˡ U+02E1 MODIFIER LETTER SMALL L (\^l) ʳ U+02B3 MODIFIER LETTER SMALL R (\^r) -}
{ "alphanum_fraction": 0.5066187286, "avg_line_length": 20.3289036545, "ext": "agda", "hexsha": "a31d4d9a19ccd032e707c92b769a353b16ed4d31", "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/x03-842Relations-hc.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/x03-842Relations-hc.agda", "max_line_length": 94, "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/x03-842Relations-hc.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": 2510, "size": 6119 }
{-# OPTIONS --cubical --no-import-sorts #-} module Test4 where open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Foundations.Logic open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv record !_ {ℓ} (X : Type ℓ) : Type ℓ where inductive constructor !!_ field x : X open !_ hiding (x) infix 1 !!_ infix 1 !_ !-iso : ∀{ℓ} {X : Type ℓ} → Iso (! X) X Iso.fun !-iso = !_.x Iso.inv !-iso = !!_ Iso.rightInv !-iso = λ x → refl Iso.leftInv !-iso = λ{ (!! x) → refl } !-≡ : ∀{ℓ} {X : Type ℓ} → (! X) ≡ X !-≡ {X = X} = isoToPath !-iso !-equiv : ∀{ℓ} {X : Type ℓ} → (! X) ≃ X !-equiv = !_.x , λ where .equiv-proof x → ((!! x) , refl) , λ{ ((!! y) , p) → λ i → (!! p (~ i)) , (λ j → p (~ i ∨ j)) } hPropRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ')) hPropRel A B ℓ' = A → B → hProp ℓ' module TestB {ℓ ℓ'} (X : Type ℓ) (0ˣ : X) (_+_ _·_ : X → X → X) (_<_ : hPropRel X X ℓ') (let infixl 5 _+_; _+_ = _+_) where _≤_ : hPropRel X X ℓ' x ≤ y = ¬(y < x) postulate sqrt : (x : X) → {{ ! [ 0ˣ ≤ x ] }} → X 0≤x² : ∀ x → [ 0ˣ ≤ (x · x) ] instance -- module-scope instances _ = λ {x} → !! 0≤x² x test4 : (x y z : X) → [ 0ˣ ≤ x ] → [ 0ˣ ≤ y ] → X test4 x y z 0≤x 0≤y = let instance -- let-scope instances _ = !! 0≤x _ = !! 0≤y _ = !! 0≤x² x -- preferred over the instance from module-scope in ( (sqrt x) -- works + (sqrt y) -- also works + (sqrt (z · z)) -- uses instance from module scope + (sqrt (x · x)) -- uses instance from let-scope (?) -- NOTE: see https://github.com/agda/agda/issues/4688 )
{ "alphanum_fraction": 0.5022962113, "avg_line_length": 29.5254237288, "ext": "agda", "hexsha": "15d3f911ece8e7e1f421bc81e63552e22c5077e5", "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": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "test/Test4.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "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": "mchristianl/synthetic-reals", "max_issues_repo_path": "test/Test4.agda", "max_line_length": 120, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "test/Test4.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 718, "size": 1742 }
---------------------------------------------------------------- -- This file contains the definition of categories. -- ---------------------------------------------------------------- module Category.Category where open import Level public renaming (suc to lsuc) open import Data.Product open import Setoid.Total public open import Relation.Relation open Setoid public record Cat {l : Level} : Set (lsuc l) where field Obj : Set l Hom : Obj → Obj → Setoid {l} comp : {A B C : Obj} → BinSetoidFun (Hom A B) (Hom B C) (Hom A C) id : {A : Obj} → el (Hom A A) assocPf : ∀{A B C D}{f : el (Hom A B)}{g : el (Hom B C)}{h : el (Hom C D)} → ⟨ Hom A D ⟩[ f ○[ comp ] (g ○[ comp ] h) ≡ (f ○[ comp ] g) ○[ comp ] h ] idPfCom : ∀{A B}{f : el (Hom A B)} → ⟨ Hom A B ⟩[ id ○[ comp ] f ≡ f ○[ comp ] id ] idPf : ∀{A B}{f : el (Hom A B)} → ⟨ Hom A B ⟩[ id ○[ comp ] f ≡ f ] open Cat public objectSetoid : {l : Level} → (ℂ : Cat {l}) → Setoid {l} objectSetoid {l} ℂ = record { el = Obj ℂ; eq = λ a b → _≅_ a b; eqRpf = record { parEqPf = record { symPf = λ x₁ → sym x₁ ; transPf = λ x₁ x₂ → trans x₁ x₂ } ; refPf = refl } } -- Identities composed on the left cancel. idPf-left : ∀{l}{ℂ : Cat {l}}{A B : Obj ℂ}{f : el (Hom ℂ A B)} → ⟨ Hom ℂ A B ⟩[ f ○[ comp ℂ ] id ℂ ≡ f ] idPf-left {_}{ℂ}{A}{B}{f} = transPf (parEqPf (eqRpf (Hom ℂ A B))) (symPf (parEqPf (eqRpf (Hom ℂ A B))) (idPfCom ℂ {A} {B} {f})) (idPf ℂ) -- Congruence results for composition. eq-comp-right : ∀{l} {ℂ : Cat {l}} {A B C : Obj ℂ} {f : el (Hom ℂ A B)} {g₁ g₂ : el (Hom ℂ B C)} → ⟨ Hom ℂ B C ⟩[ g₁ ≡ g₂ ] → ⟨ Hom ℂ A C ⟩[ f ○[ comp ℂ ] g₁ ≡ f ○[ comp ℂ ] g₂ ] eq-comp-right {_}{ℂ}{A}{B}{C}{f}{g₁}{g₂} eq = extT (appT {_}{_}{Hom ℂ A B}{SetoidFunSpace (Hom ℂ B C) (Hom ℂ A C)} (comp ℂ) f) eq eq-comp-left : ∀{l} {ℂ : Cat {l}} {A B C : Obj ℂ} {f₁ f₂ : el (Hom ℂ A B)} {g : el (Hom ℂ B C)} → ⟨ Hom ℂ A B ⟩[ f₁ ≡ f₂ ] → ⟨ Hom ℂ A C ⟩[ f₁ ○[ comp ℂ ] g ≡ f₂ ○[ comp ℂ ] g ] eq-comp-left {_}{ℂ}{A}{B}{C}{f₁}{f₂}{g} eq = extT (comp ℂ) {f₁}{f₂} eq g eq-comp-all : ∀{l} {ℂ : Cat {l}} {A B C : Obj ℂ} {f₁ f₂ : el (Hom ℂ A B)} {g₁ g₂ : el (Hom ℂ B C)} → ⟨ Hom ℂ A B ⟩[ f₁ ≡ f₂ ] → ⟨ Hom ℂ B C ⟩[ g₁ ≡ g₂ ] → ⟨ Hom ℂ A C ⟩[ f₁ ○[ comp ℂ ] g₁ ≡ f₂ ○[ comp ℂ ] g₂ ] eq-comp-all {_}{ℂ}{A}{B}{C}{f₁}{f₂}{g₁}{g₂} eq₁ eq₂ with eq-comp-left {_}{ℂ}{A}{B}{C}{f₁}{f₂}{g₁} eq₁ | eq-comp-right {_}{ℂ}{A}{B}{C}{f₂}{g₁}{g₂} eq₂ ... | eq₃ | eq₄ = transPf (parEqPf (eqRpf (Hom ℂ A C))) eq₃ eq₄
{ "alphanum_fraction": 0.4579300074, "avg_line_length": 37.3055555556, "ext": "agda", "hexsha": "d8af836aabce80d245af183a43bdcc5a3078f406", "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": "setoid-cats/Category/Category.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": "setoid-cats/Category/Category.agda", "max_line_length": 137, "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": "setoid-cats/Category/Category.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1157, "size": 2686 }
------------------------------------------------------------------------ -- The "circle" ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} -- Partly following the HoTT book. -- The module is parametrised by a notion of equality. The higher -- constructor of the HIT defining the circle uses path equality, but -- the supplied notion of equality is used for many other things. import Equality.Path as P module Circle {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq hiding (elim) open import Logical-equivalence using (_⇔_) open import Prelude open import Bijection equality-with-J as Bijection using (_↔_) import Bijection P.equality-with-J as PB open import Equality.Groupoid equality-with-J open import Equality.Path.Isomorphisms eq open import Equality.Path.Isomorphisms.Univalence eq import Equality.Path.Isomorphisms P.equality-with-paths as PI open import Equality.Tactic equality-with-J hiding (module Eq) open import Equivalence equality-with-J as Eq using (_≃_) import Equivalence P.equality-with-J as PE import Erased.Cubical eq as E open import Function-universe equality-with-J as F hiding (id; _∘_) open import Group equality-with-J as G using (_≃ᴳ_) import Group.Cyclic eq as C open import Groupoid equality-with-J open import H-level equality-with-J as H-level open import H-level.Closure equality-with-J open import H-level.Truncation eq as T using (∥_∥[1+_]) open import H-level.Truncation.Propositional eq as Trunc using (∥_∥; ∣_∣) open import H-level.Truncation.Propositional.One-step eq as O using (∥_∥¹) open import Integer equality-with-J as Int using (ℤ; +_; -[1+_]; ℤ-group) open import Nat equality-with-J open import Pointed-type equality-with-J as PT using (_≃ᴮ_) open import Pointed-type.Homotopy-group eq open import Sphere eq as Sphere using (𝕊) open import Suspension eq as Suspension using (Susp; north; south; meridian) open import Univalence-axiom equality-with-J as Univ using (Univalence) private variable a p : Level A : Type p P : A → Type p f : (x : A) → P x b ℓ x : A ------------------------------------------------------------------------ -- The type and some eliminators -- The circle. data 𝕊¹ : Type where base : 𝕊¹ loopᴾ : base P.≡ base loop : base ≡ base loop = _↔_.from ≡↔≡ loopᴾ -- A dependent eliminator, expressed using paths. elimᴾ : (P : 𝕊¹ → Type p) (b : P base) → P.[ (λ i → P (loopᴾ i)) ] b ≡ b → (x : 𝕊¹) → P x elimᴾ P b ℓ base = b elimᴾ P b ℓ (loopᴾ i) = ℓ i -- A non-dependent eliminator, expressed using paths. recᴾ : (b : A) → b P.≡ b → 𝕊¹ → A recᴾ = elimᴾ _ -- A dependent eliminator. elim : (P : 𝕊¹ → Type p) (b : P base) → subst P loop b ≡ b → (x : 𝕊¹) → P x elim P b ℓ = elimᴾ P b (subst≡→[]≡ ℓ) -- A "computation" rule. elim-loop : dcong (elim P b ℓ) loop ≡ ℓ elim-loop = dcong-subst≡→[]≡ (refl _) -- Every dependent function of type (x : 𝕊¹) → P x can be expressed -- using elim. η-elim : {f : (x : 𝕊¹) → P x} → f ≡ elim P (f base) (dcong f loop) η-elim {P = P} {f = f} = ⟨ext⟩ $ elim _ (refl _) (subst (λ x → f x ≡ elim P (f base) (dcong f loop) x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩ trans (sym (dcong f loop)) (trans (cong (subst P loop) (refl _)) (dcong (elim P (f base) (dcong f loop)) loop)) ≡⟨ cong (trans (sym (dcong f loop))) $ trans (cong (flip trans _) $ cong-refl _) $ trans-reflˡ _ ⟩ trans (sym (dcong f loop)) (dcong (elim P (f base) (dcong f loop)) loop) ≡⟨ cong (trans (sym (dcong f loop))) elim-loop ⟩ trans (sym (dcong f loop)) (dcong f loop) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) -- A non-dependent eliminator. rec : (b : A) → b ≡ b → 𝕊¹ → A rec b ℓ = recᴾ b (_↔_.to ≡↔≡ ℓ) -- A "computation" rule. rec-loop : cong (rec b ℓ) loop ≡ ℓ rec-loop = cong-≡↔≡ (refl _) -- Every function from 𝕊¹ to A can be expressed using rec. η-rec : {f : 𝕊¹ → A} → f ≡ rec (f base) (cong f loop) η-rec {f = f} = ⟨ext⟩ $ elim _ (refl _) (subst (λ x → f x ≡ rec (f base) (cong f loop) x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong f loop)) (trans (refl _) (cong (rec (f base) (cong f loop)) loop)) ≡⟨ cong (trans (sym (cong f loop))) $ trans-reflˡ _ ⟩ trans (sym (cong f loop)) (cong (rec (f base) (cong f loop)) loop) ≡⟨ cong (trans (sym (cong f loop))) rec-loop ⟩ trans (sym (cong f loop)) (cong f loop) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) -- An alternative non-dependent eliminator. rec′ : (b : A) → b ≡ b → 𝕊¹ → A rec′ {A = A} b ℓ = elim (const A) b (subst (const A) loop b ≡⟨ subst-const _ ⟩ b ≡⟨ ℓ ⟩∎ b ∎) -- A "computation" rule. rec′-loop : cong (rec′ b ℓ) loop ≡ ℓ rec′-loop = dcong≡→cong≡ elim-loop ------------------------------------------------------------------------ -- Some equivalences -- The circle can be expressed as a suspension. 𝕊¹≃Susp-Bool : 𝕊¹ ≃ Susp Bool 𝕊¹≃Susp-Bool = Eq.↔→≃ to from to∘from from∘to where north≡north = north ≡⟨ meridian false ⟩ south ≡⟨ sym $ meridian true ⟩∎ north ∎ to : 𝕊¹ → Susp Bool to = rec north north≡north module From = Suspension.Rec base base (if_then refl base else loop) from : Susp Bool → 𝕊¹ from = From.rec to∘from : ∀ x → to (from x) ≡ x to∘from = Suspension.elim _ (to (from north) ≡⟨⟩ north ∎) (to (from south) ≡⟨⟩ north ≡⟨ meridian true ⟩∎ south ∎) (λ b → subst (λ x → to (from x) ≡ x) (meridian b) (refl north) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (to ∘ from) (meridian b))) (trans (refl _) (cong id (meridian b))) ≡⟨ cong₂ (trans ∘ sym) (trans (sym $ cong-∘ _ _ _) $ cong (cong to) From.rec-meridian) (trans (trans-reflˡ _) $ sym $ cong-id _) ⟩ trans (sym (cong to (if b then refl base else loop))) (meridian b) ≡⟨ lemma b ⟩∎ meridian true ∎) where lemma : (b : Bool) → _ ≡ _ lemma true = trans (sym (cong to (if true ⦂ Bool then refl base else loop))) (meridian true) ≡⟨⟩ trans (sym (cong to (refl base))) (meridian true) ≡⟨ prove (Trans (Sym (Cong _ Refl)) (Lift _)) (Lift _) (refl _) ⟩∎ meridian true ∎ lemma false = trans (sym (cong to (if false ⦂ Bool then refl base else loop))) (meridian false) ≡⟨⟩ trans (sym (cong to loop)) (meridian false) ≡⟨ cong (λ p → trans (sym p) (meridian false)) rec-loop ⟩ trans (sym north≡north) (meridian false) ≡⟨ prove (Trans (Sym (Trans (Lift _) (Sym (Lift _)))) (Lift _)) (Trans (Trans (Lift _) (Sym (Lift _))) (Lift _)) (refl _) ⟩ trans (trans (meridian true) (sym $ meridian false)) (meridian false) ≡⟨ trans-[trans-sym]- _ _ ⟩∎ meridian true ∎ from∘to : ∀ x → from (to x) ≡ x from∘to = elim _ (from (to base) ≡⟨⟩ base ∎) (subst (λ x → from (to x) ≡ x) loop (refl base) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (from ∘ to) loop)) (trans (refl base) (cong id loop)) ≡⟨ cong₂ (trans ∘ sym) (trans (sym $ cong-∘ _ to _) $ cong (cong from) rec-loop) (trans (trans-reflˡ _) $ sym $ cong-id _) ⟩ trans (sym (cong from north≡north)) loop ≡⟨ prove (Trans (Sym (Cong _ (Trans (Lift _) (Sym (Lift _))))) (Lift _)) (Trans (Trans (Cong from (Lift (meridian true))) (Sym (Cong from (Lift (meridian false))))) (Lift _)) (refl _) ⟩ trans (trans (cong from (meridian true)) (sym $ cong from (meridian false))) loop ≡⟨ cong₂ (λ p q → trans (trans p (sym q)) loop) From.rec-meridian From.rec-meridian ⟩ trans (trans (if true ⦂ Bool then refl base else loop) (sym $ if false ⦂ Bool then refl base else loop)) loop ≡⟨⟩ trans (trans (refl base) (sym loop)) loop ≡⟨ trans-[trans-sym]- _ _ ⟩∎ refl base ∎) -- The circle is equivalent to the 1-dimensional sphere. 𝕊¹≃𝕊¹ : 𝕊¹ ≃ 𝕊 1 𝕊¹≃𝕊¹ = 𝕊¹ ↝⟨ 𝕊¹≃Susp-Bool ⟩ Susp Bool ↔⟨ Suspension.cong-↔ Sphere.Bool↔𝕊⁰ ⟩ Susp (𝕊 0) ↔⟨⟩ 𝕊 1 □ ------------------------------------------------------------------------ -- The loop space of the circle -- The function trans is commutative for the loop space of the circle. trans-commutative : (p q : base ≡ base) → trans p q ≡ trans q p trans-commutative = flip $ Transitivity-commutative.commutative base _∙_ ∙-base base-∙ where _∙_ : 𝕊¹ → 𝕊¹ → 𝕊¹ x ∙ y = rec x (elim (λ x → x ≡ x) loop lemma x) y where lemma : subst (λ x → x ≡ x) loop loop ≡ loop lemma = ≡⇒↝ _ (sym [subst≡]≡[trans≡trans]) (refl _) base-∙ : ∀ x → x ∙ base ≡ x base-∙ _ = refl _ ∙-base : ∀ y → base ∙ y ≡ y ∙-base = elim _ (refl _) (subst (λ x → rec base loop x ≡ x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (rec base loop) loop)) (trans (refl _) (cong id loop)) ≡⟨ cong (trans _) $ trans-reflˡ _ ⟩ trans (sym (cong (rec base loop) loop)) (cong id loop) ≡⟨ cong₂ (trans ∘ sym) rec-loop (sym $ cong-id _) ⟩ trans (sym loop) loop ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) -- The loop space is equivalent to x ≡ x, for any x : 𝕊¹. base≡base≃≡ : {x : 𝕊¹} → (base ≡ base) ≃ (x ≡ x) base≡base≃≡ = elim (λ x → (base ≡ base) ≃ (x ≡ x)) Eq.id (Eq.lift-equality ext $ ⟨ext⟩ λ eq → _≃_.to (subst (λ x → (base ≡ base) ≃ (x ≡ x)) loop Eq.id) eq ≡⟨ cong (_$ eq) Eq.to-subst ⟩ subst (λ x → base ≡ base → x ≡ x) loop id eq ≡⟨ subst-→ ⟩ subst (λ x → x ≡ x) loop (subst (λ _ → base ≡ base) (sym loop) eq) ≡⟨ cong (subst (λ x → x ≡ x) loop) $ subst-const _ ⟩ subst (λ x → x ≡ x) loop eq ≡⟨ ≡⇒↝ _ (sym [subst≡]≡[trans≡trans]) ( trans eq loop ≡⟨ trans-commutative _ _ ⟩∎ trans loop eq ∎) ⟩∎ eq ∎) _ private -- Definitions used to define base≡base≃ℤ and Fundamental-group≃ℤ. module base≡base≃ℤ (univ : Univalence lzero) where -- The universal cover of the circle. Cover : 𝕊¹ → Type Cover = rec ℤ (Univ.≃⇒≡ univ Int.successor) to : base ≡ x → Cover x to = flip (subst Cover) (+ 0) ≡⇒≃-cong-Cover-loop : Univ.≡⇒≃ (cong Cover loop) ≡ Int.successor ≡⇒≃-cong-Cover-loop = Univ.≡⇒≃ (cong Cover loop) ≡⟨ cong Univ.≡⇒≃ rec-loop ⟩ Univ.≡⇒≃ (Univ.≃⇒≡ univ Int.successor) ≡⟨ _≃_.right-inverse-of (Univ.≡≃≃ univ) _ ⟩∎ Int.successor ∎ subst-Cover-loop : ∀ i → subst Cover loop i ≡ Int.suc i subst-Cover-loop i = subst Cover loop i ≡⟨ subst-in-terms-of-≡⇒↝ equivalence _ _ _ ⟩ Univ.≡⇒→ (cong Cover loop) i ≡⟨ cong (λ eq → _≃_.to eq _) ≡⇒≃-cong-Cover-loop ⟩∎ _≃_.to Int.successor i ∎ subst-Cover-sym-loop : ∀ i → subst Cover (sym loop) i ≡ Int.pred i subst-Cover-sym-loop i = subst Cover (sym loop) i ≡⟨ subst-in-terms-of-inverse∘≡⇒↝ equivalence _ _ _ ⟩ _≃_.from (Univ.≡⇒≃ (cong Cover loop)) i ≡⟨ cong (λ eq → _≃_.from eq _) ≡⇒≃-cong-Cover-loop ⟩∎ _≃_.from Int.successor i ∎ module 𝕊¹-G = Groupoid (groupoid 𝕊¹) loops : ℤ → base ≡ base loops = loop 𝕊¹-G.^_ to-loops : ∀ i → to (loops i) ≡ i to-loops (+ zero) = subst Cover (refl _) (+ 0) ≡⟨ subst-refl _ _ ⟩∎ + zero ∎ to-loops (+ suc n) = subst Cover (trans (loops (+ n)) loop) (+ 0) ≡⟨ sym $ subst-subst _ _ _ _ ⟩ subst Cover loop (subst Cover (loops (+ n)) (+ 0)) ≡⟨⟩ subst Cover loop (to (loops (+ n))) ≡⟨ cong (subst Cover loop) $ to-loops (+ n) ⟩ subst Cover loop (+ n) ≡⟨ subst-Cover-loop _ ⟩∎ + suc n ∎ to-loops -[1+ zero ] = subst Cover (trans (refl _) (sym loop)) (+ 0) ≡⟨ cong (flip (subst Cover) _) $ trans-reflˡ _ ⟩ subst Cover (sym loop) (+ 0) ≡⟨ subst-Cover-sym-loop _ ⟩∎ -[1+ zero ] ∎ to-loops -[1+ suc n ] = subst Cover (trans (loops -[1+ n ]) (sym loop)) (+ 0) ≡⟨ sym $ subst-subst _ _ _ _ ⟩ subst Cover (sym loop) (subst Cover (loops -[1+ n ]) (+ 0)) ≡⟨⟩ subst Cover (sym loop) (to (loops -[1+ n ])) ≡⟨ cong (subst Cover (sym loop)) $ to-loops -[1+ n ] ⟩ subst Cover (sym loop) -[1+ n ] ≡⟨ subst-Cover-sym-loop _ ⟩∎ -[1+ suc n ] ∎ loops-pred-loop : ∀ i → trans (loops (Int.pred i)) loop ≡ loops i loops-pred-loop i = trans (loops (Int.pred i)) loop ≡⟨ cong (flip trans _ ∘ loops) $ Int.pred≡-1+ i ⟩ trans (loops (Int.-[ 1 ] Int.+ i)) loop ≡⟨ cong (flip trans _) $ sym $ 𝕊¹-G.^∘^ {j = i} Int.-[ 1 ] ⟩ trans (trans (loops i) (loops (Int.-[ 1 ]))) loop ≡⟨⟩ trans (trans (loops i) (trans (refl _) (sym loop))) loop ≡⟨ cong (flip trans _) $ cong (trans _) $ trans-reflˡ _ ⟩ trans (trans (loops i) (sym loop)) loop ≡⟨ trans-[trans-sym]- _ _ ⟩∎ loops i ∎ from : ∀ x → Cover x → base ≡ x from = elim _ loops (⟨ext⟩ λ i → subst (λ x → Cover x → base ≡ x) loop loops i ≡⟨ subst-→ ⟩ subst (base ≡_) loop (loops (subst Cover (sym loop) i)) ≡⟨ sym trans-subst ⟩ trans (loops (subst Cover (sym loop) i)) loop ≡⟨ cong (flip trans _ ∘ loops) $ subst-Cover-sym-loop _ ⟩ trans (loops (Int.pred i)) loop ≡⟨ loops-pred-loop i ⟩∎ loops i ∎) from-to : (eq : base ≡ x) → from x (to eq) ≡ eq from-to = elim¹ (λ {x} eq → from x (to eq) ≡ eq) (from base (to (refl base)) ≡⟨⟩ loops (subst Cover (refl base) (+ 0)) ≡⟨ cong loops $ subst-refl _ _ ⟩ loops (+ 0) ≡⟨⟩ refl base ∎) loops-+ : ∀ i j → loops (i Int.+ j) ≡ trans (loops i) (loops j) loops-+ i j = loops (i Int.+ j) ≡⟨ cong loops $ Int.+-comm i ⟩ loops (j Int.+ i) ≡⟨ sym $ 𝕊¹-G.^∘^ j ⟩∎ trans (loops i) (loops j) ∎ -- The loop space of the circle is equivalent to the type of integers -- (assuming univalence). -- -- The proof is based on the one presented by Licata and Shulman in -- "Calculating the Fundamental Group of the Circle in Homotopy Type -- Theory". base≡base≃ℤ : Univalence lzero → (base ≡ base) ≃ ℤ base≡base≃ℤ univ = Eq.↔→≃ to loops to-loops from-to where open base≡base≃ℤ univ -- The circle's fundamental group is equivalent to the group of -- integers (assuming univalence). Fundamental-group≃ℤ : Univalence lzero → Fundamental-group (𝕊¹ , base) ≃ᴳ ℤ-group Fundamental-group≃ℤ univ = G.≃ᴳ-sym λ where .G.Homomorphic.related → inverse (∥ base ≡ base ∥[1+ 1 ] ↝⟨ T.∥∥-cong $ base≡base≃ℤ univ ⟩ ∥ ℤ ∥[1+ 1 ] ↔⟨ _⇔_.to (T.+⇔∥∥↔ {n = 1}) Int.ℤ-set ⟩□ ℤ □) .G.Homomorphic.homomorphic i j → cong T.∣_∣ (loops-+ i j) where open base≡base≃ℤ univ -- The circle is a groupoid (assuming univalence). 𝕊¹-groupoid : Univalence lzero → H-level 3 𝕊¹ 𝕊¹-groupoid univ {x = x} {y = y} = $⟨ (λ {_ _} → Int.ℤ-set) ⟩ Is-set ℤ ↝⟨ H-level-cong _ 2 (inverse $ base≡base≃ℤ univ) ⦂ (_ → _) ⟩ Is-set (base ≡ base) ↝⟨ (λ s → elim (λ x → ∀ y → Is-set (x ≡ y)) (elim _ s (H-level-propositional ext 2 _ _)) ((Π-closure ext 1 λ _ → H-level-propositional ext 2) _ _) x y) ⟩□ Is-set (x ≡ y) □ -- The type of endofunctions on 𝕊¹ is equivalent to -- ∃ λ (x : 𝕊¹) → x ≡ x. 𝕊¹→𝕊¹≃Σ𝕊¹≡ : (𝕊¹ → 𝕊¹) ≃ ∃ λ (x : 𝕊¹) → x ≡ x 𝕊¹→𝕊¹≃Σ𝕊¹≡ = Eq.↔→≃ to from to-from from-to where to : (𝕊¹ → 𝕊¹) → ∃ λ (x : 𝕊¹) → x ≡ x to f = f base , cong f loop from : (∃ λ (x : 𝕊¹) → x ≡ x) → (𝕊¹ → 𝕊¹) from = uncurry rec to-from : ∀ p → to (from p) ≡ p to-from (x , eq) = cong (x ,_) (cong (rec x eq) loop ≡⟨ rec-loop ⟩∎ eq ∎) from-to : ∀ f → from (to f) ≡ f from-to f = rec (f base) (cong f loop) ≡⟨ sym η-rec ⟩∎ f ∎ -- The type of endofunctions on 𝕊¹ is equivalent to 𝕊¹ × ℤ (assuming -- univalence). -- -- This result was pointed out to me by Paolo Capriotti. 𝕊¹→𝕊¹≃𝕊¹×ℤ : Univalence lzero → (𝕊¹ → 𝕊¹) ≃ (𝕊¹ × ℤ) 𝕊¹→𝕊¹≃𝕊¹×ℤ univ = (𝕊¹ → 𝕊¹) ↝⟨ 𝕊¹→𝕊¹≃Σ𝕊¹≡ ⟩ (∃ λ (x : 𝕊¹) → x ≡ x) ↝⟨ (∃-cong λ _ → inverse base≡base≃≡) ⟩ 𝕊¹ × base ≡ base ↝⟨ (∃-cong λ _ → base≡base≃ℤ univ) ⟩□ 𝕊¹ × ℤ □ -- The forward direction of 𝕊¹→𝕊¹≃𝕊¹×ℤ maps the identity function to -- base , + 1. 𝕊¹→𝕊¹≃𝕊¹×ℤ-id : (univ : Univalence lzero) → _≃_.to (𝕊¹→𝕊¹≃𝕊¹×ℤ univ) id ≡ (base , + 1) 𝕊¹→𝕊¹≃𝕊¹×ℤ-id univ = _≃_.from-to (𝕊¹→𝕊¹≃𝕊¹×ℤ univ) (rec base (trans (refl base) loop) ≡⟨ cong (rec base) $ trans-reflˡ _ ⟩ rec base loop ≡⟨ cong (rec base) $ cong-id _ ⟩ rec base (cong id loop) ≡⟨ sym η-rec ⟩∎ id ∎) -- The forward direction of 𝕊¹→𝕊¹≃𝕊¹×ℤ maps the constant function -- returning base to base , + 0. 𝕊¹→𝕊¹≃𝕊¹×ℤ-const : (univ : Univalence lzero) → _≃_.to (𝕊¹→𝕊¹≃𝕊¹×ℤ univ) (const base) ≡ (base , + 0) 𝕊¹→𝕊¹≃𝕊¹×ℤ-const univ = _≃_.from-to (𝕊¹→𝕊¹≃𝕊¹×ℤ univ) (rec base (refl base) ≡⟨ cong (rec base) $ sym $ cong-const _ ⟩ rec base (cong (const base) loop) ≡⟨ sym η-rec ⟩∎ const base ∎) ------------------------------------------------------------------------ -- A conversion function -- The one-step truncation of the unit type is equivalent to the -- circle. -- -- Paolo Capriotti informed me about this result. ∥⊤∥¹≃𝕊¹ : ∥ ⊤ ∥¹ ≃ 𝕊¹ ∥⊤∥¹≃𝕊¹ = _↔_.from ≃↔≃ $ PE.↔→≃ (O.recᴾ λ where .O.∣∣ʳ _ → base .O.∣∣-constantʳ _ _ → loopᴾ) (recᴾ O.∣ _ ∣ (O.∣∣-constantᴾ _ _)) (elimᴾ _ P.refl (λ _ → P.refl)) (O.elimᴾ λ where .O.∣∣ʳ _ → P.refl .O.∣∣-constantʳ _ _ _ → P.refl) ------------------------------------------------------------------------ -- Some negative results -- The equality loop is not equal to refl base. loop≢refl : loop ≢ refl base loop≢refl = E.Stable-¬ E.[ loop ≡ refl base →⟨ Type-set ⟩ Is-set Type →⟨ Univ.¬-Type-set univ ⟩□ ⊥ □ ] where module _ (loop≡refl : loop ≡ refl base) where refl≡ : (A : Type) (A≡A : A ≡ A) → refl A ≡ A≡A refl≡ A A≡A = refl A ≡⟨⟩ refl (rec A A≡A base) ≡⟨ sym $ cong-refl _ ⟩ cong (rec A A≡A) (refl base) ≡⟨ cong (cong (rec A A≡A)) $ sym loop≡refl ⟩ cong (rec A A≡A) loop ≡⟨ rec-loop ⟩∎ A≡A ∎ Type-set : Is-set Type Type-set {x = A} {y = B} = elim¹ (λ p → ∀ q → p ≡ q) (refl≡ A) -- Thus the circle is not a set. ¬-𝕊¹-set : ¬ Is-set 𝕊¹ ¬-𝕊¹-set = Is-set 𝕊¹ ↝⟨ (λ h → h) ⟩ Is-proposition (base ≡ base) ↝⟨ (λ h → h _ _) ⟩ loop ≡ refl base ↝⟨ loop≢refl ⟩□ ⊥ □ -- It is not necessarily the case that the one-step truncation of a -- proposition is a proposition. ¬-Is-proposition-∥∥¹ : ¬ ({A : Type a} → Is-proposition A → Is-proposition ∥ A ∥¹) ¬-Is-proposition-∥∥¹ {a = a} = ({A : Type a} → Is-proposition A → Is-proposition ∥ A ∥¹) ↝⟨ _$ H-level.mono₁ 0 (↑-closure 0 ⊤-contractible) ⟩ Is-proposition ∥ ↑ a ⊤ ∥¹ ↝⟨ H-level-cong _ 1 (O.∥∥¹-cong-↔ Bijection.↑↔) ⟩ Is-proposition ∥ ⊤ ∥¹ ↝⟨ H-level-cong _ 1 ∥⊤∥¹≃𝕊¹ ⟩ Is-proposition 𝕊¹ ↝⟨ ¬-𝕊¹-set ∘ H-level.mono₁ 1 ⟩□ ⊥ □ -- A function with the type of refl (for 𝕊¹) that is not equal to -- refl. not-refl : (x : 𝕊¹) → x ≡ x not-refl = elim _ loop (subst (λ z → z ≡ z) loop loop ≡⟨ ≡⇒↝ _ (sym [subst≡]≡[trans≡trans]) (refl _) ⟩∎ loop ∎) -- The function not-refl is not equal to refl. not-refl≢refl : not-refl ≢ refl not-refl≢refl = not-refl ≡ refl ↝⟨ cong (_$ _) ⟩ loop ≡ refl base ↝⟨ loop≢refl ⟩□ ⊥ □ -- There is a value with the type of refl that is not equal to refl. ∃≢refl : ∃ λ (f : (x : 𝕊¹) → x ≡ x) → f ≢ refl ∃≢refl = not-refl , not-refl≢refl -- For every universe level there is a type A such that -- (x : A) → x ≡ x is not a proposition. ¬-type-of-refl-propositional : ∃ λ (A : Type a) → ¬ Is-proposition ((x : A) → x ≡ x) ¬-type-of-refl-propositional {a = a} = ↑ _ 𝕊¹ , (Is-proposition (∀ x → x ≡ x) ↝⟨ (λ prop → prop _ _) ⟩ cong lift ∘ proj₁ ∃≢refl ∘ lower ≡ cong lift ∘ refl ∘ lower ↝⟨ cong (_∘ lift) ⟩ cong lift ∘ proj₁ ∃≢refl ≡ cong lift ∘ refl ↝⟨ cong (cong lower ∘_) ⟩ cong lower ∘ cong lift ∘ proj₁ ∃≢refl ≡ cong lower ∘ cong lift ∘ refl ↝⟨ ≡⇒↝ _ (cong₂ _≡_ (⟨ext⟩ λ _ → cong-∘ _ _ _) (⟨ext⟩ λ _ → cong-∘ _ _ _)) ⟩ cong id ∘ proj₁ ∃≢refl ≡ cong id ∘ refl ↝⟨ ≡⇒↝ _ (sym $ cong₂ _≡_ (⟨ext⟩ λ _ → cong-id _) (⟨ext⟩ λ _ → cong-id _)) ⟩ proj₁ ∃≢refl ≡ refl ↝⟨ proj₂ ∃≢refl ⟩□ ⊥ □) -- Every element of the circle is /merely/ equal to the base point. -- -- This lemma was mentioned by Mike Shulman in a blog post -- (http://homotopytypetheory.org/2013/07/24/cohomology/). all-points-on-the-circle-are-merely-equal : (x : 𝕊¹) → ∥ x ≡ base ∥ all-points-on-the-circle-are-merely-equal = elim _ ∣ refl base ∣ (Trunc.truncation-is-proposition _ _) -- Thus every element of the circle is not not equal to the base -- point. all-points-on-the-circle-are-¬¬-equal : (x : 𝕊¹) → ¬ ¬ x ≡ base all-points-on-the-circle-are-¬¬-equal x = x ≢ base ↝⟨ Trunc.rec ⊥-propositional ⟩ ¬ ∥ x ≡ base ∥ ↝⟨ _$ all-points-on-the-circle-are-merely-equal x ⟩□ ⊥ □ -- It is not the case that every point on the circle is equal to the -- base point. ¬-all-points-on-the-circle-are-equal : ¬ ((x : 𝕊¹) → x ≡ base) ¬-all-points-on-the-circle-are-equal = ((x : 𝕊¹) → x ≡ base) ↝⟨ (λ hyp x y → x ≡⟨ hyp x ⟩ base ≡⟨ sym (hyp y) ⟩∎ y ∎) ⟩ Is-proposition 𝕊¹ ↝⟨ mono₁ 1 ⟩ Is-set 𝕊¹ ↝⟨ ¬-𝕊¹-set ⟩□ ⊥ □ -- Thus double-negation shift for Type-valued predicates over 𝕊¹ does -- not hold in general. ¬-double-negation-shift : ¬ ({P : 𝕊¹ → Type} → ((x : 𝕊¹) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹) → P x)) ¬-double-negation-shift = ({P : 𝕊¹ → Type} → ((x : 𝕊¹) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹) → P x)) ↝⟨ _$ all-points-on-the-circle-are-¬¬-equal ⟩ ¬ ¬ ((x : 𝕊¹) → x ≡ base) ↝⟨ _$ ¬-all-points-on-the-circle-are-equal ⟩□ ⊥ □ -- Furthermore excluded middle for arbitrary types (in Type) does not -- hold. ¬-excluded-middle : ¬ ({A : Type} → Dec A) ¬-excluded-middle = ({A : Type} → Dec A) ↝⟨ (λ em ¬¬a → [ id , ⊥-elim ∘ ¬¬a ] em) ⟩ ({A : Type} → ¬ ¬ A → A) ↝⟨ (λ dne → flip _$_ ∘ (dne ∘_)) ⟩ ({P : 𝕊¹ → Type} → ((x : 𝕊¹) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹) → P x)) ↝⟨ ¬-double-negation-shift ⟩□ ⊥ □ -- H-level.Closure.proj₁-closure cannot be generalised by replacing -- the assumption ∀ a → B a with ∀ a → ∥ B a ∥. -- -- This observation is due to Andrea Vezzosi. ¬-generalised-proj₁-closure : ¬ ({A : Type} {B : A → Type} → (∀ a → ∥ B a ∥) → ∀ n → H-level n (Σ A B) → H-level n A) ¬-generalised-proj₁-closure generalised-proj₁-closure = $⟨ singleton-contractible _ ⟩ Contractible (Σ 𝕊¹ (_≡ base)) ↝⟨ generalised-proj₁-closure all-points-on-the-circle-are-merely-equal 0 ⟩ Contractible 𝕊¹ ↝⟨ mono (zero≤ 2) ⟩ Is-set 𝕊¹ ↝⟨ ¬-𝕊¹-set ⟩□ ⊥ □ -- There is no based equivalence between the circle and the product of -- the circle with itself. -- -- This result was pointed out to me by Paolo Capriotti. 𝕊¹≄ᴮ𝕊¹×𝕊¹ : ¬ (𝕊¹ , base) ≃ᴮ ((𝕊¹ , base) PT.× (𝕊¹ , base)) 𝕊¹≄ᴮ𝕊¹×𝕊¹ = E.Stable-¬ E.[ (𝕊¹ , base) ≃ᴮ ((𝕊¹ , base) PT.× (𝕊¹ , base)) ↝⟨ ≃ᴮ→≃ᴳ (𝕊¹ , base) ((𝕊¹ , base) PT.× (𝕊¹ , base)) 0 ⟩ Fundamental-group (𝕊¹ , base) ≃ᴳ Fundamental-group ((𝕊¹ , base) PT.× (𝕊¹ , base)) ↝⟨ flip G.↝ᴳ-trans (Homotopy-group-[1+ 0 ]-× (𝕊¹ , base) (𝕊¹ , base)) ⟩ Fundamental-group (𝕊¹ , base) ≃ᴳ (Fundamental-group (𝕊¹ , base) G.× Fundamental-group (𝕊¹ , base)) ↝⟨ flip G.↝ᴳ-trans (G.↝-× (Fundamental-group≃ℤ univ) (Fundamental-group≃ℤ univ)) ∘ G.↝ᴳ-trans (G.≃ᴳ-sym (Fundamental-group≃ℤ univ)) ⟩ ℤ-group ≃ᴳ (ℤ-group G.× ℤ-group) ↝⟨ C.ℤ≄ᴳℤ×ℤ ⟩□ ⊥ □ ] -- 𝕊¹ is not equivalent to 𝕊¹ × 𝕊¹. -- -- This result was pointed out to me by Paolo Capriotti. 𝕊¹≄𝕊¹×𝕊¹ : ¬ 𝕊¹ ≃ (𝕊¹ × 𝕊¹) 𝕊¹≄𝕊¹×𝕊¹ hyp = let x , y = _≃_.to hyp base in all-points-on-the-circle-are-¬¬-equal x λ x≡base → all-points-on-the-circle-are-¬¬-equal y λ y≡base → 𝕊¹≄ᴮ𝕊¹×𝕊¹ (hyp , cong₂ _,_ x≡base y≡base) ------------------------------------------------------------------------ -- An alternative approach to defining eliminators and proving -- computation rules for arbitrary notions of equality, based on an -- anonymous reviewer's suggestion -- Circle eq p is an axiomatisation of the circle, for the given -- notion of equality eq, eliminating into Type p. -- -- Note that the statement of the computation rule for "loop" is more -- complicated than above (elim-loop). The reason is that the -- computation rule for "base" does not hold definitionally. Circle : ∀ {e⁺} → (∀ {a p} → P.Equality-with-paths a p e⁺) → (p : Level) → Type (lsuc p) Circle eq p = ∃ λ (𝕊¹ : Type) → ∃ λ (base : 𝕊¹) → ∃ λ (loop : base ≡.≡ base) → (P : 𝕊¹ → Type p) (b : P base) (ℓ : ≡.subst P loop b ≡.≡ b) → ∃ λ (elim : (x : 𝕊¹) → P x) → ∃ λ (elim-base : elim base ≡.≡ b) → ≡.subst (λ b → ≡.subst P loop b ≡.≡ b) elim-base (≡.dcong elim loop) ≡.≡ ℓ where module ≡ = P.Derived-definitions-and-properties eq -- A circle defined for paths (P.equality-with-J) is equivalent to one -- defined for eq. Circle≃Circle : Circle P.equality-with-paths p ≃ Circle eq p Circle≃Circle = ∃-cong λ _ → ∃-cong λ _ → Σ-cong (inverse ≡↔≡) λ loop → ∀-cong ext λ P → ∀-cong ext λ b → Π-cong-contra ext subst≡↔subst≡ λ ℓ → ∃-cong λ f → Σ-cong (inverse ≡↔≡) λ f-base → let lemma = P.elim¹ (λ eq → _↔_.from subst≡↔subst≡ (P.subst (λ b → P.subst P loop b P.≡ b) eq (P.dcong f loop)) ≡ P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) eq (_↔_.from subst≡↔subst≡ (P.dcong f loop))) (_↔_.from subst≡↔subst≡ (P.subst (λ b → P.subst P loop b P.≡ b) P.refl (P.dcong f loop)) ≡⟨ cong (_↔_.from subst≡↔subst≡) $ _↔_.from ≡↔≡ $ P.subst-refl (λ b → P.subst P loop b P.≡ b) _ ⟩ _↔_.from subst≡↔subst≡ (P.dcong f loop) ≡⟨ sym $ _↔_.from ≡↔≡ $ P.subst-refl (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) _ ⟩∎ P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) P.refl (_↔_.from subst≡↔subst≡ (P.dcong f loop)) ∎) _ in P.subst (λ b → P.subst P loop b P.≡ b) f-base (P.dcong f loop) P.≡ _↔_.to subst≡↔subst≡ ℓ ↔⟨ ≡↔≡ F.∘ inverse (from≡↔≡to (Eq.↔⇒≃ subst≡↔subst≡)) F.∘ inverse ≡↔≡ ⟩ _↔_.from subst≡↔subst≡ (P.subst (λ b → P.subst P loop b P.≡ b) f-base (P.dcong f loop)) P.≡ ℓ ↝⟨ ≡⇒↝ _ (cong (P._≡ _) lemma) ⟩ P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) f-base (_↔_.from subst≡↔subst≡ (P.dcong f loop)) P.≡ ℓ ↝⟨ ≡⇒↝ _ $ cong (λ eq → P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) f-base eq P.≡ ℓ) $ _↔_.from-to (inverse subst≡↔subst≡) dcong≡dcong ⟩ P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) f-base (dcong f (_↔_.from ≡↔≡ loop)) P.≡ ℓ ↔⟨ inverse subst≡↔subst≡ ⟩□ subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) (_↔_.from ≡↔≡ f-base) (dcong f (_↔_.from ≡↔≡ loop)) ≡ ℓ □ -- An implemention of the circle for paths (P.equality-with-paths). circleᴾ : Circle P.equality-with-paths p circleᴾ = 𝕊¹ , base , loopᴾ , λ P b ℓ → let elim = elimᴾ P b (PI.subst≡→[]≡ {B = P} ℓ) in elim , P.refl , (P.subst (λ b → P.subst P loopᴾ b P.≡ b) P.refl (P.dcong elim loopᴾ) P.≡⟨ P.subst-refl (λ b → P.subst P loopᴾ b P.≡ b) _ ⟩ P.dcong elim loopᴾ P.≡⟨ PI.dcong-subst≡→[]≡ {f = elim} {eq₂ = ℓ} P.refl ⟩∎ ℓ ∎) -- An implementation of the circle for eq. circle : Circle eq p circle = _≃_.to Circle≃Circle circleᴾ -- The latter implementation computes in the right way for "base". _ : let _ , base′ , _ , elim′ = circle {p = p} in ∀ {P b ℓ} → proj₁ (elim′ P b ℓ) base′ ≡ b _ = refl _ -- The usual computation rule for "loop" can be derived. elim-loop-circle : let _ , _ , loop′ , elim′ = circle {p = p} in ∀ {P b ℓ} → dcong (proj₁ (elim′ P b ℓ)) loop′ ≡ ℓ elim-loop-circle {P = P} {b = b} {ℓ = ℓ} = let _ , _ , loop′ , elim′ = circle elim″ , elim″-base , elim″-loop = elim′ P b ℓ lemma = refl _ ≡⟨ sym from-≡↔≡-refl ⟩ _↔_.from ≡↔≡ P.refl ≡⟨⟩ elim″-base ∎ in dcong elim″ loop′ ≡⟨ sym $ subst-refl _ _ ⟩ subst (λ b → subst P loop′ b ≡ b) (refl _) (dcong elim″ loop′) ≡⟨ cong (λ eq → subst (λ b → subst P loop′ b ≡ b) eq (dcong elim″ loop′)) lemma ⟩ subst (λ b → subst P loop′ b ≡ b) elim″-base (dcong elim″ loop′) ≡⟨ elim″-loop ⟩∎ ℓ ∎ -- An alternative to Circle≃Circle that does not give the "right" -- computational behaviour for circle′ below. Circle≃Circle′ : Circle P.equality-with-paths p ≃ Circle eq p Circle≃Circle′ = ∃-cong λ _ → ∃-cong λ _ → Σ-cong (inverse ≡↔≡) λ loop → ∀-cong ext λ P → ∀-cong ext λ b → Π-cong ext (inverse subst≡↔subst≡) λ ℓ → ∃-cong λ f → Σ-cong (inverse ≡↔≡) λ f-base → let lemma = P.elim¹ (λ eq → _↔_.from subst≡↔subst≡ (P.subst (λ b → P.subst P loop b P.≡ b) eq (P.dcong f loop)) ≡ P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) eq (_↔_.from subst≡↔subst≡ (P.dcong f loop))) (_↔_.from subst≡↔subst≡ (P.subst (λ b → P.subst P loop b P.≡ b) P.refl (P.dcong f loop)) ≡⟨ cong (_↔_.from subst≡↔subst≡) $ _↔_.from ≡↔≡ $ P.subst-refl (λ b → P.subst P loop b P.≡ b) _ ⟩ _↔_.from subst≡↔subst≡ (P.dcong f loop) ≡⟨ sym $ _↔_.from ≡↔≡ $ P.subst-refl (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) _ ⟩∎ P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) P.refl (_↔_.from subst≡↔subst≡ (P.dcong f loop)) ∎) _ in P.subst (λ b → P.subst P loop b P.≡ b) f-base (P.dcong f loop) P.≡ ℓ ↔⟨ ≡↔≡ F.∘ from-isomorphism (inverse $ Eq.≃-≡ $ Eq.↔⇒≃ $ inverse subst≡↔subst≡) F.∘ inverse ≡↔≡ ⟩ _↔_.from subst≡↔subst≡ (P.subst (λ b → P.subst P loop b P.≡ b) f-base (P.dcong f loop)) P.≡ _↔_.from subst≡↔subst≡ ℓ ↝⟨ ≡⇒↝ _ (cong (P._≡ _↔_.from subst≡↔subst≡ ℓ) lemma) ⟩ P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) f-base (_↔_.from subst≡↔subst≡ (P.dcong f loop)) P.≡ _↔_.from subst≡↔subst≡ ℓ ↝⟨ ≡⇒↝ _ $ cong (λ eq → P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) f-base eq P.≡ _↔_.from subst≡↔subst≡ ℓ) $ _↔_.from-to (inverse subst≡↔subst≡) dcong≡dcong ⟩ P.subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) f-base (dcong f (_↔_.from ≡↔≡ loop)) P.≡ _↔_.from subst≡↔subst≡ ℓ ↔⟨ inverse subst≡↔subst≡ ⟩□ subst (λ b → subst P (_↔_.from ≡↔≡ loop) b ≡ b) (_↔_.from ≡↔≡ f-base) (dcong f (_↔_.from ≡↔≡ loop)) ≡ _↔_.from subst≡↔subst≡ ℓ □ -- An alternative implementation of the circle for eq. circle′ : Circle eq p circle′ = _≃_.to Circle≃Circle′ circleᴾ -- This implementation does not compute in the right way for "base". -- The following code is (at the time of writing) rejected by Agda. -- _ : -- let _ , base′ , _ , elim′ = circle′ {p = p} in -- ∀ {P b ℓ} → -- proj₁ (elim′ P b ℓ) base′ ≡ b -- _ = refl _
{ "alphanum_fraction": 0.4536781455, "avg_line_length": 38.1934493347, "ext": "agda", "hexsha": "da10986f4dd94fc15ac1bedc512bee610b289fa0", "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/Circle.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/Circle.agda", "max_line_length": 166, "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/Circle.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": 13443, "size": 37315 }
------------------------------------------------------------------------ -- Properties related to stability for Erased ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Erased.Stability {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where open Derived-definitions-and-properties eq hiding (module Extensionality) open import Logical-equivalence as LE using (_⇔_) open import Prelude open import Bijection eq as Bijection using (_↔_) open import Double-negation eq as DN open import Embedding eq using (Embedding; Is-embedding) open import Embedding.Erased eq as EEmb using (Is-embeddingᴱ) open import Equality.Decidable-UIP eq open import Equality.Decision-procedures eq open import Equivalence eq as Eq using (_≃_; Is-equivalence) open import Equivalence.Erased eq as EEq using (_≃ᴱ_; Is-equivalenceᴱ) open import Equivalence.Erased.Contractible-preimages eq as ECP using (Contractibleᴱ) import Equivalence.Half-adjoint eq as HA open import Equivalence.Path-split eq as PS using (Is-∞-extendable-along-[_]; Is-[_]-extendable-along-[_]; _-Null_; _-Nullᴱ_) open import For-iterated-equality eq open import Function-universe eq as F hiding (id; _∘_) open import H-level eq as H-level open import H-level.Closure eq open import Injection eq using (_↣_; Injective) import List eq as L import Nat eq as Nat open import Surjection eq using (_↠_; Split-surjective) open import Univalence-axiom eq open import Erased.Level-1 eq as E₁ hiding (module []-cong; module []-cong₁; module []-cong₂; module Extensionality) import Erased.Level-2 private module E₂ = Erased.Level-2 eq private variable a b c ℓ ℓ₁ ℓ₂ ℓ₃ p : Level A B : Type a P : A → Type p ext f k k′ s x y : A n : ℕ ------------------------------------------------------------------------ -- Some lemmas related to stability -- If A is very stable, then [_]→ {A = A} is an embedding. Very-stable→Is-embedding-[] : Very-stable A → Is-embedding [ A ∣_]→ Very-stable→Is-embedding-[] {A = A} s x y = _≃_.is-equivalence ≡≃[]≡[] where A≃Erased-A : A ≃ Erased A A≃Erased-A = Eq.⟨ _ , s ⟩ ≡≃[]≡[] : (x ≡ y) ≃ ([ x ] ≡ [ y ]) ≡≃[]≡[] = inverse $ Eq.≃-≡ A≃Erased-A -- If A is very stable, then [_]→ {A = A} is split surjective. Very-stable→Split-surjective-[] : Very-stable A → Split-surjective [ A ∣_]→ Very-stable→Split-surjective-[] {A = A} = Very-stable A ↔⟨⟩ Is-equivalence [_]→ ↝⟨ (λ hyp → _↠_.split-surjective $ _≃_.surjection $ Eq.⟨ _ , hyp ⟩) ⟩ Split-surjective [_]→ □ -- Very-stable is propositional (assuming extensionality). Very-stable-propositional : {A : Type a} → Extensionality a a → Is-proposition (Very-stable A) Very-stable-propositional ext = Eq.propositional ext _ private -- The previous result can be generalised. For-iterated-equality-Very-stable-propositional : {A : Type a} → Extensionality a a → ∀ n → Is-proposition (For-iterated-equality n Very-stable A) For-iterated-equality-Very-stable-propositional ext n = H-level-For-iterated-equality ext 1 n (Very-stable-propositional ext) -- Very-stableᴱ is propositional (in erased contexts, assuming -- extensionality). @0 Very-stableᴱ-propositional : {A : Type a} → Extensionality a a → Is-proposition (Very-stableᴱ A) Very-stableᴱ-propositional ext = EEq.Is-equivalenceᴱ-propositional ext _ -- Very stable types are stable. Very-stable→Stable : ∀ n → For-iterated-equality n Very-stable A → For-iterated-equality n Stable-[ k ] A Very-stable→Stable {k = k} n = For-iterated-equality-cong₁ _ n λ {A} → Very-stable A ↝⟨ Eq.⟨ _ ,_⟩ ⟩ A ≃ Erased A ↝⟨ inverse ⟩ Erased A ≃ A ↔⟨⟩ Stable-[ equivalence ] A ↝⟨ from-equivalence ⟩□ Stable-[ k ] A □ -- The function obtained from Very-stable→Stable {k = implication} 0 -- maps [ x ] to x. -- -- This seems to imply that (say) the booleans can not be proved to be -- very stable (assuming that Agda is consistent), because -- implementing a function that resurrects a boolean, given no -- information about what the boolean was, is impossible. However, the -- booleans are stable: this follows from Dec→Stable below. Thus it -- seems as if one can not prove that all stable types are very -- stable. Very-stable→Stable-[]≡id : (s : Very-stable A) → Very-stable→Stable 0 s [ x ] ≡ x Very-stable→Stable-[]≡id {x = x} s = Very-stable→Stable 0 s [ x ] ≡⟨⟩ _≃_.from Eq.⟨ _ , s ⟩ [ x ] ≡⟨ _≃_.left-inverse-of Eq.⟨ _ , s ⟩ x ⟩∎ x ∎ -- Very stable types are very stable with erased proofs. Very-stable→Very-stableᴱ : {@0 A : Type a} → ∀ n → For-iterated-equality n Very-stable A → For-iterated-equality n Very-stableᴱ A Very-stable→Very-stableᴱ n = For-iterated-equality-cong₁ᴱ-→ n EEq.Is-equivalence→Is-equivalenceᴱ -- In erased contexts types that are very stable with erased proofs -- are very stable. @0 Very-stableᴱ→Very-stable : ∀ n → For-iterated-equality n Very-stableᴱ A → For-iterated-equality n Very-stable A Very-stableᴱ→Very-stable n = For-iterated-equality-cong₁ _ n EEq.Is-equivalenceᴱ→Is-equivalence -- If A is very stable with erased proofs, then -- Stable-[ equivalenceᴱ ] A holds. Very-stableᴱ→Stable-≃ᴱ : {@0 A : Type a} → ∀ n → For-iterated-equality n Very-stableᴱ A → For-iterated-equality n Stable-[ equivalenceᴱ ] A Very-stableᴱ→Stable-≃ᴱ {A = A} n = For-iterated-equality-cong₁ᴱ-→ n λ {A} → Very-stableᴱ A →⟨ EEq.⟨ _ ,_⟩₀ ⟩ A ≃ᴱ Erased A →⟨ EEq.inverse ⟩ Erased A ≃ᴱ A →⟨ id ⟩□ Stable-[ equivalenceᴱ ] A □ -- If A is very stable with erased proofs, then A is stable. Very-stableᴱ→Stable : {@0 A : Type a} → ∀ n → For-iterated-equality n Very-stableᴱ A → For-iterated-equality n Stable A Very-stableᴱ→Stable {A = A} n = For-iterated-equality n Very-stableᴱ A →⟨ Very-stableᴱ→Stable-≃ᴱ n ⟩ For-iterated-equality n Stable-[ equivalenceᴱ ] A →⟨ For-iterated-equality-cong₁ᴱ-→ n _≃ᴱ_.to ⟩□ For-iterated-equality n Stable A □ -- The function obtained from Very-stableᴱ→Stable 0 maps [ x ] to x -- (in erased contexts). @0 Very-stableᴱ→Stable-[]≡id : (s : Very-stableᴱ A) → Very-stableᴱ→Stable 0 s [ x ] ≡ x Very-stableᴱ→Stable-[]≡id {x = x} s = Very-stableᴱ→Stable 0 s [ x ] ≡⟨⟩ _≃ᴱ_.from EEq.⟨ _ , s ⟩ [ x ] ≡⟨ _≃ᴱ_.left-inverse-of EEq.⟨ _ , s ⟩ x ⟩∎ x ∎ -- If one can prove that A is very stable given that Erased A is -- inhabited, then A is very stable. [Erased→Very-stable]→Very-stable : (Erased A → Very-stable A) → Very-stable A [Erased→Very-stable]→Very-stable = HA.[inhabited→Is-equivalence]→Is-equivalence -- If one can prove that A is very stable (with erased proofs) given -- that Erased A is inhabited, then A is very stable (with erased -- proofs). [Erased→Very-stableᴱ]→Very-stableᴱ : {@0 A : Type a} → (Erased A → Very-stableᴱ A) → Very-stableᴱ A [Erased→Very-stableᴱ]→Very-stableᴱ = EEq.[inhabited→Is-equivalenceᴱ]→Is-equivalenceᴱ -- Erased A is very stable. Very-stable-Erased : {@0 A : Type a} → Very-stable (Erased A) Very-stable-Erased = _≃_.is-equivalence (Eq.↔⇒≃ (record { surjection = record { logical-equivalence = record { from = λ ([ x ]) → [ erased x ] } ; right-inverse-of = refl } ; left-inverse-of = λ x → refl [ erased x ] })) -- In an erased context every type is very stable. -- -- Presumably "not in an erased context" is not expressible -- internally, so it seems as if it should not be possible to prove -- that any type is /not/ very stable (in an empty, non-erased -- context, assuming that Agda is consistent). Erased-Very-stable : {@0 A : Type a} → Erased (Very-stable A) Erased-Very-stable {A = A} = [ _≃_.is-equivalence ( $⟨ Erased↔ ⟩ Erased (Erased A ↔ A) ↝⟨ erased ⟩ Erased A ↔ A ↝⟨ Eq.↔⇒≃ ∘ inverse ⟩□ A ≃ Erased A □) ] -- If Very-stable A is very stable, then A is very stable. -- -- See also Very-stable-Very-stable≃Very-stable below. Very-stable-Very-stable→Very-stable : Very-stable (Very-stable A) → Very-stable A Very-stable-Very-stable→Very-stable s = Very-stable→Stable 0 s Erased-Very-stable -- If Very-stableᴱ A is very stable with erased proofs, then A is very -- stable with erased proofs. -- -- See also Very-stableᴱ-Very-stableᴱ≃ᴱVery-stableᴱ below. Very-stableᴱ-Very-stableᴱ→Very-stableᴱ : {@0 A : Type a} → Very-stableᴱ (Very-stableᴱ A) → Very-stableᴱ A Very-stableᴱ-Very-stableᴱ→Very-stableᴱ {A = A} s = $⟨ Erased-Very-stable ⟩ Erased (Very-stable A) →⟨ map (Very-stable→Very-stableᴱ 0) ⟩ Erased (Very-stableᴱ A) →⟨ Very-stableᴱ→Stable 0 s ⟩□ Very-stableᴱ A □ -- It is not the case that every very stable type is a proposition. ¬-Very-stable→Is-proposition : ¬ ({A : Type a} → Very-stable A → Is-proposition A) ¬-Very-stable→Is-proposition {a = a} hyp = not-proposition (hyp very-stable) where very-stable : Very-stable (Erased (↑ a Bool)) very-stable = Very-stable-Erased not-proposition : ¬ Is-proposition (Erased (↑ a Bool)) not-proposition = Is-proposition (Erased (↑ a Bool)) ↝⟨ (λ prop → prop _ _) ⟩ [ lift true ] ≡ [ lift false ] ↝⟨ (λ hyp → [ cong (lower ∘ erased) hyp ]) ⟩ Erased (true ≡ false) ↝⟨ map Bool.true≢false ⟩ Erased ⊥ ↔⟨ Erased-⊥↔⊥ ⟩□ ⊥ □ -- Erased A implies ¬ ¬ A. Erased→¬¬ : {@0 A : Type a} → Erased A → ¬ ¬ A Erased→¬¬ [ x ] f = _↔_.to Erased-⊥↔⊥ [ f x ] -- Types that are stable for double negation are stable for Erased. ¬¬-stable→Stable : {@0 A : Type a} → (¬ ¬ A → A) → Stable A ¬¬-stable→Stable ¬¬-Stable x = ¬¬-Stable (Erased→¬¬ x) -- Types for which it is known whether or not they are inhabited are -- stable. Dec→Stable : {@0 A : Type a} → Dec A → Stable A Dec→Stable (yes x) _ = x Dec→Stable (no ¬x) x with () ← Erased→¬¬ x ¬x -- Every type is stable in the double negation monad. ¬¬-Stable : {@0 A : Type a} → ¬¬ Stable A ¬¬-Stable = DN.map′ Dec→Stable excluded-middle -- If equality is stable for A and B, then A ≃ᴱ B implies A ≃ B. Stable-≡→≃ᴱ→≃ : Stable-≡ A → Stable-≡ B → A ≃ᴱ B → A ≃ B Stable-≡→≃ᴱ→≃ sA sB A≃ᴱB = Eq.↔→≃ (_≃ᴱ_.to A≃ᴱB) (_≃ᴱ_.from A≃ᴱB) (λ x → sB _ _ [ _≃ᴱ_.right-inverse-of A≃ᴱB x ]) (λ x → sA _ _ [ _≃ᴱ_.left-inverse-of A≃ᴱB x ]) -- If A is stable, with an erased proof showing that [_]→ is a right -- inverse of the proof of stability, then A is very stable with -- erased proofs. Stable→Left-inverse→Very-stableᴱ : {@0 A : Type a} → (s : Stable A) → @0 (∀ x → s [ x ] ≡ x) → Very-stableᴱ A Stable→Left-inverse→Very-stableᴱ s inv = _≃ᴱ_.is-equivalence $ EEq.↔→≃ᴱ _ s (λ ([ x ]) → cong [_]→ (inv x)) inv private -- A lemma used below. H-level-suc→For-iterated-equality-Is-proposition : H-level (1 + n) A → For-iterated-equality n Is-proposition A H-level-suc→For-iterated-equality-Is-proposition {n = n} {A = A} = H-level (1 + n) A ↝⟨ _⇔_.to H-level⇔H-level′ ⟩ H-level′ (1 + n) A ↝⟨ inverse-ext? (For-iterated-equality-For-iterated-equality n 1) _ ⟩ For-iterated-equality n (H-level′ 1) A ↝⟨ For-iterated-equality-cong₁ _ n $ _⇔_.from (H-level⇔H-level′ {n = 1}) ⟩□ For-iterated-equality n Is-proposition A □ -- If A is stable, and there is an erased proof showing that A is a -- proposition, then A is very stable with erased proofs. Stable-proposition→Very-stableᴱ : {@0 A : Type a} → Stable A → @0 Is-proposition A → Very-stableᴱ A Stable-proposition→Very-stableᴱ {A = A} s prop = _≃ᴱ_.is-equivalence $ EEq.⇔→≃ᴱ prop ( $⟨ prop ⟩ Is-proposition A ↝⟨ H-level-cong _ 1 (inverse $ Erased↔ .erased) ⦂ (_ → _) ⟩□ Is-proposition (Erased A) □) [_]→ s -- The previous result can be generalised. Stable→H-level-suc→Very-stableᴱ : {@0 A : Type a} → ∀ n → For-iterated-equality n Stable A → @0 H-level (1 + n) A → For-iterated-equality n Very-stableᴱ A Stable→H-level-suc→Very-stableᴱ {A = A} n s h = $⟨ s ,′ [ H-level-suc→For-iterated-equality-Is-proposition h ] ⟩ For-iterated-equality n Stable A × Erased (For-iterated-equality n Is-proposition A) →⟨ Σ-map id $ For-iterated-equality-commutesᴱ-→ (λ A → Erased A) n (λ ([ f ]) x → [ f x ]) ⟩ For-iterated-equality n Stable A × For-iterated-equality n (λ A → Erased (Is-proposition A)) A →⟨ For-iterated-equality-commutesᴱ-×-→ n ⟩ For-iterated-equality n (λ A → Stable A × Erased (Is-proposition A)) A →⟨ (For-iterated-equality-cong₁ᴱ-→ n λ (s , [ prop ]) → Stable-proposition→Very-stableᴱ s prop) ⟩□ For-iterated-equality n Very-stableᴱ A □ -- Types that are contractible with erased proofs (n levels up) are -- very stable with erased proofs (n levels up). H-level→Very-stableᴱ : {@0 A : Type a} → ∀ n → For-iterated-equality n Contractibleᴱ A → For-iterated-equality n Very-stableᴱ A H-level→Very-stableᴱ {A = A} n = For-iterated-equality n Contractibleᴱ A →⟨ For-iterated-equality-cong₁ᴱ-→ n Contractibleᴱ→Very-stableᴱ ⟩□ For-iterated-equality n Very-stableᴱ A □ where Contractibleᴱ→Very-stableᴱ : ∀ {@0 A} → Contractibleᴱ A → Very-stableᴱ A Contractibleᴱ→Very-stableᴱ c = Stable-proposition→Very-stableᴱ (λ _ → proj₁₀ c) (mono₁ 0 $ ECP.Contractibleᴱ→Contractible c) ------------------------------------------------------------------------ -- Preservation lemmas -- A kind of map function for Stable. Stable-map : {@0 A : Type a} {@0 B : Type b} → (A → B) → @0 (B → A) → Stable A → Stable B Stable-map A→B B→A s x = A→B (s (map B→A x)) -- A variant of Stable-map. Stable-map-⇔ : {@0 A : Type a} {@0 B : Type b} → A ⇔ B → Stable A → Stable B Stable-map-⇔ A⇔B = Stable-map (to-implication A⇔B) (_⇔_.from A⇔B) -- Stable-[ equivalenceᴱ ] preserves equivalences with erased proofs -- (assuming extensionality). Stable-≃ᴱ-cong : {A : Type ℓ₁} {B : Type ℓ₂} → @0 Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) → A ≃ᴱ B → Stable-[ equivalenceᴱ ] A ≃ᴱ Stable-[ equivalenceᴱ ] B Stable-≃ᴱ-cong {A = A} {B = B} ext A≃B = Stable-[ equivalenceᴱ ] A ↔⟨⟩ Erased A ≃ᴱ A ↝⟨ EEq.≃ᴱ-cong ext (Erased-cong-≃ᴱ A≃B) A≃B ⟩ Erased B ≃ᴱ B ↔⟨⟩ Stable-[ equivalenceᴱ ] B □ -- If there is an injective function from A to B, and equality is -- stable for B, then equality is stable for A. Injective→Stable-≡→Stable-≡ : {@0 A : Type a} {@0 B : Type b} → (f : A → B) → Injective f → Stable-≡ B → Stable-≡ A Injective→Stable-≡→Stable-≡ f inj s x y = Stable-map inj (cong f) (s (f x) (f y)) -- If there is a function from A to B, with an erased proof showing -- that the function is an equivalence, and A is very stable with -- erased proofs, then B is very stable with erased proofs. →→Is-equivalence→Very-stableᴱ→Very-stableᴱ : {@0 A : Type a} {@0 B : Type b} (f : A → B) → @0 Is-equivalence f → Very-stableᴱ A → Very-stableᴱ B →→Is-equivalence→Very-stableᴱ→Very-stableᴱ {A = A} {B = B} f eq s = _≃ᴱ_.is-equivalence $ EEq.↔→≃ᴱ [_]→ (Erased B →⟨ map (_≃_.from Eq.⟨ _ , eq ⟩) ⟩ Erased A →⟨ _≃ᴱ_.from EEq.⟨ _ , s ⟩₀ ⟩ A →⟨ f ⟩□ B □) (λ ([ x ]) → cong [_]→ (lemma x)) lemma where @0 lemma : _ lemma = λ x → f (_≃ᴱ_.from EEq.⟨ _ , s ⟩ [ _≃_.from Eq.⟨ _ , eq ⟩ x ]) ≡⟨ cong f $ _≃ᴱ_.left-inverse-of EEq.⟨ _ , s ⟩ _ ⟩ f (_≃_.from Eq.⟨ _ , eq ⟩ x) ≡⟨ _≃_.right-inverse-of Eq.⟨ _ , eq ⟩ _ ⟩∎ x ∎ -- If A is equivalent (with erased proofs) to B, and A is very stable -- with erased proofs, then B is very stable with erased proofs. ≃ᴱ→Very-stableᴱ→Very-stableᴱ : {@0 A : Type a} {@0 B : Type b} → A ≃ᴱ B → Very-stableᴱ A → Very-stableᴱ B ≃ᴱ→Very-stableᴱ→Very-stableᴱ A≃ᴱB = →→Is-equivalence→Very-stableᴱ→Very-stableᴱ _ (_≃_.is-equivalence $ EEq.≃ᴱ→≃ A≃ᴱB) -- Very-stableᴱ preserves equivalences with erased proofs (assuming -- extensionality). Very-stableᴱ-cong : {@0 A : Type a} {@0 B : Type b} → @0 Extensionality (a ⊔ b) (a ⊔ b) → A ≃ᴱ B → Very-stableᴱ A ≃ᴱ Very-stableᴱ B Very-stableᴱ-cong {a = a} {b = b} ext A≃ᴱB = EEq.⇔→≃ᴱ (Very-stableᴱ-propositional (lower-extensionality b b ext)) (Very-stableᴱ-propositional (lower-extensionality a a ext)) (≃ᴱ→Very-stableᴱ→Very-stableᴱ A≃ᴱB) (≃ᴱ→Very-stableᴱ→Very-stableᴱ (EEq.inverse A≃ᴱB)) -- A variant of Very-stableᴱ-cong. Very-stableᴱ-congⁿ : {A : Type a} {B : Type b} → @0 Extensionality (a ⊔ b) (a ⊔ b) → ∀ n → A ↔[ k ] B → For-iterated-equality n Very-stableᴱ A ≃ᴱ For-iterated-equality n Very-stableᴱ B Very-stableᴱ-congⁿ ext n A↔B = For-iterated-equality-cong [ ext ] n (Very-stableᴱ-cong ext ∘ from-isomorphism) (from-isomorphism A↔B) ------------------------------------------------------------------------ -- Closure properties -- ⊤ is very stable. Very-stable-⊤ : Very-stable ⊤ Very-stable-⊤ = _≃_.is-equivalence $ Eq.↔⇒≃ $ inverse Erased-⊤↔⊤ -- ⊥ is very stable. Very-stable-⊥ : Very-stable (⊥ {ℓ = ℓ}) Very-stable-⊥ = _≃_.is-equivalence $ Eq.↔⇒≃ $ inverse Erased-⊥↔⊥ -- Stable is closed under Π A. Stable-Π : {@0 A : Type a} {@0 P : A → Type p} → (∀ x → Stable (P x)) → Stable ((x : A) → P x) Stable-Π s [ f ] x = s x [ f x ] -- A variant of Stable-Π. Stable-[]-Π : {A : Type a} {P : A → Type p} → Extensionality? k a p → (∀ x → Stable-[ k ] (P x)) → Stable-[ k ] ((x : A) → P x) Stable-[]-Π {P = P} ext s = Erased (∀ x → P x) ↔⟨ Erased-Π↔Π ⟩ (∀ x → Erased (P x)) ↝⟨ ∀-cong ext s ⟩□ (∀ x → P x) □ -- Very-stable is closed under Π A (assuming extensionality). Very-stable-Π : {A : Type a} {P : A → Type p} → Extensionality a p → (∀ x → Very-stable (P x)) → Very-stable ((x : A) → P x) Very-stable-Π ext s = _≃_.is-equivalence $ inverse $ Stable-[]-Π ext $ λ x → inverse Eq.⟨ _ , s x ⟩ -- Very-stableᴱ is closed under Π A (assuming extensionality). Very-stableᴱ-Π : {@0 A : Type a} {@0 P : A → Type p} → @0 Extensionality a p → (∀ x → Very-stableᴱ (P x)) → Very-stableᴱ ((x : A) → P x) Very-stableᴱ-Π {P = P} ext s = _≃ᴱ_.is-equivalence ((∀ x → P x) EEq.≃ᴱ⟨ (EEq.∀-cong-≃ᴱ ext λ x → EEq.⟨ _ , s x ⟩₀) ⟩ (∀ x → Erased (P x)) EEq.≃ᴱ⟨ EEq.inverse Erased-Π≃ᴱΠ ⟩□ Erased (∀ x → P x) □) -- A variant of Very-stableᴱ-Π. Very-stableᴱ-Πⁿ : {A : Type a} {P : A → Type p} → Extensionality a p → ∀ n → (∀ x → For-iterated-equality n Very-stableᴱ (P x)) → For-iterated-equality n Very-stableᴱ ((x : A) → P x) Very-stableᴱ-Πⁿ ext n = For-iterated-equality-Π ext n (≃ᴱ→Very-stableᴱ→Very-stableᴱ ∘ from-isomorphism) (Very-stableᴱ-Π ext) -- One can sometimes drop Erased from the domain of a Π-type. Π-Erased≃Π : {A : Type a} {P : @0 A → Type p} → Extensionality? ⌊ k ⌋-sym a p → (∀ (@0 x) → Stable-[ ⌊ k ⌋-sym ] (P x)) → ((x : Erased A) → P (erased x)) ↝[ ⌊ k ⌋-sym ] ((x : A) → P x) Π-Erased≃Π {a = a} {p = p} {A = A} {P = P} = lemma₂ where lemma₁ lemma₂ : Extensionality? ⌊ k ⌋-sym a p → (∀ (@0 x) → Stable-[ ⌊ k ⌋-sym ] (P x)) → ((x : Erased A) → P (erased x)) ↝[ ⌊ k ⌋-sym ] ((x : A) → P x) lemma₁ ext s = ((x : Erased A) → P (erased x)) ↝⟨ (∀-cong ext λ x → inverse $ s (erased x)) ⟩ ((x : Erased A) → Erased (P (erased x))) ↔⟨ inverse Erased-Π↔Π-Erased ⟩ Erased ((x : A) → P x) ↝⟨ Stable-[]-Π ext (λ x → s x) ⟩□ ((x : A) → P x) □ lemma₂ {k = equivalence} ext s = Eq.with-other-function (lemma₁ ext s) (_∘ [_]→) (λ f → apply-ext ext λ x → _≃_.to (s x) (_≃_.from (s x) (f [ x ])) ≡⟨ _≃_.right-inverse-of (s x) _ ⟩∎ f [ x ] ∎) lemma₂ {k = equivalenceᴱ} ext s = EEq.with-other-function (lemma₁ ext s) (_∘ [_]→) (λ f → apply-ext (erased ext) λ x → _≃ᴱ_.to (s x) (_≃ᴱ_.from (s x) (f [ x ])) ≡⟨ _≃ᴱ_.right-inverse-of (s x) _ ⟩∎ f [ x ] ∎) lemma₂ {k = bijection} ext s = Bijection.with-other-function (lemma₁ ext s) (_∘ [_]→) (λ f → apply-ext ext λ x → _↔_.to (s x) (_↔_.from (s x) (f [ x ])) ≡⟨ _↔_.right-inverse-of (s x) _ ⟩∎ f [ x ] ∎) lemma₂ {k = logical-equivalence} ext s = record (lemma₁ ext s) { to = _∘ [_]→ } _ : _≃_.to (Π-Erased≃Π ext s) f x ≡ f [ x ] _ = refl _ _ : _≃ᴱ_.to (Π-Erased≃Π ext s) f x ≡ f [ x ] _ = refl _ _ : _↔_.to (Π-Erased≃Π ext s) f x ≡ f [ x ] _ = refl _ _ : _⇔_.to (Π-Erased≃Π ext s) f x ≡ f [ x ] _ = refl _ -- Stable is closed under Σ A if A is very stable. Very-stable-Stable-Σ : Very-stable A → (∀ x → Stable-[ k ] (P x)) → Stable-[ k ] (Σ A P) Very-stable-Stable-Σ {A = A} {P = P} s s′ = Erased (Σ A P) ↔⟨ Erased-Σ↔Σ ⟩ Σ (Erased A) (λ x → Erased (P (erased x))) ↝⟨ Σ-cong-contra Eq.⟨ _ , s ⟩ s′ ⟩□ Σ A P □ -- If A is stable with a stability proof that is a right inverse of -- [_]→, and P is pointwise stable, then Σ A P is stable. Stable-Σ : (s : Stable A) → (∀ x → [ s x ] ≡ x) → (∀ x → Stable (P x)) → Stable (Σ A P) Stable-Σ {A = A} {P = P} s₁ hyp s₂ = Erased (Σ A P) ↔⟨ Erased-Σ↔Σ ⟩ Σ (Erased A) (λ x → Erased (P (erased x))) ↝⟨ Σ-cong-contra-→ surj s₂ ⟩□ Σ A P □ where surj : A ↠ Erased A surj = record { logical-equivalence = record { to = [_]→ ; from = s₁ } ; right-inverse-of = hyp } -- Very-stable is closed under Σ. -- -- See also Very-stableᴱ-Σ below. Very-stable-Σ : Very-stable A → (∀ x → Very-stable (P x)) → Very-stable (Σ A P) Very-stable-Σ {A = A} {P = P} s s′ = _≃_.is-equivalence ( Σ A P ↝⟨ Σ-cong Eq.⟨ _ , s ⟩ (λ x → Eq.⟨ _ , s′ x ⟩) ⟩ Σ (Erased A) (λ x → Erased (P (erased x))) ↔⟨ inverse Erased-Σ↔Σ ⟩□ Erased (Σ A P) □) -- Stable is closed under _×_. Stable-× : {@0 A : Type a} {@0 B : Type b} → Stable A → Stable B → Stable (A × B) Stable-× s s′ [ x , y ] = s [ x ] , s′ [ y ] -- Stable-[ k ] is closed under _×_. Stable-[]-× : Stable-[ k ] A → Stable-[ k ] B → Stable-[ k ] (A × B) Stable-[]-× {A = A} {B = B} s s′ = Erased (A × B) ↔⟨ Erased-Σ↔Σ ⟩ Erased A × Erased B ↝⟨ s ×-cong s′ ⟩□ A × B □ -- Very-stable is closed under _×_. Very-stable-× : Very-stable A → Very-stable B → Very-stable (A × B) Very-stable-× s s′ = _≃_.is-equivalence $ inverse $ Stable-[]-× (inverse Eq.⟨ _ , s ⟩) (inverse Eq.⟨ _ , s′ ⟩) -- Very-stableᴱ is closed under _×_. Very-stableᴱ-× : {@0 A : Type a} {@0 B : Type b} → Very-stableᴱ A → Very-stableᴱ B → Very-stableᴱ (A × B) Very-stableᴱ-× {A = A} {B = B} s s′ = _≃ᴱ_.is-equivalence (A × B EEq.≃ᴱ⟨ EEq.⟨ _ , s ⟩₀ EEq.×-cong-≃ᴱ EEq.⟨ _ , s′ ⟩₀ ⟩ Erased A × Erased B EEq.↔⟨ inverse Erased-Σ↔Σ ⟩□ Erased (A × B) □) -- A generalisation of Very-stableᴱ-×. Very-stableᴱ-×ⁿ : ∀ n → For-iterated-equality n Very-stableᴱ A → For-iterated-equality n Very-stableᴱ B → For-iterated-equality n Very-stableᴱ (A × B) Very-stableᴱ-×ⁿ n = For-iterated-equality-× n (≃ᴱ→Very-stableᴱ→Very-stableᴱ ∘ from-isomorphism) Very-stableᴱ-× -- Stable-[ k ] is closed under ↑ ℓ. Stable-↑ : Stable-[ k ] A → Stable-[ k ] (↑ ℓ A) Stable-↑ {A = A} s = Erased (↑ _ A) ↔⟨ Erased-↑↔↑ ⟩ ↑ _ (Erased A) ↝⟨ ↑-cong s ⟩□ ↑ _ A □ -- Very-stable is closed under ↑ ℓ. Very-stable-↑ : Very-stable A → Very-stable (↑ ℓ A) Very-stable-↑ s = _≃_.is-equivalence $ inverse $ Stable-↑ $ inverse Eq.⟨ _ , s ⟩ -- Very-stableᴱ is closed under ↑ ℓ. Very-stableᴱ-↑ : {@0 A : Type a} → Very-stableᴱ A → Very-stableᴱ (↑ ℓ A) Very-stableᴱ-↑ {A = A} s = _≃ᴱ_.is-equivalence (↑ _ A EEq.≃ᴱ⟨ EEq.↑-cong-≃ᴱ EEq.⟨ _ , s ⟩₀ ⟩ ↑ _ (Erased A) EEq.↔⟨ inverse Erased-↑↔↑ ⟩□ Erased (↑ _ A) □) -- A generalisation of Very-stableᴱ-↑. Very-stableᴱ-↑ⁿ : ∀ n → For-iterated-equality n Very-stableᴱ A → For-iterated-equality n Very-stableᴱ (↑ ℓ A) Very-stableᴱ-↑ⁿ n = For-iterated-equality-↑ _ n (≃ᴱ→Very-stableᴱ→Very-stableᴱ ∘ from-isomorphism) -- ¬ A is stable. Stable-¬ : {@0 A : Type a} → Stable (¬ A) Stable-¬ = Stable-Π λ _ → Very-stable→Stable 0 Very-stable-⊥ -- A variant of the previous result. Stable-[]-¬ : {A : Type a} → Extensionality? k a lzero → Stable-[ k ] (¬ A) Stable-[]-¬ ext = Stable-[]-Π ext λ _ → Very-stable→Stable 0 Very-stable-⊥ -- ¬ A is very stable (assuming extensionality). Very-stable-¬ : {A : Type a} → Extensionality a lzero → Very-stable (¬ A) Very-stable-¬ {A = A} ext = Very-stable-Π ext λ _ → Very-stable-⊥ -- If A is very stable with erased proofs, then W A P is very stable -- with erased proofs (assuming extensionality). Very-stableᴱ-W : {@0 A : Type a} {@0 P : A → Type p} → @0 Extensionality p (a ⊔ p) → Very-stableᴱ A → Very-stableᴱ (W A P) Very-stableᴱ-W {A = A} {P = P} ext s = _≃ᴱ_.is-equivalence $ EEq.↔→≃ᴱ [_]→ from []∘from from∘[] where A≃ᴱE-A : A ≃ᴱ Erased A A≃ᴱE-A = EEq.⟨ _ , s ⟩₀ from : Erased (W A P) → W A P from [ sup x f ] = sup (_≃ᴱ_.from A≃ᴱE-A [ x ]) (λ y → from [ f (subst P (_≃ᴱ_.left-inverse-of A≃ᴱE-A x) y) ]) @0 from∘[] : ∀ x → from [ x ] ≡ x from∘[] (sup x f) = curry (_↠_.to (W-≡,≡↠≡ ext)) (_≃ᴱ_.left-inverse-of A≃ᴱE-A x) (λ y → from∘[] (f (subst P (_≃ᴱ_.left-inverse-of A≃ᴱE-A x) y))) @0 []∘from : ∀ x → [ from x ] ≡ x []∘from [ x ] = cong [_]→ (from∘[] x) -- ∃ λ (A : Set a) → Very-stable A is stable. -- -- This result is based on Theorem 3.11 in "Modalities in Homotopy -- Type Theory" by Rijke, Shulman and Spitters. Stable-∃-Very-stable : Stable (∃ λ (A : Type a) → Very-stable A) Stable-∃-Very-stable [ A ] = Erased (proj₁ A) , Very-stable-Erased -- ∃ λ (A : Set a) → Very-stable A is stable with erased proofs. -- -- This result is based on Theorem 3.11 in "Modalities in Homotopy -- Type Theory" by Rijke, Shulman and Spitters. Stable-∃-Very-stableᴱ : Stable (∃ λ (A : Type a) → Very-stableᴱ A) Stable-∃-Very-stableᴱ [ A ] = Erased (proj₁ A) , Very-stable→Very-stableᴱ 0 Very-stable-Erased -- ∃ λ (A : Set a) → Very-stableᴱ A is very stable (with erased -- proofs), assuming extensionality and univalence. -- -- This result is based on Theorem 3.11 in "Modalities in Homotopy -- Type Theory" by Rijke, Shulman and Spitters. Very-stableᴱ-∃-Very-stableᴱ : @0 Extensionality a a → @0 Univalence a → Very-stableᴱ (∃ λ (A : Type a) → Very-stableᴱ A) Very-stableᴱ-∃-Very-stableᴱ ext univ = Stable→Left-inverse→Very-stableᴱ Stable-∃-Very-stableᴱ inv where @0 inv : ∀ p → Stable-∃-Very-stableᴱ [ p ] ≡ p inv (A , s) = Σ-≡,≡→≡ (Erased A ≡⟨ ≃⇒≡ univ (Very-stable→Stable 0 (Very-stableᴱ→Very-stable 0 s)) ⟩∎ A ∎) (Very-stableᴱ-propositional ext _ _) -- If A is "stable 1 + n levels up", then H-level′ (1 + n) A is -- stable. Stable-H-level′ : ∀ n → For-iterated-equality (1 + n) Stable A → Stable (H-level′ (1 + n) A) Stable-H-level′ {A = A} n = For-iterated-equality (1 + n) Stable A ↝⟨ inverse-ext? (λ ext → For-iterated-equality-For-iterated-equality n 1 ext) _ ⟩ For-iterated-equality n Stable-≡ A ↝⟨ For-iterated-equality-cong₁ _ n lemma ⟩ For-iterated-equality n (Stable ∘ H-level′ 1) A ↝⟨ For-iterated-equality-commutes-← _ Stable n Stable-Π ⟩ Stable (For-iterated-equality n (H-level′ 1) A) ↝⟨ Stable-map-⇔ (For-iterated-equality-For-iterated-equality n 1 _) ⟩□ Stable (H-level′ (1 + n) A) □ where lemma : ∀ {A} → Stable-≡ A → Stable (H-level′ 1 A) lemma s = Stable-map-⇔ (H-level↔H-level′ {n = 1} _) (Stable-Π λ _ → Stable-Π λ _ → s _ _) -- If A is "stable 1 + n levels up", then H-level (1 + n) A is -- stable. Stable-H-level : ∀ n → For-iterated-equality (1 + n) Stable A → Stable (H-level (1 + n) A) Stable-H-level {A = A} n = For-iterated-equality (1 + n) Stable A ↝⟨ Stable-H-level′ n ⟩ Stable (H-level′ (1 + n) A) ↝⟨ Stable-map-⇔ (inverse-ext? H-level↔H-level′ _) ⟩□ Stable (H-level (1 + n) A) □ -- If equality is stable for A and B, then it is stable for A ⊎ B. Stable-≡-⊎ : ∀ n → For-iterated-equality (1 + n) Stable A → For-iterated-equality (1 + n) Stable B → For-iterated-equality (1 + n) Stable (A ⊎ B) Stable-≡-⊎ n sA sB = For-iterated-equality-⊎-suc n lemma (Very-stable→Stable 0 Very-stable-⊥) (For-iterated-equality-↑ _ (1 + n) lemma sA) (For-iterated-equality-↑ _ (1 + n) lemma sB) where lemma : A ↔ B → Stable A → Stable B lemma = Stable-map-⇔ ∘ from-isomorphism private -- An alternative, more direct proof of the "base case" of the -- previous result. Stable-≡-⊎₀ : Stable-≡ A → Stable-≡ B → Stable-≡ (A ⊎ B) Stable-≡-⊎₀ sA sB = λ where (inj₁ x) (inj₁ y) → Erased (inj₁ x ≡ inj₁ y) ↝⟨ map (_↔_.from Bijection.≡↔inj₁≡inj₁) ⟩ Erased (x ≡ y) ↝⟨ sA _ _ ⟩ x ≡ y ↔⟨ Bijection.≡↔inj₁≡inj₁ ⟩□ inj₁ x ≡ inj₁ y □ (inj₁ x) (inj₂ y) → Erased (inj₁ x ≡ inj₂ y) ↝⟨ map (_↔_.to Bijection.≡↔⊎) ⟩ Erased ⊥ ↝⟨ Very-stable→Stable 0 Very-stable-⊥ ⟩ ⊥ ↔⟨ inverse Bijection.≡↔⊎ ⟩□ inj₁ x ≡ inj₂ y □ (inj₂ x) (inj₁ y) → Erased (inj₂ x ≡ inj₁ y) ↝⟨ map (_↔_.to Bijection.≡↔⊎) ⟩ Erased ⊥ ↝⟨ Very-stable→Stable 0 Very-stable-⊥ ⟩ ⊥ ↔⟨ inverse Bijection.≡↔⊎ ⟩□ inj₂ x ≡ inj₁ y □ (inj₂ x) (inj₂ y) → Erased (inj₂ x ≡ inj₂ y) ↝⟨ map (_↔_.from Bijection.≡↔inj₂≡inj₂) ⟩ Erased (x ≡ y) ↝⟨ sB _ _ ⟩ x ≡ y ↔⟨ Bijection.≡↔inj₂≡inj₂ ⟩□ inj₂ x ≡ inj₂ y □ -- If equality is very stable (with erased proofs) for A and B, then -- it is very stable (with erased proofs) for A ⊎ B. Very-stableᴱ-≡-⊎ : ∀ n → For-iterated-equality (1 + n) Very-stableᴱ A → For-iterated-equality (1 + n) Very-stableᴱ B → For-iterated-equality (1 + n) Very-stableᴱ (A ⊎ B) Very-stableᴱ-≡-⊎ n sA sB = For-iterated-equality-⊎-suc n lemma (Very-stable→Very-stableᴱ 0 Very-stable-⊥) (For-iterated-equality-↑ _ (1 + n) lemma sA) (For-iterated-equality-↑ _ (1 + n) lemma sB) where lemma : A ↔ B → Very-stableᴱ A → Very-stableᴱ B lemma = ≃ᴱ→Very-stableᴱ→Very-stableᴱ ∘ from-isomorphism -- If equality is stable for A, then it is stable for List A. Stable-≡-List : ∀ n → For-iterated-equality (1 + n) Stable A → For-iterated-equality (1 + n) Stable (List A) Stable-≡-List n = For-iterated-equality-List-suc n (Stable-map-⇔ ∘ from-isomorphism) (Very-stable→Stable 0 $ Very-stable-↑ Very-stable-⊤) (Very-stable→Stable 0 Very-stable-⊥) Stable-[]-× -- If equality is very stable (with erased proofs) for A, then it is -- very stable (with erased proofs) for List A. Very-stableᴱ-≡-List : ∀ n → For-iterated-equality (1 + n) Very-stableᴱ A → For-iterated-equality (1 + n) Very-stableᴱ (List A) Very-stableᴱ-≡-List n = For-iterated-equality-List-suc n (≃ᴱ→Very-stableᴱ→Very-stableᴱ ∘ from-isomorphism) (Very-stable→Very-stableᴱ 0 $ Very-stable-↑ Very-stable-⊤) (Very-stable→Very-stableᴱ 0 Very-stable-⊥) Very-stableᴱ-× ------------------------------------------------------------------------ -- Some properties related to "Modalities in Homotopy Type Theory" -- by Rijke, Shulman and Spitters -- If we assume that equality is extensional for functions, then -- λ A → Erased A is the modal operator of a Σ-closed reflective -- subuniverse with [_]→ as the modal unit and Very-stable as the -- modality predicate: -- -- * Very-stable is propositional (assuming extensionality), see -- Very-stable-propositional. -- * Erased A is very stable, see Very-stable-Erased. -- * Very-stable is Σ-closed, see Very-stable-Σ. -- * Finally precomposition with [_]→ is an equivalence for functions -- with very stable codomains (assuming extensionality): ∘-[]-equivalence : {A : Type a} {B : Type b} → Extensionality a b → Very-stable B → Is-equivalence (λ (f : Erased A → B) → f ∘ [_]→) ∘-[]-equivalence ext s = _≃_.is-equivalence (Eq.↔⇒≃ (record { surjection = record { logical-equivalence = record { from = λ f x → _≃_.from Eq.⟨ _ , s ⟩ (map f x) } ; right-inverse-of = λ f → apply-ext ext λ x → _≃_.left-inverse-of Eq.⟨ _ , s ⟩ (f x) } ; left-inverse-of = λ f → apply-ext ext λ x → _≃_.left-inverse-of Eq.⟨ _ , s ⟩ (f x) })) -- A variant of ∘-[]-equivalence. Is-equivalenceᴱ-∘[] : {@0 A : Type a} {@0 B : Type b} → @0 Extensionality a b → Very-stableᴱ B → Is-equivalenceᴱ (λ (f : Erased A → B) → f ∘ [_]→) Is-equivalenceᴱ-∘[] ext s = _≃ᴱ_.is-equivalence $ EEq.↔→≃ᴱ _ (λ f x → _≃ᴱ_.from EEq.⟨ _ , s ⟩₀ (map f x)) (λ f → apply-ext ext λ x → _≃ᴱ_.left-inverse-of EEq.⟨ _ , s ⟩ (f x)) (λ f → apply-ext ext λ x → _≃ᴱ_.left-inverse-of EEq.⟨ _ , s ⟩ (f x)) -- The Coq code accompanying "Modalities in Homotopy Type Theory" uses -- a somewhat different definition of reflective subuniverses than the -- paper: -- * The definition has been adapted to Coq's notion of universe -- polymorphism. -- * The proof showing that the modality predicate is propositional is -- allowed to make use of function extensionality for arbitrary -- universe levels. -- * One extra property is assumed: if A and B are equivalent and A is -- modal, then B is modal. Such a property is proved below, assuming -- that the []-cong axioms can be instantiated (Very-stable-cong). -- * The property corresponding to ∘-[]-equivalence is replaced by a -- property that is intended to avoid uses of extensionality. This -- property is stated using Is-∞-extendable-along-[_]. Such a -- property is proved below, assuming that the []-cong axioms can be -- instantiated (const-extendable). -- (This refers to one version of the code, which seems to have -- changed since I first looked at it.) -- -- Here is a definition of Σ-closed reflective subuniverses that is -- based on the definition of reflective subuniverses in (one version -- of) the Coq code of Rijke et al. Note that Is-modal-propositional -- is only given access to function extensionality for a given -- universe level. Below (Erased-Σ-closed-reflective-subuniverse) it -- is proved that λ A → Erased A, [_]→ and Very-stable form a Σ-closed -- reflective subuniverse of this kind (assuming that the []-cong -- axioms can be instantiated). record Σ-closed-reflective-subuniverse a : Type (lsuc a) where field ◯ : Type a → Type a η : A → ◯ A Is-modal : Type a → Type a Is-modal-propositional : Extensionality a a → Is-proposition (Is-modal A) Is-modal-◯ : Is-modal (◯ A) Is-modal-respects-≃ : A ≃ B → Is-modal A → Is-modal B extendable-along-η : Is-modal B → Is-∞-extendable-along-[ η ] (λ (_ : ◯ A) → B) Σ-closed : Is-modal A → (∀ x → Is-modal (P x)) → Is-modal (Σ A P) ------------------------------------------------------------------------ -- Erased is accessible and topological (assuming extensionality) -- A definition of what it means for a Σ-closed reflective subuniverse -- to be accessible (for a certain universe level). -- -- This definition is based on (one version of) the Coq code -- accompanying "Modalities in Homotopy Type Theory" by Rijke, Shulman -- and Spitters. Accessible : (ℓ : Level) → Σ-closed-reflective-subuniverse a → Type (lsuc (a ⊔ ℓ)) Accessible {a = a} ℓ U = ∃ λ (I : Type ℓ) → ∃ λ (P : I → Type ℓ) → (A : Type a) → Is-modal A ⇔ ∀ i → Is-∞-extendable-along-[ (λ (_ : P i) → lift tt) ] (λ (_ : ↑ ℓ ⊤) → A) where open Σ-closed-reflective-subuniverse U -- A definition of what it means for a Σ-closed reflective subuniverse -- to be topological (for a certain universe level). -- -- This definition is based on (one version of) the Coq code -- accompanying "Modalities in Homotopy Type Theory" by Rijke, Shulman -- and Spitters. -- -- Below it is proved that Erased-Σ-closed-reflective-subuniverse is -- topological (assuming extensionality and that the []-cong axioms -- can be instantiated). Topological : (ℓ : Level) → Σ-closed-reflective-subuniverse a → Type (lsuc (a ⊔ ℓ)) Topological {a = a} ℓ U = ∃ λ (I : Type ℓ) → ∃ λ (P : I → Type ℓ) → (∀ i → Is-proposition (P i)) × ((A : Type a) → Is-modal A ⇔ ∀ i → Is-∞-extendable-along-[ (λ (_ : P i) → lift tt) ] (λ (_ : ↑ ℓ ⊤) → A)) where open Σ-closed-reflective-subuniverse U -- A definition of what it means for Erased to be accessible and -- topological (for certain universe levels). -- -- This definition is based on (one version of) the Coq code -- accompanying "Modalities in Homotopy Type Theory" by Rijke, Shulman -- and Spitters. Erased-is-accessible-and-topological′ : (ℓ a : Level) → Type (lsuc (a ⊔ ℓ)) Erased-is-accessible-and-topological′ ℓ a = ∃ λ (I : Type ℓ) → ∃ λ (P : I → Type ℓ) → (∀ i → Is-proposition (P i)) × ((A : Type a) → Very-stable A ⇔ ∀ i → Is-∞-extendable-along-[ (λ (_ : P i) → lift tt) ] (λ (_ : ↑ ℓ ⊤) → A)) -- A variant of Erased-is-accessible-and-topological′ that does not -- use Is-∞-extendable-along-[_]. Erased-is-accessible-and-topological : (ℓ a : Level) → Type (lsuc (a ⊔ ℓ)) Erased-is-accessible-and-topological ℓ a = ∃ λ (I : Type ℓ) → ∃ λ (P : I → Type ℓ) → (∀ i → Is-proposition (P i)) × ((A : Type a) → Very-stable A ⇔ P -Null A) -- Erased-is-accessible-and-topological′ and -- Erased-is-accessible-and-topological are pointwise equivalent -- (assuming extensionality). ≃Erased-is-accessible-and-topological : Extensionality (lsuc a ⊔ ℓ) (a ⊔ ℓ) → Erased-is-accessible-and-topological′ ℓ a ≃ Erased-is-accessible-and-topological ℓ a ≃Erased-is-accessible-and-topological {a = a} {ℓ = ℓ} ext = ∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → ∀-cong (lower-extensionality ℓ lzero ext) λ _ → ⇔-cong (lower-extensionality (lsuc a) lzero ext) Eq.id $ PS.Π-Is-∞-extendable-along≃Null (lower-extensionality (lsuc a) lzero ext) -- A variant of Erased-is-accessible-and-topological that uses -- Very-stableᴱ instead of Very-stable and _-Nullᴱ_ instead of -- _-Null_, and for which Is-proposition is replaced by -- Erased ∘ Is-proposition. Erased-is-accessible-and-topologicalᴱ : (ℓ a : Level) → Type (lsuc (a ⊔ ℓ)) Erased-is-accessible-and-topologicalᴱ ℓ a = ∃ λ (I : Type ℓ) → ∃ λ (P : I → Type ℓ) → (∀ i → Erased (Is-proposition (P i))) × ((A : Type a) → Very-stableᴱ A ⇔ P -Nullᴱ A) -- In erased contexts Erased is accessible and topological (assuming -- extensionality). @0 erased-is-accessible-and-topological-in-erased-contexts : Extensionality (a ⊔ ℓ) (a ⊔ ℓ) → Erased-is-accessible-and-topological ℓ a erased-is-accessible-and-topological-in-erased-contexts {a = a} {ℓ = ℓ} ext = ↑ ℓ ⊤ , (λ _ → ↑ ℓ ⊤) , (λ _ → H-level.mono₁ 0 $ ↑-closure 0 ⊤-contractible) , λ A → Very-stable A ↔⟨ _⇔_.to contractible⇔↔⊤ $ propositional⇒inhabited⇒contractible (Very-stable-propositional (lower-extensionality ℓ ℓ ext)) (Erased-Very-stable .erased) ⟩ ⊤ ↝⟨ record { to = λ _ _ → _≃_.is-equivalence $ Eq.↔→≃ _ (_$ _) refl refl } ⟩□ (λ _ → ↑ ℓ ⊤) -Null A □ -- Very-stable {a = a} is pointwise equivalent to -- (λ (A : Type a) → Very-stable A) -Null_ (assuming extensionality). Very-stable≃Very-stable-Null : {A : Type a} → Extensionality a a → Very-stable A ↝[ lsuc a ∣ a ] (λ (A : Type a) → Very-stable A) -Null A Very-stable≃Very-stable-Null {A = A} ext = generalise-ext?-prop (record { to = to; from = from }) (λ _ → Very-stable-propositional ext) (λ ext′ → Π-closure ext′ 1 λ _ → Eq.propositional ext _) where open []-cong-axiomatisation (Extensionality→[]-cong-axiomatisation ext) to : Very-stable A → Very-stable -Null A to sA _ = _≃_.is-equivalence $ Eq.↔→≃ const (λ f → Very-stable→Stable 0 sA [ f sB ]) (λ f → apply-ext ext λ x → const (Very-stable→Stable 0 sA [ f sB ]) x ≡⟨⟩ Very-stable→Stable 0 sA [ f sB ] ≡⟨ cong (Very-stable→Stable 0 sA) $ []-cong [ cong f $ Very-stable-propositional ext _ _ ] ⟩ Very-stable→Stable 0 sA [ f x ] ≡⟨ Very-stable→Stable-[]≡id sA ⟩∎ f x ∎) (λ x → Very-stable→Stable 0 sA [ x ] ≡⟨ Very-stable→Stable-[]≡id sA ⟩∎ x ∎) where @0 sB : Very-stable B sB = Erased-Very-stable .erased from : Very-stable -Null A → Very-stable A from hyp = _≃_.is-equivalence $ Eq.↔→≃ [_]→ (Erased A →⟨ flip (Very-stable→Stable 0) ⟩ (Very-stable A → A) ↔⟨ inverse A≃ ⟩□ A □) (λ ([ x ]) → []-cong [ lemma x ]) lemma where A≃ : A ≃ (Very-stable A → A) A≃ = Eq.⟨ const , hyp A ⟩ lemma : ∀ x → _≃_.from A≃ (λ s → Very-stable→Stable 0 s [ x ]) ≡ x lemma x = _≃_.from A≃ (λ s → Very-stable→Stable 0 s [ x ]) ≡⟨ (cong (_≃_.from A≃) $ apply-ext ext λ s → Very-stable→Stable-[]≡id s) ⟩ _≃_.from A≃ (const x) ≡⟨⟩ _≃_.from A≃ (_≃_.to A≃ x) ≡⟨ _≃_.left-inverse-of A≃ _ ⟩∎ x ∎ -- Very-stableᴱ {a = a} is pointwise equivalent to -- (λ (A : Type a) → Very-stableᴱ A) -Nullᴱ_ (assuming -- extensionality). Very-stableᴱ≃Very-stableᴱ-Nullᴱ : {A : Type a} → @0 Extensionality (lsuc a) a → Very-stableᴱ A ≃ᴱ (λ (A : Type a) → Very-stableᴱ A) -Nullᴱ A Very-stableᴱ≃Very-stableᴱ-Nullᴱ {A = A} ext = EEq.⇔→≃ᴱ (Very-stableᴱ-propositional ext′) (Π-closure ext 1 λ _ → EEq.Is-equivalenceᴱ-propositional ext′ _) to from where @0 ext′ : _ ext′ = lower-extensionality _ lzero ext to : Very-stableᴱ A → Very-stableᴱ -Nullᴱ A to sA _ = _≃ᴱ_.is-equivalence $ EEq.↔→≃ᴱ const (λ f → Very-stableᴱ→Stable 0 sA [ f sB ]) (λ f → apply-ext ext′ λ x → const (Very-stableᴱ→Stable 0 sA [ f sB ]) x ≡⟨⟩ Very-stableᴱ→Stable 0 sA [ f sB ] ≡⟨ cong (Very-stableᴱ→Stable 0 sA ∘ [_]→ ∘ f) $ Very-stableᴱ-propositional ext′ _ _ ⟩ Very-stableᴱ→Stable 0 sA [ f x ] ≡⟨ Very-stableᴱ→Stable-[]≡id sA ⟩∎ f x ∎) (λ x → Very-stableᴱ→Stable 0 sA [ x ] ≡⟨ Very-stableᴱ→Stable-[]≡id sA ⟩∎ x ∎) where @0 sB : Very-stableᴱ B sB = Very-stable→Very-stableᴱ 0 (Erased-Very-stable .erased) from : Very-stableᴱ -Nullᴱ A → Very-stableᴱ A from hyp = _≃ᴱ_.is-equivalence $ EEq.↔→≃ᴱ [_]→ (Erased A →⟨ flip (Very-stableᴱ→Stable 0) ⟩ (Very-stableᴱ A → A) →⟨ _≃ᴱ_.from A≃ ⟩□ A □) (cong [_]→ ∘ lemma ∘ erased) lemma where A≃ : A ≃ᴱ (Very-stableᴱ A → A) A≃ = EEq.⟨ const , hyp A ⟩ @0 lemma : ∀ x → _≃ᴱ_.from A≃ (λ s → Very-stableᴱ→Stable 0 s [ x ]) ≡ x lemma x = _≃ᴱ_.from A≃ (λ s → Very-stableᴱ→Stable 0 s [ x ]) ≡⟨ (cong (_≃ᴱ_.from A≃) $ apply-ext ext′ λ s → Very-stableᴱ→Stable-[]≡id s) ⟩ _≃ᴱ_.from A≃ (const x) ≡⟨⟩ _≃ᴱ_.from A≃ (_≃ᴱ_.to A≃ x) ≡⟨ _≃ᴱ_.left-inverse-of A≃ _ ⟩∎ x ∎ -- Erased is accessible and topological (for certain universe levels, -- assuming extensionality). erased-is-accessible-and-topological : ∀ ℓ → Extensionality (lsuc a ⊔ ℓ) (lsuc a ⊔ ℓ) → Erased-is-accessible-and-topological (lsuc a ⊔ ℓ) a erased-is-accessible-and-topological {a = a} ℓ ext = ↑ ℓ (Type a) , ↑ _ ∘ Very-stable ∘ lower , (λ _ → ↑-closure 1 $ Very-stable-propositional ext′) , (λ A → Very-stable A ↝⟨ Very-stable≃Very-stable-Null ext′ _ ⟩ Very-stable -Null A ↝⟨ (inverse $ Π-cong _ Bijection.↑↔ λ B → Is-equivalence≃Is-equivalence-∘ˡ (_≃_.is-equivalence $ Eq.↔→≃ (_∘ lift) (_∘ lower) refl refl) _) ⟩□ (↑ _ ∘ Very-stable ∘ lower) -Null A □) where ext′ = lower-extensionality _ _ ext -- The property Erased-is-accessible-and-topologicalᴱ holds for -- certain universe levels (assuming extensionality). erased-is-accessible-and-topologicalᴱ : ∀ ℓ → @0 Extensionality (lsuc a) a → Erased-is-accessible-and-topologicalᴱ (lsuc a ⊔ ℓ) a erased-is-accessible-and-topologicalᴱ {a = a} ℓ ext = ↑ ℓ (Type a) , ↑ _ ∘ Very-stableᴱ ∘ lower , (λ _ → [ ↑-closure 1 $ Very-stableᴱ-propositional (lower-extensionality _ lzero ext) ]) , (λ A → Very-stableᴱ A ↝⟨ _≃ᴱ_.logical-equivalence $ Very-stableᴱ≃Very-stableᴱ-Nullᴱ ext ⟩ Very-stableᴱ -Nullᴱ A ↝⟨ (inverse $ Π-cong _ Bijection.↑↔ λ B → EEq.Is-equivalenceᴱ⇔Is-equivalenceᴱ-∘ˡ (_≃ᴱ_.is-equivalence $ EEq.↔→≃ᴱ (_∘ lift) (_∘ lower) refl refl)) ⟩□ (↑ _ ∘ Very-stableᴱ ∘ lower) -Nullᴱ A □) ------------------------------------------------------------------------ -- Erased singletons -- A variant of the Singleton type family with erased equality proofs. Erased-singleton : {A : Type a} → @0 A → Type a Erased-singleton x = ∃ λ y → Erased (y ≡ x) -- A variant of Other-singleton. Erased-other-singleton : {A : Type a} → @0 A → Type a Erased-other-singleton x = ∃ λ y → Erased (x ≡ y) -- "Inspection" with erased proofs. inspectᴱ : {@0 A : Type a} (x : A) → Erased-other-singleton x inspectᴱ x = x , [ refl x ] -- The type of triples consisting of two values of type A, one erased, -- and an erased proof of equality of the two values is logically -- equivalent to A. Σ-Erased-Erased-singleton⇔ : {A : Type ℓ} → (∃ λ (x : Erased A) → Erased-singleton (erased x)) ⇔ A Σ-Erased-Erased-singleton⇔ {A = A} = (∃ λ (x : Erased A) → ∃ λ y → Erased (y ≡ erased x)) ↔⟨ ∃-comm ⟩ (∃ λ y → ∃ λ (x : Erased A) → Erased (y ≡ erased x)) ↔⟨ (∃-cong λ _ → inverse Erased-Σ↔Σ) ⟩ (∃ λ y → Erased (∃ λ (x : A) → y ≡ x)) ↝⟨ (∃-cong λ _ → Erased-cong-⇔ (from-isomorphism $ _⇔_.to contractible⇔↔⊤ $ other-singleton-contractible _)) ⟩ A × Erased ⊤ ↔⟨ drop-⊤-right (λ _ → Erased-⊤↔⊤) ⟩□ A □ -- If equality is very stable for A, then Erased-singleton x is -- contractible for x : A. -- -- See also Very-stableᴱ-≡→Contractible-Erased-singleton, -- erased-singleton-with-erased-center-propositional and -- erased-singleton-with-erased-center-contractible below. erased-singleton-contractible : {x : A} → Very-stable-≡ A → Contractible (Erased-singleton x) erased-singleton-contractible {x = x} s = $⟨ singleton-contractible x ⟩ Contractible (Singleton x) ↝⟨ H-level-cong _ 0 (∃-cong λ _ → Eq.⟨ _ , s _ _ ⟩) ⦂ (_ → _) ⟩□ Contractible (Erased-singleton x) □ -- If equality is very stable for A, then Erased-other-singleton x is -- contractible for x : A. erased-other-singleton-contractible : {x : A} → Very-stable-≡ A → Contractible (Erased-other-singleton x) erased-other-singleton-contractible {x = x} s = $⟨ other-singleton-contractible x ⟩ Contractible (Other-singleton x) ↝⟨ H-level-cong _ 0 (∃-cong λ _ → Eq.⟨ _ , s _ _ ⟩) ⦂ (_ → _) ⟩□ Contractible (Erased-other-singleton x) □ -- Erased-singleton x is contractible with an erased proof. Contractibleᴱ-Erased-singleton : {@0 A : Type a} {x : A} → Contractibleᴱ (Erased-singleton x) Contractibleᴱ-Erased-singleton {x = x} = (x , [ proj₂₀ (proj₁₀ contr) .erased ]) , [ proj₂ contr ] where @0 contr : Contractible (Erased-singleton x) contr = erased-singleton-contractible (λ _ _ → Erased-Very-stable .erased) -- Erased-other-singleton x is contractible with an erased proof. Contractibleᴱ-Erased-other-singleton : {@0 A : Type a} {x : A} → Contractibleᴱ (Erased-other-singleton x) Contractibleᴱ-Erased-other-singleton {x = x} = (x , [ proj₂ (proj₁ contr) .erased ]) , [ proj₂ contr ] where @0 contr : Contractible (Erased-other-singleton x) contr = erased-other-singleton-contractible (λ _ _ → Erased-Very-stable .erased) -- Erased-singleton x is equivalent, with erased proofs, to ⊤. Erased-singleton≃ᴱ⊤ : {@0 A : Type a} {x : A} → Erased-singleton x ≃ᴱ ⊤ Erased-singleton≃ᴱ⊤ = let record { to = to } = EEq.Contractibleᴱ⇔≃ᴱ⊤ in to Contractibleᴱ-Erased-singleton -- Erased-other-singleton x is equivalent, with erased proofs, to ⊤. Erased-other-singleton≃ᴱ⊤ : {@0 A : Type a} {x : A} → Erased-other-singleton x ≃ᴱ ⊤ Erased-other-singleton≃ᴱ⊤ = let record { to = to } = EEq.Contractibleᴱ⇔≃ᴱ⊤ in to Contractibleᴱ-Erased-other-singleton ------------------------------------------------------------------------ -- Results that depend on an instantiation of the []-cong axioms (for -- two universe levels) module []-cong₂ (ax₁ : []-cong-axiomatisation ℓ₁) (ax₂ : []-cong-axiomatisation ℓ₂) where open Erased-cong ax₁ ax₂ ---------------------------------------------------------------------- -- Preservation lemmas -- Stable-[ equivalence ] preserves equivalences (assuming -- extensionality). Stable-≃-cong : {A : Type ℓ₁} {B : Type ℓ₂} → Extensionality? k (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) → A ≃ B → Stable-[ equivalence ] A ↝[ k ] Stable-[ equivalence ] B Stable-≃-cong {A = A} {B = B} ext A≃B = Stable-[ equivalence ] A ↔⟨⟩ Erased A ≃ A ↝⟨ generalise-ext? (Eq.≃-preserves-⇔ (Erased-cong-≃ A≃B) A≃B) (λ ext → let eq = Eq.≃-preserves ext (Erased-cong-≃ A≃B) A≃B in _≃_.right-inverse-of eq , _≃_.left-inverse-of eq) ext ⟩ Erased B ≃ B ↔⟨⟩ Stable-[ equivalence ] B □ -- Very-stable preserves equivalences (assuming extensionality). Very-stable-cong : {A : Type ℓ₁} {B : Type ℓ₂} → Extensionality? k (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) → A ≃ B → Very-stable A ↝[ k ] Very-stable B Very-stable-cong ext A≃B = generalise-ext?-prop (record { to = lemma A≃B (Erased-cong-≃ A≃B) (λ x → cong [_]→ (_≃_.right-inverse-of A≃B x)) ; from = lemma (inverse A≃B) (inverse $ Erased-cong-≃ A≃B) (λ x → cong [_]→ (_≃_.left-inverse-of A≃B x)) }) (Very-stable-propositional ∘ lower-extensionality ℓ₂ ℓ₂) (Very-stable-propositional ∘ lower-extensionality ℓ₁ ℓ₁) ext where lemma : (A≃B : A ≃ B) (E-A≃E-B : Erased A ≃ Erased B) → (∀ x → _≃_.to E-A≃E-B [ _≃_.from A≃B x ] ≡ [ x ]) → Very-stable A → Very-stable B lemma {A = A} {B = B} A≃B E-A≃E-B hyp s = _≃_.is-equivalence $ Eq.with-other-function (B ↝⟨ inverse A≃B ⟩ A ↝⟨ Eq.⟨ [_]→ , s ⟩ ⟩ Erased A ↝⟨ E-A≃E-B ⟩□ Erased B □) [_]→ (λ x → _≃_.to E-A≃E-B [ _≃_.from A≃B x ] ≡⟨ hyp x ⟩∎ [ x ] ∎) -- A generalisation of Very-stable-cong. Very-stable-congⁿ : {A : Type ℓ₁} {B : Type ℓ₂} → Extensionality? k′ (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) → ∀ n → A ↔[ k ] B → For-iterated-equality n Very-stable A ↝[ k′ ] For-iterated-equality n Very-stable B Very-stable-congⁿ ext n A↔B = For-iterated-equality-cong ext n (Very-stable-cong ext ∘ from-isomorphism) (from-isomorphism A↔B) ------------------------------------------------------------------------ -- Results that depend on an instantiation of the []-cong axioms (for -- two universe levels as well as their maximum) module []-cong₂-⊔₁ (ax₁ : []-cong-axiomatisation ℓ₁) (ax₂ : []-cong-axiomatisation ℓ₂) (ax : []-cong-axiomatisation (ℓ₁ ⊔ ℓ₂)) where open []-cong-axiomatisation ax open E₂.[]-cong₂-⊔ ax₁ ax₂ ax ---------------------------------------------------------------------- -- Preservation lemmas -- A kind of map function for Stable-[_]. Stable-[]-map : {A : Type ℓ₂} {B : Type ℓ₁} → A ↝[ k ] B → @0 B ↝[ k ] A → Stable-[ k ] A → Stable-[ k ] B Stable-[]-map {A = A} {B = B} A↝B B↝A s = Erased B ↝⟨ Erased-cong B↝A ⟩ Erased A ↝⟨ s ⟩ A ↝⟨ A↝B ⟩□ B □ -- Variants of Stable-[]-map. Stable-[]-map-↔ : {A : Type ℓ₂} {B : Type ℓ₁} → A ↔ B → Stable-[ k ] A → Stable-[ k ] B Stable-[]-map-↔ A↔B = Stable-[]-map (from-isomorphism A↔B) (from-isomorphism $ inverse A↔B) Stable-[]-map-↝ : {A : Type ℓ₂} {B : Type ℓ₁} → A ↝[ ℓ₂ ∣ ℓ₁ ] B → Extensionality? k ℓ₂ ℓ₁ → Stable-[ k ] A → Stable-[ k ] B Stable-[]-map-↝ A↝B ext = Stable-[]-map (A↝B ext) (inverse-ext? A↝B ext) -- Stable preserves some kinds of functions (those that are -- "symmetric"), possibly assuming extensionality. Stable-cong : {A : Type ℓ₁} {B : Type ℓ₂} → Extensionality? ⌊ k ⌋-sym (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) → A ↝[ ⌊ k ⌋-sym ] B → Stable A ↝[ ⌊ k ⌋-sym ] Stable B Stable-cong {k = k} {A = A} {B = B} ext A↝B = Stable A ↔⟨⟩ (Erased A → A) ↝⟨ →-cong ext (Erased-cong A↝B) A↝B ⟩ (Erased B → B) ↔⟨⟩ Stable B □ ---------------------------------------------------------------------- -- More lemmas -- All kinds of functions between erased types are stable. Stable-Erased↝Erased : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} → Stable (Erased A ↝[ k ] Erased B) Stable-Erased↝Erased {k = k} {A = A} {B = B} = $⟨ Very-stable-Erased ⟩ Very-stable (Erased (A ↝[ k ] B)) ↝⟨ Very-stable→Stable 0 ⟩ Stable (Erased (A ↝[ k ] B)) ↝⟨ Stable-map-⇔ (Erased-↝↝↝ _) ⟩□ Stable (Erased A ↝[ k ] Erased B) □ -- If A is very stable, then W A P is very stable (assuming -- extensionality). Very-stable-W : {A : Type ℓ₁} {P : A → Type ℓ₂} → Extensionality ℓ₂ (ℓ₁ ⊔ ℓ₂) → Very-stable A → Very-stable (W A P) Very-stable-W {A = A} {P = P} ext s = _≃_.is-equivalence $ Eq.↔⇒≃ (record { surjection = record { logical-equivalence = record { to = [_]→ ; from = from } ; right-inverse-of = []∘from } ; left-inverse-of = from∘[] }) where module E = _≃_ Eq.⟨ _ , s ⟩ from : Erased (W A P) → W A P from [ sup x f ] = sup (E.from [ x ]) (λ y → from [ f (subst P (E.left-inverse-of x) y) ]) from∘[] : ∀ x → from [ x ] ≡ x from∘[] (sup x f) = curry (_↠_.to (W-≡,≡↠≡ ext)) (E.left-inverse-of x) (λ y → from∘[] (f (subst P (E.left-inverse-of x) y))) []∘from : ∀ x → [ from x ] ≡ x []∘from [ x ] = []-cong [ from∘[] x ] ------------------------------------------------------------------------ -- Results that depend on an instantiation of the []-cong axioms (for -- a single universe level) module []-cong₁ (ax : []-cong-axiomatisation ℓ) where open E₁.[]-cong₁ ax open []-cong₂ ax ax open []-cong₂-⊔₁ ax ax ax ---------------------------------------------------------------------- -- Some lemmas related to stability -- If A is stable, with [_]→ as a right inverse of the proof of -- stability, then A is very stable. Stable→Left-inverse→Very-stable : {A : Type ℓ} (s : Stable A) → (∀ x → s [ x ] ≡ x) → Very-stable A Stable→Left-inverse→Very-stable s inv = _≃_.is-equivalence (Eq.↔⇒≃ (record { surjection = record { logical-equivalence = record { from = s } ; right-inverse-of = λ ([ x ]) → []-cong [ inv x ] } ; left-inverse-of = inv })) -- If A is a stable proposition, then A is very stable. -- -- Note that it is not the case that every very stable type is a -- proposition, see ¬-Very-stable→Is-proposition. Stable-proposition→Very-stable : {A : Type ℓ} → Stable A → Is-proposition A → Very-stable A Stable-proposition→Very-stable s prop = _≃_.is-equivalence $ Eq.⇔→≃ prop (H-level-Erased 1 prop) [_]→ s -- The previous result can be generalised. Stable→H-level-suc→Very-stable : {A : Type ℓ} → ∀ n → For-iterated-equality n Stable A → H-level (1 + n) A → For-iterated-equality n Very-stable A Stable→H-level-suc→Very-stable {A = A} n = curry ( For-iterated-equality n Stable A × H-level (1 + n) A ↝⟨ (∃-cong λ _ → H-level-suc→For-iterated-equality-Is-proposition) ⟩ For-iterated-equality n Stable A × For-iterated-equality n Is-proposition A ↝⟨ For-iterated-equality-commutes-× n _ ⟩ For-iterated-equality n (λ A → Stable A × Is-proposition A) A ↝⟨ For-iterated-equality-cong₁ _ n $ uncurry Stable-proposition→Very-stable ⟩ For-iterated-equality n Very-stable A □) -- If equality is decidable for A, then equality is very stable for -- A. Decidable-equality→Very-stable-≡ : {A : Type ℓ} → Decidable-equality A → Very-stable-≡ A Decidable-equality→Very-stable-≡ dec = Stable→H-level-suc→Very-stable 1 (λ x y → Dec→Stable (dec x y)) (decidable⇒set dec) -- Types with h-level n are very stable "n levels up". H-level→Very-stable : {A : Type ℓ} → ∀ n → H-level n A → For-iterated-equality n Very-stable A H-level→Very-stable {A = A} n = H-level n A ↝⟨ _⇔_.to H-level⇔H-level′ ⟩ H-level′ n A ↝⟨ For-iterated-equality-cong₁ _ n Contractible→Very-stable ⟩□ For-iterated-equality n Very-stable A □ where Contractible→Very-stable : ∀ {A} → Contractible A → Very-stable A Contractible→Very-stable c = Stable-proposition→Very-stable (λ _ → proj₁ c) (mono₁ 0 c) -- Equality is stable for A if and only if [_]→ is injective for A. Stable-≡↔Injective-[] : {A : Type ℓ} → Stable-≡ A ↝[ ℓ ∣ ℓ ] Injective [ A ∣_]→ Stable-≡↔Injective-[] ext = (∀ x y → Erased (x ≡ y) → x ≡ y) ↝⟨ (∀-cong ext λ _ → from-isomorphism $ inverse Bijection.implicit-Π↔Π) ⟩ (∀ x {y} → Erased (x ≡ y) → x ≡ y) ↔⟨ inverse Bijection.implicit-Π↔Π ⟩ (∀ {x y} → Erased (x ≡ y) → x ≡ y) ↝⟨ (implicit-∀-cong ext $ implicit-∀-cong ext $ Π-cong ext Erased-≡↔[]≡[] λ _ → F.id) ⟩□ (∀ {x y} → [ x ] ≡ [ y ] → x ≡ y) □ -- Equality is very stable for A if and only if [_]→ is an embedding -- for A. Very-stable-≡↔Is-embedding-[] : {A : Type ℓ} → Very-stable-≡ A ↝[ ℓ ∣ ℓ ] Is-embedding [ A ∣_]→ Very-stable-≡↔Is-embedding-[] ext = (∀ x y → Is-equivalence [ x ≡ y ∣_]→) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → Is-equivalence≃Is-equivalence-∘ˡ []-cong-equivalence ext) ⟩ (∀ x y → Is-equivalence ([]-cong ∘ [ x ≡ y ∣_]→)) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → Is-equivalence-cong ext λ _ → []-cong-[]≡cong-[]) ⟩□ (∀ x y → Is-equivalence (cong {x = x} {y = y} [_]→)) □ private -- The previous result can be generalised. Very-stable-≡↔Is-embedding-[]→ : {A : Type ℓ} → ∀ n → For-iterated-equality (1 + n) Very-stable A ↝[ ℓ ∣ ℓ ] For-iterated-equality n (λ A → Is-embedding [ A ∣_]→) A Very-stable-≡↔Is-embedding-[]→ {A = A} n ext = For-iterated-equality (1 + n) Very-stable A ↝⟨ inverse-ext? (For-iterated-equality-For-iterated-equality n 1) ext ⟩ For-iterated-equality n Very-stable-≡ A ↝⟨ For-iterated-equality-cong₁ ext n (Very-stable-≡↔Is-embedding-[] ext) ⟩□ For-iterated-equality n (λ A → Is-embedding [ A ∣_]→) A □ -- There is a logical equivalence between "equality for A is very -- stable with erased proofs" and "[_]→ for A is an embedding with -- erased proofs". Very-stableᴱ-≡⇔Is-embeddingᴱ-[] : {@0 A : Type ℓ} → Very-stableᴱ-≡ A ⇔ Is-embeddingᴱ [ A ∣_]→ Very-stableᴱ-≡⇔Is-embeddingᴱ-[] = (∀ x y → Is-equivalenceᴱ [ x ≡ y ∣_]→) LE.⇔⟨ (LE.∀-cong λ _ → LE.∀-cong λ _ → EEq.Is-equivalenceᴱ⇔Is-equivalenceᴱ-∘ˡ (EEq.Is-equivalence→Is-equivalenceᴱ []-cong-equivalence)) ⟩ (∀ x y → Is-equivalenceᴱ ([]-cong ∘ [ x ≡ y ∣_]→)) LE.⇔⟨ (LE.∀-cong λ _ → LE.∀-cong λ _ → EEq.Is-equivalenceᴱ-cong-⇔ λ _ → []-cong-[]≡cong-[]) ⟩□ (∀ x y → Is-equivalenceᴱ (cong {x = x} {y = y} [_]→)) □ -- There is an equivalence with erased proofs between "equality for -- A is very stable with erased proofs" and "[_]→ for A is an -- embedding with erased proofs" (assuming extensionality). Very-stableᴱ-≡≃ᴱIs-embeddingᴱ-[] : {@0 A : Type ℓ} → @0 Extensionality ℓ ℓ → Very-stableᴱ-≡ A ≃ᴱ Is-embeddingᴱ [ A ∣_]→ Very-stableᴱ-≡≃ᴱIs-embeddingᴱ-[] ext = let record { to = to; from = from } = Very-stableᴱ-≡⇔Is-embeddingᴱ-[] in EEq.⇔→≃ᴱ (H-level-For-iterated-equality ext 1 1 λ {A} → Very-stableᴱ-propositional {A = A} ext) (EEmb.Is-embeddingᴱ-propositional ext) to from ---------------------------------------------------------------------- -- Closure properties -- Very-stableᴱ is closed under Σ. Very-stableᴱ-Σ : {@0 A : Type ℓ} {@0 P : A → Type p} → Very-stableᴱ A → (∀ x → Very-stableᴱ (P x)) → Very-stableᴱ (Σ A P) Very-stableᴱ-Σ {A = A} {P = P} s s′ = _≃ᴱ_.is-equivalence ( Σ A P EEq.≃ᴱ⟨ EEq.[]-cong₁.Σ-cong-≃ᴱ-Erased ax EEq.⟨ _ , s ⟩₀ (λ x → EEq.⟨ _ , s′ x ⟩₀) ⟩ Σ (Erased A) (λ x → Erased (P (erased x))) EEq.↔⟨ inverse Erased-Σ↔Σ ⟩□ Erased (Σ A P) □) -- A generalisation of Very-stableᴱ-Σ. Very-stableᴱ-Σⁿ : {A : Type ℓ} {P : A → Type p} → ∀ n → For-iterated-equality n Very-stableᴱ A → (∀ x → For-iterated-equality n Very-stableᴱ (P x)) → For-iterated-equality n Very-stableᴱ (Σ A P) Very-stableᴱ-Σⁿ n = For-iterated-equality-Σ n (≃ᴱ→Very-stableᴱ→Very-stableᴱ ∘ from-isomorphism) Very-stableᴱ-Σ -- A generalisation of Very-stableᴱ-W. Very-stableᴱ-Wⁿ : {A : Type ℓ} {P : A → Type p} → Extensionality p (ℓ ⊔ p) → ∀ n → For-iterated-equality n Very-stableᴱ A → For-iterated-equality n Very-stableᴱ (W A P) Very-stableᴱ-Wⁿ {A = A} {P = P} ext n = For-iterated-equality-W ext n (≃ᴱ→Very-stableᴱ→Very-stableᴱ ∘ from-isomorphism) (Very-stableᴱ-Π ext) Very-stableᴱ-Σ (Very-stableᴱ-W ext) ---------------------------------------------------------------------- -- Closure properties related to equality -- If A is very stable, then equality is very stable for A. Very-stable→Very-stable-≡ : {A : Type ℓ} → ∀ n → For-iterated-equality n Very-stable A → For-iterated-equality (1 + n) Very-stable A Very-stable→Very-stable-≡ {A = A} n = For-iterated-equality n Very-stable A ↝⟨ For-iterated-equality-cong₁ _ n lemma ⟩ For-iterated-equality n Very-stable-≡ A ↝⟨ For-iterated-equality-For-iterated-equality n 1 _ ⟩□ For-iterated-equality (1 + n) Very-stable A □ where lemma : ∀ {A} → Very-stable A → Very-stable-≡ A lemma {A = A} = Very-stable A ↝⟨ Very-stable→Is-embedding-[] ⟩ Is-embedding [ A ∣_]→ ↝⟨ inverse-ext? Very-stable-≡↔Is-embedding-[] _ ⟩□ Very-stable-≡ A □ private -- Some examples showing how Very-stable→Very-stable-≡ can be -- used. -- Equalities between erased values are very stable. Very-stable-≡₀ : {@0 A : Type ℓ} → Very-stable-≡ (Erased A) Very-stable-≡₀ = Very-stable→Very-stable-≡ 0 Very-stable-Erased -- Equalities between equalities between erased values are very -- stable. Very-stable-≡₁ : {@0 A : Type ℓ} → For-iterated-equality 2 Very-stable (Erased A) Very-stable-≡₁ = Very-stable→Very-stable-≡ 1 Very-stable-≡₀ -- And so on… -- A generalisation of Very-stable→Very-stable-≡. Very-stable→Very-stable⁺ : {A : Type ℓ} → ∀ m → For-iterated-equality n Very-stable A → For-iterated-equality (m + n) Very-stable A Very-stable→Very-stable⁺ zero = id Very-stable→Very-stable⁺ {n = n} (suc m) = Very-stable→Very-stable-≡ (m + n) ∘ Very-stable→Very-stable⁺ m -- A variant of Very-stable→Very-stable-≡. Very-stable→Very-stableⁿ : {A : Type ℓ} → ∀ n → Very-stable A → For-iterated-equality n Very-stable A Very-stable→Very-stableⁿ n = subst (λ n → For-iterated-equality n Very-stable _) (Nat.+-right-identity {n = n}) ∘ Very-stable→Very-stable⁺ n -- A generalisation of Stable-H-level′. Stable-[]-H-level′ : {A : Type ℓ} → Extensionality? k ℓ ℓ → ∀ n → For-iterated-equality (1 + n) Stable-[ k ] A → Stable-[ k ] (H-level′ (1 + n) A) Stable-[]-H-level′ {k = k} {A = A} ext n = For-iterated-equality (1 + n) Stable-[ k ] A ↝⟨ inverse-ext? (For-iterated-equality-For-iterated-equality n 1) _ ⟩ For-iterated-equality n Stable-≡-[ k ] A ↝⟨ For-iterated-equality-cong₁ _ n lemma ⟩ For-iterated-equality n (Stable-[ k ] ∘ H-level′ 1) A ↝⟨ For-iterated-equality-commutes-← _ Stable-[ k ] n (Stable-[]-Π ext) ⟩ Stable-[ k ] (For-iterated-equality n (H-level′ 1) A) ↝⟨ Stable-[]-map-↝ (For-iterated-equality-For-iterated-equality n 1) ext ⟩□ Stable-[ k ] (H-level′ (1 + n) A) □ where lemma : ∀ {A} → Stable-≡-[ k ] A → Stable-[ k ] (H-level′ 1 A) lemma s = Stable-[]-map-↝ (H-level↔H-level′ {n = 1}) ext (Stable-[]-Π ext λ _ → Stable-[]-Π ext λ _ → s _ _) -- A generalisation of Stable-H-level. Stable-[]-H-level : {A : Type ℓ} → Extensionality? k ℓ ℓ → ∀ n → For-iterated-equality (1 + n) Stable-[ k ] A → Stable-[ k ] (H-level (1 + n) A) Stable-[]-H-level {k = k} {A = A} ext n = For-iterated-equality (1 + n) Stable-[ k ] A ↝⟨ Stable-[]-H-level′ ext n ⟩ Stable-[ k ] (H-level′ (1 + n) A) ↝⟨ Stable-[]-map-↝ (inverse-ext? H-level↔H-level′) ext ⟩□ Stable-[ k ] (H-level (1 + n) A) □ -- If A is "very stable n levels up", then H-level′ n A is very -- stable (assuming extensionality). Very-stable-H-level′ : {A : Type ℓ} → Extensionality ℓ ℓ → ∀ n → For-iterated-equality n Very-stable A → Very-stable (H-level′ n A) Very-stable-H-level′ {A = A} ext n = For-iterated-equality n Very-stable A ↝⟨ For-iterated-equality-cong₁ _ n lemma ⟩ For-iterated-equality n (Very-stable ∘ Contractible) A ↝⟨ For-iterated-equality-commutes-← _ Very-stable n (Very-stable-Π ext) ⟩□ Very-stable (H-level′ n A) □ where lemma : ∀ {A} → Very-stable A → Very-stable (Contractible A) lemma s = Very-stable-Σ s λ _ → Very-stable-Π ext λ _ → Very-stable→Very-stable-≡ 0 s _ _ -- If A is "very stable with erased proofs n levels up", then -- For-iterated-equality n Contractibleᴱ A is very stable with -- erased proofs (assuming extensionality). Very-stableᴱ-H-levelᴱ : {@0 A : Type ℓ} → @0 Extensionality ℓ ℓ → ∀ n → For-iterated-equality n Very-stableᴱ A → Very-stableᴱ (For-iterated-equality n Contractibleᴱ A) Very-stableᴱ-H-levelᴱ {A = A} ext n = For-iterated-equality n Very-stableᴱ A →⟨ For-iterated-equality-cong₁ᴱ-→ n lemma ⟩ For-iterated-equality n (Very-stableᴱ ∘ Contractibleᴱ) A →⟨ For-iterated-equality-commutesᴱ-← Very-stableᴱ n (Very-stableᴱ-Π ext) ⟩□ Very-stableᴱ (For-iterated-equality n Contractibleᴱ A) □ where lemma : ∀ {@0 A} → Very-stableᴱ A → Very-stableᴱ (Contractibleᴱ A) lemma s = Very-stableᴱ-Σ s λ _ → Very-stable→Very-stableᴱ 0 Very-stable-Erased -- If A is "very stable n levels up", then H-level n A is very -- stable (assuming extensionality). Very-stable-H-level : {A : Type ℓ} → Extensionality ℓ ℓ → ∀ n → For-iterated-equality n Very-stable A → Very-stable (H-level n A) Very-stable-H-level {A = A} ext n = For-iterated-equality n Very-stable A ↝⟨ Very-stable-H-level′ ext n ⟩ Very-stable (H-level′ n A) ↝⟨ Very-stable-cong _ (inverse $ H-level↔H-level′ ext) ⟩□ Very-stable (H-level n A) □ -- There is an equivalence between Very-stable (Very-stable A) and -- Very-stable A (assuming extensionality). Very-stable-Very-stable≃Very-stable : {A : Type ℓ} → Extensionality ℓ ℓ → Very-stable (Very-stable A) ≃ Very-stable A Very-stable-Very-stable≃Very-stable ext = _↠_.from (Eq.≃↠⇔ (Very-stable-propositional ext) (Very-stable-propositional ext)) (record { to = Very-stable-Very-stable→Very-stable ; from = λ s → Very-stable-cong _ (inverse $ Is-equivalence≃Is-equivalence-CP ext) $ Very-stable-Π ext λ _ → Very-stable-H-level ext 0 $ Very-stable-Σ s (λ _ → Very-stable-≡₀ _ _) }) -- There is an equivalence with erased proofs between -- Very-stableᴱ (Very-stableᴱ A) and Very-stableᴱ A (assuming -- extensionality). Very-stableᴱ-Very-stableᴱ≃ᴱVery-stableᴱ : {@0 A : Type ℓ} → @0 Extensionality ℓ ℓ → Very-stableᴱ (Very-stableᴱ A) ≃ᴱ Very-stableᴱ A Very-stableᴱ-Very-stableᴱ≃ᴱVery-stableᴱ ext = EEq.⇔→≃ᴱ (Very-stableᴱ-propositional ext) (Very-stableᴱ-propositional ext) Very-stableᴱ-Very-stableᴱ→Very-stableᴱ (λ s → ≃ᴱ→Very-stableᴱ→Very-stableᴱ (EEq.inverse $ EEq.Is-equivalenceᴱ≃ᴱIs-equivalenceᴱ-CP ext) $ Very-stableᴱ-Π ext λ _ → Very-stableᴱ-H-levelᴱ ext 0 $ Very-stableᴱ-Σ s λ _ → Very-stable→Very-stableᴱ 0 $ Very-stable-Erased) -- A generalisation of Stable-≡-List. Stable-[]-≡-List : {A : Type ℓ} → ∀ n → For-iterated-equality (1 + n) Stable-[ k ] A → For-iterated-equality (1 + n) Stable-[ k ] (List A) Stable-[]-≡-List n = For-iterated-equality-List-suc n Stable-[]-map-↔ (Very-stable→Stable 0 $ Very-stable-↑ Very-stable-⊤) (Very-stable→Stable 0 Very-stable-⊥) Stable-[]-× -- If equality is very stable for A, then it is very stable for -- List A. Very-stable-≡-List : {A : Type ℓ} → ∀ n → For-iterated-equality (1 + n) Very-stable A → For-iterated-equality (1 + n) Very-stable (List A) Very-stable-≡-List n = For-iterated-equality-List-suc n (Very-stable-cong _ ∘ from-isomorphism) (Very-stable-↑ Very-stable-⊤) Very-stable-⊥ Very-stable-× ---------------------------------------------------------------------- -- The function λ A → Erased A, [_]→ and Very-stable form a Σ-closed -- reflective subuniverse -- As a consequence of Very-stable→Very-stable-≡ we get that every -- family of very stable types, indexed by Erased A, is ∞-extendable -- along [_]→. extendable : {@0 A : Type a} {P : Erased A → Type ℓ} → (∀ x → Very-stable (P x)) → Is-∞-extendable-along-[ [_]→ ] P extendable s zero = _ extendable s (suc n) = (λ f → (λ x → _≃_.from Eq.⟨ _ , s x ⟩ (map f x)) , λ x → _≃_.from Eq.⟨ _ , s [ x ] ⟩ (map f [ x ]) ≡⟨⟩ _≃_.from Eq.⟨ _ , s [ x ] ⟩ [ f x ] ≡⟨ _≃_.left-inverse-of Eq.⟨ _ , s [ x ] ⟩ _ ⟩∎ f x ∎) , λ g h → extendable (λ x → Very-stable→Very-stable-≡ 0 (s x) _ _) n -- As a special case we get the following property, which is based -- on one part of the definition of a reflective subuniverse used in -- (one version of) the Coq code accompanying "Modalities in -- Homotopy Type Theory" by Rijke, Shulman and Spitters. const-extendable : {@0 A : Type a} {B : Type ℓ} → Very-stable B → Is-∞-extendable-along-[ [_]→ ] (λ (_ : Erased A) → B) const-extendable s = extendable (λ _ → s) -- The function λ A → Erased A, [_]→ and Very-stable form a Σ-closed -- reflective subuniverse. Erased-Σ-closed-reflective-subuniverse : Σ-closed-reflective-subuniverse ℓ Erased-Σ-closed-reflective-subuniverse = λ where .◯ → λ A → Erased A .η → [_]→ .Is-modal → Very-stable .Is-modal-propositional → Very-stable-propositional .Is-modal-◯ → Very-stable-Erased .Is-modal-respects-≃ → Very-stable-cong _ .extendable-along-η → const-extendable .Σ-closed → Very-stable-Σ where open Σ-closed-reflective-subuniverse -- This Σ-closed reflective subuniverse is topological (for certain -- universe levels, assuming extensionality). Erased-topological : ∀ ℓ′ → Extensionality (lsuc ℓ ⊔ ℓ′) (lsuc ℓ ⊔ ℓ′) → Topological (lsuc ℓ ⊔ ℓ′) Erased-Σ-closed-reflective-subuniverse Erased-topological ℓ′ ext = $⟨ erased-is-accessible-and-topological ℓ′ ext ⟩ Erased-is-accessible-and-topological (lsuc ℓ ⊔ ℓ′) ℓ ↝⟨ inverse $ ≃Erased-is-accessible-and-topological ext ⟩□ Erased-is-accessible-and-topological′ (lsuc ℓ ⊔ ℓ′) ℓ □ ---------------------------------------------------------------------- -- Erased singletons -- The type of triples consisting of two values of type A, one erased, -- and an erased proof of equality of the two values is isomorphic to -- A. Σ-Erased-Erased-singleton↔ : {A : Type ℓ} → (∃ λ (x : Erased A) → Erased-singleton (erased x)) ↔ A Σ-Erased-Erased-singleton↔ {A = A} = (∃ λ (x : Erased A) → ∃ λ y → Erased (y ≡ erased x)) ↝⟨ ∃-comm ⟩ (∃ λ y → ∃ λ (x : Erased A) → Erased (y ≡ erased x)) ↝⟨ (∃-cong λ _ → inverse Erased-Σ↔Σ) ⟩ (∃ λ y → Erased (∃ λ (x : A) → y ≡ x)) ↝⟨ (∃-cong λ _ → Erased-cong.Erased-cong-↔ ax (lower-[]-cong-axiomatisation _ ax) (_⇔_.to contractible⇔↔⊤ (other-singleton-contractible _))) ⟩ A × Erased ⊤ ↝⟨ drop-⊤-right (λ _ → Erased-⊤↔⊤) ⟩□ A □ -- The logical equivalence underlying -- Σ-Erased-Erased-singleton↔ {A = A} is definitionally equal to -- Σ-Erased-Erased-singleton⇔. _ : _↔_.logical-equivalence (Σ-Erased-Erased-singleton↔ {A = A}) ≡ Σ-Erased-Erased-singleton⇔ _ = refl _ -- A variant of erased-singleton-contractible. Very-stableᴱ-≡→Contractible-Erased-singleton : {A : Type ℓ} {x : A} → Very-stableᴱ-≡ A → Contractible (Erased-singleton x) Very-stableᴱ-≡→Contractible-Erased-singleton {x = x} s = (x , [ refl x ]) , λ (y , [ y≡x ]) → Σ-≡,≡→≡ (_≃ᴱ_.from EEq.⟨ _ , s _ _ ⟩₀ [ sym y≡x ]) (subst (λ y → Erased (y ≡ x)) (_≃ᴱ_.from EEq.⟨ _ , s _ _ ⟩₀ [ sym y≡x ]) [ refl x ] ≡⟨ push-subst-[] ⟩ [ subst (_≡ x) (_≃ᴱ_.from EEq.⟨ _ , s _ _ ⟩₀ [ sym y≡x ]) (refl x) ] ≡⟨ []-cong [ cong (flip (subst _) _) $ _≃ᴱ_.left-inverse-of EEq.⟨ _ , s _ _ ⟩₀ _ ] ⟩ [ subst (_≡ x) (sym y≡x) (refl x) ] ≡⟨ []-cong [ subst-trans _ ] ⟩ [ trans y≡x (refl x) ] ≡⟨ []-cong [ trans-reflʳ _ ] ⟩∎ [ y≡x ] ∎) -- If equality is very stable (with erased proofs) for A, and x : A -- is erased, then Erased-singleton x is a proposition. erased-singleton-with-erased-center-propositional : {A : Type ℓ} {@0 x : A} → Very-stableᴱ-≡ A → Is-proposition (Erased-singleton x) erased-singleton-with-erased-center-propositional {x = x} s = $⟨ [ erased-singleton-contractible (λ _ _ → erased Erased-Very-stable) ] ⟩ Erased (Contractible (Erased-singleton x)) ↝⟨ map (mono₁ 0) ⟩ Erased (Is-proposition (Erased-singleton x)) ↝⟨ (Stable-H-level 0 $ Very-stableᴱ→Stable 1 $ Very-stableᴱ-Σⁿ 1 s λ _ → Very-stable→Very-stableᴱ 1 $ Very-stable→Very-stable-≡ 0 Very-stable-Erased) ⟩□ Is-proposition (Erased-singleton x) □ -- If A is very stable, and x : A is erased, then Erased-singleton x -- is contractible. erased-singleton-with-erased-center-contractible : {A : Type ℓ} {@0 x : A} → Very-stable A → Contractible (Erased-singleton x) erased-singleton-with-erased-center-contractible {x = x} s = $⟨ [ (x , [ refl _ ]) ] ⟩ Erased (Erased-singleton x) ↝⟨ Very-stable→Stable 0 (Very-stable-Σ s λ _ → Very-stable-Erased) ⟩ Erased-singleton x ↝⟨ propositional⇒inhabited⇒contractible $ erased-singleton-with-erased-center-propositional $ Very-stable→Very-stableᴱ 1 $ Very-stable→Very-stable-≡ 0 s ⟩□ Contractible (Erased-singleton x) □ ------------------------------------------------------------------------ -- Results that depend on an axiomatisation of []-cong (for the -- successor of a universe level) module []-cong₁-lsuc (ax : []-cong-axiomatisation (lsuc ℓ)) where open []-cong₁ ax -- ∃ λ (A : Set a) → Very-stable A is very stable, assuming -- extensionality and univalence. -- -- This result is based on Theorem 3.11 in "Modalities in Homotopy -- Type Theory" by Rijke, Shulman and Spitters. Very-stable-∃-Very-stable : Extensionality ℓ ℓ → Univalence ℓ → Very-stable (∃ λ (A : Type ℓ) → Very-stable A) Very-stable-∃-Very-stable ext univ = Stable→Left-inverse→Very-stable Stable-∃-Very-stable inv where inv : ∀ p → Stable-∃-Very-stable [ p ] ≡ p inv (A , s) = Σ-≡,≡→≡ (Erased A ≡⟨ ≃⇒≡ univ (Very-stable→Stable 0 s) ⟩∎ A ∎) (Very-stable-propositional ext _ _) ------------------------------------------------------------------------ -- More results that depend on an instantiation of the []-cong axioms -- (for two universe levels as well as their maximum) module []-cong₂-⊔₂ (ax₁ : []-cong-axiomatisation ℓ₁) (ax₂ : []-cong-axiomatisation ℓ₂) (ax : []-cong-axiomatisation (ℓ₁ ⊔ ℓ₂)) where ---------------------------------------------------------------------- -- Some lemmas related to Very-stable -- All kinds of functions between erased types are very stable (in -- some cases assuming extensionality). Very-stable-Erased↝Erased : {@0 A : Type ℓ₁} {@0 B : Type ℓ₂} → Extensionality? k (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) → Very-stable (Erased A ↝[ k ] Erased B) Very-stable-Erased↝Erased {k = k} {A = A} {B = B} ext = $⟨ Very-stable-Erased ⟩ Very-stable (Erased (A ↝[ k ] B)) ↝⟨ []-cong₂.Very-stable-cong ax ax _ (from-isomorphism $ E₂.[]-cong₂-⊔.Erased-↝↔↝ ax₁ ax₂ ax ext) ⦂ (_ → _) ⟩□ Very-stable (Erased A ↝[ k ] Erased B) □ -- A generalisation of Very-stable-Σ. -- -- Based on a lemma called inO_unsigma, implemented by Mike Shulman -- in the file ReflectiveSubuniverse.v in (one version of) the Coq -- HoTT library. Very-stable-Σ↔Π : {A : Type ℓ₁} {P : A → Type ℓ₂} → Very-stable A → Very-stable (Σ A P) ↝[ ℓ₁ ⊔ ℓ₂ ∣ ℓ₁ ⊔ ℓ₂ ] (∀ x → Very-stable (P x)) Very-stable-Σ↔Π {A = A} {P = P} s = generalise-ext?-prop (record { from = Very-stable-Σ s ; to = flip λ x → Very-stable (Σ A P) ↝⟨ flip Very-stable-Σ (λ _ → []-cong₁.Very-stable→Very-stable-≡ ax₁ 0 s _ _) ⟩ Very-stable (∃ λ ((y , _) : Σ A P) → y ≡ x) ↝⟨ []-cong₂.Very-stable-cong ax ax _ $ from-bijection $ inverse Σ-assoc ⟩ Very-stable (∃ λ (y : A) → P y × y ≡ x) ↝⟨ []-cong₂.Very-stable-cong ax ax₂ _ $ from-bijection $ inverse $ ∃-intro _ _ ⟩□ Very-stable (P x) □ }) Very-stable-propositional (λ ext → Π-closure (lower-extensionality ℓ₂ ℓ₁ ext) 1 λ _ → Very-stable-propositional (lower-extensionality ℓ₁ ℓ₁ ext)) -- A variant of Very-stableᴱ-Σ. -- -- Based on a lemma called inO_unsigma, implemented by Mike Shulman -- in the file ReflectiveSubuniverse.v in (one version of) the Coq -- HoTT library. Very-stableᴱ-Σ≃ᴱΠ : {A : Type ℓ₁} {P : A → Type ℓ₂} → @0 Extensionality (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) → Very-stableᴱ A → Very-stableᴱ-≡ A → Very-stableᴱ (Σ A P) ≃ᴱ (∀ x → Very-stableᴱ (P x)) Very-stableᴱ-Σ≃ᴱΠ {A = A} {P = P} ext s s-≡ = EEq.⇔→≃ᴱ (Very-stableᴱ-propositional ext) (Π-closure (lower-extensionality ℓ₂ ℓ₁ ext) 1 λ _ → Very-stableᴱ-propositional (lower-extensionality ℓ₁ ℓ₁ ext)) (flip λ x → Very-stableᴱ (Σ A P) ↝⟨ flip ([]-cong₁.Very-stableᴱ-Σ ax) (λ _ → s-≡ _ _) ⟩ Very-stableᴱ (∃ λ ((y , _) : Σ A P) → y ≡ x) ↝⟨ ≃ᴱ→Very-stableᴱ→Very-stableᴱ $ from-bijection $ inverse Σ-assoc ⟩ Very-stableᴱ (∃ λ (y : A) → P y × y ≡ x) ↝⟨ ≃ᴱ→Very-stableᴱ→Very-stableᴱ $ from-bijection $ inverse $ ∃-intro _ _ ⟩□ Very-stableᴱ (P x) □) ([]-cong₁.Very-stableᴱ-Σ ax₁ s) ---------------------------------------------------------------------- -- Closure properties related to equality -- A generalisation of Stable-≡-⊎. Stable-[]-≡-⊎ : {A : Type ℓ₁} {B : Type ℓ₂} → ∀ n → For-iterated-equality (1 + n) Stable-[ k ] A → For-iterated-equality (1 + n) Stable-[ k ] B → For-iterated-equality (1 + n) Stable-[ k ] (A ⊎ B) Stable-[]-≡-⊎ n sA sB = For-iterated-equality-⊎-suc n ([]-cong₂-⊔₁.Stable-[]-map-↔ ax ax ax) (Very-stable→Stable 0 Very-stable-⊥) (For-iterated-equality-↑ _ (1 + n) ([]-cong₂-⊔₁.Stable-[]-map-↔ ax ax₁ ax) sA) (For-iterated-equality-↑ _ (1 + n) ([]-cong₂-⊔₁.Stable-[]-map-↔ ax ax₂ ax) sB) -- If equality is very stable for A and B, then it is very stable -- for A ⊎ B. Very-stable-≡-⊎ : {A : Type ℓ₁} {B : Type ℓ₂} → ∀ n → For-iterated-equality (1 + n) Very-stable A → For-iterated-equality (1 + n) Very-stable B → For-iterated-equality (1 + n) Very-stable (A ⊎ B) Very-stable-≡-⊎ n sA sB = For-iterated-equality-⊎-suc n (lemma ax ax) Very-stable-⊥ (For-iterated-equality-↑ _ (1 + n) (lemma ax₁ ax) sA) (For-iterated-equality-↑ _ (1 + n) (lemma ax₂ ax) sB) where lemma : ∀ {ℓ₁ ℓ₂} {A : Type ℓ₁} {B : Type ℓ₂} → []-cong-axiomatisation ℓ₁ → []-cong-axiomatisation ℓ₂ → A ↔ B → Very-stable A → Very-stable B lemma ax₁ ax₂ = []-cong₂.Very-stable-cong ax₁ ax₂ _ ∘ from-isomorphism ---------------------------------------------------------------------- -- Simple corollaries or variants of results above -- A generalisation of Stable-Π. Stable-Πⁿ : {A : Type ℓ₁} {P : A → Type ℓ₂} → Extensionality ℓ₁ ℓ₂ → ∀ n → (∀ x → For-iterated-equality n Stable-[ k ] (P x)) → For-iterated-equality n Stable-[ k ] ((x : A) → P x) Stable-Πⁿ {k = k} ext n = For-iterated-equality-Π ext n ([]-cong₂-⊔₁.Stable-[]-map-↔ ax ax ax) (Stable-[]-Π (forget-ext? k ext)) -- A generalisation of Very-stable-Π. Very-stable-Πⁿ : {A : Type ℓ₁} {P : A → Type ℓ₂} → Extensionality ℓ₁ ℓ₂ → ∀ n → (∀ x → For-iterated-equality n Very-stable (P x)) → For-iterated-equality n Very-stable ((x : A) → P x) Very-stable-Πⁿ ext n = For-iterated-equality-Π ext n ([]-cong₂.Very-stable-cong ax ax _ ∘ from-isomorphism) (Very-stable-Π ext) -- A generalisation of Very-stable-Stable-Σ. Very-stable-Stable-Σⁿ : {A : Type ℓ₁} {P : A → Type ℓ₂} → ∀ n → For-iterated-equality n Very-stable A → (∀ x → For-iterated-equality n Stable-[ k ] (P x)) → For-iterated-equality n Stable-[ k ] (Σ A P) Very-stable-Stable-Σⁿ {k = k} n = For-iterated-equality-Σ n ([]-cong₂-⊔₁.Stable-[]-map-↔ ax ax ax) Very-stable-Stable-Σ -- A variant of Stable-Σ for equality. Stable-≡-Σ : {A : Type ℓ₁} {P : A → Type ℓ₂} {p q : Σ A P} → (s : Stable (proj₁ p ≡ proj₁ q)) → (∀ eq → [ s eq ] ≡ eq) → (∀ eq → Stable (subst P eq (proj₂ p) ≡ proj₂ q)) → Stable (p ≡ q) Stable-≡-Σ {P = P} {p = p} {q = q} s₁ hyp s₂ = $⟨ Stable-Σ s₁ hyp s₂ ⟩ Stable (∃ λ (eq : proj₁ p ≡ proj₁ q) → subst P eq (proj₂ p) ≡ proj₂ q) ↝⟨ []-cong₂-⊔₁.Stable-[]-map-↔ ax ax ax Bijection.Σ-≡,≡↔≡ ⟩□ Stable (p ≡ q) □ -- A generalisation of Very-stable-Σ. Very-stable-Σⁿ : {A : Type ℓ₁} {P : A → Type ℓ₂} → ∀ n → For-iterated-equality n Very-stable A → (∀ x → For-iterated-equality n Very-stable (P x)) → For-iterated-equality n Very-stable (Σ A P) Very-stable-Σⁿ n = For-iterated-equality-Σ n ([]-cong₂.Very-stable-cong ax ax _ ∘ from-isomorphism) Very-stable-Σ -- A generalisation of Stable-[]-×. Stable-[]-×ⁿ : {A : Type ℓ₁} {B : Type ℓ₂} → ∀ n → For-iterated-equality n Stable-[ k ] A → For-iterated-equality n Stable-[ k ] B → For-iterated-equality n Stable-[ k ] (A × B) Stable-[]-×ⁿ n = For-iterated-equality-× n ([]-cong₂-⊔₁.Stable-[]-map-↔ ax ax ax) Stable-[]-× -- A generalisation of Very-stable-×. Very-stable-×ⁿ : {A : Type ℓ₁} {B : Type ℓ₂} → ∀ n → For-iterated-equality n Very-stable A → For-iterated-equality n Very-stable B → For-iterated-equality n Very-stable (A × B) Very-stable-×ⁿ n = For-iterated-equality-× n ([]-cong₂.Very-stable-cong ax ax _ ∘ from-isomorphism) Very-stable-× -- A generalisation of Stable-↑. Stable-↑ⁿ : {A : Type ℓ₂} → ∀ n → For-iterated-equality n Stable-[ k ] A → For-iterated-equality n Stable-[ k ] (↑ ℓ₁ A) Stable-↑ⁿ n = For-iterated-equality-↑ _ n ([]-cong₂-⊔₁.Stable-[]-map-↔ ax ax₂ ax) -- A generalisation of Very-stable-↑. Very-stable-↑ⁿ : {A : Type ℓ₂} → ∀ n → For-iterated-equality n Very-stable A → For-iterated-equality n Very-stable (↑ ℓ₁ A) Very-stable-↑ⁿ n = For-iterated-equality-↑ _ n ([]-cong₂.Very-stable-cong ax₂ ax _ ∘ from-isomorphism) -- A generalisation of Very-stable-W. Very-stable-Wⁿ : {A : Type ℓ₁} {P : A → Type ℓ₂} → Extensionality ℓ₂ (ℓ₁ ⊔ ℓ₂) → ∀ n → For-iterated-equality n Very-stable A → For-iterated-equality n Very-stable (W A P) Very-stable-Wⁿ {A = A} {P = P} ext n = For-iterated-equality-W ext n ([]-cong₂.Very-stable-cong ax ax _ ∘ from-isomorphism) (Very-stable-Π ext) Very-stable-Σ ([]-cong₂-⊔₁.Very-stable-W ax₁ ax₂ ax ext) ------------------------------------------------------------------------ -- Results that depend on instances of the axiomatisation of []-cong -- for all universe levels module []-cong (ax : ∀ {ℓ} → []-cong-axiomatisation ℓ) where private open module BC₂ {ℓ₁ ℓ₂} = []-cong₂ (ax {ℓ = ℓ₁}) (ax {ℓ = ℓ₂}) public open module BC₂₁ {ℓ₁ ℓ₂} = []-cong₂-⊔₁ (ax {ℓ = ℓ₁}) (ax {ℓ = ℓ₂}) ax public open module BC₁ {ℓ} = []-cong₁ (ax {ℓ = ℓ}) public open module BC₁-lsuc {ℓ} = []-cong₁-lsuc (ax {ℓ = lsuc ℓ}) public open module BC₂₂ {ℓ₁ ℓ₂} = []-cong₂-⊔₂ (ax {ℓ = ℓ₁}) (ax {ℓ = ℓ₂}) ax public ------------------------------------------------------------------------ -- Some results that were proved assuming extensionality and also that -- one or more instances of the []-cong axioms can be implemented, -- reproved without the latter assumptions module Extensionality where -- If A is "very stable n levels up", then H-level′ n A is very -- stable (assuming extensionality). Very-stable-H-level′ : {A : Type a} → Extensionality a a → ∀ n → For-iterated-equality n Very-stable A → Very-stable (H-level′ n A) Very-stable-H-level′ ext = []-cong₁.Very-stable-H-level′ (Extensionality→[]-cong-axiomatisation ext) ext -- If A is "very stable n levels up", then H-level n A is very -- stable (assuming extensionality). Very-stable-H-level : {A : Type a} → Extensionality a a → ∀ n → For-iterated-equality n Very-stable A → Very-stable (H-level n A) Very-stable-H-level ext = []-cong₁.Very-stable-H-level (Extensionality→[]-cong-axiomatisation ext) ext -- There is an equivalence between Very-stable (Very-stable A) and -- Very-stable A (assuming extensionality). Very-stable-Very-stable≃Very-stable : {A : Type a} → Extensionality a a → Very-stable (Very-stable A) ≃ Very-stable A Very-stable-Very-stable≃Very-stable ext = []-cong₁.Very-stable-Very-stable≃Very-stable (Extensionality→[]-cong-axiomatisation ext) ext -- The function λ A → Erased A, [_]→ and Very-stable form a Σ-closed -- reflective subuniverse (assuming extensionality). Erased-Σ-closed-reflective-subuniverse : Extensionality ℓ ℓ → Σ-closed-reflective-subuniverse ℓ Erased-Σ-closed-reflective-subuniverse ext = []-cong₁.Erased-Σ-closed-reflective-subuniverse (Extensionality→[]-cong-axiomatisation ext) -- This Σ-closed reflective subuniverse is topological (for certain -- universe levels, assuming extensionality). Erased-topological : ∀ ℓ′ (ext : Extensionality (lsuc ℓ ⊔ ℓ′) (lsuc ℓ ⊔ ℓ′)) → Topological (lsuc ℓ ⊔ ℓ′) (Erased-Σ-closed-reflective-subuniverse {ℓ = ℓ} (lower-extensionality _ _ ext)) Erased-topological ℓ′ ext = []-cong₁.Erased-topological (Extensionality→[]-cong-axiomatisation (lower-extensionality _ _ ext)) ℓ′ ext ------------------------------------------------------------------------ -- Some lemmas related to Stable-≡-Erased-axiomatisation private -- The type []-cong-axiomatisation ℓ is logically equivalent to -- Stable-≡-Erased-axiomatisation ℓ. []-cong-axiomatisation⇔Stable-≡-Erased-axiomatisation : []-cong-axiomatisation ℓ ⇔ Stable-≡-Erased-axiomatisation ℓ []-cong-axiomatisation⇔Stable-≡-Erased-axiomatisation {ℓ = ℓ} = record { to = λ ax → let open []-cong₁ ax s : {@0 A : Type ℓ} → Very-stable-≡ (Erased A) s = Very-stable→Very-stable-≡ 0 Very-stable-Erased in Very-stable→Stable 1 s , (λ {_ x} → Very-stable→Stable 1 s x x [ refl x ] ≡⟨ _≃_.left-inverse-of Eq.⟨ _ , s x x ⟩ _ ⟩∎ refl x ∎) ; from = S→B.instance-of-[]-cong-axiomatisation } where module S→B = Stable-≡-Erased-axiomatisation→[]-cong-axiomatisation -- The type Stable-≡-Erased-axiomatisation ℓ is propositional -- (assuming extensionality). -- -- The proof is based on a proof due to Nicolai Kraus that shows that -- "J + its computation rule" is contractible, see -- Equality.Instances-related.Equality-with-J-contractible. Stable-≡-Erased-axiomatisation-propositional : Extensionality (lsuc ℓ) ℓ → Is-proposition (Stable-≡-Erased-axiomatisation ℓ) Stable-≡-Erased-axiomatisation-propositional {ℓ = ℓ} ext = [inhabited⇒contractible]⇒propositional λ ax → let ax′ = _⇔_.from []-cong-axiomatisation⇔Stable-≡-Erased-axiomatisation ax module BC = []-cong-axiomatisation ax′ module EC = Erased-cong ax′ ax′ in _⇔_.from contractible⇔↔⊤ (Stable-≡-Erased-axiomatisation ℓ ↔⟨ Eq.↔→≃ (λ (Stable-≡-Erased , Stable-≡-Erased-[refl]) _ → (λ ([ x , y , x≡y ]) → Stable-≡-Erased [ x ] [ y ] [ x≡y ]) , (λ _ → Stable-≡-Erased-[refl])) (λ hyp → (λ ([ x ]) ([ y ]) ([ x≡y ]) → hyp _ .proj₁ [ (x , y , x≡y) ]) , hyp _ .proj₂ _) refl refl ⟩ ((([ A ]) : Erased (Type ℓ)) → ∃ λ (s : (([ x , y , _ ]) : Erased (∃ λ x → ∃ λ y → [ x ] ≡ [ y ])) → [ x ] ≡ [ y ]) → ((([ x ]) : Erased A) → s [ (x , x , refl [ x ]) ] ≡ refl [ x ])) ↝⟨ (∀-cong ext λ _ → inverse $ Σ-cong (inverse $ Π-cong ext′ (EC.Erased-cong-≃ (∃-cong λ _ → ∃-cong λ _ → []≡[]≃≡)) (λ _ → Eq.id)) λ s → ∀-cong ext′ λ ([ x ]) → s [ (x , x , refl x) ] ≡ refl [ x ] ↝⟨ ≡⇒↝ _ $ cong (_≡ _) $ cong (λ (([ eq ]) : Erased (x ≡ x)) → s [ (x , x , eq) ]) $ BC.[]-cong [ sym $ cong-refl _ ] ⟩□ s [ (x , x , cong erased (refl [ x ])) ] ≡ refl [ x ] □) ⟩ ((([ A ]) : Erased (Type ℓ)) → ∃ λ (s : (([ x , y , _ ]) : Erased (A ²/≡)) → [ x ] ≡ [ y ]) → ((([ x ]) : Erased A) → s [ (x , x , refl x) ] ≡ refl [ x ])) ↝⟨ (∀-cong ext λ _ → Σ-cong (inverse $ Π-cong ext′ (inverse $ EC.Erased-cong-↔ -²/≡↔-) (λ _ → Eq.id)) λ _ → F.id) ⟩ ((([ A ]) : Erased (Type ℓ)) → ∃ λ (r : (x : Erased A) → x ≡ x) → (x : Erased A) → r x ≡ refl x) ↝⟨ (∀-cong ext λ _ → inverse ΠΣ-comm) ⟩ ((([ A ]) : Erased (Type ℓ)) (x : Erased A) → ∃ λ (x≡x : x ≡ x) → x≡x ≡ refl x) ↝⟨ (_⇔_.to contractible⇔↔⊤ $ Π-closure ext 0 λ _ → Π-closure ext′ 0 λ _ → singleton-contractible _) ⟩□ ⊤ □) where ext′ : Extensionality ℓ ℓ ext′ = lower-extensionality _ lzero ext -- The type []-cong-axiomatisation ℓ is equivalent to -- Stable-≡-Erased-axiomatisation ℓ (assuming extensionality). []-cong-axiomatisation≃Stable-≡-Erased-axiomatisation : []-cong-axiomatisation ℓ ↝[ lsuc ℓ ∣ ℓ ] Stable-≡-Erased-axiomatisation ℓ []-cong-axiomatisation≃Stable-≡-Erased-axiomatisation {ℓ = ℓ} = generalise-ext?-prop []-cong-axiomatisation⇔Stable-≡-Erased-axiomatisation []-cong-axiomatisation-propositional Stable-≡-Erased-axiomatisation-propositional ------------------------------------------------------------------------ -- Another alternative to []-cong-axiomatisation -- This axiomatisation states that equality is very stable for -- Erased A, for every (erased) type A in a certain universe. Very-stable-≡-Erased-axiomatisation : (ℓ : Level) → Type (lsuc ℓ) Very-stable-≡-Erased-axiomatisation ℓ = {@0 A : Type ℓ} → Very-stable-≡ (Erased A) -- The type Very-stable-≡-Erased-axiomatisation ℓ is propositional -- (assuming extensionality). Very-stable-≡-Erased-axiomatisation-propositional : Extensionality (lsuc ℓ) ℓ → Is-proposition (Very-stable-≡-Erased-axiomatisation ℓ) Very-stable-≡-Erased-axiomatisation-propositional ext = implicit-Πᴱ-closure ext 1 λ _ → For-iterated-equality-Very-stable-propositional (lower-extensionality _ lzero ext) 1 -- The type Stable-≡-Erased-axiomatisation ℓ is equivalent to -- Very-stable-≡-Erased-axiomatisation ℓ (assuming extensionality). Stable-≡-Erased-axiomatisation≃Very-stable-≡-Erased-axiomatisation : Stable-≡-Erased-axiomatisation ℓ ↝[ lsuc ℓ ∣ ℓ ] Very-stable-≡-Erased-axiomatisation ℓ Stable-≡-Erased-axiomatisation≃Very-stable-≡-Erased-axiomatisation {ℓ = ℓ} = generalise-ext?-prop (record { to = to; from = from }) Stable-≡-Erased-axiomatisation-propositional Very-stable-≡-Erased-axiomatisation-propositional where to : Stable-≡-Erased-axiomatisation ℓ → Very-stable-≡-Erased-axiomatisation ℓ to ax = Very-stable→Very-stable-≡ 0 Very-stable-Erased where open []-cong₁ (_⇔_.from []-cong-axiomatisation⇔Stable-≡-Erased-axiomatisation ax) from : Very-stable-≡-Erased-axiomatisation ℓ → Stable-≡-Erased-axiomatisation ℓ from Very-stable-≡-Erased = Very-stable→Stable 1 Very-stable-≡-Erased , (λ {_ x} → Very-stable→Stable 1 Very-stable-≡-Erased x x [ refl x ] ≡⟨ _≃_.left-inverse-of Eq.⟨ _ , Very-stable-≡-Erased x x ⟩ _ ⟩∎ refl x ∎) -- The type []-cong-axiomatisation ℓ is equivalent to -- Very-stable-≡-Erased-axiomatisation ℓ (assuming extensionality). []-cong-axiomatisation≃Very-stable-≡-Erased-axiomatisation : []-cong-axiomatisation ℓ ↝[ lsuc ℓ ∣ ℓ ] Very-stable-≡-Erased-axiomatisation ℓ []-cong-axiomatisation≃Very-stable-≡-Erased-axiomatisation {ℓ = ℓ} = generalise-ext?-prop ([]-cong-axiomatisation ℓ ↝⟨ []-cong-axiomatisation⇔Stable-≡-Erased-axiomatisation ⟩ Stable-≡-Erased-axiomatisation ℓ ↝⟨ Stable-≡-Erased-axiomatisation≃Very-stable-≡-Erased-axiomatisation _ ⟩□ Very-stable-≡-Erased-axiomatisation ℓ □) []-cong-axiomatisation-propositional Very-stable-≡-Erased-axiomatisation-propositional ------------------------------------------------------------------------ -- Yet another alternative to []-cong-axiomatisation -- This axiomatisation states that, for types A and B in a given -- universe, if B is very stable, then the constant function from -- Erased A that returns B is 2-extendable along [_]→. 2-extendable-along-[]→-axiomatisation : (ℓ : Level) → Type (lsuc ℓ) 2-extendable-along-[]→-axiomatisation ℓ = {A B : Type ℓ} → Very-stable B → Is-[ 2 ]-extendable-along-[ [_]→ ] (λ (_ : Erased A) → B) -- The type 2-extendable-along-[]→-axiomatisation ℓ is propositional -- (assuming extensionality). 2-extendable-along-[]→-axiomatisation-propositional : Extensionality (lsuc ℓ) (lsuc ℓ) → Is-proposition (2-extendable-along-[]→-axiomatisation ℓ) 2-extendable-along-[]→-axiomatisation-propositional ext = implicit-Π-closure ext 1 λ _ → implicit-Π-closure ext′ 1 λ _ → Π-closure ext″ 1 λ _ → PS.Is-extendable-along-propositional ext″ where ext′ = lower-extensionality lzero _ ext ext″ = lower-extensionality _ _ ext -- The type []-cong-axiomatisation ℓ is equivalent to -- 2-extendable-along-[]→-axiomatisation ℓ (assuming extensionality). []-cong-axiomatisation≃2-extendable-along-[]→-axiomatisation : []-cong-axiomatisation ℓ ↝[ lsuc ℓ ∣ lsuc ℓ ] 2-extendable-along-[]→-axiomatisation ℓ []-cong-axiomatisation≃2-extendable-along-[]→-axiomatisation {ℓ = ℓ} = generalise-ext?-prop {B = 2-extendable-along-[]→-axiomatisation ℓ} (record { to = λ ax s → []-cong₁.extendable ax (λ _ → s) 2 ; from = 2-extendable-along-[]→-axiomatisation ℓ ↝⟨ (λ ext → Stable-≡-Erased ext , Stable-≡-Erased-[refl] ext) ⟩ Stable-≡-Erased-axiomatisation ℓ ↝⟨ _⇔_.from $ []-cong-axiomatisation≃Stable-≡-Erased-axiomatisation _ ⟩□ []-cong-axiomatisation ℓ □ }) ([]-cong-axiomatisation-propositional ∘ lower-extensionality lzero _) 2-extendable-along-[]→-axiomatisation-propositional where module _ (ext : 2-extendable-along-[]→-axiomatisation ℓ) where Stable-≡-Erased : {@0 A : Type ℓ} → Stable-≡ (Erased A) Stable-≡-Erased x y = ext Very-stable-Erased .proj₂ (λ _ → x) (λ _ → y) .proj₁ id .proj₁ Stable-≡-Erased-[refl] : {@0 A : Type ℓ} {x : Erased A} → Stable-≡-Erased x x [ refl x ] ≡ refl x Stable-≡-Erased-[refl] {x = x} = ext Very-stable-Erased .proj₂ (λ _ → x) (λ _ → x) .proj₁ id .proj₂ (refl x) ------------------------------------------------------------------------ -- And another alternative to []-cong-axiomatisation -- This axiomatisation states that, for types A and B in a given -- universe, if B is very stable, then the constant function from -- Erased A that returns B is ∞-extendable along [_]→. ∞-extendable-along-[]→-axiomatisation : (ℓ : Level) → Type (lsuc ℓ) ∞-extendable-along-[]→-axiomatisation ℓ = {A B : Type ℓ} → Very-stable B → Is-∞-extendable-along-[ [_]→ ] (λ (_ : Erased A) → B) -- The type ∞-extendable-along-[]→-axiomatisation ℓ is propositional -- (assuming extensionality). ∞-extendable-along-[]→-axiomatisation-propositional : Extensionality (lsuc ℓ) (lsuc ℓ) → Is-proposition (∞-extendable-along-[]→-axiomatisation ℓ) ∞-extendable-along-[]→-axiomatisation-propositional ext = implicit-Π-closure ext 1 λ _ → implicit-Π-closure ext′ 1 λ _ → Π-closure ext″ 1 λ _ → PS.Is-∞-extendable-along-propositional ext″ where ext′ = lower-extensionality lzero _ ext ext″ = lower-extensionality _ _ ext -- The type []-cong-axiomatisation ℓ is equivalent to -- ∞-extendable-along-[]→-axiomatisation ℓ (assuming extensionality). []-cong-axiomatisation≃∞-extendable-along-[]→-axiomatisation : []-cong-axiomatisation ℓ ↝[ lsuc ℓ ∣ lsuc ℓ ] ∞-extendable-along-[]→-axiomatisation ℓ []-cong-axiomatisation≃∞-extendable-along-[]→-axiomatisation {ℓ = ℓ} = generalise-ext?-prop {B = ∞-extendable-along-[]→-axiomatisation ℓ} (record { to = λ ax s → []-cong₁.extendable ax (λ _ → s) ; from = ∞-extendable-along-[]→-axiomatisation ℓ ↝⟨ (λ ext s → ext s 2) ⟩ 2-extendable-along-[]→-axiomatisation ℓ ↝⟨ _⇔_.from ([]-cong-axiomatisation≃2-extendable-along-[]→-axiomatisation _) ⟩□ []-cong-axiomatisation ℓ □ }) ([]-cong-axiomatisation-propositional ∘ lower-extensionality lzero _) ∞-extendable-along-[]→-axiomatisation-propositional ------------------------------------------------------------------------ -- A lemma related to []-cong-axiomatisation′ -- The type []-cong-axiomatisation′ a is propositional (assuming -- extensionality). []-cong-axiomatisation′-propositional : Extensionality (lsuc a) a → Is-proposition ([]-cong-axiomatisation′ a) []-cong-axiomatisation′-propositional {a = a} ext = [inhabited⇒contractible]⇒propositional λ ax → let ax′ = []-cong-axiomatisation′→[]-cong-axiomatisation ax module BC = []-cong₁ ax′ s₁ : {@0 A : Type a} → Very-stable-≡ (Erased A) s₁ = BC.Very-stable→Very-stable-≡ 0 Very-stable-Erased s₂ : {@0 A : Type a} → For-iterated-equality 2 Very-stable (Erased A) s₂ = BC.Very-stable→Very-stable-≡ 1 s₁ s₃ : {@0 A : Type a} {@0 x y : A} {f : Erased (x ≡ y) → [ x ] ≡ [ y ]} → Very-stable (Is-equivalence f) s₃ = Very-stable-Σ (Very-stable-Π ext′ λ _ → Very-stable-Erased) λ _ → Very-stable-Σ (Very-stable-Π ext′ λ _ → BC.Very-stable→Very-stable-≡ 0 (s₁ _ _) _ _) λ _ → Very-stable-Σ (Very-stable-Π ext′ λ _ → s₁ _ _) λ _ → Very-stable-Π ext′ λ _ → BC.Very-stable→Very-stable-≡ 0 (BC.Very-stable→Very-stable-≡ 0 (s₁ _ _) _ _) _ _ in _⇔_.from contractible⇔↔⊤ ([]-cong-axiomatisation′ a ↔⟨ Eq.↔→≃ (λ (record { []-cong = c ; []-cong-equivalence = e ; []-cong-[refl] = r }) _ → (λ _ _ ([ x≡y ]) → c [ x≡y ]) , (λ _ → r) , (λ _ _ → e)) (λ f → record { []-cong = λ ([ x≡y ]) → f _ .proj₁ _ _ [ x≡y ] ; []-cong-equivalence = f _ .proj₂ .proj₂ _ _ ; []-cong-[refl] = f _ .proj₂ .proj₁ _ }) refl refl ⟩ ((A : Type a) → ∃ λ (c : ((x y : A) → Erased (x ≡ y) → [ x ] ≡ [ y ])) → ((x : A) → c x x [ refl x ] ≡ refl [ x ]) × ((x y : A) → Is-equivalence {A = Erased (x ≡ y)} {B = [ x ] ≡ [ y ]} (λ ([ x≡y ]) → c x y [ x≡y ]))) ↝⟨ (∀-cong ext λ _ → inverse $ Σ-cong ((Π-Erased≃Π ext′ λ _ → Very-stable→Stable 0 $ Very-stable-Π ext′ λ _ → Very-stable-Π ext′ λ _ → s₁ _ _) Eq.∘ (∀-cong ext′ λ _ → Π-Erased≃Π ext′ λ _ → Very-stable→Stable 0 $ Very-stable-Π ext′ λ _ → s₁ _ _)) λ _ → F.id) ⟩ ((A : Type a) → ∃ λ (c : ((([ x ]) ([ y ]) : Erased A) → Erased (x ≡ y) → [ x ] ≡ [ y ])) → ((x : A) → c [ x ] [ x ] [ refl x ] ≡ refl [ x ]) × ((x y : A) → Is-equivalence {A = Erased (x ≡ y)} {B = [ x ] ≡ [ y ]} (λ ([ x≡y ]) → c [ x ] [ y ] [ x≡y ]))) ↝⟨ (∀-cong ext λ _ → Σ-cong (inverse $ (∀-cong ext′ λ _ → currying) F.∘ currying F.∘ (Π-cong ext′ (∃-cong λ _ → Erased-Σ↔Σ) λ _ → F.id) F.∘ (Π-cong ext′ Erased-Σ↔Σ λ _ → F.id)) λ _ → F.id) ⟩ ((A : Type a) → ∃ λ (c : ((([ x , y , _ ]) : Erased (A ²/≡)) → [ x ] ≡ [ y ])) → ((x : A) → c [ (x , x , refl x) ] ≡ refl [ x ]) × ((x y : A) → Is-equivalence {A = Erased (x ≡ y)} {B = [ x ] ≡ [ y ]} (λ ([ x≡y ]) → c [ (x , y , x≡y) ]))) ↝⟨ (∀-cong ext λ _ → ∃-cong λ _ → (inverse $ Π-Erased≃Π ext′ λ _ → Very-stable→Stable 2 s₂ _ _ _ _) ×-cong (inverse $ (∀-cong ext′ λ _ → Π-Erased≃Π ext′ λ _ → Very-stable→Stable 0 s₃) F.∘ Π-Erased≃Π ext′ λ _ → Very-stable→Stable 0 $ Very-stable-Π ext′ λ _ → s₃)) ⟩ ((A : Type a) → ∃ λ (c : ((([ x , y , _ ]) : Erased (A ²/≡)) → [ x ] ≡ [ y ])) → ((([ x ]) : Erased A) → c [ (x , x , refl x) ] ≡ refl [ x ]) × ((([ x ]) ([ y ]) : Erased A) → Is-equivalence {A = Erased (x ≡ y)} {B = [ x ] ≡ [ y ]} (λ ([ x≡y ]) → c [ (x , y , x≡y) ]))) ↝⟨ (inverse $ Π-Erased≃Π ext λ A → Very-stable→Stable 0 $ Very-stable-Σ (Very-stable-Π ext′ λ _ → s₁ _ _) λ _ → Very-stable-× (Very-stable-Π ext′ λ _ → s₂ _ _ _ _) (Very-stable-Π ext′ λ _ → Very-stable-Π ext′ λ _ → s₃)) ⟩ ((([ A ]) : Erased (Type a)) → ∃ λ (c : ((([ x , y , _ ]) : Erased (A ²/≡)) → [ x ] ≡ [ y ])) → ((([ x ]) : Erased A) → c [ (x , x , refl x) ] ≡ refl [ x ]) × ((([ x ]) ([ y ]) : Erased A) → Is-equivalence {A = Erased (x ≡ y)} {B = [ x ] ≡ [ y ]} (λ ([ x≡y ]) → c [ (x , y , x≡y) ]))) ↔⟨ Eq.↔→≃ (λ f → record { []-cong = λ ([ x≡y ]) → f _ .proj₁ [ (_ , _ , x≡y) ] ; []-cong-equivalence = f _ .proj₂ .proj₂ _ _ ; []-cong-[refl] = f _ .proj₂ .proj₁ _ }) (λ (record { []-cong = c ; []-cong-equivalence = e ; []-cong-[refl] = r }) _ → (λ ([ _ , _ , x≡y ]) → c [ x≡y ]) , (λ _ → r) , (λ _ _ → e)) refl refl ⟩ []-cong-axiomatisation a ↝⟨ _⇔_.to contractible⇔↔⊤ $ []-cong-axiomatisation-contractible ext ⟩□ ⊤ □) where ext′ : Extensionality a a ext′ = lower-extensionality _ lzero ext -- The type []-cong-axiomatisation ℓ is equivalent to -- []-cong-axiomatisation′ ℓ (assuming extensionality). []-cong-axiomatisation≃[]-cong-axiomatisation′ : []-cong-axiomatisation ℓ ↝[ lsuc ℓ ∣ ℓ ] []-cong-axiomatisation′ ℓ []-cong-axiomatisation≃[]-cong-axiomatisation′ {ℓ = ℓ} = generalise-ext?-prop (record { from = []-cong-axiomatisation′→[]-cong-axiomatisation ; to = λ ax → let open []-cong-axiomatisation ax in record { []-cong = []-cong ; []-cong-equivalence = []-cong-equivalence ; []-cong-[refl] = []-cong-[refl] } }) []-cong-axiomatisation-propositional []-cong-axiomatisation′-propositional
{ "alphanum_fraction": 0.5089105226, "avg_line_length": 37.8945512821, "ext": "agda", "hexsha": "803c8bb4a75c0a753fb3b2f988950c8bf6855757", "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/Erased/Stability.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/Erased/Stability.agda", "max_line_length": 148, "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/Erased/Stability.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": 41436, "size": 118231 }
open import Agda.Builtin.Nat open import Agda.Builtin.Equality record Eq (A : Set) : Set₁ where field _≈_ : A → A → Set open Eq {{...}} public record Setoid : Set₁ where field ∣_∣ : Set {{eq}} : Eq ∣_∣ open Setoid public instance EqNat : Eq Nat _≈_ {{EqNat}} = _≡_ NatSetoid : Setoid ∣ NatSetoid ∣ = Nat thm : (x : ∣ NatSetoid ∣) → x ≈ x thm x = refl
{ "alphanum_fraction": 0.5916230366, "avg_line_length": 14.1481481481, "ext": "agda", "hexsha": "61038f9b28f64be1a6cecce47cf919caa7239286", "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/Issue2288.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/Issue2288.agda", "max_line_length": 33, "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/Issue2288.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": 157, "size": 382 }
module Numeral.Integer.Function where open import Numeral.Integer open import Numeral.Integer.Oper open import Numeral.Natural as ℕ using (ℕ)
{ "alphanum_fraction": 0.8251748252, "avg_line_length": 23.8333333333, "ext": "agda", "hexsha": "6e660b2e25a42fe27b9f6513e32fff60140ab865", "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/Integer/Function.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/Integer/Function.agda", "max_line_length": 42, "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/Integer/Function.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": 34, "size": 143 }
{-# OPTIONS --allow-unsolved-metas #-} module AgdaIssue2557 where record Superclass : Set₁ where field super : Set open Superclass ⦃ … ⦄ public record Subclass : Set₁ where field ⦃ iSuperclass ⦄ : Superclass sub : super open Subclass postulate A : Set instance SuperclassA : Superclass Superclass.super SuperclassA = A → A postulate function-A : A → A test-1 : Subclass Subclass.sub test-1 = {!!} -- Goal: A → A test-2 : Subclass test-2 = record { sub = function-A } -- works test-3 : Subclass Subclass.iSuperclass test-3 = SuperclassA -- (could also put "it" here) Subclass.sub test-3 = function-A -- works test-4 : Subclass Subclass.sub test-4 = {!function-A!} -- fails -- test-5 : Subclass -- Subclass.sub test-5 x = {!!} -- fails test-6 : Subclass Subclass.sub test-6 = {!λ x → {!!}!} -- fails
{ "alphanum_fraction": 0.6674727932, "avg_line_length": 19.2325581395, "ext": "agda", "hexsha": "d3497ac7ceead1dc93bf2bb60ddbed881de07920", "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/AgdaIssue2557.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/AgdaIssue2557.agda", "max_line_length": 71, "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/AgdaIssue2557.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 267, "size": 827 }
{-# OPTIONS --cubical --no-import-sorts --allow-unsolved-metas #-} module Test.Number where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) private variable ℓ ℓ' ℓ'' : Level open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) open import Cubical.Relation.Nullary.Base -- ¬_ open import Cubical.Relation.Binary.Base -- Rel open import Cubical.Data.Unit.Base -- Unit open import Cubical.Data.Empty -- ⊥ open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim) -- `⊥` and `elim` open import Function.Base using (it; _∋_; _$_) -- open import Data.Nat.Base using (ℕ) renaming (_≤_ to _≤ₙ_) -- open import Cubical.Data.Nat using (ℕ; zero; suc) renaming (_+_ to _+ₙ_) -- open import Cubical.Data.Nat.Order renaming (zero-≤ to z≤n; suc-≤-suc to s≤s; _≤_ to _≤ₙ_; _<_ to _<ₙ_) -- open import Cubical.Data.Fin.Base -- import Cubical.Data.Fin.Properties -- open import Cubical.Data.Nat using (ℕ; zero; suc) renaming (_+_ to _+ₙ_) -- open import Cubical.Data.Nat.Properties using (+-suc; injSuc; snotz; +-comm; +-assoc; +-zero; inj-m+) -- open import Cubical.Data.Nat.Order renaming (zero-≤ to z≤n; suc-≤-suc to s≤s; _≤_ to _≤ₙ_; _<_ to _<ₙ_; _≟_ to _≟ₙ_) -- open import Data.Nat.Base using (ℕ; z≤n; s≤s; zero; suc) renaming (_≤_ to _≤ₙ_; _<_ to _<ₙ_; _+_ to _+ₙ_) -- open import Agda.Builtin.Bool renaming (true to TT; false to FF) -- import Cubical.Data.Fin.Properties -- open import Data.Nat.Properties using (+-mono-<) -- open import Bundles open import Number.Postulates open import Number.Structures open import Number.Bundles open import Number.Inclusions open import Number.Base open import Number.Coercions open import Number.Operations open ℕⁿ open ℤᶻ open ℚᶠ open ℝʳ open ℂᶜ import Data.Nat.Properties -- NOTE: well, for 15 allowed coercions, we might just enumerate them -- unfortunately with overlapping patterns a style as in `Cl` is not possible -- we need to explicitly write out all the 5×5 combinations -- or, we implement a min operator which might work even with overlapping patterns -- num {isNat ,, p} (x ,, q) = x -- num {isInt ,, p} (x ,, q) = x -- num {isRat ,, p} (x ,, q) = x -- num {isReal ,, p} (x ,, q) = x -- num {isComplex ,, p} (x ,, q) = x -- TODO: name this "inject" instead of "coerce" -- TODO: make the module ℤ and the Carrier ℤ.ℤ -- TODO: for a binary relation `a # b` it would be nice to have a way to compose ≡-pathes to the left and the right -- similar to how ∙ can be used for pathes -- this reasoning might extend to transitive relations -- `cong₂ _#_ refl x` and `cong₂ _#_ x refl` to this (together with `transport`) -- NOTE: maybe ℕ↪ℤ should be a postfix operation -- module _ where -- module ℕ' = ROrderedCommSemiring ℕ.Bundle -- module ℤ' = ROrderedCommRing ℤ.Bundle -- module ℚ' = ROrderedField ℚ.Bundle -- module ℝ' = ROrderedField ℝ.Bundle -- module ℂ' = RField ℂ.Bundle-- -- coerce-OCSR : ∀{l p} {ll : NumberKind} {𝕏OCSR 𝕐OCSR : ROrderedCommSemiring {ℝℓ} {ℝℓ'}} -- → (x : Number (l ,, p)) -- → {f : Il l → Il ll} -- → IsROrderedCommSemiringInclusion 𝕏OCSR 𝕐OCSR f -- → Ip ll p (f (num x)) -- coerce-OCSR {l} {ll} {p} {𝕏OCSR} {𝕐OCSR} {f} (x ,, q) = ? {- private instance z≤n' : ∀ {n} → zero ≤ₙ n z≤n' {n} = z≤n s≤s' : ∀ {m n} {{m≤n : m ≤ₙ n}} → suc m ≤ₙ suc n s≤s' {m} {n} {{m≤n}} = s≤s m≤n -} {- -- TODO: why does `it` not work here? ⁻¹-Levels : (a : NumberKind) → Σ[ b ∈ NumberKind ] a ≤ₙₗ b ⁻¹-Levels isNat = isRat , z≤n -- it ⁻¹-Levels isInt = isRat , s≤s z≤n -- s≤s' {{z≤n'}} ⁻¹-Levels isRat = isRat , s≤s (s≤s z≤n) ⁻¹-Levels isReal = isReal , s≤s (s≤s (s≤s z≤n)) -- it ⁻¹-Levels isComplex = isComplex , s≤s (s≤s (s≤s (s≤s z≤n))) ⁻¹-Levels' : (a : NumberKind) → NumberKind ⁻¹-Levels' x = maxₙₗ x isRat -} open PatternsType {- private pattern X = anyPositivity pattern X⁺⁻ = isNonzero pattern X₀⁺ = isNonnegative pattern X⁺ = isPositive pattern X⁻ = isNegative pattern X₀⁻ = isNonpositive -} {- ⁻¹-Types : NumberProp → Maybe NumberProp ⁻¹-Types (level ,, X ) = nothing ⁻¹-Types (level ,, X₀⁺) = nothing ⁻¹-Types (level ,, X₀⁻) = nothing ⁻¹-Types (level ,, p ) = just (fst (⁻¹-Levels level) ,, p) -} -- ∀{{ q : Unit }} → Number (level ,, X⁺⁻) -- ∀{{ q : Unit }} → Number (level ,, X⁺ ) -- ∀{{ q : Unit }} → Number (level ,, X⁻ ) -- pattern [ℝ₀⁺] = (isReal , X₀⁺) -- [ℝ₀⁺] = Number (isReal , isNonnegativeᵒʳ) -- [ℝ⁺] = Number (isReal , isPositiveᵒʳ) -- [ℕ⁺] = Number (isNat , isPositiveᵒʳ) -- [ℝ] = Number (isReal , anyPositivityᵒʳ) open import Number.Prettyprint -- {-# DISPLAY maxₙₗ' isReal isReal = isReal #-} -- {-# DISPLAY Number (isReal , isNonnegative) = [ℝ₀⁺] #-} -- {-# DISPLAY Number (isReal , isPositive) = [ℝ⁺] #-} [1ʳ] : [ℝ⁺] [1ʳ] = 1ʳ ,, ℝ.0<1 [1]-Type : (l : NumberKind) → Type (NumberLevel l) [1]-Type isNat = [ℕ⁺] [1]-Type isInt = [ℤ⁺] [1]-Type isRat = [ℚ⁺] [1]-Type isReal = [ℝ⁺] [1]-Type isComplex = [ℂ⁺⁻] -- NOTE: this is ambiguous with generic operations such as _+_ [1] : ∀{l} → [1]-Type l [1] {isNat} = 1ⁿ ,, ℕ.0<1 [1] {isInt} = 1ᶻ ,, ℤ.0<1 [1] {isRat} = 1ᶠ ,, ℚ.0<1 [1] {isReal} = 1ʳ ,, ℝ.0<1 [1] {isComplex} = 1ᶜ ,, ℂ.1#0 -- test101 : Number (isNat , isPositiveᵒʳ) → Number (isReal , isNonnegativeᵒʳ) → {!!} open import Function.Base using (typeOf) test201 : [ℕ⁺] → [ℝ₀⁺] → [ℝ] -- As-patterns (or @-patterns) go well with resolving things in our approach test201 n@(nn ,, np) r@(rn ,, rp) = let -- generic operations are provided -- q : [ℕ⁺] -- z : [ℝ₀⁺] q = n + n z = r + r -- we can project-out the underlying number of a `Number` with `num` -- zʳ : ℝ zʳ = num z -- and we can project-out the property of a `Number` with `prp` -- zp : 0ʳ ≤ʳ (rn +ʳ rn) zp = prp z -- since the generic `_+_` makes use of `_+ʳ_` on ℝ, we get definitional equality _ : zʳ ≡ rn +ʳ rn _ = refl -- we can turn a generic number into a Σ pair with `pop` -- qʳ : ℕ₀ -- qʳ = nn +ⁿ nn -- qp : 0ⁿ <ⁿ (nn +ⁿ nn) -- qp = +-<-<-implies-<ʳ nn nn np np (qʳ , qp) = pop q -- and we can create a number with `_,,_` -- this needs some type annotation for help q' : typeOf q q' = qʳ ,, qp -- if the two parts of q and q' are in scope, then we get definitional equality _ : q ≡ q' _ = refl -- r is nonnegative from [ℝ₀⁺], [1ʳ] is positive from [ℝ⁺] -- and _+_ makes use of the fact that "positive + nonnegative = positive" -- y : [ℝ⁺] -- y = (rn +ʳ 1ʳ) ,, +-≤-<-implies-<ʳ rn 1ʳ rp 0<1 y = r + [1ʳ] -- _+_ automatically coerces n from ℕ⁺ to ℝ⁺ -- and uses the fact that "positive + nonnegative = positive" -- n+r : [ℝ⁺] -- n+r = (ℕ↪ℝ nn +ʳ rn) ,, +-<-≤-implies-<ʳ (ℕ↪ℝ nn) rn (coerce-ℕ↪ℝ (nn ,, np)) rp n+r = n + r -- generic relations like _<_ also make use of their underlying relations -- and therefore we also get definitional equality, no matter how the relation is stated pp : [1ʳ] < (r + [1ʳ]) pp = {!!} pp' : 1ʳ <ʳ num (r + [1ʳ]) pp' = {!!} pp'' : 1ʳ <ʳ (rn +ʳ 1ʳ ) pp'' = {!!} _ : (pp ≡ pp') × (pp ≡ pp'') _ = refl , refl in {! - [1ʳ]!} _ = {! ℕ!} {- distance : ∀(x y : [ℝ]) → [ℝ] distance x y = max (x + (- y)) (- (x + (- y))) IsCauchy : (x : ℕ → ℝ) → Type (ℓ-max ℓ' ℚℓ) IsCauchy x = ∀(ε : [ℚ⁺]) → ∃[ N ∈ ℕ ] ∀(m n : ℕ) → N ≤ⁿ m → N ≤ⁿ n → distance (x m) (x n) < ε -} test : [ℕ⁺] → [ℝ₀⁺] → [ℝ] test n@(nn ,, np) r@(rn ,, rp) = let q : [ℕ⁺] q = n + n z : [ℝ₀⁺] z = r + r k : [ℝ⁺] k = n + r in {!!}
{ "alphanum_fraction": 0.5869144406, "avg_line_length": 30.26953125, "ext": "agda", "hexsha": "461a9ffca51e2d2b722fc0ed21ccc04cd53aac49", "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": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/Test/Number.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "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": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/Test/Number.agda", "max_line_length": 119, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/Test/Number.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 3141, "size": 7749 }
open import Prelude open import core open import contexts open import lemmas-matching module synth-unicity where -- synthesis only produces equal types. note that there is no need for an -- analagous theorem for analytic positions because we think of -- the type as an input synthunicity : {Γ : tctx} {e : hexp} {t t' : htyp} → Γ ⊢ e => t → Γ ⊢ e => t' → t == t' synthunicity (SAsc _) (SAsc _) = refl synthunicity {Γ = G} (SVar in1) (SVar in2) = ctxunicity {Γ = G} in1 in2 synthunicity (SAp D1 MAHole _) (SAp D2 MAHole y) = refl synthunicity (SAp D1 MAHole _) (SAp D2 MAArr y) with synthunicity D1 D2 ... | () synthunicity (SAp D1 MAArr _) (SAp D2 MAHole y) with synthunicity D1 D2 ... | () synthunicity (SAp D1 MAArr _) (SAp D2 MAArr y) with synthunicity D1 D2 ... | refl = refl synthunicity SEHole SEHole = refl synthunicity (SNEHole _) (SNEHole _) = refl synthunicity SNum SNum = refl synthunicity (SPlus _ _) (SPlus _ _) = refl synthunicity (SLam _ D1) (SLam _ D2) with synthunicity D1 D2 synthunicity (SLam x₁ D1) (SLam x₂ D2) | refl = refl synthunicity (SPair D1 D2) (SPair D3 D4) with synthunicity D1 D3 | synthunicity D2 D4 ... | refl | refl = refl synthunicity (SFst D1 x) (SFst D2 x₁) with synthunicity D1 D2 ... | refl with ▸prod-unicity x x₁ ... | refl = refl synthunicity (SSnd D1 x) (SSnd D2 x₁) with synthunicity D1 D2 ... | refl with ▸prod-unicity x x₁ ... | refl = refl
{ "alphanum_fraction": 0.6468624833, "avg_line_length": 39.4210526316, "ext": "agda", "hexsha": "6612f4ed8fdb07ff1abec271e878527be3e8ea02", "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": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "synth-unicity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "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": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "synth-unicity.agda", "max_line_length": 75, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "synth-unicity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 566, "size": 1498 }
-- Minimal logic, PHOAS approach, initial encoding module Pi.M (Indiv : Set) where -- Types data Ty : Set Pred : Set Pred = Indiv -> Ty infixl 2 _&&_ infixl 1 _||_ infixr 0 _=>_ data Ty where UNIT : Ty _=>_ : Ty -> Ty -> Ty _&&_ : Ty -> Ty -> Ty _||_ : Ty -> Ty -> Ty FALSE : Ty FORALL : Pred -> Ty EXISTS : Pred -> Ty infixr 0 _<=>_ _<=>_ : Ty -> Ty -> Ty a <=> b = (a => b) && (b => a) NOT : Ty -> Ty NOT a = a => FALSE TRUE : Ty TRUE = FALSE => FALSE -- Context and truth/individual judgement data El : Set where mkTrue : Ty -> El mkIndiv : Indiv -> El Cx : Set1 Cx = El -> Set isTrue : Ty -> Cx -> Set isTrue a tc = tc (mkTrue a) isIndiv : Indiv -> Cx -> Set isIndiv x tc = tc (mkIndiv x) -- Terms module M where infixl 2 _$$_ infixl 1 _$_ data Tm (tc : Cx) : Ty -> Set where var : forall {a} -> isTrue a tc -> Tm tc a lam' : forall {a b} -> (isTrue a tc -> Tm tc b) -> Tm tc (a => b) _$_ : forall {a b} -> Tm tc (a => b) -> Tm tc a -> Tm tc b pair' : forall {a b} -> Tm tc a -> Tm tc b -> Tm tc (a && b) fst : forall {a b} -> Tm tc (a && b) -> Tm tc a snd : forall {a b} -> Tm tc (a && b) -> Tm tc b left : forall {a b} -> Tm tc a -> Tm tc (a || b) right : forall {a b} -> Tm tc b -> Tm tc (a || b) case' : forall {a b c} -> Tm tc (a || b) -> (isTrue a tc -> Tm tc c) -> (isTrue b tc -> Tm tc c) -> Tm tc c pi' : forall {p} -> (forall {x} -> isIndiv x tc -> Tm tc (p x)) -> Tm tc (FORALL p) _$$_ : forall {p x} -> Tm tc (FORALL p) -> isIndiv x tc -> Tm tc (p x) sig' : forall {p x} -> isIndiv x tc -> Tm tc (p x) -> Tm tc (EXISTS p) split' : forall {p x a} -> Tm tc (EXISTS p) -> (isTrue (p x) tc -> Tm tc a) -> Tm tc a lam'' : forall {tc a b} -> (Tm tc a -> Tm tc b) -> Tm tc (a => b) lam'' f = lam' \x -> f (var x) case'' : forall {tc a b c} -> Tm tc (a || b) -> (Tm tc a -> Tm tc c) -> (Tm tc b -> Tm tc c) -> Tm tc c case'' xy f g = case' xy (\x -> f (var x)) (\y -> g (var y)) split'' : forall {tc p x a} -> Tm tc (EXISTS p) -> (Tm tc (p x) -> Tm tc a) -> Tm tc a split'' x f = split' x \y -> f (var y) syntax lam'' (\a -> b) = lam a => b syntax pair' x y = [ x , y ] syntax case'' xy (\x -> z1) (\y -> z2) = case xy of x => z1 or y => z2 syntax pi' (\x -> px) = pi x => px syntax sig' x px = [ x ,, px ] syntax split'' x (\y -> z) = split x as y => z Thm : Ty -> Set1 Thm a = forall {tc} -> Tm tc a open M public
{ "alphanum_fraction": 0.4439544285, "avg_line_length": 29.9010989011, "ext": "agda", "hexsha": "8ac00b2f15ac5896dcd97539b9587111dd0b17eb", "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": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/formal-logic", "max_forks_repo_path": "src/Pi/M.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "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/formal-logic", "max_issues_repo_path": "src/Pi/M.agda", "max_line_length": 114, "max_stars_count": 26, "max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/formal-logic", "max_stars_repo_path": "src/Pi/M.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z", "num_tokens": 1065, "size": 2721 }
module _ where open import Agda.Builtin.Bool open import Agda.Builtin.List open import Agda.Builtin.Reflection open import Agda.Builtin.Unit record R : Set₁ where field _≡_ : {A : Set} → A → A → Set refl : {A : Set} (x : A) → x ≡ x record R′ (_ : Set) : Set where module _ (r : R) (_ : {A : Set} → R′ A) where open R r macro m : Term → TC ⊤ m goal = bindTC (unify (def (quote refl) (arg (arg-info visible relevant) unknown ∷ [])) goal) λ _ → bindTC solveConstraints λ _ → bindTC (reduce goal) λ where (meta m _) → typeError (strErr "Meta" ∷ []) _ → returnTC _ test : true ≡ true test = m macro m′ : Term → TC ⊤ m′ goal = bindTC (unify (def (quote refl) (arg (arg-info visible relevant) unknown ∷ [])) goal) λ _ → bindTC (reduce goal) λ where goal@(meta m _) → bindTC (solveConstraintsMentioning (m ∷ [])) λ _ → bindTC (reduce goal) λ where (meta _ _) → typeError (strErr "Meta" ∷ []) _ → returnTC _ _ → returnTC _ test′ : true ≡ true test′ = m′
{ "alphanum_fraction": 0.5061932287, "avg_line_length": 23.7450980392, "ext": "agda", "hexsha": "14df2b2f099cc1a4ffc4d57f4cb590d8fd2d896e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "hborum/agda", "max_forks_repo_path": "test/Succeed/SolveConstraints.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "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": "hborum/agda", "max_issues_repo_path": "test/Succeed/SolveConstraints.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Succeed/SolveConstraints.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 370, "size": 1211 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.Relation open import lib.NType2 open import lib.types.Pi module lib.types.SetQuotient {i} {A : Type i} {j} where postulate -- HIT SetQuot : (R : Rel A j) → Type (lmax i j) module _ {R : Rel A j} where postulate -- HIT q[_] : (a : A) → SetQuot R quot-rel : {a₁ a₂ : A} → R a₁ a₂ → q[ a₁ ] == q[ a₂ ] SetQuot-level : is-set (SetQuot R) SetQuot-is-set = SetQuot-level module SetQuotElim {k} {P : SetQuot R → Type k} (p : (x : SetQuot R) → is-set (P x)) (q[_]* : (a : A) → P q[ a ]) (rel* : ∀ {a₁ a₂} (r : R a₁ a₂) → q[ a₁ ]* == q[ a₂ ]* [ P ↓ quot-rel r ]) where postulate -- HIT f : Π (SetQuot R) P q[_]-β : (a : A) → f q[ a ] ↦ q[ a ]* {-# REWRITE q[_]-β #-} postulate -- HIT quot-rel-β : ∀ {a₁ a₂} (r : R a₁ a₂) → apd f (quot-rel r) == rel* r open SetQuotElim public using () renaming (f to SetQuot-elim) module SetQuotRec {k} {B : Type k} (p : is-set B) (q[_]* : A → B) (rel* : ∀ {a₁ a₂} (r : R a₁ a₂) → q[ a₁ ]* == q[ a₂ ]*) where private module M = SetQuotElim (λ x → p) q[_]* (λ {a₁ a₂} r → ↓-cst-in (rel* r)) f : SetQuot R → B f = M.f open SetQuotRec public using () renaming (f to SetQuot-rec) -- If [R] is an equivalence relation, then [quot-rel] is an equivalence. module _ {R : Rel A j} (R-is-prop : ∀ {a b} → is-prop (R a b)) (R-is-refl : is-refl R) (R-is-sym : is-sym R) (R-is-trans : is-trans R) where private Q : Type (lmax i j) Q = SetQuot R R'-over-quot : Q → Q → hProp j R'-over-quot = SetQuot-rec (→-is-set $ hProp-is-set j) (λ a → SetQuot-rec (hProp-is-set j) (λ b → R a b , R-is-prop) (nType=-out ∘ lemma-a)) (λ ra₁a₂ → λ= $ SetQuot-elim (λ _ → raise-level -1 $ hProp-is-set j _ _) (λ _ → nType=-out $ lemma-b ra₁a₂) (λ _ → prop-has-all-paths-↓ $ hProp-is-set j _ _)) where abstract lemma-a : ∀ {a b₁ b₂} → R b₁ b₂ → R a b₁ == R a b₂ lemma-a rb₁b₂ = ua $ equiv (λ rab₁ → R-is-trans rab₁ rb₁b₂) (λ rab₂ → R-is-trans rab₂ (R-is-sym rb₁b₂)) (λ _ → prop-has-all-paths R-is-prop _ _) (λ _ → prop-has-all-paths R-is-prop _ _) lemma-b : ∀ {a₁ a₂ b} → R a₁ a₂ → R a₁ b == R a₂ b lemma-b ra₁a₂ = ua $ equiv (λ ra₁b → R-is-trans (R-is-sym ra₁a₂) ra₁b) (λ ra₂b → R-is-trans ra₁a₂ ra₂b) (λ _ → prop-has-all-paths R-is-prop _ _) (λ _ → prop-has-all-paths R-is-prop _ _) R-over-quot : Q → Q → Type j R-over-quot q₁ q₂ = fst (R'-over-quot q₁ q₂) abstract R-over-quot-is-prop : {q₁ q₂ : Q} → is-prop (R-over-quot q₁ q₂) R-over-quot-is-prop {q₁} {q₂} = snd (R'-over-quot q₁ q₂) R-over-quot-is-refl : (q : Q) → R-over-quot q q R-over-quot-is-refl = SetQuot-elim (λ q → raise-level -1 (R-over-quot-is-prop {q} {q})) (λ a → R-is-refl a) (λ _ → prop-has-all-paths-↓ R-is-prop) path-to-R-over-quot : {q₁ q₂ : Q} → q₁ == q₂ → R-over-quot q₁ q₂ path-to-R-over-quot {q} idp = R-over-quot-is-refl q quot-rel-equiv : ∀ {a₁ a₂ : A} → R a₁ a₂ ≃ (q[ a₁ ] == q[ a₂ ]) quot-rel-equiv {a₁} {a₂} = equiv quot-rel (path-to-R-over-quot {q[ a₁ ]} {q[ a₂ ]}) (λ _ → prop-has-all-paths (SetQuot-is-set _ _) _ _) (λ _ → prop-has-all-paths R-is-prop _ _)
{ "alphanum_fraction": 0.5185938408, "avg_line_length": 33.0961538462, "ext": "agda", "hexsha": "501a36ee8612845a30f0dc1f5596a957046d874c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "core/lib/types/SetQuotient.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "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": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "core/lib/types/SetQuotient.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "core/lib/types/SetQuotient.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1360, "size": 3442 }
module Issue4022 where open import Common.Prelude open import Agda.Builtin.Equality open import Agda.Builtin.Char.Properties open import Agda.Builtin.String.Properties open import Agda.Builtin.Float.Properties open import Issue4022.Import
{ "alphanum_fraction": 0.8506224066, "avg_line_length": 24.1, "ext": "agda", "hexsha": "8ad4ca18ce657990c7d3d1f276f57b84fb302ec5", "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/Issue4022.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/Issue4022.agda", "max_line_length": 42, "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/Issue4022.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": 55, "size": 241 }
{-# OPTIONS --cubical --no-import-sorts --guardedness --safe #-} module Cubical.Codata.M.AsLimit.M where open import Cubical.Codata.M.AsLimit.M.Base public open import Cubical.Codata.M.AsLimit.M.Properties public
{ "alphanum_fraction": 0.7674418605, "avg_line_length": 30.7142857143, "ext": "agda", "hexsha": "09247e9d2912f53c00238b2786a143ed715ccf36", "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": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Codata/M/AsLimit/M.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Codata/M/AsLimit/M.agda", "max_line_length": 64, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Codata/M/AsLimit/M.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 54, "size": 215 }
module Main where import Proof
{ "alphanum_fraction": 0.7647058824, "avg_line_length": 5.6666666667, "ext": "agda", "hexsha": "8495ec9816f1cee94702004f3968fe35ff0849ce", "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/outdated-and-incorrect/iird/Main.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/outdated-and-incorrect/iird/Main.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/outdated-and-incorrect/iird/Main.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": 8, "size": 34 }
{-# OPTIONS --copatterns --sized-types #-} -- {-# OPTIONS -v tc.size.solve:30 #-} -- {-# OPTIONS -v term:40 -v term.proj:60 --show-implicit #-} -- Andreas, 2013-10-01 Make sure trailing implicit insertion -- works with copatterns module CopatternTrailingImplicit where import Common.Level open import Common.Size open import Common.Prelude -- Sized streams record Stream (A : Set) {i : Size} : Set where coinductive field head : A tail : {j : Size< i} → Stream A {j} open Stream -- Mapping over streams map : {A B : Set} (f : A → B) {i : Size} → Stream A {i} → Stream B {i} tail (map f {i} s) {j} = map f (tail s) head (map f s) = f (head s) -- Nats defined using map nats : {i : Size} → Stream Nat {i} head nats = 0 tail nats = map suc nats -- Before this patch, Agda would insert a {_} also in the `head' clause -- leading to a type error. -- 2013-10-12 works now also without manual {_} insertion -- (See TermCheck.introHiddenLambdas.) nats' : {i : Size} → Stream Nat {i} head nats' = 0 tail nats' = map suc nats' -- Before this latest patch, the termination checker would complain -- since it would not see the type of the hidden {j : Size< i} -- which is the argument to the recursive call. -- All this would not be an issue if Agda still eagerly introduced -- trailing hidden arguments on the LHS, but this has other -- drawbacks (Q: even with varying arity?): cannot have -- hidden lambdas on rhs (used to name trailing hiddens in with-clauses).
{ "alphanum_fraction": 0.6806779661, "avg_line_length": 30.1020408163, "ext": "agda", "hexsha": "581c08721086347bb37307741f459acaf9d6e06e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "larrytheliquid/agda", "max_forks_repo_path": "test/succeed/CopatternTrailingImplicit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "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/agda", "max_issues_repo_path": "test/succeed/CopatternTrailingImplicit.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "larrytheliquid/agda", "max_stars_repo_path": "test/succeed/CopatternTrailingImplicit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 435, "size": 1475 }
{-# OPTIONS --without-K #-} -- The universe of all types module hott.core.universe where open import Agda.Primitive public using (Level; lzero; lsuc; _⊔_) -- We give an new name for Set Type : (ℓ : Level) → Set (lsuc ℓ) Type ℓ = Set ℓ lone : Level; lone = lsuc lzero ltwo : Level; ltwo = lsuc lone lthree : Level; lthree = lsuc ltwo lfour : Level; lfour = lsuc lthree lfive : Level; lfive = lsuc lfour lsix : Level; lsix = lsuc lfive lseven : Level; lseven = lsuc lsix leight : Level; leight = lsuc lseven lnine : Level; lnine = lsuc leight Type₀ = Type lzero Type₁ = Type lone Type₂ = Type ltwo Type₃ = Type lthree Type₄ = Type lfour Type₅ = Type lfive Type₆ = Type lsix Type₇ = Type lseven Type₈ = Type leight Type₉ = Type lnine
{ "alphanum_fraction": 0.6856763926, "avg_line_length": 23.5625, "ext": "agda", "hexsha": "31c6a4af94679326887fcff9e5658eee607981bc", "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": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "piyush-kurur/hott", "max_forks_repo_path": "agda/hott/core/universe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "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": "piyush-kurur/hott", "max_issues_repo_path": "agda/hott/core/universe.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "876ecdcfddca1abf499e8f00db321c6dc3d5b2bc", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "piyush-kurur/hott", "max_stars_repo_path": "agda/hott/core/universe.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 279, "size": 754 }
{-# OPTIONS --no-positivity-check #-} module STLC.Coquand.Normalisation where open import STLC.Coquand.Substitution public -------------------------------------------------------------------------------- record 𝔐 : Set₁ where field 𝒲 : Set 𝒢 : 𝒲 → Set _⊒_ : 𝒲 → 𝒲 → Set idₐ : ∀ {w} → w ⊒ w _◇_ : ∀ {w w′ w″} → w″ ⊒ w′ → w′ ⊒ w → w″ ⊒ w lid◇ : ∀ {w w′} → (ξ : w′ ⊒ w) → idₐ ◇ ξ ≡ ξ rid◇ : ∀ {w w′} → (ξ : w′ ⊒ w) → ξ ◇ idₐ ≡ ξ assoc◇ : ∀ {w w′ w″ w‴} → (ξ₁ : w‴ ⊒ w″) (ξ₂ : w″ ⊒ w′) (ξ₃ : w′ ⊒ w) → ξ₁ ◇ (ξ₂ ◇ ξ₃) ≡ (ξ₁ ◇ ξ₂) ◇ ξ₃ module _ {{𝔪 : 𝔐}} where open 𝔐 𝔪 infix 3 _⊩_ data _⊩_ : 𝒲 → 𝒯 → Set where ⟦G⟧ : ∀ {w} → (h : ∀ {w′} → (ξ : w′ ⊒ w) → 𝒢 w′) → w ⊩ ⎵ ⟦ƛ⟧ : ∀ {A B w} → (h : ∀ {w′} → (ξ : w′ ⊒ w) (a : w′ ⊩ A) → w′ ⊩ B) → w ⊩ A ⇒ B ⟦g⟧⟨_⟩ : ∀ {w w′} → w′ ⊒ w → w ⊩ ⎵ → 𝒢 w′ ⟦g⟧⟨ ξ ⟩ (⟦G⟧ f) = f ξ _⟦∙⟧⟨_⟩_ : ∀ {A B w w′} → w ⊩ A ⇒ B → w′ ⊒ w → w′ ⊩ A → w′ ⊩ B (⟦ƛ⟧ f) ⟦∙⟧⟨ ξ ⟩ a = f ξ a -- ⟦putᵣ⟧ can’t be stated here -- ⟦getᵣ⟧ can’t be stated here -- ⟦wkᵣ⟧ can’t be stated here -- ⟦liftᵣ⟧ can’t be stated here -- idₐ = ⟦idᵣ⟧ -- acc = ⟦ren⟧ acc : ∀ {A w w′} → w′ ⊒ w → w ⊩ A → w′ ⊩ A acc {⎵} ξ f = ⟦G⟧ (λ ξ′ → ⟦g⟧⟨ ξ′ ◇ ξ ⟩ f) acc {A ⇒ B} ξ f = ⟦ƛ⟧ (λ ξ′ a → f ⟦∙⟧⟨ ξ′ ◇ ξ ⟩ a) -- ⟦wk⟧ can’t be stated here -- _◇_ = _⟦○⟧_ -------------------------------------------------------------------------------- module _ {{𝔪 : 𝔐}} where open 𝔐 𝔪 mutual data Eq : ∀ {A w} → w ⊩ A → w ⊩ A → Set where eq⎵ : ∀ {w} → {f₁ f₂ : w ⊩ ⎵} → (h : ∀ {w′} → (ξ : w′ ⊒ w) → ⟦g⟧⟨ ξ ⟩ f₁ ≡ ⟦g⟧⟨ ξ ⟩ f₂) → Eq f₁ f₂ eq⊃ : ∀ {A B w} → {f₁ f₂ : w ⊩ A ⇒ B} → (h : ∀ {w′} → (ξ : w′ ⊒ w) {a : w′ ⊩ A} (u : Un a) → Eq (f₁ ⟦∙⟧⟨ ξ ⟩ a) (f₂ ⟦∙⟧⟨ ξ ⟩ a)) → Eq f₁ f₂ data Un : ∀ {A w} → w ⊩ A → Set where un⎵ : ∀ {w} → {f : w ⊩ ⎵} → Un f un⊃ : ∀ {A B w} → {f : w ⊩ A ⇒ B} → (h₁ : ∀ {w′} → (ξ : w′ ⊒ w) {a : w′ ⊩ A} (u : Un a) → Un (f ⟦∙⟧⟨ ξ ⟩ a)) → (h₂ : ∀ {w′} → (ξ : w′ ⊒ w) {a₁ a₂ : w′ ⊩ A} (p : Eq a₁ a₂) (u₁ : Un a₁) (u₂ : Un a₂) → Eq (f ⟦∙⟧⟨ ξ ⟩ a₁) (f ⟦∙⟧⟨ ξ ⟩ a₂)) → (h₃ : ∀ {w′ w″} → (ξ₁ : w″ ⊒ w′) (ξ₂ : w′ ⊒ w) {a : w′ ⊩ A} (u : Un a) → Eq (acc ξ₁ (f ⟦∙⟧⟨ ξ₂ ⟩ a)) (f ⟦∙⟧⟨ ξ₁ ◇ ξ₂ ⟩ (acc ξ₁ a))) → Un f reflEq : ∀ {A w} → {a : w ⊩ A} → Un a → Eq a a reflEq un⎵ = eq⎵ (λ ξ → refl) reflEq (un⊃ h₁ h₂ h₃) = eq⊃ (λ ξ u → reflEq (h₁ ξ u)) _⁻¹Eq : ∀ {A w} → {a₁ a₂ : w ⊩ A} → Eq a₁ a₂ → Eq a₂ a₁ _⁻¹Eq {⎵} (eq⎵ h) = eq⎵ (λ ξ → h ξ ⁻¹) _⁻¹Eq {A ⇒ B} (eq⊃ h) = eq⊃ (λ ξ u → h ξ u ⁻¹Eq) _⦙Eq_ : ∀ {A w} → {a₁ a₂ a₃ : w ⊩ A} → Eq a₁ a₂ → Eq a₂ a₃ → Eq a₁ a₃ _⦙Eq_ {⎵} (eq⎵ h₁) (eq⎵ h₂) = eq⎵ (λ ξ → h₁ ξ ⦙ h₂ ξ) _⦙Eq_ {A ⇒ B} (eq⊃ h₁) (eq⊃ h₂) = eq⊃ (λ ξ u → h₁ ξ u ⦙Eq h₂ ξ u) ≡→Eq : ∀ {A w} → {a₁ a₂ : w ⊩ A} → a₁ ≡ a₂ → Un a₁ → Eq a₁ a₂ ≡→Eq refl u = reflEq u instance perEq : ∀ {A w} → PER (w ⊩ A) Eq perEq = record { _⁻¹ = _⁻¹Eq ; _⦙_ = _⦙Eq_ } -------------------------------------------------------------------------------- module _ {{𝔪 : 𝔐}} where open 𝔐 𝔪 -- (cong⟦∙⟧⟨_⟩Eq) postulate cong⟦∙⟧Eq : ∀ {A B w w′} → {f₁ f₂ : w ⊩ A ⇒ B} {a₁ a₂ : w′ ⊩ A} → (ξ : w′ ⊒ w) → Eq f₁ f₂ → Un f₁ → Un f₂ → Eq a₁ a₂ → Un a₁ → Un a₂ → Eq (f₁ ⟦∙⟧⟨ ξ ⟩ a₁) (f₂ ⟦∙⟧⟨ ξ ⟩ a₂) cong⟦∙⟧Un : ∀ {A B w w′} → {f : w ⊩ A ⇒ B} {a : w′ ⊩ A} → (ξ : w′ ⊒ w) → Un f → Un a → Un (f ⟦∙⟧⟨ ξ ⟩ a) cong⟦∙⟧Un ξ (un⊃ h₁ h₂ h₃) u = h₁ ξ u -- (cong↑⟨_⟩Eq) postulate congaccEq : ∀ {A w w′} → {a₁ a₂ : w ⊩ A} → (ξ : w′ ⊒ w) → Eq a₁ a₂ → Eq (acc ξ a₁) (acc ξ a₂) -- (cong↑⟨_⟩𝒰) postulate congaccUn : ∀ {A w w′} → {a : w ⊩ A} → (ξ : w′ ⊒ w) → Un a → Un (acc ξ a) -- (aux₄₁₁) postulate lidaccEq : ∀ {A w} → {a : w ⊩ A} → Un a → Eq (acc idₐ a) a -- (aux₄₁₂) postulate acc◇Eq : ∀ {A w w′ w″} → {a : w ⊩ A} → (ξ₁ : w″ ⊒ w′) (ξ₂ : w′ ⊒ w) → Un a → Eq (acc (ξ₁ ◇ ξ₂) a) ((acc ξ₁ ∘ acc ξ₂) a) -- (aux₄₁₃) postulate acc⟦∙⟧idEq : ∀ {A B w w′} → {f : w ⊩ A ⇒ B} {a : w′ ⊩ A} → (ξ : w′ ⊒ w) → Un f → Un a → Eq (acc ξ f ⟦∙⟧⟨ idₐ ⟩ a) (f ⟦∙⟧⟨ ξ ⟩ a) acc⟦∙⟧Eq : ∀ {A B w w′ w″} → {f : w ⊩ A ⇒ B} {a : w′ ⊩ A} → (ξ₁ : w′ ⊒ w) (ξ₂ : w″ ⊒ w′) → Un f → Un a → Eq (acc ξ₁ f ⟦∙⟧⟨ ξ₂ ⟩ acc ξ₂ a) (acc ξ₂ (f ⟦∙⟧⟨ ξ₁ ⟩ a)) acc⟦∙⟧Eq ξ₁ ξ₂ (un⊃ h₁ h₂ h₃) u = h₃ ξ₂ ξ₁ u ⁻¹ -------------------------------------------------------------------------------- module _ {{𝔪 : 𝔐}} where open 𝔐 𝔪 infix 3 _⊩⋆_ data _⊩⋆_ : 𝒲 → 𝒞 → Set where ∅ : ∀ {w} → w ⊩⋆ ∅ _,_ : ∀ {Ξ A w} → (ρ : w ⊩⋆ Ξ) (a : w ⊩ A) → w ⊩⋆ Ξ , A -- ⟦putₛ⟧ can’t be stated here -- getᵥ = ⟦getₛ⟧ (lookup) getᵥ : ∀ {Ξ A w} → w ⊩⋆ Ξ → Ξ ∋ A → w ⊩ A getᵥ (ρ , a) zero = a getᵥ (ρ , a) (suc i) = getᵥ ρ i -- unwkᵥ ≡ ⟦unwkₛ⟧ unwkᵥ : ∀ {Ξ A w} → w ⊩⋆ Ξ , A → w ⊩⋆ Ξ unwkᵥ (ρ , a) = ρ -- ⟦wkₛ⟧ can’t be stated here -- ⟦liftₛ⟧ can’t be stated here -- ⟦idₛ⟧ can’t be stated here -- ⟦sub⟧ can’t be stated here -- ⟦cut⟧ can’t be stated here -- _◆_ can’t be stated here -------------------------------------------------------------------------------- module _ {{𝔪 : 𝔐}} where open 𝔐 𝔪 -- (⟦_◑_⟧ / ↑⟨_⟩⊩⋆) _⬗_ : ∀ {Ξ w w′} → w′ ⊒ w → w ⊩⋆ Ξ → w′ ⊩⋆ Ξ ξ ⬗ ∅ = ∅ ξ ⬗ (ρ , a) = ξ ⬗ ρ , acc ξ a -- (⟦_◐_⟧ / ↓⟨_⟩⊩⋆) _⬖_ : ∀ {Ξ Ξ′ w} → w ⊩⋆ Ξ′ → Ξ′ ∋⋆ Ξ → w ⊩⋆ Ξ ρ ⬖ ∅ = ∅ ρ ⬖ (η , i) = ρ ⬖ η , getᵥ ρ i -------------------------------------------------------------------------------- module _ {{𝔪 : 𝔐}} where open 𝔐 𝔪 zap⬖ : ∀ {Ξ Ξ′ A w} → (ρ : w ⊩⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) (a : w ⊩ A) → (ρ , a) ⬖ wkᵣ η ≡ ρ ⬖ η zap⬖ ρ ∅ a = refl zap⬖ ρ (η , i) a = (_, getᵥ ρ i) & zap⬖ ρ η a rid⬖ : ∀ {Ξ w} → (ρ : w ⊩⋆ Ξ) → ρ ⬖ idᵣ ≡ ρ rid⬖ ∅ = refl rid⬖ (ρ , a) = (_, a) & ( zap⬖ ρ idᵣ a ⦙ rid⬖ ρ ) -------------------------------------------------------------------------------- module _ {{𝔪 : 𝔐}} where open 𝔐 𝔪 get⬖ : ∀ {Ξ Ξ′ A w} → (ρ : w ⊩⋆ Ξ′) (η : Ξ′ ∋⋆ Ξ) (i : Ξ ∋ A) → getᵥ (ρ ⬖ η) i ≡ (getᵥ ρ ∘ getᵣ η) i get⬖ ρ (η , j) zero = refl get⬖ ρ (η , j) (suc i) = get⬖ ρ η i comp⬖○ : ∀ {Ξ Ξ′ Ξ″ w} → (ρ : w ⊩⋆ Ξ″) (η₁ : Ξ″ ∋⋆ Ξ′) (η₂ : Ξ′ ∋⋆ Ξ) → ρ ⬖ (η₁ ○ η₂) ≡ (ρ ⬖ η₁) ⬖ η₂ comp⬖○ σ η₁ ∅ = refl comp⬖○ σ η₁ (η₂ , i) = _,_ & comp⬖○ σ η₁ η₂ ⊗ (get⬖ σ η₁ i ⁻¹) -- wk⬖ can’t be stated here -- lift⬖ can’t be stated here -- wkrid⬖ can’t be stated here -- liftwkrid⬖ can’t be stated here -- sub⬖ can’t be stated here -- subwk⬖ can’t be stated here -- sublift⬖ can’t be stated here -- subliftwk⬖ can’t be stated here -------------------------------------------------------------------------------- module _ {{𝔪 : 𝔐}} where open 𝔐 𝔪 data Eq⋆ : ∀ {Ξ w} → w ⊩⋆ Ξ → w ⊩⋆ Ξ → Set where ∅ : ∀ {w} → Eq⋆ (∅ {w}) ∅ _,_ : ∀ {Ξ A w} → {ρ₁ ρ₂ : w ⊩⋆ Ξ} {a₁ a₂ : w ⊩ A} → (χ : Eq⋆ ρ₁ ρ₂) (p : Eq a₁ a₂) → Eq⋆ (ρ₁ , a₁) (ρ₂ , a₂) data Un⋆ : ∀ {Ξ w} → w ⊩⋆ Ξ → Set where ∅ : ∀ {w} → Un⋆ (∅ {w}) _,_ : ∀ {Ξ A w} → {ρ : w ⊩⋆ Ξ} {a : w ⊩ A} → (υ : Un⋆ ρ) (u : Un a) → Un⋆ (ρ , a) reflEq⋆ : ∀ {Ξ w} → {ρ : w ⊩⋆ Ξ} → Un⋆ ρ → Eq⋆ ρ ρ reflEq⋆ ∅ = ∅ reflEq⋆ (υ , u) = reflEq⋆ υ , reflEq u _⁻¹Eq⋆ : ∀ {Ξ w} → {ρ₁ ρ₂ : w ⊩⋆ Ξ} → Eq⋆ ρ₁ ρ₂ → Eq⋆ ρ₂ ρ₁ ∅ ⁻¹Eq⋆ = ∅ (χ , p) ⁻¹Eq⋆ = χ ⁻¹Eq⋆ , p ⁻¹Eq _⦙Eq⋆_ : ∀ {Ξ w} → {ρ₁ ρ₂ ρ₃ : w ⊩⋆ Ξ} → Eq⋆ ρ₁ ρ₂ → Eq⋆ ρ₂ ρ₃ → Eq⋆ ρ₁ ρ₃ ∅ ⦙Eq⋆ ∅ = ∅ (χ₁ , p) ⦙Eq⋆ (χ₂ , q) = χ₁ ⦙Eq⋆ χ₂ , p ⦙Eq q ≡→Eq⋆ : ∀ {Ξ w} → {ρ₁ ρ₂ : w ⊩⋆ Ξ} → ρ₁ ≡ ρ₂ → Un⋆ ρ₁ → Eq⋆ ρ₁ ρ₂ ≡→Eq⋆ refl υ = reflEq⋆ υ instance perEq⋆ : ∀ {Ξ w} → PER (w ⊩⋆ Ξ) Eq⋆ perEq⋆ = record { _⁻¹ = _⁻¹Eq⋆ ; _⦙_ = _⦙Eq⋆_ } -------------------------------------------------------------------------------- module _ {{𝔪 : 𝔐}} where open 𝔐 𝔪 -- (conglookupEq) postulate conggetEq : ∀ {Ξ A w} → {ρ₁ ρ₂ : w ⊩⋆ Ξ} → (i : Ξ ∋ A) → Eq⋆ ρ₁ ρ₂ → Eq (getᵥ ρ₁ i) (getᵥ ρ₂ i) -- (cong↑⟨_⟩Eq⋆) postulate cong⬗Eq⋆ : ∀ {Ξ w w′} → {ρ₁ ρ₂ : w ⊩⋆ Ξ} → (ξ : w′ ⊒ w) → Eq⋆ ρ₁ ρ₂ → Eq⋆ (ξ ⬗ ρ₁) (ξ ⬗ ρ₂) -- (cong↓⟨_⟩Eq⋆) postulate cong⬖Eq⋆ : ∀ {Ξ Ξ′ w} → {ρ₁ ρ₂ : w ⊩⋆ Ξ′} → Eq⋆ ρ₁ ρ₂ → (η : Ξ′ ∋⋆ Ξ) → Eq⋆ (ρ₁ ⬖ η) (ρ₂ ⬖ η) -- (conglookup𝒰) postulate conggetUn : ∀ {Ξ A w} → {ρ : w ⊩⋆ Ξ} → (i : Ξ ∋ A) → Un⋆ ρ → Un (getᵥ ρ i) -- (cong↑⟨_⟩𝒰⋆) postulate cong⬗Un⋆ : ∀ {Ξ w w′} → {ρ : w ⊩⋆ Ξ} → (ξ : w′ ⊒ w) → Un⋆ ρ → Un⋆ (ξ ⬗ ρ) -- (cong↓⟨_⟩𝒰⋆) postulate cong⬖Un⋆ : ∀ {Ξ Ξ′ w} → {ρ : w ⊩⋆ Ξ′} → (η : Ξ′ ∋⋆ Ξ) → Un⋆ ρ → Un⋆ (ρ ⬖ η) -------------------------------------------------------------------------------- module _ {{𝔪 : 𝔐}} where open 𝔐 𝔪 -- (aux₄₂₁) postulate get⬖Eq : ∀ {Ξ Ξ′ A w} → {ρ : w ⊩⋆ Ξ′} → (η : Ξ′ ∋⋆ Ξ) (i : Ξ′ ∋ A) (j : Ξ ∋ A) → Un⋆ ρ → Eq (getᵥ (ρ ⬖ η) j) (getᵥ ρ i) -- (conglookup↑⟨_⟩Eq) postulate get⬗Eq : ∀ {Ξ A w w′} → {ρ : w ⊩⋆ Ξ} → (ξ : w′ ⊒ w) (i : Ξ ∋ A) → Un⋆ ρ → Eq (getᵥ (ξ ⬗ ρ) i) (acc ξ (getᵥ ρ i)) -- (aux₄₂₃) postulate zap⬖Eq⋆ : ∀ {Ξ Ξ′ A w} → {ρ : w ⊩⋆ Ξ′} {a : w ⊩ A} → (η₁ : Ξ′ , A ∋⋆ Ξ) (η₂ : Ξ′ ∋⋆ Ξ) → Un⋆ ρ → Eq⋆ ((ρ , a) ⬖ η₁) (ρ ⬖ η₂) -- (aux₄₂₄) postulate rid⬖Eq⋆ : ∀ {Ξ w} → {ρ : w ⊩⋆ Ξ} → Un⋆ ρ → Eq⋆ (ρ ⬖ idᵣ) ρ -- (aux₄₂₅) postulate lid⬗Eq⋆ : ∀ {Ξ w} → {ρ : w ⊩⋆ Ξ} → Un⋆ ρ → Eq⋆ (idₐ ⬗ ρ) ρ -- (aux₄₂₆) postulate comp⬖○Eq⋆ : ∀ {Ξ Ξ′ Ξ″ w} → {ρ : w ⊩⋆ Ξ″} → (η₁ : Ξ″ ∋⋆ Ξ′) (η₂ : Ξ′ ∋⋆ Ξ) → Un⋆ ρ → Eq⋆ (ρ ⬖ (η₁ ○ η₂)) ((ρ ⬖ η₁) ⬖ η₂) -- (aux₄₂₇) postulate comp⬗◇Eq⋆ : ∀ {Ξ w w′ w″} → {ρ : w ⊩⋆ Ξ} → (ξ₁ : w″ ⊒ w′) (ξ₂ : w′ ⊒ w) → Un⋆ ρ → Eq⋆ (ξ₁ ⬗ (ξ₂ ⬗ ρ)) ((ξ₁ ◇ ξ₂) ⬗ ρ) -- (aux₄₂₈) postulate comp⬗⬖Eq⋆ : ∀ {Ξ Ξ′ w w′} → {ρ : w ⊩⋆ Ξ′} → (ξ : w′ ⊒ w) (η : Ξ′ ∋⋆ Ξ) → Un⋆ ρ → Eq⋆ (ξ ⬗ (ρ ⬖ η)) ((ξ ⬗ ρ) ⬖ η) -------------------------------------------------------------------------------- module _ {{𝔪 : 𝔐}} where open 𝔐 𝔪 ⟦_⟧ : ∀ {Ξ A w} → Ξ ⊢ A → w ⊩⋆ Ξ → w ⊩ A ⟦ 𝓋 i ⟧ ρ = getᵥ ρ i ⟦ ƛ M ⟧ ρ = ⟦ƛ⟧ (λ ξ a → ⟦ M ⟧ (ξ ⬗ ρ , a)) ⟦ M ∙ N ⟧ ρ = ⟦ M ⟧ ρ ⟦∙⟧⟨ idₐ ⟩ ⟦ N ⟧ ρ ⟦_⟧⋆ : ∀ {Ξ Φ w} → Ξ ⊢⋆ Φ → w ⊩⋆ Ξ → w ⊩⋆ Φ ⟦ ∅ ⟧⋆ ρ = ∅ ⟦ σ , M ⟧⋆ ρ = ⟦ σ ⟧⋆ ρ , ⟦ M ⟧ ρ -------------------------------------------------------------------------------- instance canon : 𝔐 canon = record { 𝒲 = 𝒞 ; 𝒢 = _⊢ ⎵ ; _⊒_ = _∋⋆_ ; idₐ = idᵣ ; _◇_ = _○_ ; lid◇ = lid○ ; rid◇ = rid○ ; assoc◇ = assoc○ } mutual reify : ∀ {A Γ} → Γ ⊩ A → Γ ⊢ A reify {⎵} f = ⟦g⟧⟨ idᵣ ⟩ f reify {A ⇒ B} f = ƛ (reify (f ⟦∙⟧⟨ wkᵣ idᵣ ⟩ ⟪𝓋 0 ⟫)) ⟪_⟫ : ∀ {A Γ} → (∀ {Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊢ A) → Γ ⊩ A ⟪_⟫ {⎵} f = ⟦G⟧ (λ η → f η) ⟪_⟫ {A ⇒ B} f = ⟦ƛ⟧ (λ η a → ⟪ (λ η′ → f (η′ ○ η) ∙ reify (acc η′ a)) ⟫) ⟪𝓋_⟫ : ∀ {Γ A} → Γ ∋ A → Γ ⊩ A ⟪𝓋 i ⟫ = ⟪ (λ η → ren η (𝓋 i)) ⟫ aux₄₄₁ : ∀ {A Γ} → (f₁ f₂ : ∀ {Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊢ A) → (∀ {Γ′} → (η : Γ′ ∋⋆ Γ) → f₁ η ≡ f₂ η) → Eq (⟪ f₁ ⟫) (⟪ f₂ ⟫) aux₄₄₁ {⎵} f₁ f₂ h = eq⎵ (λ η → h η) aux₄₄₁ {A ⇒ B} f₁ f₂ h = eq⊃ (λ η′ {a} u → aux₄₄₁ (λ η″ → f₁ (η″ ○ η′) ∙ reify (acc η″ a)) (λ η″ → f₂ (η″ ○ η′) ∙ reify (acc η″ a)) (λ η″ → (_∙ reify (acc η″ a)) & h (η″ ○ η′))) aux₄₄₂ : ∀ {A Γ Γ′} → (η : Γ′ ∋⋆ Γ) (f : (∀ {Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊢ A)) → Eq (acc η ⟪ f ⟫) (⟪ (λ η′ → f (η′ ○ η)) ⟫) aux₄₄₂ {⎵} η f = eq⎵ (λ η′ → f & refl) aux₄₄₂ {A ⇒ B} η f = eq⊃ (λ η′ {a} u → aux₄₄₁ (λ η″ → f (η″ ○ (η′ ○ η)) ∙ reify (acc η″ a)) (λ η″ → f ((η″ ○ η′) ○ η) ∙ reify (acc η″ a)) (λ η″ → (_∙ reify (acc η″ a)) & (f & assoc○ η″ η′ η))) -------------------------------------------------------------------------------- -- Theorem 1. mutual thm₁ : ∀ {Γ A} → {a₁ a₂ : Γ ⊩ A} → Eq a₁ a₂ → reify a₁ ≡ reify a₂ thm₁ (eq⎵ h) = h idᵣ thm₁ (eq⊃ h) = ƛ & thm₁ (h (wkᵣ idᵣ) ⟪𝓋 0 ⟫ᵤ) ⟪𝓋_⟫ᵤ : ∀ {Γ A} → (i : Γ ∋ A) → Un (⟪𝓋 i ⟫) ⟪𝓋 i ⟫ᵤ = aux₄₄₃ (λ η → 𝓋 (getᵣ η i)) aux₄₄₃ : ∀ {A Γ} → (f : ∀ {Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊢ A) → Un (⟪ f ⟫) aux₄₄₃ {⎵} f = un⎵ aux₄₄₃ {A ⇒ B} f = un⊃ (λ η {a} u → aux₄₄₃ (λ η′ → f (η′ ○ η) ∙ reify (acc η′ a))) (λ η {a₁} {a₂} p u₁ u₂ → aux₄₄₁ (λ η′ → f (η′ ○ η) ∙ reify (acc η′ a₁)) (λ η′ → f (η′ ○ η) ∙ reify (acc η′ a₂)) (λ η′ → (f (η′ ○ η) ∙_) & thm₁ (congaccEq η′ p))) (λ η₁ η₂ {a} u → aux₄₄₂ η₁ (λ η′ → f (η′ ○ η₂) ∙ reify (acc η′ a)) ⦙ aux₄₄₁ (λ η′ → f ((η′ ○ η₁) ○ η₂) ∙ reify (acc (η′ ○ η₁) a)) (λ η′ → f (η′ ○ (η₁ ○ η₂)) ∙ reify (acc η′ (acc η₁ a))) (λ η′ → _∙_ & (f & assoc○ η′ η₁ η₂ ⁻¹) ⊗ thm₁ (acc◇Eq η′ η₁ u))) -------------------------------------------------------------------------------- ⌊_⌋ᵥ : ∀ {Γ Γ′} → Γ′ ∋⋆ Γ → Γ′ ⊩⋆ Γ ⌊ ∅ ⌋ᵥ = ∅ ⌊ η , i ⌋ᵥ = ⌊ η ⌋ᵥ , ⟪𝓋 i ⟫ idᵥ : ∀ {Γ} → Γ ⊩⋆ Γ idᵥ = ⌊ idᵣ ⌋ᵥ nf : ∀ {Γ A} → Γ ⊢ A → Γ ⊢ A nf M = reify (⟦ M ⟧ idᵥ) -- Corollary 1. cor₁ : ∀ {Γ A} → (M₁ M₂ : Γ ⊢ A) → Eq (⟦ M₁ ⟧ idᵥ) (⟦ M₂ ⟧ idᵥ) → nf M₁ ≡ nf M₂ cor₁ M₁ M₂ = thm₁ --------------------------------------------------------------------------------
{ "alphanum_fraction": 0.2619105642, "avg_line_length": 28.1061643836, "ext": "agda", "hexsha": "bd2839c9a01aebbf4da266ca90d4abb3ed998735", "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/STLC/Coquand/Normalisation.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/STLC/Coquand/Normalisation.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/STLC/Coquand/Normalisation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8276, "size": 16414 }
module Haskell.RangedSets.Boundaries where open import Agda.Builtin.Nat as Nat hiding (_==_; _<_; _+_; _-_) open import Agda.Builtin.Char open import Agda.Builtin.Int using (pos; negsuc) open import Haskell.Prim open import Haskell.Prim.Ord open import Haskell.Prim.Bool open import Haskell.Prim.Char open import Haskell.Prim.Maybe open import Haskell.Prim.Enum open import Haskell.Prim.Num open import Haskell.Prim.Eq open import Haskell.Prim.Functor open import Haskell.Prim.Monoid open import Haskell.Prim.Monad open import Haskell.Prim.Applicative open import Haskell.Prim.Int open import Haskell.Prim.List open import Haskell.Prim.Integer open import Haskell.Prim.Real open import Haskell.Prim.Tuple open import Haskell.Prim.Double open import Haskell.Prim.Bounded open import Agda.Builtin.Char {-# FOREIGN AGDA2HS import Data.Ratio #-} record DiscreteOrdered (a : Set) ⦃ _ : Ord a ⦄ : Set where field adjacent : a → a → Bool adjacentBelow : a → Maybe a open DiscreteOrdered ⦃ ... ⦄ public {-# COMPILE AGDA2HS DiscreteOrdered class #-} orderingFromInt : Int → Ordering orderingFromInt n = if_then_else_ (n == 0) LT (if_then_else_ (n == 1) EQ GT) {-# COMPILE AGDA2HS orderingFromInt #-} boundedAdjacentBool : (x y : Bool) → Bool boundedAdjacentBool x y = if_then_else_ (x < y) true false {-# COMPILE AGDA2HS boundedAdjacentBool #-} boundedBelowBool : (x : Bool) → Maybe Bool boundedBelowBool x = if_then_else_ (x == false) Nothing (Just false) {-# COMPILE AGDA2HS boundedBelowBool #-} boundedAdjacentOrdering : (x y : Ordering) → Bool boundedAdjacentOrdering x y = if_then_else_ (x < y && x < GT) ((fromEnum x) + 1 == (fromEnum y)) false {-# COMPILE AGDA2HS boundedAdjacentOrdering #-} boundedBelowOrdering : (x : Ordering) → Maybe Ordering boundedBelowOrdering x = if_then_else_ (x == LT) Nothing (Just (orderingFromInt ((fromEnum x) - 1))) {-# COMPILE AGDA2HS boundedBelowOrdering #-} boundedAdjacentChar : (x y : Char) → Bool boundedAdjacentChar x y = if_then_else_ (x < y && x /= '\1114111') (((fromEnum x) + 1) == fromEnum y) false {-# COMPILE AGDA2HS boundedAdjacentChar #-} boundedBelowChar : (x : Char) → Maybe Char boundedBelowChar x = if_then_else_ (x == '\0') Nothing (Just (chr ((ord x) - 1))) {-# COMPILE AGDA2HS boundedBelowChar #-} boundedAdjacentInt : (x y : Int) → Bool boundedAdjacentInt x y = if_then_else_ (x < y && x /= 9223372036854775807) (x + 1 == y) false {-# COMPILE AGDA2HS boundedAdjacentInt #-} boundedBelowInt : (x : Int) → Maybe Int boundedBelowInt x = if_then_else_ (x == -9223372036854775808) Nothing (Just (x - 1)) {-# COMPILE AGDA2HS boundedBelowInt #-} boundedAdjacentInteger : (x y : Integer) → Bool boundedAdjacentInteger x y = ((fromEnum x) + 1 == (fromEnum y)) {-# COMPILE AGDA2HS boundedAdjacentInteger #-} boundedBelowInteger : (x : Integer) → Maybe Integer boundedBelowInteger x = Just (x - (toInteger 1)) {-# COMPILE AGDA2HS boundedBelowInteger #-} constructTuple : ⦃ o : Ord a ⦄ → ⦃ o2 : Ord b ⦄ → ⦃ DiscreteOrdered b ⦃ o2 ⦄ ⦄ → a → Maybe b → Maybe (a × b) constructTuple _ Nothing = Nothing constructTuple a (Just value) = Just (a , value) {-# COMPILE AGDA2HS constructTuple #-} constructTriple : ⦃ Ord a ⦄ → ⦃ Ord b ⦄ → ⦃ o : Ord c ⦄ → ⦃ DiscreteOrdered c ⦃ o ⦄ ⦄ → a → b → Maybe c → Maybe (a × b × c) constructTriple _ _ Nothing = Nothing constructTriple a b (Just value) = Just (a , b , value) {-# COMPILE AGDA2HS constructTriple #-} constructQuadtruple : ⦃ Ord a ⦄ → ⦃ Ord b ⦄ → ⦃ Ord c ⦄ → ⦃ o : Ord d ⦄ → ⦃ DiscreteOrdered d ⦃ o ⦄ ⦄ → a → b → c → Maybe d → Maybe (Tuple (a ∷ b ∷ c ∷ d ∷ [])) constructQuadtruple _ _ _ Nothing = Nothing constructQuadtruple a b c (Just value) = Just (a ∷ b ∷ c ∷ value ∷ []) {-# COMPILE AGDA2HS constructQuadtruple #-} instance isDiscreteOrderedBool : DiscreteOrdered Bool isDiscreteOrderedBool . adjacent = boundedAdjacentBool isDiscreteOrderedBool . adjacentBelow = boundedBelowBool {-# COMPILE AGDA2HS isDiscreteOrderedBool #-} instance isDiscreteOrderedOrdering : DiscreteOrdered Ordering isDiscreteOrderedOrdering . adjacent = boundedAdjacentOrdering isDiscreteOrderedOrdering . adjacentBelow = boundedBelowOrdering {-# COMPILE AGDA2HS isDiscreteOrderedOrdering #-} instance isDiscreteOrderedChar : DiscreteOrdered Char isDiscreteOrderedChar . adjacent = boundedAdjacentChar isDiscreteOrderedChar . adjacentBelow = boundedBelowChar {-# COMPILE AGDA2HS isDiscreteOrderedChar #-} instance isDiscreteOrderedInt : DiscreteOrdered Int isDiscreteOrderedInt . adjacent = boundedAdjacentInt isDiscreteOrderedInt . adjacentBelow = boundedBelowInt {-# COMPILE AGDA2HS isDiscreteOrderedInt #-} instance isDiscreteOrderedInteger : DiscreteOrdered Integer isDiscreteOrderedInteger . adjacent = boundedAdjacentInteger isDiscreteOrderedInteger . adjacentBelow = boundedBelowInteger {-# COMPILE AGDA2HS isDiscreteOrderedInteger #-} instance isDiscreteOrderedDouble : DiscreteOrdered Double isDiscreteOrderedDouble . adjacent x y = false isDiscreteOrderedDouble . adjacentBelow x = Nothing {-# COMPILE AGDA2HS isDiscreteOrderedDouble #-} instance isDiscreteOrderedList : ⦃ o : Ord a ⦄ → ⦃ ol : Ord (List a) ⦄ → DiscreteOrdered (List a) ⦃ ol ⦄ isDiscreteOrderedList . adjacent x y = false isDiscreteOrderedList . adjacentBelow x = Nothing {-# COMPILE AGDA2HS isDiscreteOrderedList #-} instance isDiscreteOrderedRatio : ⦃ o : Ord a ⦄ → ⦃ Integral a ⦄ → ⦃ or : Ord (Ratio a )⦄ → DiscreteOrdered (Ratio a) ⦃ or ⦄ isDiscreteOrderedRatio . adjacent x y = false isDiscreteOrderedRatio . adjacentBelow x = Nothing {-# COMPILE AGDA2HS isDiscreteOrderedRatio #-} instance isDiscreteOrderedTuple : ⦃ Ord a ⦄ → ⦃ o : Ord b ⦄ → ⦃ DiscreteOrdered b ⦃ o ⦄ ⦄ → ⦃ ot : Ord (a × b) ⦄ → DiscreteOrdered (a × b) ⦃ ot ⦄ isDiscreteOrderedTuple . adjacent (x1 , x2) (y1 , y2) = (x1 == y1) && (adjacent x2 y2) isDiscreteOrderedTuple . adjacentBelow (x1 , x2) = constructTuple x1 (adjacentBelow x2) {-# COMPILE AGDA2HS isDiscreteOrderedTuple #-} instance isDiscreteOrderedTriple : ⦃ Ord a ⦄ → ⦃ Ord b ⦄ → ⦃ o : Ord c ⦄ → ⦃ DiscreteOrdered c ⦃ o ⦄ ⦄ → ⦃ ot : Ord (a × b × c) ⦄ → DiscreteOrdered (a × b × c) ⦃ ot ⦄ isDiscreteOrderedTriple . adjacent (x1 , x2 , x3) (y1 , y2 , y3) = (x1 == y1) && (x2 == y2) && (adjacent x3 y3) isDiscreteOrderedTriple . adjacentBelow (x1 , x2 , x3) = constructTriple x1 x2 (adjacentBelow x3) {-# COMPILE AGDA2HS isDiscreteOrderedTriple #-} instance isDiscreteOrderedQuadtruple : ⦃ Ord a ⦄ → ⦃ Ord b ⦄ → ⦃ Ord c ⦄ → ⦃ o : Ord d ⦄ → ⦃ DiscreteOrdered d ⦃ o ⦄ ⦄ → ⦃ ot : Ord (Tuple (a ∷ b ∷ c ∷ d ∷ [])) ⦄ → DiscreteOrdered (Tuple (a ∷ b ∷ c ∷ d ∷ [])) ⦃ ot ⦄ isDiscreteOrderedQuadtruple . adjacent (x1 ∷ x2 ∷ x3 ∷ x4 ∷ []) (y1 ∷ y2 ∷ y3 ∷ y4 ∷ []) = (x1 == y1) && (x2 == y2) && (x3 == y3) && (adjacent x4 y4) isDiscreteOrderedQuadtruple . adjacentBelow (x1 ∷ x2 ∷ x3 ∷ x4 ∷ []) = constructQuadtruple x1 x2 x3 (adjacentBelow x4) {-# COMPILE AGDA2HS isDiscreteOrderedQuadtruple #-} data Boundary (a : Set) ⦃ b : Ord a ⦄ ⦃ _ : DiscreteOrdered a ⦃ b ⦄ ⦄ : Set where BoundaryAbove : a → Boundary a BoundaryBelow : a → Boundary a BoundaryAboveAll : Boundary a BoundaryBelowAll : Boundary a {-# COMPILE AGDA2HS Boundary #-} above : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → Boundary a ⦃ o ⦄ → a → Bool above (BoundaryAbove b) a = a > b above (BoundaryBelow b) a = a >= b above BoundaryAboveAll _ = false above BoundaryBelowAll _ = true {-# COMPILE AGDA2HS above #-} infixr 4 _/>/_ _/>/_ : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → a → Boundary a ⦃ o ⦄ → Bool _/>/_ x (BoundaryAbove b) = x > b _/>/_ x (BoundaryBelow b) = x >= b _/>/_ _ BoundaryAboveAll = false _/>/_ _ BoundaryBelowAll = true {-# COMPILE AGDA2HS _/>/_ #-} instance isBoundaryEq : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → Eq (Boundary a) isBoundaryEq . _==_ (BoundaryAbove b1) (BoundaryAbove b2) = (b1 == b2) isBoundaryEq . _==_ (BoundaryAbove b1) (BoundaryBelow b2) = if_then_else_ (b1 < b2 && (adjacent b1 b2)) true false isBoundaryEq . _==_ (BoundaryBelow b1) (BoundaryBelow b2) = (b1 == b2) isBoundaryEq . _==_ (BoundaryBelow b1) (BoundaryAbove b2) = if_then_else_ (b1 > b2 && (adjacent b2 b1)) true false isBoundaryEq . _==_ BoundaryAboveAll BoundaryAboveAll = true isBoundaryEq . _==_ BoundaryBelowAll BoundaryBelowAll = true isBoundaryEq . _==_ _ _ = false {-# COMPILE AGDA2HS isBoundaryEq #-} instance isBoundaryOrd : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → Ord (Boundary a) isBoundaryOrd . compare (BoundaryAbove b1) (BoundaryAbove b2) = compare b1 b2 isBoundaryOrd . compare (BoundaryAbove b1) (BoundaryBelow b2) = if_then_else_ (b1 < b2) (if_then_else_ (adjacent b1 b2) EQ LT) GT isBoundaryOrd . compare (BoundaryAbove b1) BoundaryAboveAll = LT isBoundaryOrd . compare (BoundaryAbove b1) BoundaryBelowAll = GT isBoundaryOrd . compare (BoundaryBelow b1) (BoundaryBelow b2) = compare b1 b2 isBoundaryOrd . compare (BoundaryBelow b1) (BoundaryAbove b2) = if_then_else_ (b1 > b2) (if_then_else_ (adjacent b2 b1) EQ GT) LT isBoundaryOrd . compare (BoundaryBelow b1) BoundaryAboveAll = LT isBoundaryOrd . compare (BoundaryBelow b1) BoundaryBelowAll = GT isBoundaryOrd . compare BoundaryAboveAll BoundaryAboveAll = EQ isBoundaryOrd . compare BoundaryAboveAll _ = GT isBoundaryOrd . compare BoundaryBelowAll BoundaryBelowAll = EQ isBoundaryOrd . compare BoundaryBelowAll _ = LT isBoundaryOrd ._<_ x y = compare x y == LT isBoundaryOrd ._>_ x y = compare x y == GT isBoundaryOrd ._<=_ x BoundaryAboveAll = true isBoundaryOrd ._<=_ BoundaryBelowAll y = true isBoundaryOrd ._<=_ x y = (compare x y == LT) || (compare x y == EQ) isBoundaryOrd ._>=_ x y = (compare x y == GT) || (compare x y == EQ) isBoundaryOrd .max x y = if (compare x y == GT) then x else y isBoundaryOrd .min x y = if (compare x y == LT) then x else y {-# COMPILE AGDA2HS isBoundaryOrd #-}
{ "alphanum_fraction": 0.6820583056, "avg_line_length": 44.2510822511, "ext": "agda", "hexsha": "6036eb6e5b430181d5c18728cb15924e3a40ca79", "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": "17cdbeb36af3d0b735c5db83bb811034c39a19cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ioanasv/agda2hs", "max_forks_repo_path": "lib/Haskell/RangedSets/Boundaries.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd", "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": "ioanasv/agda2hs", "max_issues_repo_path": "lib/Haskell/RangedSets/Boundaries.agda", "max_line_length": 153, "max_stars_count": 1, "max_stars_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ioanasv/agda2hs", "max_stars_repo_path": "lib/Haskell/RangedSets/Boundaries.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-25T09:41:34.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T09:41:34.000Z", "num_tokens": 3315, "size": 10222 }
open import Prelude module Implicits.Resolution.Termination.Lemmas.Stack where open import Induction.WellFounded open import Induction.Nat open import Data.Fin.Substitution open import Implicits.Syntax open import Implicits.Substitutions open import Implicits.Substitutions.Lemmas open import Data.Nat hiding (_<_) open import Data.Nat.Properties open import Implicits.Resolution.Termination.SizeMeasures open import Implicits.Resolution.Termination.Stack open import Data.Nat.Base +k<+k : ∀ {n m} k → n N< m → k N+ n N< k N+ m +k<+k zero p = p +k<+k (suc k) p = s≤s (+k<+k k p) +k<+k' : ∀ {n m} k → n N< m → n N+ k N< m N+ k +k<+k' {n} {m} k p = subst₂ (λ u v → u N< v) (+-comm k n) (+-comm k m) (+k<+k k p) where open import Data.Nat.Properties.Simple -k<-k : ∀ {n m} k → k N+ n N< k N+ m → n < m -k<-k zero x = x -k<-k (suc k) (s≤s x) = -k<-k k x -k<-k' : ∀ {n m} k → n N+ k N< m N+ k → n < m -k<-k' {n} {m} k p = -k<-k k (subst₂ _N<_ (+-comm n k) (+-comm m k) p) where open import Data.Nat.Properties.Simple ---------------------------------------------------------------- -- stack properties push< : ∀ {ν r a} {Δ : ICtx ν} (s : Stack Δ) (r∈Δ : r List.∈ Δ) → (, a) ρ< (, s get r∈Δ) → (s push a for r∈Δ) s< s push< (b All.∷ s) (here _) a<b = +k<+k' (ssum s) a<b push< (b All.∷ s) (there r∈Δ) p = +k<+k h|| b || (push< s r∈Δ p) push≮ : ∀ {ν r a} {Δ : ICtx ν} (s : Stack Δ) (r∈Δ : r List.∈ Δ) → ¬ ((, a) ρ< (, s get r∈Δ)) → ¬ (s push a for r∈Δ) s< s push≮ (b All.∷ s) (here _) ¬a<b = λ x → ¬a<b (-k<-k' (ssum s) x) push≮ (b All.∷ s) (there r∈Δ) ¬a<b = λ x → push≮ s r∈Δ ¬a<b (-k<-k h|| b || x) ---------------------------------------------------------------- -- a type dominates a stack if pushing it to the stack makes the stack bigger _for_?⊬dom_ : ∀ {ν r} {Δ : ICtx ν} → (a : Type ν) → (r∈Δ : r List.∈ Δ) → (s : Stack Δ) → Dec (a for r∈Δ ⊬dom s) a for r∈Δ ?⊬dom s with (, a) ρ<? (, s get r∈Δ) a for r∈Δ ?⊬dom s | yes p = yes (push< s r∈Δ p) a for r∈Δ ?⊬dom s | no ¬p = no (push≮ s r∈Δ ¬p) -- we also show that the ordering on stacks is well founded s<-well-founded : ∀ {ν} {Δ : ICtx ν} → Well-founded (_s<_ {ν} {Δ}) s<-well-founded = sub.well-founded (image.well-founded <-well-founded) where open import Data.Nat.Base open import Data.Nat.Properties module sub = Inverse-image (λ{ s → ssum s}) module image = Subrelation {A = ℕ} {_N<_} {_<′_} ≤⇒≤′ {-} -- we can show that our strict size measure a ρ< b is well founded -- by relating it to the well-foundedness proof of _<'_ sρ<-well-founded : Well-founded _sρ<_ sρ<-well-founded = sub.well-founded (image.well-founded <-well-founded) where module sub = Inverse-image (λ{ (_ , a) → || a ||}) module image = Subrelation {A = ℕ} {_N<_} {_<′_} ≤⇒≤′ -}
{ "alphanum_fraction": 0.5531227566, "avg_line_length": 36.1818181818, "ext": "agda", "hexsha": "6d06724d58f150c69175c85c9e676146f730be2f", "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/Termination/Lemmas/Stack.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/Termination/Lemmas/Stack.agda", "max_line_length": 88, "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/Termination/Lemmas/Stack.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": 1127, "size": 2786 }
module Issue555c where import Common.Level record R {a} (A : Set a) : Set record R A where field f : A
{ "alphanum_fraction": 0.6822429907, "avg_line_length": 13.375, "ext": "agda", "hexsha": "a50ef31a6e398e74ae66af5dba5d5b00538a0f75", "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/Issue555c.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/Issue555c.agda", "max_line_length": 30, "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/Issue555c.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": 34, "size": 107 }
------------------------------------------------------------------------------ -- Inductive PA properties using the induction principle ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module PA.Inductive.PropertiesByInductionATP where open import PA.Inductive.Base open import PA.Inductive.PropertiesByInduction ------------------------------------------------------------------------------ +-comm : ∀ m n → m + n ≡ n + m +-comm m n = ℕ-ind A A0 is m where A : ℕ → Set A i = i + n ≡ n + i {-# ATP definition A #-} A0 : A zero A0 = sym (+-rightIdentity n) postulate is : ∀ i → A i → A (succ i) -- TODO (21 November 2014). See Apia issue 16 -- {-# ATP prove is x+Sy≡S[x+y] #-}
{ "alphanum_fraction": 0.4318936877, "avg_line_length": 30.1, "ext": "agda", "hexsha": "06c7fadd3ef81d1470777d01096fc58874fb5d8b", "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/PA/Inductive/PropertiesByInductionATP.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/PA/Inductive/PropertiesByInductionATP.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/PA/Inductive/PropertiesByInductionATP.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": 207, "size": 903 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Pointwise sum ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Sum.Relation.Binary.Pointwise where open import Data.Product using (_,_) open import Data.Sum as Sum open import Data.Sum.Properties open import Level using (_⊔_) open import Function using (_∘_; id) open import Function.Inverse using (Inverse) open import Relation.Nullary import Relation.Nullary.Decidable as Dec open import Relation.Binary open import Relation.Binary.PropositionalEquality as P using (_≡_) ---------------------------------------------------------------------- -- Definition data Pointwise {a b c d r s} {A : Set a} {B : Set b} {C : Set c} {D : Set d} (R : REL A C r) (S : REL B D s) : REL (A ⊎ B) (C ⊎ D) (a ⊔ b ⊔ c ⊔ d ⊔ r ⊔ s) where inj₁ : ∀ {a c} → R a c → Pointwise R S (inj₁ a) (inj₁ c) inj₂ : ∀ {b d} → S b d → Pointwise R S (inj₂ b) (inj₂ d) ---------------------------------------------------------------------- -- Relational properties module _ {a₁ a₂ ℓ₁ ℓ₂} {A₁ : Set a₁} {A₂ : Set a₂} {∼₁ : Rel A₁ ℓ₁} {∼₂ : Rel A₂ ℓ₂} where drop-inj₁ : ∀ {x y} → Pointwise ∼₁ ∼₂ (inj₁ x) (inj₁ y) → ∼₁ x y drop-inj₁ (inj₁ x) = x drop-inj₂ : ∀ {x y} → Pointwise ∼₁ ∼₂ (inj₂ x) (inj₂ y) → ∼₂ x y drop-inj₂ (inj₂ x) = x ⊎-refl : Reflexive ∼₁ → Reflexive ∼₂ → Reflexive (Pointwise ∼₁ ∼₂) ⊎-refl refl₁ refl₂ {inj₁ x} = inj₁ refl₁ ⊎-refl refl₁ refl₂ {inj₂ y} = inj₂ refl₂ ⊎-symmetric : Symmetric ∼₁ → Symmetric ∼₂ → Symmetric (Pointwise ∼₁ ∼₂) ⊎-symmetric sym₁ sym₂ (inj₁ x) = inj₁ (sym₁ x) ⊎-symmetric sym₁ sym₂ (inj₂ x) = inj₂ (sym₂ x) ⊎-transitive : Transitive ∼₁ → Transitive ∼₂ → Transitive (Pointwise ∼₁ ∼₂) ⊎-transitive trans₁ trans₂ (inj₁ x) (inj₁ y) = inj₁ (trans₁ x y) ⊎-transitive trans₁ trans₂ (inj₂ x) (inj₂ y) = inj₂ (trans₂ x y) ⊎-asymmetric : Asymmetric ∼₁ → Asymmetric ∼₂ → Asymmetric (Pointwise ∼₁ ∼₂) ⊎-asymmetric asym₁ asym₂ (inj₁ x) = λ { (inj₁ y) → asym₁ x y } ⊎-asymmetric asym₁ asym₂ (inj₂ x) = λ { (inj₂ y) → asym₂ x y } ⊎-substitutive : ∀ {ℓ₃} → Substitutive ∼₁ ℓ₃ → Substitutive ∼₂ ℓ₃ → Substitutive (Pointwise ∼₁ ∼₂) ℓ₃ ⊎-substitutive subst₁ subst₂ P (inj₁ x) = subst₁ (P ∘ inj₁) x ⊎-substitutive subst₁ subst₂ P (inj₂ x) = subst₂ (P ∘ inj₂) x ⊎-decidable : Decidable ∼₁ → Decidable ∼₂ → Decidable (Pointwise ∼₁ ∼₂) ⊎-decidable _≟₁_ _≟₂_ (inj₁ x) (inj₁ y) = Dec.map′ inj₁ drop-inj₁ (x ≟₁ y) ⊎-decidable _≟₁_ _≟₂_ (inj₁ x) (inj₂ y) = no λ() ⊎-decidable _≟₁_ _≟₂_ (inj₂ x) (inj₁ y) = no λ() ⊎-decidable _≟₁_ _≟₂_ (inj₂ x) (inj₂ y) = Dec.map′ inj₂ drop-inj₂ (x ≟₂ y) module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} {ℓ₁ ℓ₂} {∼₁ : Rel A₁ ℓ₁} {≈₁ : Rel A₁ ℓ₂} {ℓ₃ ℓ₄} {∼₂ : Rel A₂ ℓ₃} {≈₂ : Rel A₂ ℓ₄} where ⊎-reflexive : ≈₁ ⇒ ∼₁ → ≈₂ ⇒ ∼₂ → (Pointwise ≈₁ ≈₂) ⇒ (Pointwise ∼₁ ∼₂) ⊎-reflexive refl₁ refl₂ (inj₁ x) = inj₁ (refl₁ x) ⊎-reflexive refl₁ refl₂ (inj₂ x) = inj₂ (refl₂ x) ⊎-irreflexive : Irreflexive ≈₁ ∼₁ → Irreflexive ≈₂ ∼₂ → Irreflexive (Pointwise ≈₁ ≈₂) (Pointwise ∼₁ ∼₂) ⊎-irreflexive irrefl₁ irrefl₂ (inj₁ x) (inj₁ y) = irrefl₁ x y ⊎-irreflexive irrefl₁ irrefl₂ (inj₂ x) (inj₂ y) = irrefl₂ x y ⊎-antisymmetric : Antisymmetric ≈₁ ∼₁ → Antisymmetric ≈₂ ∼₂ → Antisymmetric (Pointwise ≈₁ ≈₂) (Pointwise ∼₁ ∼₂) ⊎-antisymmetric antisym₁ antisym₂ (inj₁ x) (inj₁ y) = inj₁ (antisym₁ x y) ⊎-antisymmetric antisym₁ antisym₂ (inj₂ x) (inj₂ y) = inj₂ (antisym₂ x y) ⊎-respectsˡ : ∼₁ Respectsˡ ≈₁ → ∼₂ Respectsˡ ≈₂ → (Pointwise ∼₁ ∼₂) Respectsˡ (Pointwise ≈₁ ≈₂) ⊎-respectsˡ resp₁ resp₂ (inj₁ x) (inj₁ y) = inj₁ (resp₁ x y) ⊎-respectsˡ resp₁ resp₂ (inj₂ x) (inj₂ y) = inj₂ (resp₂ x y) ⊎-respectsʳ : ∼₁ Respectsʳ ≈₁ → ∼₂ Respectsʳ ≈₂ → (Pointwise ∼₁ ∼₂) Respectsʳ (Pointwise ≈₁ ≈₂) ⊎-respectsʳ resp₁ resp₂ (inj₁ x) (inj₁ y) = inj₁ (resp₁ x y) ⊎-respectsʳ resp₁ resp₂ (inj₂ x) (inj₂ y) = inj₂ (resp₂ x y) ⊎-respects₂ : ∼₁ Respects₂ ≈₁ → ∼₂ Respects₂ ≈₂ → (Pointwise ∼₁ ∼₂) Respects₂ (Pointwise ≈₁ ≈₂) ⊎-respects₂ (r₁ , l₁) (r₂ , l₂) = ⊎-respectsʳ r₁ r₂ , ⊎-respectsˡ l₁ l₂ ---------------------------------------------------------------------- -- Structures module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} {ℓ₁ ℓ₂} {≈₁ : Rel A₁ ℓ₁} {≈₂ : Rel A₂ ℓ₂} where ⊎-isEquivalence : IsEquivalence ≈₁ → IsEquivalence ≈₂ → IsEquivalence (Pointwise ≈₁ ≈₂) ⊎-isEquivalence eq₁ eq₂ = record { refl = ⊎-refl (refl eq₁) (refl eq₂) ; sym = ⊎-symmetric (sym eq₁) (sym eq₂) ; trans = ⊎-transitive (trans eq₁) (trans eq₂) } where open IsEquivalence ⊎-isDecEquivalence : IsDecEquivalence ≈₁ → IsDecEquivalence ≈₂ → IsDecEquivalence (Pointwise ≈₁ ≈₂) ⊎-isDecEquivalence eq₁ eq₂ = record { isEquivalence = ⊎-isEquivalence (isEquivalence eq₁) (isEquivalence eq₂) ; _≟_ = ⊎-decidable (_≟_ eq₁) (_≟_ eq₂) } where open IsDecEquivalence module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂} {ℓ₁ ℓ₂} {≈₁ : Rel A₁ ℓ₁} {∼₁ : Rel A₁ ℓ₂} {ℓ₃ ℓ₄} {≈₂ : Rel A₂ ℓ₃} {∼₂ : Rel A₂ ℓ₄} where ⊎-isPreorder : IsPreorder ≈₁ ∼₁ → IsPreorder ≈₂ ∼₂ → IsPreorder (Pointwise ≈₁ ≈₂) (Pointwise ∼₁ ∼₂) ⊎-isPreorder pre₁ pre₂ = record { isEquivalence = ⊎-isEquivalence (isEquivalence pre₁) (isEquivalence pre₂) ; reflexive = ⊎-reflexive (reflexive pre₁) (reflexive pre₂) ; trans = ⊎-transitive (trans pre₁) (trans pre₂) } where open IsPreorder ⊎-isPartialOrder : IsPartialOrder ≈₁ ∼₁ → IsPartialOrder ≈₂ ∼₂ → IsPartialOrder (Pointwise ≈₁ ≈₂) (Pointwise ∼₁ ∼₂) ⊎-isPartialOrder po₁ po₂ = record { isPreorder = ⊎-isPreorder (isPreorder po₁) (isPreorder po₂) ; antisym = ⊎-antisymmetric (antisym po₁) (antisym po₂) } where open IsPartialOrder ⊎-isStrictPartialOrder : IsStrictPartialOrder ≈₁ ∼₁ → IsStrictPartialOrder ≈₂ ∼₂ → IsStrictPartialOrder (Pointwise ≈₁ ≈₂) (Pointwise ∼₁ ∼₂) ⊎-isStrictPartialOrder spo₁ spo₂ = record { isEquivalence = ⊎-isEquivalence (isEquivalence spo₁) (isEquivalence spo₂) ; irrefl = ⊎-irreflexive (irrefl spo₁) (irrefl spo₂) ; trans = ⊎-transitive (trans spo₁) (trans spo₂) ; <-resp-≈ = ⊎-respects₂ (<-resp-≈ spo₁) (<-resp-≈ spo₂) } where open IsStrictPartialOrder ------------------------------------------------------------------------ -- Packages module _ {a b c d} where ⊎-setoid : Setoid a b → Setoid c d → Setoid _ _ ⊎-setoid s₁ s₂ = record { isEquivalence = ⊎-isEquivalence (isEquivalence s₁) (isEquivalence s₂) } where open Setoid ⊎-decSetoid : DecSetoid a b → DecSetoid c d → DecSetoid _ _ ⊎-decSetoid ds₁ ds₂ = record { isDecEquivalence = ⊎-isDecEquivalence (isDecEquivalence ds₁) (isDecEquivalence ds₂) } where open DecSetoid -- Some additional notation for combining setoids infix 4 _⊎ₛ_ _⊎ₛ_ : Setoid a b → Setoid c d → Setoid _ _ _⊎ₛ_ = ⊎-setoid module _ {a b c d e f} where ⊎-preorder : Preorder a b c → Preorder d e f → Preorder _ _ _ ⊎-preorder p₁ p₂ = record { isPreorder = ⊎-isPreorder (isPreorder p₁) (isPreorder p₂) } where open Preorder ⊎-poset : Poset a b c → Poset a b c → Poset _ _ _ ⊎-poset po₁ po₂ = record { isPartialOrder = ⊎-isPartialOrder (isPartialOrder po₁) (isPartialOrder po₂) } where open Poset ------------------------------------------------------------------------ -- The propositional equality setoid over products can be -- decomposed using Pointwise module _ {a b} {A : Set a} {B : Set b} where Pointwise-≡⇒≡ : (Pointwise _≡_ _≡_) ⇒ _≡_ {A = A ⊎ B} Pointwise-≡⇒≡ (inj₁ x) = P.cong inj₁ x Pointwise-≡⇒≡ (inj₂ x) = P.cong inj₂ x ≡⇒Pointwise-≡ : _≡_ {A = A ⊎ B} ⇒ (Pointwise _≡_ _≡_) ≡⇒Pointwise-≡ P.refl = ⊎-refl P.refl P.refl Pointwise-≡↔≡ : ∀ {a b} (A : Set a) (B : Set b) → Inverse (P.setoid A ⊎ₛ P.setoid B) (P.setoid (A ⊎ B)) Pointwise-≡↔≡ _ _ = record { to = record { _⟨$⟩_ = id; cong = Pointwise-≡⇒≡ } ; from = record { _⟨$⟩_ = id; cong = ≡⇒Pointwise-≡ } ; inverse-of = record { left-inverse-of = λ _ → ⊎-refl P.refl P.refl ; right-inverse-of = λ _ → P.refl } } ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.0 module _ {a b c d r s} {A : Set a} {B : Set b} {C : Set c} {D : Set d} {R : REL A C r} {S : REL B D s} where ₁∼₁ : ∀ {a c} → R a c → Pointwise R S (inj₁ a) (inj₁ c) ₁∼₁ = inj₁ {-# WARNING_ON_USAGE ₁∼₁ "Warning: ₁∼₁ was deprecated in v1.0. Please use inj₁ in `Data.Sum.Properties` instead." #-} ₂∼₂ : ∀ {b d} → S b d → Pointwise R S (inj₂ b) (inj₂ d) ₂∼₂ = inj₂ {-# WARNING_ON_USAGE ₂∼₂ "Warning: ₂∼₂ was deprecated in v1.0. Please use inj₂ in `Data.Sum.Properties` instead." #-} _⊎-≟_ : ∀ {a b} {A : Set a} {B : Set b} → Decidable {A = A} _≡_ → Decidable {A = B} _≡_ → Decidable {A = A ⊎ B} _≡_ (dec₁ ⊎-≟ dec₂) s₁ s₂ = Dec.map′ Pointwise-≡⇒≡ ≡⇒Pointwise-≡ (s₁ ≟ s₂) where open DecSetoid (⊎-decSetoid (P.decSetoid dec₁) (P.decSetoid dec₂)) {-# WARNING_ON_USAGE _⊎-≟_ "Warning: _⊎-≟_ was deprecated in v1.0. Please use ≡-dec in `Data.Sum.Properties` instead." #-}
{ "alphanum_fraction": 0.5422711356, "avg_line_length": 37.0185185185, "ext": "agda", "hexsha": "ace2bf50b585066bfb71d91944b00601255726b1", "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": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Sum/Relation/Binary/Pointwise.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/Sum/Relation/Binary/Pointwise.agda", "max_line_length": 76, "max_stars_count": null, "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/Sum/Relation/Binary/Pointwise.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3969, "size": 9995 }
module Human.IO where postulate IO : ∀ {a} → Set a → Set a {-# BUILTIN IO IO #-}
{ "alphanum_fraction": 0.5975609756, "avg_line_length": 16.4, "ext": "agda", "hexsha": "551c6b3edd4a665219d11c10c4c5774bc7911dcb", "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": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MaisaMilena/JuiceMaker", "max_forks_repo_path": "src/Human/IO.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "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": "MaisaMilena/JuiceMaker", "max_issues_repo_path": "src/Human/IO.agda", "max_line_length": 36, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MaisaMilena/JuiceMaker", "max_stars_repo_path": "src/Human/IO.agda", "max_stars_repo_stars_event_max_datetime": "2020-11-28T05:46:27.000Z", "max_stars_repo_stars_event_min_datetime": "2019-03-29T17:35:20.000Z", "num_tokens": 26, "size": 82 }
module Data.Fin.Subset.Disjoint where open import Data.Nat open import Data.Vec hiding (_∈_) open import Data.Fin open import Data.List as List hiding (zipWith) open import Data.Fin.Subset -- disjointness and relational specifiation of disjoint union module _ {n} where _◆_ : Subset n → Subset n → Set l ◆ r = Empty (l ∩ r) data _⨄_ : List (Subset n) → Subset n → Set where [] : [] ⨄ ⊥ _∷_ : ∀ {xs x y} → x ◆ y → xs ⨄ y → (x ∷ xs) ⨄ (x ∪ y) -- picking from support module _ {n} where _⊇⟨_⟩_ : Subset n → (l : ℕ) → Vec (Fin n) l → Set xs ⊇⟨ l ⟩ ys = All (λ y → y ∈ xs) ys where open import Data.Vec.All -- removing from support module _ {n} where _\\_ : ∀ {l} → Subset n → Vec (Fin n) l → Subset n xs \\ [] = xs xs \\ (x ∷ ys) = (xs [ x ]≔ outside) \\ ys
{ "alphanum_fraction": 0.588086185, "avg_line_length": 26.3, "ext": "agda", "hexsha": "6d9ce80003261e0262d15c4f9afe61ea99f67d98", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/Data/Fin/Subset/Disjoint.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/Data/Fin/Subset/Disjoint.agda", "max_line_length": 61, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/Data/Fin/Subset/Disjoint.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 303, "size": 789 }
module natThms where open import lib -- this function divides a natural number by 2, dropping any remainder div2 : ℕ → ℕ div2 0 = 0 div2 1 = 0 div2 (suc (suc x)) = suc (div2 x) div2-double : ∀(x : ℕ) → (div2 (x * 2)) ≡ x div2-double zero = refl div2-double (suc x) rewrite div2-double (x) = refl {- Hint: consider the same cases as in the definition of div2: 0, 1, (suc (suc x)). The case for 1 is impossible, so you can just drop that case or use the absurd pattern for the proof of is-even 1 ≡ tt. -} div2-even : ∀(x : ℕ) → is-even x ≡ tt → div2 x ≡ div2 (suc x) div2-even zero x = refl div2-even (suc (suc x))y rewrite div2-even x y = refl -- same hint as for div2-even, except now the 0 case is impossible div2-odd : ∀(x : ℕ) → is-odd x ≡ tt → div2 (suc x) ≡ suc (div2 x) div2-odd (suc(suc x))y rewrite div2-odd x y = refl div2-odd (suc zero) y = refl {- hint: do *not* do induction on x. Look at the definitions of square and pow. There are lemmas about multiplication in the IAL that will help you (nat-thms.agda). -} square-square : ∀(x : ℕ) → square (square x) ≡ x pow 4 square-square x rewrite *1{x} | *assoc x x ( x * x ) = refl
{ "alphanum_fraction": 0.6361344538, "avg_line_length": 38.3870967742, "ext": "agda", "hexsha": "b20cc2db270bf8c39040895da8d67a33b3a3c6df", "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": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_forks_repo_path": "natThms.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "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": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_issues_repo_path": "natThms.agda", "max_line_length": 91, "max_stars_count": null, "max_stars_repo_head_hexsha": "0117aa66ff3cbc8d75be3c9705bada96bdcf8d5a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout7", "max_stars_repo_path": "natThms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 421, "size": 1190 }
-- Reported by nad 2018-01-23 {-# OPTIONS --sized-types #-} module Issue3517 where import Issue3517.S import Issue3517.M
{ "alphanum_fraction": 0.7317073171, "avg_line_length": 15.375, "ext": "agda", "hexsha": "ee12df6f7e161e231bf3ffddc5667ecbb8debc2d", "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/Issue3517.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/Issue3517.agda", "max_line_length": 29, "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/Issue3517.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": 37, "size": 123 }
module Lang.Vars.Structure.Operator where import Lvl open import Data open import Logic.Predicate open import Structure.Setoid open import Structure.Function.Domain open import Structure.Operator.Properties open import Structure.Operator open import Type -- TODO: These are to make the generalized variables work when they depend on each other. Are there any better ways? module Select where module _ {ℓ ℓₑ} {T : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ where select-invol : ∀(f : T → T) → Involution(f) → Type{Lvl.𝟎} select-invol _ _ = Data.Unit module _ {ℓ ℓₑ} {T : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ {_▫_ : T → T → T} where select-id : ∀(id) → Identity(_▫_)(id) → Type{Lvl.𝟎} select-id _ _ = Data.Unit select-idₗ : ∀(id) → Identityₗ(_▫_)(id) → Type{Lvl.𝟎} select-idₗ _ _ = Data.Unit select-idᵣ : ∀(id) → Identityᵣ(_▫_)(id) → Type{Lvl.𝟎} select-idᵣ _ _ = Data.Unit select-inv : ∀(id)(ident)(inv) → InverseFunction(_▫_) ⦃ [∃]-intro(id) ⦃ ident ⦄ ⦄ (inv) → Type{Lvl.𝟎} select-inv _ _ _ _ = Data.Unit select-invₗ : ∀(id)(ident)(inv) → InverseFunctionₗ(_▫_) ⦃ [∃]-intro(id) ⦃ ident ⦄ ⦄ (inv) → Type{Lvl.𝟎} select-invₗ _ _ _ _ = Data.Unit select-invᵣ : ∀(id)(ident)(inv) → InverseFunctionᵣ(_▫_) ⦃ [∃]-intro(id) ⦃ ident ⦄ ⦄ (inv) → Type{Lvl.𝟎} select-invᵣ _ _ _ _ = Data.Unit select-invPropₗ : ∀(inv) → InversePropertyₗ(_▫_)(inv) → Type{Lvl.𝟎} select-invPropₗ _ _ = Data.Unit select-invPropᵣ : ∀(inv) → InversePropertyᵣ(_▫_)(inv) → Type{Lvl.𝟎} select-invPropᵣ _ _ = Data.Unit select-abs : ∀(id) → Absorber(_▫_)(id) → Type{Lvl.𝟎} select-abs _ _ = Data.Unit select-absₗ : ∀(id) → Absorberₗ(_▫_)(id) → Type{Lvl.𝟎} select-absₗ _ _ = Data.Unit select-absᵣ : ∀(id) → Absorberᵣ(_▫_)(id) → Type{Lvl.𝟎} select-absᵣ _ _ = Data.Unit module One {ℓ ℓₑ} {T : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ {_▫_ : T → T → T} where variable {id idₗ idᵣ ab abₗ abᵣ} : T variable {inv invₗ invᵣ} : T → T variable ⦃ op ⦄ : BinaryOperator ⦃ equiv ⦄ ⦃ equiv ⦄ ⦃ equiv ⦄ (_▫_) variable ⦃ comm ⦄ : Commutativity ⦃ equiv ⦄ (_▫_) variable ⦃ cancₗ ⦄ : Cancellationₗ ⦃ equiv ⦄ ⦃ equiv ⦄ (_▫_) variable ⦃ cancᵣ ⦄ : Cancellationᵣ ⦃ equiv ⦄ ⦃ equiv ⦄ (_▫_) variable ⦃ assoc ⦄ : Associativity ⦃ equiv ⦄ (_▫_) variable ⦃ ident ⦄ : Identity ⦃ equiv ⦄ (_▫_)(id) variable ⦃ identₗ ⦄ : Identityₗ ⦃ equiv ⦄ (_▫_)(id) variable ⦃ identᵣ ⦄ : Identityᵣ ⦃ equiv ⦄ (_▫_)(id) variable ⦃ inver ⦄ : InverseFunction ⦃ equiv ⦄ (_▫_) ⦃ [∃]-intro(id) ⦃ ident ⦄ ⦄ (inv) variable ⦃ inverₗ ⦄ : InverseFunctionₗ ⦃ equiv ⦄ (_▫_) ⦃ [∃]-intro(idₗ) ⦃ identₗ ⦄ ⦄ (invₗ) variable ⦃ inverᵣ ⦄ : InverseFunctionᵣ ⦃ equiv ⦄ (_▫_) ⦃ [∃]-intro(idᵣ) ⦃ identᵣ ⦄ ⦄ (invᵣ) variable ⦃ inverPropₗ ⦄ : InversePropertyₗ ⦃ equiv ⦄ (_▫_) (invₗ) variable ⦃ inverPropᵣ ⦄ : InversePropertyᵣ ⦃ equiv ⦄ (_▫_) (invᵣ) variable ⦃ invol ⦄ : Involution ⦃ equiv ⦄ (inv) variable ⦃ absorb ⦄ : Absorber ⦃ equiv ⦄ (_▫_)(ab) variable ⦃ absorbₗ ⦄ : Absorberₗ ⦃ equiv ⦄ (_▫_)(ab) variable ⦃ absorbᵣ ⦄ : Absorberᵣ ⦃ equiv ⦄ (_▫_)(ab) module OneTypeTwoOp {ℓ ℓₑ} {T : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ {_▫₁_ _▫₂_ : T → T → T} where variable {id} : T variable {inv} : T → T variable ⦃ op₁ ⦄ : BinaryOperator ⦃ equiv ⦄ ⦃ equiv ⦄ ⦃ equiv ⦄ (_▫₁_) variable ⦃ comm₁ ⦄ : Commutativity ⦃ equiv ⦄ (_▫₁_) variable ⦃ cancₗ₁ ⦄ : Cancellationₗ ⦃ equiv ⦄ ⦃ equiv ⦄ (_▫₁_) variable ⦃ cancᵣ₁ ⦄ : Cancellationᵣ ⦃ equiv ⦄ ⦃ equiv ⦄ (_▫₁_) variable ⦃ assoc₁ ⦄ : Associativity ⦃ equiv ⦄ (_▫₁_) variable ⦃ ident₁ ⦄ : Identity ⦃ equiv ⦄ (_▫₁_)(id) variable ⦃ identₗ₁ ⦄ : Identityₗ ⦃ equiv ⦄ (_▫₁_)(id) variable ⦃ identᵣ₁ ⦄ : Identityᵣ ⦃ equiv ⦄ (_▫₁_)(id) variable ⦃ inver₁ ⦄ : InverseFunction ⦃ equiv ⦄ (_▫₁_) ⦃ [∃]-intro(id) ⦃ ident₁ ⦄ ⦄ (inv) variable ⦃ inverₗ₁ ⦄ : InverseFunctionₗ ⦃ equiv ⦄ (_▫₁_) ⦃ [∃]-intro(id) ⦃ identₗ₁ ⦄ ⦄ (inv) variable ⦃ inverᵣ₁ ⦄ : InverseFunctionᵣ ⦃ equiv ⦄ (_▫₁_) ⦃ [∃]-intro(id) ⦃ identᵣ₁ ⦄ ⦄ (inv) variable ⦃ absorbₗ₁ ⦄ : Absorberₗ ⦃ equiv ⦄ (_▫₁_)(id) variable ⦃ absorbᵣ₁ ⦄ : Absorberᵣ ⦃ equiv ⦄ (_▫₁_)(id) variable ⦃ op₂ ⦄ : BinaryOperator ⦃ equiv ⦄ ⦃ equiv ⦄ ⦃ equiv ⦄ (_▫₂_) variable ⦃ comm₂ ⦄ : Commutativity ⦃ equiv ⦄ (_▫₂_) variable ⦃ cancₗ₂ ⦄ : Cancellationₗ ⦃ equiv ⦄ ⦃ equiv ⦄ (_▫₂_) variable ⦃ cancᵣ₂ ⦄ : Cancellationᵣ ⦃ equiv ⦄ ⦃ equiv ⦄ (_▫₂_) variable ⦃ assoc₂ ⦄ : Associativity ⦃ equiv ⦄ (_▫₂_) variable ⦃ ident₂ ⦄ : Identity ⦃ equiv ⦄ (_▫₂_)(id) variable ⦃ identₗ₂ ⦄ : Identityₗ ⦃ equiv ⦄ (_▫₂_)(id) variable ⦃ identᵣ₂ ⦄ : Identityᵣ ⦃ equiv ⦄ (_▫₂_)(id) variable ⦃ inver₂ ⦄ : InverseFunction ⦃ equiv ⦄ (_▫₂_) ⦃ [∃]-intro(id) ⦃ ident₂ ⦄ ⦄ (inv) variable ⦃ inverₗ₂ ⦄ : InverseFunctionₗ ⦃ equiv ⦄ (_▫₂_) ⦃ [∃]-intro(id) ⦃ identₗ₂ ⦄ ⦄ (inv) variable ⦃ inverᵣ₂ ⦄ : InverseFunctionᵣ ⦃ equiv ⦄ (_▫₂_) ⦃ [∃]-intro(id) ⦃ identᵣ₂ ⦄ ⦄ (inv) variable ⦃ absorbₗ₂ ⦄ : Absorberₗ ⦃ equiv ⦄ (_▫₂_)(id) variable ⦃ absorbᵣ₂ ⦄ : Absorberᵣ ⦃ equiv ⦄ (_▫₂_)(id) variable ⦃ distriₗ ⦄ : Distributivityₗ ⦃ equiv ⦄ (_▫₁_)(_▫₂_) variable ⦃ distriᵣ ⦄ : Distributivityᵣ ⦃ equiv ⦄ (_▫₁_)(_▫₂_) variable ⦃ absorpₗ ⦄ : Absorptionₗ ⦃ equiv ⦄ (_▫₁_)(_▫₂_) variable ⦃ absorpᵣ ⦄ : Absorptionᵣ ⦃ equiv ⦄ (_▫₁_)(_▫₂_) variable ⦃ inverOpₗ ⦄ : InverseOperatorₗ ⦃ equiv ⦄ (_▫₁_)(_▫₂_) variable ⦃ inverOpᵣ ⦄ : InverseOperatorᵣ ⦃ equiv ⦄ (_▫₁_)(_▫₂_) module Two {ℓ₁ ℓ₂ ℓₑ₁ ℓₑ₂} {A : Type{ℓ₁}} ⦃ equiv-A : Equiv{ℓₑ₁}(A) ⦄ {_▫₁_ : A → A → A} {B : Type{ℓ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ {_▫₂_ : B → B → B} where variable {id₁} : A variable {inv₁} : A → A variable {id₂} : B variable {inv₂} : B → B variable ⦃ op₁ ⦄ : BinaryOperator ⦃ equiv-A ⦄ ⦃ equiv-A ⦄ ⦃ equiv-A ⦄ (_▫₁_) variable ⦃ comm₁ ⦄ : Commutativity ⦃ equiv-A ⦄ (_▫₁_) variable ⦃ cancₗ₁ ⦄ : Cancellationₗ ⦃ equiv-A ⦄ ⦃ equiv-A ⦄ (_▫₁_) variable ⦃ cancᵣ₁ ⦄ : Cancellationᵣ ⦃ equiv-A ⦄ ⦃ equiv-A ⦄ (_▫₁_) variable ⦃ assoc₁ ⦄ : Associativity ⦃ equiv-A ⦄ (_▫₁_) variable ⦃ ident₁ ⦄ : Identity ⦃ equiv-A ⦄ (_▫₁_)(id₁) variable ⦃ identₗ₁ ⦄ : Identityₗ ⦃ equiv-A ⦄ (_▫₁_)(id₁) variable ⦃ identᵣ₁ ⦄ : Identityᵣ ⦃ equiv-A ⦄ (_▫₁_)(id₁) variable ⦃ inver₁ ⦄ : InverseFunction ⦃ equiv-A ⦄ (_▫₁_) ⦃ [∃]-intro(id₁) ⦃ ident₁ ⦄ ⦄ (inv₁) variable ⦃ inverₗ₁ ⦄ : InverseFunctionₗ ⦃ equiv-A ⦄ (_▫₁_) ⦃ [∃]-intro(id₁) ⦃ identₗ₁ ⦄ ⦄ (inv₁) variable ⦃ inverᵣ₁ ⦄ : InverseFunctionᵣ ⦃ equiv-A ⦄ (_▫₁_) ⦃ [∃]-intro(id₁) ⦃ identᵣ₁ ⦄ ⦄ (inv₁) variable ⦃ op₂ ⦄ : BinaryOperator ⦃ equiv-B ⦄ ⦃ equiv-B ⦄ ⦃ equiv-B ⦄ (_▫₂_) variable ⦃ comm₂ ⦄ : Commutativity ⦃ equiv-B ⦄ (_▫₂_) variable ⦃ cancₗ₂ ⦄ : Cancellationₗ ⦃ equiv-B ⦄ ⦃ equiv-B ⦄ (_▫₂_) variable ⦃ cancᵣ₂ ⦄ : Cancellationᵣ ⦃ equiv-B ⦄ ⦃ equiv-B ⦄ (_▫₂_) variable ⦃ assoc₂ ⦄ : Associativity ⦃ equiv-B ⦄ (_▫₂_) variable ⦃ ident₂ ⦄ : Identity ⦃ equiv-B ⦄ (_▫₂_)(id₂) variable ⦃ identₗ₂ ⦄ : Identityₗ ⦃ equiv-B ⦄ (_▫₂_)(id₂) variable ⦃ identᵣ₂ ⦄ : Identityᵣ ⦃ equiv-B ⦄ (_▫₂_)(id₂) variable ⦃ inver₂ ⦄ : InverseFunction ⦃ equiv-B ⦄ (_▫₂_) ⦃ [∃]-intro(id₂) ⦃ ident₂ ⦄ ⦄ (inv₂) variable ⦃ inverₗ₂ ⦄ : InverseFunctionₗ ⦃ equiv-B ⦄ (_▫₂_) ⦃ [∃]-intro(id₂) ⦃ identₗ₂ ⦄ ⦄ (inv₂) variable ⦃ inverᵣ₂ ⦄ : InverseFunctionᵣ ⦃ equiv-B ⦄ (_▫₂_) ⦃ [∃]-intro(id₂) ⦃ identᵣ₂ ⦄ ⦄ (inv₂)
{ "alphanum_fraction": 0.6046091906, "avg_line_length": 51.085106383, "ext": "agda", "hexsha": "e62ec0709c03d0f2c5410d35baeaf52148e6c359", "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": "Lang/Vars/Structure/Operator.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": "Lang/Vars/Structure/Operator.agda", "max_line_length": 156, "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": "Lang/Vars/Structure/Operator.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": 3765, "size": 7203 }
{-# OPTIONS --without-K #-} open import HoTT open import homotopy.elims.Lemmas {- Given a span [A ←f– C –g→ B] and a map [h : A ⊔_C B → D] where - [g] has a left inverse: - To define a fundction [Π (Cof h) P], one can give only the [cfbase], - [cfcod], [cfglue∘left], and [cfglue∘right] cases, and construct a map - which has the right behavior on [cfbase], [cfcod], [cfglue∘left], - with [cfglue∘right] edited to achieve the highest coherence. - This is useful for for proving equivalences where (at least) one side - involves one of these iterated pushouts. It could be generalized - further by loosening from cofiber to some more general class of pushouts, - but this is sufficient for the current applications. -} module homotopy.elims.CofPushoutSection where module _ {i j k l} {s : Span {i} {j} {k}} {D : Type l} {h : Pushout s → D} where open Span s module CofPushoutSection (r : B → C) (inv : ∀ c → r (g c) == c) where elim : ∀ {m} {P : Cofiber h → Type m} (cfbase* : P cfbase) (cfcod* : (d : D) → P (cfcod d)) (cfglue-left* : (a : A) → cfbase* == cfcod* (h (left a)) [ P ↓ cfglue (left a) ]) (cfglue-right* : (b : B) → cfbase* == cfcod* (h (right b)) [ P ↓ cfglue (right b) ]) → Π (Cofiber h) P elim {P = P} cfbase* cfcod* cfglue-left* cfglue-right* = Cofiber-elim cfbase* cfcod* (Pushout-elim cfglue-left* (λ b → (fst (fill (r b))) ◃ cfglue-right* b) (λ c → ↓↓-from-squareover $ transport (λ c' → SquareOver P (natural-square cfglue (glue c)) (cfglue-left* (f c)) (↓-ap-in P (λ _ → cfbase) (apd (λ _ → cfbase*) (glue c))) (↓-ap-in P (cfcod ∘ h) (apd (cfcod* ∘ h) (glue c))) (fst (fill c') ◃ cfglue-right* (g c))) (! (inv c)) (snd (fill c)))) where fill : (c : C) → Σ (cfbase* == cfbase*) (λ q → SquareOver P (natural-square cfglue (glue c)) (cfglue-left* (f c)) _ _ (q ◃ cfglue-right* (g c))) fill c = fill-upper-right _ _ _ _ _ rec : ∀ {m} {E : Type m} (cfbase* : E) (cfcod* : D → E) (cfglue-left* : (a : A) → cfbase* == cfcod* (h (left a))) (cfglue-right* : (b : B) → cfbase* == cfcod* (h (right b))) → (Cofiber h → E) rec cfbase* cfcod* cfglue-left* cfglue-right* = elim cfbase* cfcod* (↓-cst-in ∘ cfglue-left*) (↓-cst-in ∘ cfglue-right*)
{ "alphanum_fraction": 0.5326693227, "avg_line_length": 38.0303030303, "ext": "agda", "hexsha": "5dd1143c475944e68156d7c18c6bd111b0b88ee4", "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": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cmknapp/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/elims/CofPushoutSection.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "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": "cmknapp/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/elims/CofPushoutSection.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cmknapp/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/elims/CofPushoutSection.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 896, "size": 2510 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Substitution.Introductions.Universe {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties open import Definition.LogicalRelation.Substitution open import Tools.Product import Tools.PropositionalEquality as PE -- Validity of the universe type. Uᵛ : ∀ {Γ} ([Γ] : ⊩ᵛ Γ) → Γ ⊩ᵛ⟨ ¹ ⟩ U / [Γ] Uᵛ [Γ] ⊢Δ [σ] = Uᵣ′ ⁰ 0<1 ⊢Δ , λ _ x₂ → U₌ PE.refl -- Valid terms of type U are valid types. univᵛ : ∀ {A Γ l l′} ([Γ] : ⊩ᵛ Γ) ([U] : Γ ⊩ᵛ⟨ l ⟩ U / [Γ]) → Γ ⊩ᵛ⟨ l ⟩ A ∷ U / [Γ] / [U] → Γ ⊩ᵛ⟨ l′ ⟩ A / [Γ] univᵛ {l′ = l′} [Γ] [U] [A] ⊢Δ [σ] = let [A]₁ = maybeEmb′ {l′} (univEq (proj₁ ([U] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ]))) in [A]₁ , (λ [σ′] [σ≡σ′] → univEqEq (proj₁ ([U] ⊢Δ [σ])) [A]₁ ((proj₂ ([A] ⊢Δ [σ])) [σ′] [σ≡σ′])) -- Valid term equality of type U is valid type equality. univEqᵛ : ∀ {A B Γ l l′} ([Γ] : ⊩ᵛ Γ) ([U] : Γ ⊩ᵛ⟨ l′ ⟩ U / [Γ]) ([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ]) → Γ ⊩ᵛ⟨ l′ ⟩ A ≡ B ∷ U / [Γ] / [U] → Γ ⊩ᵛ⟨ l ⟩ A ≡ B / [Γ] / [A] univEqᵛ {A} [Γ] [U] [A] [t≡u] ⊢Δ [σ] = univEqEq (proj₁ ([U] ⊢Δ [σ])) (proj₁ ([A] ⊢Δ [σ])) ([t≡u] ⊢Δ [σ])
{ "alphanum_fraction": 0.5121234386, "avg_line_length": 34.8974358974, "ext": "agda", "hexsha": "0c7819695ca3a6e573360591609d332191dc1077", "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": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Universe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "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": "loic-p/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Universe.agda", "max_line_length": 96, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Substitution/Introductions/Universe.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 649, "size": 1361 }
-- Andreas, 2018-06-09, issue #2513, parsing attributes postulate @0 @ω A : Set -- Should fail with error: -- Conflicting attributes: 0 ω
{ "alphanum_fraction": 0.6901408451, "avg_line_length": 17.75, "ext": "agda", "hexsha": "f25434352b4acd68bbd84cf2f43ca49850e4ed9e", "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/AttributeConflict.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/AttributeConflict.agda", "max_line_length": 55, "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/AttributeConflict.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": 142 }
module Data.FixedTree where import Lvl open import Data hiding (empty) open import Data.List open import Data.Tuple using (_⨯_ ; _,_) open import Data.Tuple.Raise open import Functional as Fn open import Numeral.Natural open import Type private variable ℓ ℓᵢ ℓₗ ℓₙ ℓₒ : Lvl.Level private variable n : ℕ private variable N N₁ N₂ L T A B : Type{ℓ} module _ {I : Type{ℓᵢ}} (children : I → ℕ) (step : I → I) (L : Type{ℓₗ}) (N : Type{ℓₙ}) where data Tree₊ : I → Type{ℓₗ Lvl.⊔ ℓₙ Lvl.⊔ ℓᵢ} where Leaf : ∀{i} → L → Tree₊(i) Node : ∀{i} → N → (Tree₊(step i) ^ children(step i)) → Tree₊(i) data Tree₋ : I → Type{ℓₗ Lvl.⊔ ℓₙ Lvl.⊔ ℓᵢ} where Leaf : ∀{i} → L → Tree₋(i) Node : ∀{i} → N → (Tree₋(i) ^ children(i)) → Tree₋(step i) -- Alternative definition: -- data FixedTree (n : ℕ) (L : Type{ℓₗ}) (N : Type{ℓₙ}) : Type{ℓₗ Lvl.⊔ ℓₙ} where -- Leaf : L → FixedTree(n) L N -- Node : N → ((FixedTree(n) L N) ^ n) → FixedTree(n) L N FixedTree : ℕ → Type{ℓₗ} → Type{ℓₙ} → Type{ℓₗ Lvl.⊔ ℓₙ} FixedTree(n) L N = Tree₊ id id L N n open import Data using (Unit ; <>) open import Data.Boolean open import Data.Boolean.Operators open Data.Boolean.Operators.Programming open import Data.Option import Data.Tuple.Raiseᵣ.Functions as Raise open import Logic.Propositional open import Logic.Predicate open import Numeral.Finite open import Numeral.Finite.Oper.Comparisons open import Numeral.Natural.Function open import Numeral.Natural.Oper hiding (_^_) emptyTree : FixedTree{ℓₗ}(n) Unit N emptyTree{n = n} = Leaf <> singleton : N → FixedTree{ℓₗ}(n) Unit N singleton{n = n} a = Node a (Raise.repeat n emptyTree) isLeaf : FixedTree(n) L N → Bool isLeaf (Leaf _) = 𝑇 isLeaf (Node _ _) = 𝐹 isNode : FixedTree(n) L N → Bool isNode (Leaf _) = 𝐹 isNode (Node _ _) = 𝑇 root : FixedTree(n) L N → Option(N) root (Leaf _) = None root (Node a _) = Some a foldChildNodesᵣ : (((FixedTree(n) L N) ^ n) → N → T → T) → T → FixedTree(n) L N → T foldChildNodesᵣ join id (Leaf _) = id foldChildNodesᵣ{n = n} join id (Node _ c) = Raise.foldᵣ{n} (\{(Leaf _) → Fn.id ; (Node a c) → join c a}) id c -- TODO: Is it correct? Also termination checker {- testfoldᵣ : ∀{n : ℕ}{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → B → B) → B → (FixedTree(n)(A) ^ n) → B testfoldᵣ {0} (_▫_) id _ = id testfoldᵣ {1} (_▫_) id Leaf = id testfoldᵣ {1} (_▫_) id (Node a c) = a ▫ testfoldᵣ {1} (_▫_) id c -- x ▫ def testfoldᵣ {𝐒(𝐒(n))} (_▫_) def (x , xs) = {!!} -- x ▫ testfoldᵣ {𝐒(n)} (_▫_) def xs fold : (A → B → B) → B → FixedTree(n)(A) → B fold (_▫_) id Leaf = id fold{n = n} (_▫_) id (Node a c) = a ▫ Raise.foldᵣ{n} (\{Leaf -> Fn.id ; node@(Node _ _) acc → fold{n = n} (_▫_) acc node}) id c fold : (A → B → B) → B → FixedTree(n)(A) → B fold{A = A}{B = B}{n = n} (_▫_) id tree = foldChildNodesᵣ ({!swap(fold{n = n} (_▫_))!}) id tree where f : ∀{n₁ n₂} → FixedTree(n₁)(A) ^ n₂ → A → B → B f {n₂ = 0} <> a acc = a ▫ acc f {n₂ = 1} Leaf a acc = a ▫ acc f {n₂ = 1} (Node ca cc) a acc = f cc a (ca ▫ acc) -- ca ▫ (a ▫ acc) f {n₂ = 𝐒(𝐒(n₂))} c a acc = {!!} testfoldDepthFirst : (A → B → B) → B → FixedTree(n)(A) → B testfoldᵣ : ∀{n₁ n₂ : ℕ}{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → B → B) → B → (FixedTree(n₁)(A) ^ n₂) → B testfoldDepthFirst (_▫_) id Leaf = id testfoldDepthFirst{n = n} (_▫_) id (Node a c) = a ▫ testfoldᵣ{n} (_▫_) id c testfoldᵣ {n₂ = 0} (_▫_) def _ = def testfoldᵣ {n₁ = n₁}{n₂ = 1} (_▫_) def x = testfoldDepthFirst{n = n₁} (_▫_) def x -- testfoldᵣ {n₂ = 𝐒(𝐒(n₂))} (_▫_) def (x , xs) = swap(testfoldDepthFirst{n = _} (_▫_)) x (testfoldᵣ {n₂ = 𝐒(n₂)} (_▫_) def xs) testfoldᵣ : ∀{n₁ n₂ : ℕ}{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → B → B) → B → (FixedTree(n₁)(A) ^ n₂) → B testfoldᵣ {n₂ = 0} (_▫_) id <> = id testfoldᵣ {n₂ = 1} (_▫_) id Leaf = id testfoldᵣ {n₂ = 1} (_▫_) id (Node a c) = a ▫ testfoldᵣ(_▫_) id c testfoldᵣ {n₂ = 𝐒(𝐒(n))} (_▫_) id (Leaf , xs) = testfoldᵣ(_▫_) id xs testfoldᵣ {n₂ = 𝐒(𝐒(n))} (_▫_) id (Node a c , xs) = testfoldᵣ(_▫_) (a ▫ testfoldᵣ(_▫_) id xs) c -} {-# TERMINATING #-} foldDepthFirst : (N → T → T) → T → FixedTree(n) L N → T foldDepthFirst (_▫_) id (Leaf _) = id foldDepthFirst{n = n} (_▫_) id (Node a c) = a ▫ Raise.foldᵣ{n} (swap(foldDepthFirst{n = n} (_▫_))) id c import Data.Tuple.RaiseTypeᵣ.Functions as RaiseType open import Function.Multi import Function.Multi.Functions as Multi {-# TERMINATING #-} FixedTree-induction : ∀{P : FixedTree{ℓₗ}{ℓₙ}(n) L N → Type{ℓ}} → (∀{l} → P(Leaf l)) → ((a : N) → (c : (FixedTree(n) L N) ^ n) → (RaiseType.from-[^] (Raise.map P(c)) ⇉ P(Node a c))) → ((tree : FixedTree(n) L N) → P(tree)) FixedTree-induction base _ (Leaf l) = base{l} FixedTree-induction {n = 0} _ step (Node a c) = step a c FixedTree-induction {n = 1} base step (Node a c) = step a c (FixedTree-induction{n = 1} base step c) FixedTree-induction {n = 𝐒(𝐒(n))} {P = P} base step (Node a c) = recurseChildren{𝐒(𝐒(n))}(step a c) where recurseChildren : ∀{L}{l : _ ^ L} → (RaiseType.from-[^] (Raise.map P(l)) ⇉ P(Node a c)) → P(Node a c) recurseChildren {0} = id recurseChildren {1} {l} p = p(FixedTree-induction{n = 𝐒(𝐒(n))} base step l) recurseChildren {𝐒(𝐒(L))} {x , l} p = recurseChildren{𝐒(L)}{l} (p(FixedTree-induction{n = 𝐒(𝐒(n))} base step x)) -- The size is the number of nodes in the tree. -- Alternative implementation: -- size{n = n}{L = L}{N = N} = FixedTree-induction 𝟎 (rec{w = n}) where -- rec : ∀{w} → (a : N) → (c : (FixedTree(n) L N) ^ w) → RaiseType.from-[^] (Raise.map{w} (const ℕ)(c)) ⇉ ℕ -- rec {w = 0} _ _ = 1 -- rec {w = 1} _ _ n = 𝐒(n) -- rec {w = 𝐒(𝐒(w))} a (_ , c) n = Multi.compose(𝐒(w)) (n +_) (rec{w = 𝐒(w)} a c) {-# TERMINATING #-} size : FixedTree(n) L N → ℕ size (Leaf _) = 𝟎 size (Node _ c) = 𝐒(Raise.foldᵣ((_+_) ∘ size) 𝟎 c) -- The height is the length of the longest path from the root node. -- Alternative implementation: -- height{n = n}{L = L}{N = N} = FixedTree-induction 𝟎 (rec{w = n}) where -- -- Note: The return type is equal to `RaiseType.repeat(L) ℕ ⇉ ℕ` -- rec : ∀{w} → (a : N) → (c : (FixedTree(n) L N) ^ w) → RaiseType.from-[^] (Raise.map{w} (const ℕ)(c)) ⇉ ℕ -- rec {w = 0} _ _ = 1 -- rec {w = 1} _ _ n = 𝐒(n) -- rec {w = 𝐒(𝐒(w))} a (_ , c) n = Multi.compose(𝐒(w)) (max n) (rec{w = 𝐒(w)} a c) {-# TERMINATING #-} height : FixedTree(n) L N → ℕ height (Leaf _) = 𝟎 height (Node _ c) = 𝐒(Raise.foldᵣ(max ∘ height) 𝟎 c) import Data.Tuple.Raiseᵣ.Functions as TupleRaiseᵣ import Data.List.Functions as List treesOfDepth : ℕ → FixedTree(n) L N → List(FixedTree(n) L N) treesOfDepth 𝟎 tree = tree ⊰ ∅ treesOfDepth (𝐒(_)) (Leaf _) = ∅ treesOfDepth (𝐒(n)) (Node _ c) = TupleRaiseᵣ.foldᵣ((List._++_) ∘ treesOfDepth n) ∅ c
{ "alphanum_fraction": 0.5570032573, "avg_line_length": 44.13125, "ext": "agda", "hexsha": "b9b9fa0633dfa3597b622fdefad7c502fda181ad", "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/FixedTree.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/FixedTree.agda", "max_line_length": 221, "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/FixedTree.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": 2975, "size": 7061 }
{-# OPTIONS --cubical --safe #-} module HITs.PropositionalTruncation.Sugar where open import Cubical.HITs.PropositionalTruncation open import Level _=<<_ : ∀ {a} {A : Type a} {b} {B : ∥ A ∥ → Type b} → ((x : A) → ∥ B ∣ x ∣ ∥) → (xs : ∥ A ∥) → ∥ B xs ∥ _=<<_ = elimPropTrunc (λ _ → squash) _>>=_ : ∀ {a} {A : Type a} {b} {B : Type b} → (xs : ∥ A ∥) → (A → ∥ B ∥) → ∥ B ∥ _>>=_ {a} {A} {b} {B} xs f = elimPropTrunc (λ _ → squash) f xs _>>_ : ∥ A ∥ → ∥ B ∥ → ∥ B ∥ _ >> ys = ys pure : A → ∥ A ∥ pure = ∣_∣ _<*>_ : ∥ (A → B) ∥ → ∥ A ∥ → ∥ B ∥ fs <*> xs = do f ← fs x ← xs ∣ f x ∣ infixr 1 _∥$∥_ _∥$∥_ : (A → B)→ ∥ A ∥ → ∥ B ∥ f ∥$∥ xs = recPropTrunc squash (λ x → ∣ f x ∣) xs
{ "alphanum_fraction": 0.441260745, "avg_line_length": 22.5161290323, "ext": "agda", "hexsha": "4d300b0c6b16567f044c75fc20d7e34bee09630b", "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": "3c176d4690566d81611080e9378f5a178b39b851", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/combinatorics-paper", "max_forks_repo_path": "agda/HITs/PropositionalTruncation/Sugar.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "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": "oisdk/combinatorics-paper", "max_issues_repo_path": "agda/HITs/PropositionalTruncation/Sugar.agda", "max_line_length": 62, "max_stars_count": null, "max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/combinatorics-paper", "max_stars_repo_path": "agda/HITs/PropositionalTruncation/Sugar.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 362, "size": 698 }
{- Part 3: Univalence and the SIP • Univalence from ua and uaβ • Transporting with ua • The SIP as a consequence of ua -} {-# OPTIONS --cubical #-} module Part3 where open import Cubical.Core.Glue public using ( Glue ; glue ; unglue ; lineToEquiv ) open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Part1 open import Part2 -- A key concept in HoTT/UF is univalence. As we have seen earlier in -- the week this is assumed as an axiom in HoTT. In Cubical Agda it is -- instead provable and has computational content. This means that -- transporting with paths constructed using univalence reduces as -- opposed to HoTT where they would be stuck. This simplifies some -- proofs and make it possible to actually do concrete computations -- using univalence. -- The part of univalence which is most useful for our applications is -- to be able to turn equivalences (written _≃_ and defined as a Σ-type -- of a function and a proof that it has contractible fibers) into -- paths: ua : {A B : Type ℓ} → A ≃ B → A ≡ B ua {A = A} {B = B} e i = Glue B (λ { (i = i0) → (A , e) ; (i = i1) → (B , idEquiv B) }) -- This term is defined using "Glue types" which were introduced in -- the CCHM paper. We won't have time to go into details about them -- today, but for practical applications one can usually forget about -- them and use ua as a black box. There are multiple useful lemmas in -- Cubical.Foundations.Univalence and Cubical.Foundations.Transport -- which are helpful when reasoning about ua which don't require -- knowing what Glue types are. -- The important point is that transporting along the path constructed -- using ua applies the function underlying the equivalence. This is -- easily proved using transportRefl: uaβ : (e : A ≃ B) (x : A) → transport (ua e) x ≡ fst e x uaβ e x = transportRefl (equivFun e x) -- Note that for concrete types this typically hold definitionally, -- but for an arbitrary equivalence e we have to prove it. -- The fact that we have both ua and uaβ suffices to be able to prove -- the standard formulation of univalence. For details see: -- -- Cubical.Foundations.Univalence -- The standard way of constructing equivalences is to start with an -- isomorphism and then improve it into an equivalence. The lemma in -- the library which does this is -- -- isoToEquiv : {A B : Type ℓ} → Iso A B → A ≃ B -- Composing this with ua lets us directly turn isomorphisms into paths: -- -- isoToPath : {A B : Type ℓ} → Iso A B → A ≡ B -- Time for an example! -- Booleans data Bool : Type₀ where false true : Bool not : Bool → Bool not false = true not true = false notPath : Bool ≡ Bool notPath = isoToPath (iso not not rem rem) where rem : (b : Bool) → not (not b) ≡ b rem false = refl rem true = refl _ : transport notPath true ≡ false _ = refl -- Another example, integers: open import Cubical.Data.Int hiding (_+_ ; +-assoc) sucPath : Int ≡ Int sucPath = isoToPath (iso sucInt predInt sucPred predSuc) _ : transport sucPath (pos 0) ≡ pos 1 _ = refl _ : transport (sucPath ∙ sucPath) (pos 0) ≡ pos 2 _ = refl _ : transport (sym sucPath) (pos 0) ≡ negsuc 0 _ = refl ------------------------------------------------------------------------- -- The structure identity principle -- Combining subst and ua lets us transport any structure on A to get -- a structure on an equivalent type B substEquiv : (S : Type ℓ → Type ℓ') (e : A ≃ B) → S A → S B substEquiv S e = subst S (ua e) -- Example with binary numbers: open import Cubical.Data.BinNat.BinNat renaming (ℕ≃binnat to ℕ≃Bin ; binnat to Bin) open import Cubical.Data.Nat T : Set → Set T X = Σ[ _+_ ∈ (X → X → X) ] ((x y z : X) → x + (y + z) ≡ (x + y) + z) TBin : T Bin TBin = substEquiv T ℕ≃Bin (_+_ , +-assoc) _+Bin_ : Bin → Bin → Bin _+Bin_ = fst TBin +Bin-assoc : (m n o : Bin) → m +Bin (n +Bin o) ≡ (m +Bin n) +Bin o +Bin-assoc = snd TBin -- This is however not always what we want as _+Bin_ will translate -- its input to unary numbers, add, and then translate back. Instead -- we want to use efficient addition on binary numbers, but get the -- associativity proof for free. So what we really want is to -- characterize the equality of T-structured types, i.e. we want a -- proof that two types equipped with T-structures are equal if there -- is a T-structure preserving equivalence between them. This is the -- usual meaning of the *structure identity principle* (SIP). This -- implies in particular that the type of paths of -- monoids/groups/rings/R-modules/... is equivalent to the type of -- monoid/group/ring/R-module/... preserving equivalences. -- We formalize this and much more using a cubical version of the SIP in: -- -- Internalizing Representation Independence with Univalence -- Carlo Angiuli, Evan Cavallo, Anders Mörtberg, Max Zeuner -- https://arxiv.org/abs/2009.05547 -- -- The binary numbers example with efficient addition is spelled out -- in detail in Section 2.1.1 of: -- -- https://www.doi.org/10.1017/S0956796821000034 -- (Can be downloaded from: https://staff.math.su.se/anders.mortberg/papers/cubicalagda2.pdf)
{ "alphanum_fraction": 0.6937984496, "avg_line_length": 32.4528301887, "ext": "agda", "hexsha": "9b012f2cf8cbc62ca4bbc58888e7740945650000", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_forks_event_min_datetime": "2021-08-02T16:16:34.000Z", "max_forks_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "EgbertRijke/EPIT-2020", "max_forks_repo_path": "04-cubical-type-theory/material/Part3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9a510959fb0e6da9bcc6b0faa0dea76a2821bbdb", "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": "EgbertRijke/EPIT-2020", "max_issues_repo_path": "04-cubical-type-theory/material/Part3.agda", "max_line_length": 93, "max_stars_count": 1, "max_stars_repo_head_hexsha": "19d72759e18e05d2c509f62d23a998573270140c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "williamdemeo/EPIT-2020", "max_stars_repo_path": "04-cubical-type-theory/material/Part3.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-03T16:28:06.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-03T16:28:06.000Z", "num_tokens": 1474, "size": 5160 }
{-# OPTIONS --copatterns #-} open import Common.Prelude record R : Set where field f1 : Nat f2 : String r : R R.f1 r = 5 R.f2 r = "yes" main = putStrLn (R.f2 r)
{ "alphanum_fraction": 0.5885714286, "avg_line_length": 11.6666666667, "ext": "agda", "hexsha": "bc5cc8a884dda92f14b9db841fa63faf8530dc77", "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/Compiler/simple/Issue1632.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/Compiler/simple/Issue1632.agda", "max_line_length": 28, "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/Compiler/simple/Issue1632.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": 63, "size": 175 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types import LibraBFT.Impl.OBM.ECP-LBFT-OBM-Diff.ECP-LBFT-OBM-Diff-0 as ECP-LBFT-OBM-Diff-0 open import Util.Prelude module LibraBFT.Impl.OBM.ECP-LBFT-OBM-Diff.ECP-LBFT-OBM-Diff-2 where -- This is a separate file to avoid a cyclic dependency. ------------------------------------------------------------------------------ e_DiemDB_getEpochEndingLedgerInfosImpl_limit : Epoch → Epoch → Epoch → (Epoch × Bool) e_DiemDB_getEpochEndingLedgerInfosImpl_limit startEpoch endEpoch limit = if not ECP-LBFT-OBM-Diff-0.enabled then if-dec endEpoch >? startEpoch + limit then (startEpoch + limit , true) else (endEpoch , false) else (endEpoch , false)
{ "alphanum_fraction": 0.6774530271, "avg_line_length": 38.32, "ext": "agda", "hexsha": "d5efc3151a36700d2d0f442d35faca3af67548e0", "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": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/OBM/ECP-LBFT-OBM-Diff/ECP-LBFT-OBM-Diff-2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/OBM/ECP-LBFT-OBM-Diff/ECP-LBFT-OBM-Diff-2.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/OBM/ECP-LBFT-OBM-Diff/ECP-LBFT-OBM-Diff-2.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 274, "size": 958 }
-- Andreas, 2012-10-18 wish granted module Issue481 where -- Use case: open import Common.Issue481ParametrizedModule Set using () renaming (id to idSet) open import Common.Issue481ParametrizedModule (Set → Set) using () renaming (id to idSetToSet) open import Common.Issue481ParametrizedModule -- With 'as' clause: open import Common.Issue481ParametrizedModule Set as PSet using (id) {- MEANS: import Common.Issue481ParametrizedModule private open module PSet = Common.Issue481ParametrizedModule Set using (id) -} -- Abuse case: as = Set open import Common.Issue481ParametrizedModule as as as module M = as -- Test case: module Test where -- should succeed: open import Issue481Record as Rec open Issue481Record {- Note: this is NOT equivalent to the following, failing sequence import Issue481Record open module Rec = Issue481Record open Issue481Record -- Ambiguous module name Issue481Record. It could refer to any one of -- Rec.Issue481Record -- Issue481Record It is equivalent to: -} module Test2 where import Issue481Record private open module Rec = Issue481Record
{ "alphanum_fraction": 0.7709648332, "avg_line_length": 19.8035714286, "ext": "agda", "hexsha": "30cf057702c1d8239569a07dbf440c53eb4336da", "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/Issue481.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/Issue481.agda", "max_line_length": 94, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/succeed/Issue481.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": 287, "size": 1109 }
module Haskell.Prim.Word where open import Agda.Builtin.Nat open import Agda.Builtin.Bool open import Agda.Builtin.List open import Agda.Builtin.Char open import Agda.Builtin.String open import Agda.Builtin.Unit open import Agda.Builtin.Int using (pos; negsuc) import Agda.Builtin.Word renaming (Word64 to Word; primWord64ToNat to w2n; primWord64FromNat to n2w) open Agda.Builtin.Word open Agda.Builtin.Word public using (Word) open import Haskell.Prim open import Haskell.Prim.Integer -------------------------------------------------- -- Literals private 2⁶⁴ : Nat 2⁶⁴ = 18446744073709551616 instance iNumberWord : Number Word iNumberWord .Number.Constraint n = IsTrue (n < 2⁶⁴) iNumberWord .fromNat n = n2w n -------------------------------------------------- -- Arithmetic negateWord : Word → Word negateWord a = n2w (2⁶⁴ - w2n a) addWord : Word → Word → Word addWord a b = n2w (w2n a + w2n b) subWord : Word → Word → Word subWord a b = addWord a (negateWord b) mulWord : Word → Word → Word mulWord a b = n2w (w2n a * w2n b) eqWord : Word → Word → Bool eqWord a b = w2n a == w2n b ltWord : Word → Word → Bool ltWord a b = w2n a < w2n b showWord : Word → List Char showWord a = primStringToList (primShowNat (w2n a)) integerToWord : Integer → Word integerToWord (pos n) = n2w n integerToWord (negsuc n) = negateWord (n2w (suc n)) wordToInteger : Word → Integer wordToInteger n = pos (w2n n)
{ "alphanum_fraction": 0.675315568, "avg_line_length": 22.6349206349, "ext": "agda", "hexsha": "4dcaf0c3519f6020f7229765d7bb2e7c78caa340", "lang": "Agda", "max_forks_count": 18, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_path": "lib/Haskell/Prim/Word.agda", "max_issues_count": 63, "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_path": "lib/Haskell/Prim/Word.agda", "max_line_length": 100, "max_stars_count": 55, "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_path": "lib/Haskell/Prim/Word.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "num_tokens": 464, "size": 1426 }
{-# OPTIONS --universe-polymorphism #-} module Issue232 where open import Common.Level data T {ℓ} : {α : Set ℓ} → α → Set (lsuc ℓ) where c : {α : Set ℓ} {x : α} → T x
{ "alphanum_fraction": 0.5930232558, "avg_line_length": 19.1111111111, "ext": "agda", "hexsha": "a551c1df10212be0dc481fca0f316161ffff744b", "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/Issue232.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/Issue232.agda", "max_line_length": 49, "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/Issue232.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": 64, "size": 172 }
{-# OPTIONS --without-K --safe #-} module Reader where -- The reader monad (mainly used for nice syntax with idiom brackets) open import Level Reader : ∀ {r a} → Set r → Set a → Set (a ⊔ r) Reader R A = R → A module _ {r} {R′ : Set r} where R : ∀ {a} → Set a → Set (a ⊔ r) R = Reader R′ pure : ∀ {a} {A : Set a} → A → R A pure x = λ _ → x {-# INLINE pure #-} _<*>_ : ∀ {a b} {A : Set a} {B : Set b} → R (A → B) → R A → R B f <*> g = λ x → f x (g x) {-# INLINE _<*>_ #-} _>>=_ : ∀ {a b} {A : Set a} {B : Set b} → R A → (A → R B) → R B f >>= k = λ x → k (f x) x {-# INLINE _>>=_ #-}
{ "alphanum_fraction": 0.4426751592, "avg_line_length": 20.9333333333, "ext": "agda", "hexsha": "72992f35bd4623011562ae06bdd2a969d6380e61", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-20T07:07:11.000Z", "max_forks_repo_forks_event_min_datetime": "2019-04-16T02:23:16.000Z", "max_forks_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mckeankylej/agda-ring-solver", "max_forks_repo_path": "src/Reader.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_issues_repo_issues_event_max_datetime": "2022-03-12T01:55:42.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-17T20:48:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mckeankylej/agda-ring-solver", "max_issues_repo_path": "src/Reader.agda", "max_line_length": 69, "max_stars_count": 36, "max_stars_repo_head_hexsha": "f18d9c6bdfae5b4c3ead9a83e06f16a0b7204500", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mckeankylej/agda-ring-solver", "max_stars_repo_path": "src/Reader.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-15T00:57:55.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-25T16:40:52.000Z", "num_tokens": 256, "size": 628 }
module AbstractTermination where data Nat : Set where zero : Nat suc : Nat → Nat mutual f : Nat → Nat f n = g n where abstract g : Nat → Nat g n = f n -- Andreas, 2016-10-03 re issue #2231. -- Should give termination error. -- Wrong behavior with Agda-2.3.2. -- Correct behavior from at least Agda-2.4.2.2.
{ "alphanum_fraction": 0.6144927536, "avg_line_length": 17.25, "ext": "agda", "hexsha": "da1a2a39317115415fb17eea14abfea21ae2b44b", "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/AbstractTermination.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/AbstractTermination.agda", "max_line_length": 47, "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/AbstractTermination.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": 113, "size": 345 }
module TypesMore where open import Basics open import Types4 module DESC (I : Set) where data Desc : Set1 where inx : I -> Desc sg : (A : Set)(D : A -> Desc) -> Desc _!_ : I -> Desc -> Desc Node : Desc -> (I -> Set) -> I -> Set Node (inx x) R i = x == i Node (sg A D) R i = Sg A \ a -> Node (D a) R i Node (x ! D) R i = R x * Node D R i data Mu (D : Desc)(i : I) : Set where [_] : Node D (Mu D) i -> Mu D i cata : forall D {X} -> ({i : I} -> Node D X i -> X i) -> forall {i} -> Mu D i -> X i mapCata : forall {D} E {X} -> ({i : I} -> Node D X i -> X i) -> forall {i} -> Node E (Mu D) i -> Node E X i cata D f [ x ] = f (mapCata D f x) mapCata (inx x) f q = q mapCata (sg A E) f (a , e) = a , mapCata (E a) f e mapCata (i ! E) f (x , e) = cata _ f x , mapCata E f e module ORN (J : Set)(ji : J -> I) where Hits : I -> Set Hits i = Sg J \ j -> ji j == i data Orn : Desc -> Set1 where inx : forall {i} -> Hits i -> Orn (inx i) sg : forall A {D} -> ((a : A) -> Orn (D a)) -> Orn (sg A D) _!_ : forall {i D} -> Hits i -> Orn D -> Orn (i ! D) ins : forall (X : Set) {D} -> (X -> Orn D) -> Orn D del : forall {A D} a -> Orn (D a) -> Orn (sg A D) open DESC NatDesc : Desc One NatDesc = sg Two \ { tt -> inx <> ; ff -> <> ! inx <> } NAT : Set NAT = Mu One NatDesc <> pattern ZE = [ tt , refl ] pattern SU n = [ ff , n , refl ] PLUS : NAT -> NAT -> NAT PLUS ZE y = y PLUS (SU x) y = SU (PLUS x y) open ORN orned : forall {I D J ji} -> Orn I J ji D -> Desc J orned (inx (j , q)) = inx j orned (sg A D) = sg A \ a -> orned (D a) orned ((j , q) ! O) = j ! orned O orned (ins X O) = sg X \ x -> orned (O x) orned (del a O) = orned O ListOrn : Set -> Orn One One _ NatDesc ListOrn X = sg Two \ { tt -> inx (<> , refl) ; ff -> ins X \ _ -> (<> , refl) ! (inx (<> , refl)) } forget : forall {I D J ji} (O : Orn I J ji D) {P : I -> Set} -> {j : J} -> Node J (orned O) (\ j -> P (ji j)) j -> Node I D P (ji j) forget (inx (j , refl)) refl = refl forget (sg A O) (a , o) = a , forget (O a) o forget ((j , refl) ! O) (p , o) = p , forget O o forget (ins X O) (x , o) = forget (O x) o forget (del a O) o = a , forget O o plain : forall {I D J ji} (O : Orn I J ji D) {j : J} -> Mu J (orned O) j -> Mu I D (ji j) plain O = cata _ (orned O) (\ x -> [ forget O {Mu _ _} x ])
{ "alphanum_fraction": 0.4737277617, "avg_line_length": 29.4756097561, "ext": "agda", "hexsha": "f1dad5e2831fac5398d125f190494cf44e73bdbe", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-06-09T05:39:02.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-09T05:39:02.000Z", "max_forks_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "pigworker/WhatRTypes4", "max_forks_repo_path": "TypesMore.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "pigworker/WhatRTypes4", "max_issues_repo_path": "TypesMore.agda", "max_line_length": 66, "max_stars_count": 11, "max_stars_repo_head_hexsha": "21ac5be5a0a04fc75699d595c08b5ae4b7d7712d", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "pigworker/WhatRTypes4", "max_stars_repo_path": "TypesMore.agda", "max_stars_repo_stars_event_max_datetime": "2019-06-09T05:38:44.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-11T09:12:25.000Z", "num_tokens": 965, "size": 2417 }
-- Andreas, 2016-07-17 issue 2101 -- It should be possible to place a single function with a where block -- inside `abstract`. -- This will work if type signatures inside a where-block -- are considered private, since in private type signatures, -- abstract definitions are transparent. -- (Unlike in public type signatures.) record Wrap (A : Set) : Set where field unwrap : A postulate P : ∀{A : Set} → A → Set module AbstractPrivate (A : Set) where abstract B : Set B = Wrap A postulate b : B private -- this no longer (since #418) make abstract defs transparent in type signatures postulate test : P (Wrap.unwrap b) -- should no longer succeed
{ "alphanum_fraction": 0.6810344828, "avg_line_length": 24.8571428571, "ext": "agda", "hexsha": "6f4428fa9cdaed5fa6c3c998f6061419fda49839", "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/Issue2101.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/Issue2101.agda", "max_line_length": 92, "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/Issue2101.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": 177, "size": 696 }
-- Andreas, 2015-03-10, issue reported by Andrea Vezzosi postulate X : Set data D p : X → Set p where c : ∀ i → D _ i -- WAS: internal error in Substitute.hs due to negative De Bruijn index -- should work now
{ "alphanum_fraction": 0.6728110599, "avg_line_length": 18.0833333333, "ext": "agda", "hexsha": "ff0a1ab890bb5606a58d5bc931684717b895d9e2", "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/Issue1454.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/Issue1454.agda", "max_line_length": 71, "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/Issue1454.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": 70, "size": 217 }
{- Name: Bowornmet (Ben) Hudson --Preorders 2: Electric Boogaloo-- -} open import Preliminaries module Preorder-withmax where {- Doing the same thing as we did in Preorder.agda but this time we want to keep our end goal in mind and extend the notion of preorders to include information about maximums as well. This will make it easier to 'ensure' that functions on nats are monotone (because they sometimes aren't - e.g. sine, cosine, etc.) so we can give them a reasonable upper bound. If we don't monotonize functions on nats then that makes bounding more complicated. This also means we have to extend the idea of maximums to all our other types... -} record Preorder-max-str (A : Set) : Set1 where constructor preorder-max field ≤ : A → A → Set refl : ∀ x → ≤ x x trans : ∀ x y z → ≤ x y → ≤ y z → ≤ x z max : A → A → A max-l : ∀ l r → ≤ l (max l r) max-r : ∀ l r → ≤ r (max l r) max-lub : ∀ k l r → ≤ l k → ≤ r k → ≤ (max l r) k ------------------------------------------ -- order on nats ≤nat : Nat → Nat → Set ≤nat Z Z = Unit ≤nat Z (S y) = Unit ≤nat (S x) Z = Void ≤nat (S x) (S y) = ≤nat x y -- proof that Nat is reflexive under ≤ nat-refl : ∀ (x : Nat) → ≤nat x x nat-refl Z = <> nat-refl (S x) = nat-refl x -- proof that Nat is transitive under ≤ nat-trans : ∀ (x y z : Nat) → ≤nat x y → ≤nat y z → ≤nat x z nat-trans Z Z Z p q = <> nat-trans Z Z (S z) p q = <> nat-trans Z (S y) Z p q = <> nat-trans Z (S y) (S z) p q = <> nat-trans (S x) Z Z p q = p nat-trans (S x) Z (S z) () q nat-trans (S x) (S y) Z p () nat-trans (S x) (S y) (S z) p q = nat-trans x y z p q -- nat max nat-max : Nat → Nat → Nat nat-max Z n = n nat-max (S m) Z = S m nat-max (S m) (S n) = S (nat-max m n) -- left max nat-max-l : ∀ (l r : Nat) → ≤nat l (nat-max l r) nat-max-l Z Z = <> nat-max-l Z (S n) = <> nat-max-l (S m) Z = nat-refl m nat-max-l (S m) (S n) = nat-max-l m n -- right max nat-max-r : ∀ (l r : Nat) → ≤nat r (nat-max l r) nat-max-r Z Z = <> nat-max-r Z (S n) = nat-refl n nat-max-r (S m) Z = <> nat-max-r (S m) (S n) = nat-max-r m n -- rub a dub dub, Nats have a lub nat-max-lub : ∀ (k l r : Nat) → ≤nat l k → ≤nat r k → ≤nat (nat-max l r) k nat-max-lub Z Z Z p q = <> nat-max-lub Z Z (S r) p () nat-max-lub Z (S l) Z () q nat-max-lub Z (S l) (S r) () q nat-max-lub (S k) Z Z p q = <> nat-max-lub (S k) Z (S r) p q = q nat-max-lub (S k) (S l) Z p q = p nat-max-lub (S k) (S l) (S r) p q = nat-max-lub k l r p q -- Nat is preorder with max nat-p : Preorder-max-str Nat nat-p = preorder-max ≤nat nat-refl nat-trans nat-max nat-max-l nat-max-r nat-max-lub ------------------------------------------ --same thing for products -- relation for products ≤axb : ∀ {A B : Set} → Preorder-max-str A → Preorder-max-str B → (A × B) → (A × B) → Set ≤axb PA PB (a1 , b1) (a2 , b2) = Preorder-max-str.≤ PA a1 a2 × Preorder-max-str.≤ PB b1 b2 axb-refl : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (x : (A × B)) → ≤axb PA PB x x axb-refl PA PB (a , b) = Preorder-max-str.refl PA a , Preorder-max-str.refl PB b axb-trans : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (x y z : (A × B)) → ≤axb PA PB x y → ≤axb PA PB y z → ≤axb PA PB x z axb-trans PA PB (a1 , b1) (a2 , b2) (a3 , b3) (a1<a2 , b1<b2) (a2<a3 , b2<b3) = Preorder-max-str.trans PA a1 a2 a3 a1<a2 a2<a3 , Preorder-max-str.trans PB b1 b2 b3 b1<b2 b2<b3 axb-max : ∀ {A B : Set} → Preorder-max-str A → Preorder-max-str B → (A × B) → (A × B) → (A × B) axb-max PA PB (a1 , b1) (a2 , b2) = Preorder-max-str.max PA a1 a2 , Preorder-max-str.max PB b1 b2 axb-max-l : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (l r : (A × B)) → ≤axb PA PB l (axb-max PA PB l r) axb-max-l PA PB (a1 , b1) (a2 , b2) = Preorder-max-str.max-l PA a1 a2 , Preorder-max-str.max-l PB b1 b2 axb-max-r : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (l r : (A × B)) → ≤axb PA PB r (axb-max PA PB l r) axb-max-r PA PB (a1 , b1) (a2 , b2) = Preorder-max-str.max-r PA a1 a2 , Preorder-max-str.max-r PB b1 b2 axb-max-lub : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (k l r : (A × B)) → ≤axb PA PB l k → ≤axb PA PB r k → ≤axb PA PB (axb-max PA PB l r) k axb-max-lub PA PB (k1 , k2) (l1 , l2) (r1 , r2) (l1<k1 , l2<k2) (r1<k1 , r2<k2) = Preorder-max-str.max-lub PA k1 l1 r1 l1<k1 r1<k1 , Preorder-max-str.max-lub PB k2 l2 r2 l2<k2 r2<k2 axb-p : ∀ (A B : Set) → Preorder-max-str A → Preorder-max-str B → Preorder-max-str (A × B) axb-p A B PA PB = preorder-max (≤axb PA PB) (axb-refl PA PB) (axb-trans PA PB) (axb-max PA PB) (axb-max-l PA PB) (axb-max-r PA PB) (axb-max-lub PA PB) ------------------------------------------ -- the type of monotone functions from A to B record Monotone (A : Set) (B : Set) (PA : Preorder-max-str A) (PB : Preorder-max-str B) : Set where constructor monotone field f : A → B is-monotone : ∀ (x y : A) → Preorder-max-str.≤ PA x y → Preorder-max-str.≤ PB (f x) (f y) ≤mono : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (Monotone A B PA PB) → (Monotone A B PA PB) → Set ≤mono {A} PA PB f g = (x : A) → Preorder-max-str.≤ PB (Monotone.f f x) (Monotone.f g x) mono-refl : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (x : (Monotone A B PA PB)) → ≤mono PA PB x x mono-refl PA PB f = λ x → Preorder-max-str.refl PB (Monotone.f f x) mono-trans : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (x y z : (Monotone A B PA PB)) → ≤mono PA PB x y → ≤mono PA PB y z → ≤mono PA PB x z mono-trans PA PB f g h p q = λ x → Preorder-max-str.trans PB (Monotone.f f x) (Monotone.f g x) (Monotone.f h x) (p x) (q x) mono-max : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (Monotone A B PA PB) → (Monotone A B PA PB) → (Monotone A B PA PB) mono-max PA PB (monotone f f-ismono) (monotone g g-ismono) = monotone (λ x → Preorder-max-str.max PB (f x) (g x)) (λ x y x₁ → Preorder-max-str.max-lub PB (Preorder-max-str.max PB (f y) (g y)) (f x) (g x) (Preorder-max-str.trans PB (f x) (f y) (Preorder-max-str.max PB (f y) (g y)) (f-ismono x y x₁) (Preorder-max-str.max-l PB (f y) (g y))) (Preorder-max-str.trans PB (g x) (g y) (Preorder-max-str.max PB (f y) (g y)) (g-ismono x y x₁) (Preorder-max-str.max-r PB (f y) (g y)))) mono-max-l : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (l r : Monotone A B PA PB) → ≤mono PA PB l (mono-max PA PB l r) mono-max-l PA PB f g = λ x → Preorder-max-str.max-l PB (Monotone.f f x) (Monotone.f g x) mono-max-r : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (l r : Monotone A B PA PB) → ≤mono PA PB r (mono-max PA PB l r) mono-max-r PA PB f g = λ x → Preorder-max-str.max-r PB (Monotone.f f x) (Monotone.f g x) mono-max-lub : ∀ {A B : Set} → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → (k l r : Monotone A B PA PB) → ≤mono PA PB l k → ≤mono PA PB r k → ≤mono PA PB (mono-max PA PB l r) k mono-max-lub PA PB f g h p q = λ x → Preorder-max-str.max-lub PB (Monotone.f f x) (Monotone.f g x) (Monotone.f h x) (p x) (q x) mono-p : ∀ (A B : Set) → (PA : Preorder-max-str A) → (PB : Preorder-max-str B) → Preorder-max-str (Monotone A B PA PB) mono-p A B PA PB = preorder-max (≤mono PA PB) (mono-refl PA PB) (mono-trans PA PB) (mono-max PA PB) (mono-max-l PA PB) (mono-max-r PA PB) (mono-max-lub PA PB) ------------------------------------------ --"Hey, let's make things monotone!" -- another way to define the ≤ relation on Nat data _≤'_ : Nat → Nat → Set where x≤'x : {x : Nat} → x ≤' x x≤'y : {x y : Nat} → x ≤' y → x ≤' (S y) -- silly lemmas about silly nats nat-lemma : (x : Nat) → Z ≤' x nat-lemma Z = x≤'x nat-lemma (S x) = x≤'y (nat-lemma x) nat-lemma2 : (x y : Nat) → x ≤' y → (S x) ≤' (S y) nat-lemma2 .y y x≤'x = x≤'x nat-lemma2 x .(S y) (x≤'y {.x} {y} p) = x≤'y (nat-lemma2 x y p) nat-lemma3 : (x : Nat) → ≤nat x (S x) nat-lemma3 Z = <> nat-lemma3 (S x) = nat-lemma3 x -- maps to and from the old and new definitions of the ≤ relation ≤-map : (x y : Nat) → ≤nat x y → x ≤' y ≤-map Z Z f = x≤'x ≤-map Z (S y) f = nat-lemma (S y) ≤-map (S x) Z () ≤-map (S x) (S y) f = nat-lemma2 x y (≤-map x y f) ≤-map2 : (x y : Nat) → x ≤' y → ≤nat x y ≤-map2 .y y x≤'x = nat-refl y ≤-map2 x .(S y) (x≤'y {.x} {y} f) = nat-trans x y (S y) (≤-map2 x y f) (nat-lemma3 y) -- a function to find the maximum of a whole set and not just a pair of values max' : ∀ {A : Set} → (PA : Preorder-max-str A) → Nat → (Nat → A) → A max' PA Z f = f Z max' PA (S n) f = Preorder-max-str.max PA (f (S n)) (max' PA n f) -- primitive recursion function corresponding to rec natrec : ∀{C : Set} → C → (Nat → C → C) → Nat → C natrec base step Z = base natrec base step (S n) = step n (natrec base step n) -- another lemma mono-f-lemma : ∀ {A : Set} → (x y : Nat) → x ≤' y → (PA : Preorder-max-str A) → (f : Nat → A) → Preorder-max-str.≤ PA (max' PA x f) (max' PA y f) mono-f-lemma .y y x≤'x PA f = Preorder-max-str.refl PA (max' PA y f) mono-f-lemma x .(S y) (x≤'y {.x} {y} p) PA f = Preorder-max-str.trans PA (max' PA x f) (max' PA y f) (max' PA (S y) f) (mono-f-lemma x y p PA f) (Preorder-max-str.max-r PA (f (S y)) (max' PA y f)) -- make a function monotone by taking the max at every point mono-f : ∀ {A : Set} → (PA : Preorder-max-str A) → (f : Nat → A) → Monotone Nat A nat-p PA mono-f PA f = monotone (λ x → max' PA x f) (λ x y x₁ → mono-f-lemma x y (≤-map x y x₁) PA f) -- f ≤ (monotonization of f) mono-f-is-monotone : ∀ {A : Set} → (PA : Preorder-max-str A) → (x : Nat) → (f : Nat → A) → Preorder-max-str.≤ PA (f x) (Monotone.f (mono-f PA f) x) mono-f-is-monotone PA Z f = Preorder-max-str.refl PA (f Z) mono-f-is-monotone PA (S x) f = Preorder-max-str.max-l PA (f (S x)) (max' PA x f) -- if f is already monotone, then its monotonization is less than or equal to itself mono-f-≤-itself : ∀ {A : Set} → (PA : Preorder-max-str A) → (x : Nat) → (f : Monotone Nat A nat-p PA) → Preorder-max-str.≤ PA (Monotone.f (mono-f PA (Monotone.f f)) x) (Monotone.f f x) mono-f-≤-itself PA Z f = Preorder-max-str.refl PA (Monotone.f (mono-f PA (Monotone.f f)) Z) mono-f-≤-itself PA (S x) f = Preorder-max-str.max-lub PA (Monotone.f f (S x)) (Monotone.f f (S x)) (max' PA x (Monotone.f f)) (Preorder-max-str.refl PA (Monotone.f f (S x))) (Preorder-max-str.trans PA (max' PA x (Monotone.f f)) (Monotone.f f x) (Monotone.f f (S x)) (mono-f-≤-itself PA x f) (Monotone.is-monotone f x (S x) (≤-map2 x (S x) (x≤'y x≤'x)))) -- monotonize at the end mnatrec : ∀ {A : Set} → (PA : Preorder-max-str A) → A → (Nat → A → A) → Nat → A mnatrec PA zc sc e = max' PA e (natrec zc sc) -- still incorrect mono-natrec : ∀ {A : Set} → (PA : Preorder-max-str A) → A → (Nat → A → A) → Nat → A mono-natrec PA zc sc Z = zc mono-natrec PA zc sc (S y') = Preorder-max-str.max PA zc (sc y' (mono-natrec PA zc sc y')) data N' : Set where Z1 : N' Sa : N' → N' Sb : N' → N' ------------------------------------------ -- same thing as Preorder.agda but for this module PREORDER = Σ (λ (A : Set) → Preorder-max-str A) MONOTONE : (PΓ PA : PREORDER) → Set MONOTONE (Γ , PΓ) (A , PA) = Monotone Γ A PΓ PA -- some operations _×p_ : PREORDER → PREORDER → PREORDER (A , PA) ×p (B , PB) = A × B , axb-p A B PA PB _->p_ : PREORDER → PREORDER → PREORDER (A , PA) ->p (B , PB) = Monotone A B PA PB , mono-p A B PA PB -- Unit is a preorder unit-p : PREORDER unit-p = Unit , preorder-max (λ x x₁ → Unit) (λ x → <>) (λ x y z _ _ → <>) (λ _ _ → <>) (λ l r → <>) (λ l r → <>) (λ k l r _ _ → <>) -- identity preserves monotonicity id : ∀ {Γ} → MONOTONE Γ Γ id = λ {Γ} → monotone (λ x → x) (λ x y x₁ → x₁) -- composition preserves monotonicity comp : ∀ {PA PB PC} → MONOTONE PA PB → MONOTONE PB PC → MONOTONE PA PC comp (monotone f f-ismono) (monotone g g-ismono) = monotone (λ x → g (f x)) (λ x y x₁ → g-ismono (f x) (f y) (f-ismono x y x₁)) -- proofs that types like pairs etc. with preorders are monotone pair' : ∀ {PΓ PA PB} → MONOTONE PΓ PA → MONOTONE PΓ PB → MONOTONE PΓ (PA ×p PB) pair' (monotone f f-ismono) (monotone g g-ismono) = monotone (λ x → (f x) , (g x)) (λ x y x₁ → f-ismono x y x₁ , g-ismono x y x₁) fst' : ∀ {PΓ PA PB} → MONOTONE PΓ (PA ×p PB) → MONOTONE PΓ PA fst' (monotone f f-ismono) = monotone (λ x → fst (f x)) (λ x y z → fst (f-ismono x y z)) snd' : ∀ {PΓ PA PB} → MONOTONE PΓ (PA ×p PB) → MONOTONE PΓ PB snd' (monotone f f-ismono) = monotone (λ x → snd (f x)) (λ x y z → snd (f-ismono x y z)) lam' : ∀ {PΓ PA PB} → MONOTONE (PΓ ×p PA) PB → MONOTONE PΓ (PA ->p PB) lam' {Γ , preorder-max _ reflΓ _ _ _ _ _} {A , preorder-max _ refla _ _ _ _ _} (monotone f f-ismono) = monotone (λ x → monotone (λ p → f (x , p)) (λ a b c → f-ismono (x , a) (x , b) ((reflΓ x) , c))) (λ x y z w → f-ismono (x , w) (y , w) (z , (refla w))) app' : ∀ {PΓ PA PB} → MONOTONE PΓ (PA ->p PB) → MONOTONE PΓ PA → MONOTONE PΓ PB app' {_} {_} {b , preorder-max _ _ transb _ _ _ _} (monotone f f-ismono) (monotone g g-ismono) = monotone (λ x → Monotone.f (f x) (g x)) (λ x y z → transb (Monotone.f (f x) (g x)) (Monotone.f (f y) (g x)) (Monotone.f (f y) (g y)) (f-ismono x y z (g x)) (Monotone.is-monotone (f y) (g x) (g y) (g-ismono x y z)))
{ "alphanum_fraction": 0.5311757305, "avg_line_length": 47.3708609272, "ext": "agda", "hexsha": "e9b9c778158f2286af78aff460d9303d8acffe9e", "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-drafts/Preorder-withmax.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-drafts/Preorder-withmax.agda", "max_line_length": 171, "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-drafts/Preorder-withmax.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": 5593, "size": 14306 }
module Text.Greek.SBLGNT.Jude where open import Data.List open import Text.Greek.Bible open import Text.Greek.Script open import Text.Greek.Script.Unicode ΙΟΥΔΑ : List (Word) ΙΟΥΔΑ = word (Ἰ ∷ ο ∷ ύ ∷ δ ∷ α ∷ ς ∷ []) "Jude.1.1" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Jude.1.1" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.1" ∷ word (δ ∷ ο ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "Jude.1.1" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ὸ ∷ ς ∷ []) "Jude.1.1" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.1" ∷ word (Ἰ ∷ α ∷ κ ∷ ώ ∷ β ∷ ο ∷ υ ∷ []) "Jude.1.1" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Jude.1.1" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.1" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "Jude.1.1" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὶ ∷ []) "Jude.1.1" ∷ word (ἠ ∷ γ ∷ α ∷ π ∷ η ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.1" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Jude.1.1" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Jude.1.1" ∷ word (τ ∷ ε ∷ τ ∷ η ∷ ρ ∷ η ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.1" ∷ word (κ ∷ ∙λ ∷ η ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Jude.1.1" ∷ word (ἔ ∷ ∙λ ∷ ε ∷ ο ∷ ς ∷ []) "Jude.1.2" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Jude.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.2" ∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "Jude.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.2" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ []) "Jude.1.2" ∷ word (π ∷ ∙λ ∷ η ∷ θ ∷ υ ∷ ν ∷ θ ∷ ε ∷ ί ∷ η ∷ []) "Jude.1.2" ∷ word (Ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.3" ∷ word (π ∷ ᾶ ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.3" ∷ word (σ ∷ π ∷ ο ∷ υ ∷ δ ∷ ὴ ∷ ν ∷ []) "Jude.1.3" ∷ word (π ∷ ο ∷ ι ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Jude.1.3" ∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ε ∷ ι ∷ ν ∷ []) "Jude.1.3" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Jude.1.3" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Jude.1.3" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Jude.1.3" ∷ word (κ ∷ ο ∷ ι ∷ ν ∷ ῆ ∷ ς ∷ []) "Jude.1.3" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.3" ∷ word (σ ∷ ω ∷ τ ∷ η ∷ ρ ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.3" ∷ word (ἀ ∷ ν ∷ ά ∷ γ ∷ κ ∷ η ∷ ν ∷ []) "Jude.1.3" ∷ word (ἔ ∷ σ ∷ χ ∷ ο ∷ ν ∷ []) "Jude.1.3" ∷ word (γ ∷ ρ ∷ ά ∷ ψ ∷ α ∷ ι ∷ []) "Jude.1.3" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Jude.1.3" ∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ῶ ∷ ν ∷ []) "Jude.1.3" ∷ word (ἐ ∷ π ∷ α ∷ γ ∷ ω ∷ ν ∷ ί ∷ ζ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Jude.1.3" ∷ word (τ ∷ ῇ ∷ []) "Jude.1.3" ∷ word (ἅ ∷ π ∷ α ∷ ξ ∷ []) "Jude.1.3" ∷ word (π ∷ α ∷ ρ ∷ α ∷ δ ∷ ο ∷ θ ∷ ε ∷ ί ∷ σ ∷ ῃ ∷ []) "Jude.1.3" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Jude.1.3" ∷ word (ἁ ∷ γ ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.3" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "Jude.1.3" ∷ word (π ∷ α ∷ ρ ∷ ε ∷ ι ∷ σ ∷ έ ∷ δ ∷ υ ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.4" ∷ word (γ ∷ ά ∷ ρ ∷ []) "Jude.1.4" ∷ word (τ ∷ ι ∷ ν ∷ ε ∷ ς ∷ []) "Jude.1.4" ∷ word (ἄ ∷ ν ∷ θ ∷ ρ ∷ ω ∷ π ∷ ο ∷ ι ∷ []) "Jude.1.4" ∷ word (ο ∷ ἱ ∷ []) "Jude.1.4" ∷ word (π ∷ ά ∷ ∙λ ∷ α ∷ ι ∷ []) "Jude.1.4" ∷ word (π ∷ ρ ∷ ο ∷ γ ∷ ε ∷ γ ∷ ρ ∷ α ∷ μ ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.4" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.4" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Jude.1.4" ∷ word (τ ∷ ὸ ∷ []) "Jude.1.4" ∷ word (κ ∷ ρ ∷ ί ∷ μ ∷ α ∷ []) "Jude.1.4" ∷ word (ἀ ∷ σ ∷ ε ∷ β ∷ ε ∷ ῖ ∷ ς ∷ []) "Jude.1.4" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Jude.1.4" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.4" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Jude.1.4" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.4" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ τ ∷ α ∷ []) "Jude.1.4" ∷ word (μ ∷ ε ∷ τ ∷ α ∷ τ ∷ ι ∷ θ ∷ έ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.4" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.4" ∷ word (ἀ ∷ σ ∷ έ ∷ ∙λ ∷ γ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "Jude.1.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.4" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Jude.1.4" ∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "Jude.1.4" ∷ word (δ ∷ ε ∷ σ ∷ π ∷ ό ∷ τ ∷ η ∷ ν ∷ []) "Jude.1.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.4" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.4" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.4" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ν ∷ []) "Jude.1.4" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ν ∷ []) "Jude.1.4" ∷ word (ἀ ∷ ρ ∷ ν ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.4" ∷ word (Ὑ ∷ π ∷ ο ∷ μ ∷ ν ∷ ῆ ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.5" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.5" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Jude.1.5" ∷ word (β ∷ ο ∷ ύ ∷ ∙λ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Jude.1.5" ∷ word (ε ∷ ἰ ∷ δ ∷ ό ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.5" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Jude.1.5" ∷ word (ἅ ∷ π ∷ α ∷ ξ ∷ []) "Jude.1.5" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Jude.1.5" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Jude.1.5" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ς ∷ []) "Jude.1.5" ∷ word (∙λ ∷ α ∷ ὸ ∷ ν ∷ []) "Jude.1.5" ∷ word (ἐ ∷ κ ∷ []) "Jude.1.5" ∷ word (γ ∷ ῆ ∷ ς ∷ []) "Jude.1.5" ∷ word (Α ∷ ἰ ∷ γ ∷ ύ ∷ π ∷ τ ∷ ο ∷ υ ∷ []) "Jude.1.5" ∷ word (σ ∷ ώ ∷ σ ∷ α ∷ ς ∷ []) "Jude.1.5" ∷ word (τ ∷ ὸ ∷ []) "Jude.1.5" ∷ word (δ ∷ ε ∷ ύ ∷ τ ∷ ε ∷ ρ ∷ ο ∷ ν ∷ []) "Jude.1.5" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.5" ∷ word (μ ∷ ὴ ∷ []) "Jude.1.5" ∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ σ ∷ α ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.5" ∷ word (ἀ ∷ π ∷ ώ ∷ ∙λ ∷ ε ∷ σ ∷ ε ∷ ν ∷ []) "Jude.1.5" ∷ word (ἀ ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "Jude.1.6" ∷ word (τ ∷ ε ∷ []) "Jude.1.6" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.6" ∷ word (μ ∷ ὴ ∷ []) "Jude.1.6" ∷ word (τ ∷ η ∷ ρ ∷ ή ∷ σ ∷ α ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.6" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Jude.1.6" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.6" ∷ word (ἀ ∷ ρ ∷ χ ∷ ὴ ∷ ν ∷ []) "Jude.1.6" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Jude.1.6" ∷ word (ἀ ∷ π ∷ ο ∷ ∙λ ∷ ι ∷ π ∷ ό ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.6" ∷ word (τ ∷ ὸ ∷ []) "Jude.1.6" ∷ word (ἴ ∷ δ ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.6" ∷ word (ο ∷ ἰ ∷ κ ∷ η ∷ τ ∷ ή ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.6" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.6" ∷ word (κ ∷ ρ ∷ ί ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.6" ∷ word (μ ∷ ε ∷ γ ∷ ά ∷ ∙λ ∷ η ∷ ς ∷ []) "Jude.1.6" ∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "Jude.1.6" ∷ word (δ ∷ ε ∷ σ ∷ μ ∷ ο ∷ ῖ ∷ ς ∷ []) "Jude.1.6" ∷ word (ἀ ∷ ϊ ∷ δ ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.6" ∷ word (ὑ ∷ π ∷ ὸ ∷ []) "Jude.1.6" ∷ word (ζ ∷ ό ∷ φ ∷ ο ∷ ν ∷ []) "Jude.1.6" ∷ word (τ ∷ ε ∷ τ ∷ ή ∷ ρ ∷ η ∷ κ ∷ ε ∷ ν ∷ []) "Jude.1.6" ∷ word (ὡ ∷ ς ∷ []) "Jude.1.7" ∷ word (Σ ∷ ό ∷ δ ∷ ο ∷ μ ∷ α ∷ []) "Jude.1.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.7" ∷ word (Γ ∷ ό ∷ μ ∷ ο ∷ ρ ∷ ρ ∷ α ∷ []) "Jude.1.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.7" ∷ word (α ∷ ἱ ∷ []) "Jude.1.7" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Jude.1.7" ∷ word (α ∷ ὐ ∷ τ ∷ ὰ ∷ ς ∷ []) "Jude.1.7" ∷ word (π ∷ ό ∷ ∙λ ∷ ε ∷ ι ∷ ς ∷ []) "Jude.1.7" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Jude.1.7" ∷ word (ὅ ∷ μ ∷ ο ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.7" ∷ word (τ ∷ ρ ∷ ό ∷ π ∷ ο ∷ ν ∷ []) "Jude.1.7" ∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.7" ∷ word (ἐ ∷ κ ∷ π ∷ ο ∷ ρ ∷ ν ∷ ε ∷ ύ ∷ σ ∷ α ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.7" ∷ word (ἀ ∷ π ∷ ε ∷ ∙λ ∷ θ ∷ ο ∷ ῦ ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.7" ∷ word (ὀ ∷ π ∷ ί ∷ σ ∷ ω ∷ []) "Jude.1.7" ∷ word (σ ∷ α ∷ ρ ∷ κ ∷ ὸ ∷ ς ∷ []) "Jude.1.7" ∷ word (ἑ ∷ τ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "Jude.1.7" ∷ word (π ∷ ρ ∷ ό ∷ κ ∷ ε ∷ ι ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.7" ∷ word (δ ∷ ε ∷ ῖ ∷ γ ∷ μ ∷ α ∷ []) "Jude.1.7" ∷ word (π ∷ υ ∷ ρ ∷ ὸ ∷ ς ∷ []) "Jude.1.7" ∷ word (α ∷ ἰ ∷ ω ∷ ν ∷ ί ∷ ο ∷ υ ∷ []) "Jude.1.7" ∷ word (δ ∷ ί ∷ κ ∷ η ∷ ν ∷ []) "Jude.1.7" ∷ word (ὑ ∷ π ∷ έ ∷ χ ∷ ο ∷ υ ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.7" ∷ word (Ὁ ∷ μ ∷ ο ∷ ί ∷ ω ∷ ς ∷ []) "Jude.1.8" ∷ word (μ ∷ έ ∷ ν ∷ τ ∷ ο ∷ ι ∷ []) "Jude.1.8" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.8" ∷ word (ο ∷ ὗ ∷ τ ∷ ο ∷ ι ∷ []) "Jude.1.8" ∷ word (ἐ ∷ ν ∷ υ ∷ π ∷ ν ∷ ι ∷ α ∷ ζ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.8" ∷ word (σ ∷ ά ∷ ρ ∷ κ ∷ α ∷ []) "Jude.1.8" ∷ word (μ ∷ ὲ ∷ ν ∷ []) "Jude.1.8" ∷ word (μ ∷ ι ∷ α ∷ ί ∷ ν ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.8" ∷ word (κ ∷ υ ∷ ρ ∷ ι ∷ ό ∷ τ ∷ η ∷ τ ∷ α ∷ []) "Jude.1.8" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.8" ∷ word (ἀ ∷ θ ∷ ε ∷ τ ∷ ο ∷ ῦ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.8" ∷ word (δ ∷ ό ∷ ξ ∷ α ∷ ς ∷ []) "Jude.1.8" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.8" ∷ word (β ∷ ∙λ ∷ α ∷ σ ∷ φ ∷ η ∷ μ ∷ ο ∷ ῦ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.8" ∷ word (ὁ ∷ []) "Jude.1.9" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.9" ∷ word (Μ ∷ ι ∷ χ ∷ α ∷ ὴ ∷ ∙λ ∷ []) "Jude.1.9" ∷ word (ὁ ∷ []) "Jude.1.9" ∷ word (ἀ ∷ ρ ∷ χ ∷ ά ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ο ∷ ς ∷ []) "Jude.1.9" ∷ word (ὅ ∷ τ ∷ ε ∷ []) "Jude.1.9" ∷ word (τ ∷ ῷ ∷ []) "Jude.1.9" ∷ word (δ ∷ ι ∷ α ∷ β ∷ ό ∷ ∙λ ∷ ῳ ∷ []) "Jude.1.9" ∷ word (δ ∷ ι ∷ α ∷ κ ∷ ρ ∷ ι ∷ ν ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Jude.1.9" ∷ word (δ ∷ ι ∷ ε ∷ ∙λ ∷ έ ∷ γ ∷ ε ∷ τ ∷ ο ∷ []) "Jude.1.9" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Jude.1.9" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.9" ∷ word (Μ ∷ ω ∷ ϋ ∷ σ ∷ έ ∷ ω ∷ ς ∷ []) "Jude.1.9" ∷ word (σ ∷ ώ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "Jude.1.9" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "Jude.1.9" ∷ word (ἐ ∷ τ ∷ ό ∷ ∙λ ∷ μ ∷ η ∷ σ ∷ ε ∷ ν ∷ []) "Jude.1.9" ∷ word (κ ∷ ρ ∷ ί ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.9" ∷ word (ἐ ∷ π ∷ ε ∷ ν ∷ ε ∷ γ ∷ κ ∷ ε ∷ ῖ ∷ ν ∷ []) "Jude.1.9" ∷ word (β ∷ ∙λ ∷ α ∷ σ ∷ φ ∷ η ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.9" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Jude.1.9" ∷ word (ε ∷ ἶ ∷ π ∷ ε ∷ ν ∷ []) "Jude.1.9" ∷ word (Ἐ ∷ π ∷ ι ∷ τ ∷ ι ∷ μ ∷ ή ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.9" ∷ word (σ ∷ ο ∷ ι ∷ []) "Jude.1.9" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "Jude.1.9" ∷ word (ο ∷ ὗ ∷ τ ∷ ο ∷ ι ∷ []) "Jude.1.10" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.10" ∷ word (ὅ ∷ σ ∷ α ∷ []) "Jude.1.10" ∷ word (μ ∷ ὲ ∷ ν ∷ []) "Jude.1.10" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "Jude.1.10" ∷ word (ο ∷ ἴ ∷ δ ∷ α ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.10" ∷ word (β ∷ ∙λ ∷ α ∷ σ ∷ φ ∷ η ∷ μ ∷ ο ∷ ῦ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.10" ∷ word (ὅ ∷ σ ∷ α ∷ []) "Jude.1.10" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.10" ∷ word (φ ∷ υ ∷ σ ∷ ι ∷ κ ∷ ῶ ∷ ς ∷ []) "Jude.1.10" ∷ word (ὡ ∷ ς ∷ []) "Jude.1.10" ∷ word (τ ∷ ὰ ∷ []) "Jude.1.10" ∷ word (ἄ ∷ ∙λ ∷ ο ∷ γ ∷ α ∷ []) "Jude.1.10" ∷ word (ζ ∷ ῷ ∷ α ∷ []) "Jude.1.10" ∷ word (ἐ ∷ π ∷ ί ∷ σ ∷ τ ∷ α ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.10" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.10" ∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.10" ∷ word (φ ∷ θ ∷ ε ∷ ί ∷ ρ ∷ ο ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.10" ∷ word (ο ∷ ὐ ∷ α ∷ ὶ ∷ []) "Jude.1.11" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Jude.1.11" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Jude.1.11" ∷ word (τ ∷ ῇ ∷ []) "Jude.1.11" ∷ word (ὁ ∷ δ ∷ ῷ ∷ []) "Jude.1.11" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.11" ∷ word (Κ ∷ ά ∷ ϊ ∷ ν ∷ []) "Jude.1.11" ∷ word (ἐ ∷ π ∷ ο ∷ ρ ∷ ε ∷ ύ ∷ θ ∷ η ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.11" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.11" ∷ word (τ ∷ ῇ ∷ []) "Jude.1.11" ∷ word (π ∷ ∙λ ∷ ά ∷ ν ∷ ῃ ∷ []) "Jude.1.11" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.11" ∷ word (Β ∷ α ∷ ∙λ ∷ α ∷ ὰ ∷ μ ∷ []) "Jude.1.11" ∷ word (μ ∷ ι ∷ σ ∷ θ ∷ ο ∷ ῦ ∷ []) "Jude.1.11" ∷ word (ἐ ∷ ξ ∷ ε ∷ χ ∷ ύ ∷ θ ∷ η ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.11" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.11" ∷ word (τ ∷ ῇ ∷ []) "Jude.1.11" ∷ word (ἀ ∷ ν ∷ τ ∷ ι ∷ ∙λ ∷ ο ∷ γ ∷ ί ∷ ᾳ ∷ []) "Jude.1.11" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.11" ∷ word (Κ ∷ ό ∷ ρ ∷ ε ∷ []) "Jude.1.11" ∷ word (ἀ ∷ π ∷ ώ ∷ ∙λ ∷ ο ∷ ν ∷ τ ∷ ο ∷ []) "Jude.1.11" ∷ word (ο ∷ ὗ ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.12" ∷ word (ε ∷ ἰ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.12" ∷ word (ο ∷ ἱ ∷ []) "Jude.1.12" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.12" ∷ word (τ ∷ α ∷ ῖ ∷ ς ∷ []) "Jude.1.12" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ α ∷ ι ∷ ς ∷ []) "Jude.1.12" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.12" ∷ word (σ ∷ π ∷ ι ∷ ∙λ ∷ ά ∷ δ ∷ ε ∷ ς ∷ []) "Jude.1.12" ∷ word (σ ∷ υ ∷ ν ∷ ε ∷ υ ∷ ω ∷ χ ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.12" ∷ word (ἀ ∷ φ ∷ ό ∷ β ∷ ω ∷ ς ∷ []) "Jude.1.12" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.12" ∷ word (π ∷ ο ∷ ι ∷ μ ∷ α ∷ ί ∷ ν ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.12" ∷ word (ν ∷ ε ∷ φ ∷ έ ∷ ∙λ ∷ α ∷ ι ∷ []) "Jude.1.12" ∷ word (ἄ ∷ ν ∷ υ ∷ δ ∷ ρ ∷ ο ∷ ι ∷ []) "Jude.1.12" ∷ word (ὑ ∷ π ∷ ὸ ∷ []) "Jude.1.12" ∷ word (ἀ ∷ ν ∷ έ ∷ μ ∷ ω ∷ ν ∷ []) "Jude.1.12" ∷ word (π ∷ α ∷ ρ ∷ α ∷ φ ∷ ε ∷ ρ ∷ ό ∷ μ ∷ ε ∷ ν ∷ α ∷ ι ∷ []) "Jude.1.12" ∷ word (δ ∷ έ ∷ ν ∷ δ ∷ ρ ∷ α ∷ []) "Jude.1.12" ∷ word (φ ∷ θ ∷ ι ∷ ν ∷ ο ∷ π ∷ ω ∷ ρ ∷ ι ∷ ν ∷ ὰ ∷ []) "Jude.1.12" ∷ word (ἄ ∷ κ ∷ α ∷ ρ ∷ π ∷ α ∷ []) "Jude.1.12" ∷ word (δ ∷ ὶ ∷ ς ∷ []) "Jude.1.12" ∷ word (ἀ ∷ π ∷ ο ∷ θ ∷ α ∷ ν ∷ ό ∷ ν ∷ τ ∷ α ∷ []) "Jude.1.12" ∷ word (ἐ ∷ κ ∷ ρ ∷ ι ∷ ζ ∷ ω ∷ θ ∷ έ ∷ ν ∷ τ ∷ α ∷ []) "Jude.1.12" ∷ word (κ ∷ ύ ∷ μ ∷ α ∷ τ ∷ α ∷ []) "Jude.1.13" ∷ word (ἄ ∷ γ ∷ ρ ∷ ι ∷ α ∷ []) "Jude.1.13" ∷ word (θ ∷ α ∷ ∙λ ∷ ά ∷ σ ∷ σ ∷ η ∷ ς ∷ []) "Jude.1.13" ∷ word (ἐ ∷ π ∷ α ∷ φ ∷ ρ ∷ ί ∷ ζ ∷ ο ∷ ν ∷ τ ∷ α ∷ []) "Jude.1.13" ∷ word (τ ∷ ὰ ∷ ς ∷ []) "Jude.1.13" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.13" ∷ word (α ∷ ἰ ∷ σ ∷ χ ∷ ύ ∷ ν ∷ α ∷ ς ∷ []) "Jude.1.13" ∷ word (ἀ ∷ σ ∷ τ ∷ έ ∷ ρ ∷ ε ∷ ς ∷ []) "Jude.1.13" ∷ word (π ∷ ∙λ ∷ α ∷ ν ∷ ῆ ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.13" ∷ word (ο ∷ ἷ ∷ ς ∷ []) "Jude.1.13" ∷ word (ὁ ∷ []) "Jude.1.13" ∷ word (ζ ∷ ό ∷ φ ∷ ο ∷ ς ∷ []) "Jude.1.13" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.13" ∷ word (σ ∷ κ ∷ ό ∷ τ ∷ ο ∷ υ ∷ ς ∷ []) "Jude.1.13" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.13" ∷ word (α ∷ ἰ ∷ ῶ ∷ ν ∷ α ∷ []) "Jude.1.13" ∷ word (τ ∷ ε ∷ τ ∷ ή ∷ ρ ∷ η ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.13" ∷ word (Π ∷ ρ ∷ ο ∷ ε ∷ φ ∷ ή ∷ τ ∷ ε ∷ υ ∷ σ ∷ ε ∷ ν ∷ []) "Jude.1.14" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.14" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.14" ∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ο ∷ ι ∷ ς ∷ []) "Jude.1.14" ∷ word (ἕ ∷ β ∷ δ ∷ ο ∷ μ ∷ ο ∷ ς ∷ []) "Jude.1.14" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "Jude.1.14" ∷ word (Ἀ ∷ δ ∷ ὰ ∷ μ ∷ []) "Jude.1.14" ∷ word (Ἑ ∷ ν ∷ ὼ ∷ χ ∷ []) "Jude.1.14" ∷ word (∙λ ∷ έ ∷ γ ∷ ω ∷ ν ∷ []) "Jude.1.14" ∷ word (Ἰ ∷ δ ∷ ο ∷ ὺ ∷ []) "Jude.1.14" ∷ word (ἦ ∷ ∙λ ∷ θ ∷ ε ∷ ν ∷ []) "Jude.1.14" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "Jude.1.14" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.14" ∷ word (ἁ ∷ γ ∷ ί ∷ α ∷ ι ∷ ς ∷ []) "Jude.1.14" ∷ word (μ ∷ υ ∷ ρ ∷ ι ∷ ά ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.14" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.14" ∷ word (π ∷ ο ∷ ι ∷ ῆ ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.15" ∷ word (κ ∷ ρ ∷ ί ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.15" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Jude.1.15" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "Jude.1.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.15" ∷ word (ἐ ∷ ∙λ ∷ έ ∷ γ ∷ ξ ∷ α ∷ ι ∷ []) "Jude.1.15" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.15" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.15" ∷ word (ἀ ∷ σ ∷ ε ∷ β ∷ ε ∷ ῖ ∷ ς ∷ []) "Jude.1.15" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Jude.1.15" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "Jude.1.15" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.15" ∷ word (ἔ ∷ ρ ∷ γ ∷ ω ∷ ν ∷ []) "Jude.1.15" ∷ word (ἀ ∷ σ ∷ ε ∷ β ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.15" ∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.15" ∷ word (ὧ ∷ ν ∷ []) "Jude.1.15" ∷ word (ἠ ∷ σ ∷ έ ∷ β ∷ η ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.15" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Jude.1.15" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "Jude.1.15" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.15" ∷ word (σ ∷ κ ∷ ∙λ ∷ η ∷ ρ ∷ ῶ ∷ ν ∷ []) "Jude.1.15" ∷ word (ὧ ∷ ν ∷ []) "Jude.1.15" ∷ word (ἐ ∷ ∙λ ∷ ά ∷ ∙λ ∷ η ∷ σ ∷ α ∷ ν ∷ []) "Jude.1.15" ∷ word (κ ∷ α ∷ τ ∷ []) "Jude.1.15" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.15" ∷ word (ἁ ∷ μ ∷ α ∷ ρ ∷ τ ∷ ω ∷ ∙λ ∷ ο ∷ ὶ ∷ []) "Jude.1.15" ∷ word (ἀ ∷ σ ∷ ε ∷ β ∷ ε ∷ ῖ ∷ ς ∷ []) "Jude.1.15" ∷ word (ο ∷ ὗ ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.16" ∷ word (ε ∷ ἰ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.16" ∷ word (γ ∷ ο ∷ γ ∷ γ ∷ υ ∷ σ ∷ τ ∷ α ∷ ί ∷ []) "Jude.1.16" ∷ word (μ ∷ ε ∷ μ ∷ ψ ∷ ί ∷ μ ∷ ο ∷ ι ∷ ρ ∷ ο ∷ ι ∷ []) "Jude.1.16" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Jude.1.16" ∷ word (τ ∷ ὰ ∷ ς ∷ []) "Jude.1.16" ∷ word (ἐ ∷ π ∷ ι ∷ θ ∷ υ ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.16" ∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.16" ∷ word (π ∷ ο ∷ ρ ∷ ε ∷ υ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.16" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.16" ∷ word (τ ∷ ὸ ∷ []) "Jude.1.16" ∷ word (σ ∷ τ ∷ ό ∷ μ ∷ α ∷ []) "Jude.1.16" ∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.16" ∷ word (∙λ ∷ α ∷ ∙λ ∷ ε ∷ ῖ ∷ []) "Jude.1.16" ∷ word (ὑ ∷ π ∷ έ ∷ ρ ∷ ο ∷ γ ∷ κ ∷ α ∷ []) "Jude.1.16" ∷ word (θ ∷ α ∷ υ ∷ μ ∷ ά ∷ ζ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.16" ∷ word (π ∷ ρ ∷ ό ∷ σ ∷ ω ∷ π ∷ α ∷ []) "Jude.1.16" ∷ word (ὠ ∷ φ ∷ ε ∷ ∙λ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.16" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ν ∷ []) "Jude.1.16" ∷ word (Ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "Jude.1.17" ∷ word (δ ∷ έ ∷ []) "Jude.1.17" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.17" ∷ word (μ ∷ ν ∷ ή ∷ σ ∷ θ ∷ η ∷ τ ∷ ε ∷ []) "Jude.1.17" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.17" ∷ word (ῥ ∷ η ∷ μ ∷ ά ∷ τ ∷ ω ∷ ν ∷ []) "Jude.1.17" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.17" ∷ word (π ∷ ρ ∷ ο ∷ ε ∷ ι ∷ ρ ∷ η ∷ μ ∷ έ ∷ ν ∷ ω ∷ ν ∷ []) "Jude.1.17" ∷ word (ὑ ∷ π ∷ ὸ ∷ []) "Jude.1.17" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.17" ∷ word (ἀ ∷ π ∷ ο ∷ σ ∷ τ ∷ ό ∷ ∙λ ∷ ω ∷ ν ∷ []) "Jude.1.17" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.17" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "Jude.1.17" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.17" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Jude.1.17" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.17" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Jude.1.18" ∷ word (ἔ ∷ ∙λ ∷ ε ∷ γ ∷ ο ∷ ν ∷ []) "Jude.1.18" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Jude.1.18" ∷ word (Ἐ ∷ π ∷ []) "Jude.1.18" ∷ word (ἐ ∷ σ ∷ χ ∷ ά ∷ τ ∷ ο ∷ υ ∷ []) "Jude.1.18" ∷ word (χ ∷ ρ ∷ ό ∷ ν ∷ ο ∷ υ ∷ []) "Jude.1.18" ∷ word (ἔ ∷ σ ∷ ο ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.18" ∷ word (ἐ ∷ μ ∷ π ∷ α ∷ ῖ ∷ κ ∷ τ ∷ α ∷ ι ∷ []) "Jude.1.18" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Jude.1.18" ∷ word (τ ∷ ὰ ∷ ς ∷ []) "Jude.1.18" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "Jude.1.18" ∷ word (ἐ ∷ π ∷ ι ∷ θ ∷ υ ∷ μ ∷ ί ∷ α ∷ ς ∷ []) "Jude.1.18" ∷ word (π ∷ ο ∷ ρ ∷ ε ∷ υ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.18" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Jude.1.18" ∷ word (ἀ ∷ σ ∷ ε ∷ β ∷ ε ∷ ι ∷ ῶ ∷ ν ∷ []) "Jude.1.18" ∷ word (ο ∷ ὗ ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.19" ∷ word (ε ∷ ἰ ∷ σ ∷ ι ∷ ν ∷ []) "Jude.1.19" ∷ word (ο ∷ ἱ ∷ []) "Jude.1.19" ∷ word (ἀ ∷ π ∷ ο ∷ δ ∷ ι ∷ ο ∷ ρ ∷ ί ∷ ζ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.19" ∷ word (ψ ∷ υ ∷ χ ∷ ι ∷ κ ∷ ο ∷ ί ∷ []) "Jude.1.19" ∷ word (π ∷ ν ∷ ε ∷ ῦ ∷ μ ∷ α ∷ []) "Jude.1.19" ∷ word (μ ∷ ὴ ∷ []) "Jude.1.19" ∷ word (ἔ ∷ χ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.19" ∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "Jude.1.20" ∷ word (δ ∷ έ ∷ []) "Jude.1.20" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ο ∷ ί ∷ []) "Jude.1.20" ∷ word (ἐ ∷ π ∷ ο ∷ ι ∷ κ ∷ ο ∷ δ ∷ ο ∷ μ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.20" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.20" ∷ word (τ ∷ ῇ ∷ []) "Jude.1.20" ∷ word (ἁ ∷ γ ∷ ι ∷ ω ∷ τ ∷ ά ∷ τ ∷ ῃ ∷ []) "Jude.1.20" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.20" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "Jude.1.20" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.20" ∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "Jude.1.20" ∷ word (ἁ ∷ γ ∷ ί ∷ ῳ ∷ []) "Jude.1.20" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ υ ∷ χ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.20" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.21" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.21" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ ῃ ∷ []) "Jude.1.21" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Jude.1.21" ∷ word (τ ∷ η ∷ ρ ∷ ή ∷ σ ∷ α ∷ τ ∷ ε ∷ []) "Jude.1.21" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ δ ∷ ε ∷ χ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Jude.1.21" ∷ word (τ ∷ ὸ ∷ []) "Jude.1.21" ∷ word (ἔ ∷ ∙λ ∷ ε ∷ ο ∷ ς ∷ []) "Jude.1.21" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.21" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "Jude.1.21" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.21" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Jude.1.21" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.21" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.21" ∷ word (ζ ∷ ω ∷ ὴ ∷ ν ∷ []) "Jude.1.21" ∷ word (α ∷ ἰ ∷ ώ ∷ ν ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.21" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.22" ∷ word (ο ∷ ὓ ∷ ς ∷ []) "Jude.1.22" ∷ word (μ ∷ ὲ ∷ ν ∷ []) "Jude.1.22" ∷ word (ἐ ∷ ∙λ ∷ ε ∷ ᾶ ∷ τ ∷ ε ∷ []) "Jude.1.22" ∷ word (δ ∷ ι ∷ α ∷ κ ∷ ρ ∷ ι ∷ ν ∷ ο ∷ μ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "Jude.1.22" ∷ word (ο ∷ ὓ ∷ ς ∷ []) "Jude.1.23" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.23" ∷ word (σ ∷ ῴ ∷ ζ ∷ ε ∷ τ ∷ ε ∷ []) "Jude.1.23" ∷ word (ἐ ∷ κ ∷ []) "Jude.1.23" ∷ word (π ∷ υ ∷ ρ ∷ ὸ ∷ ς ∷ []) "Jude.1.23" ∷ word (ἁ ∷ ρ ∷ π ∷ ά ∷ ζ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.23" ∷ word (ο ∷ ὓ ∷ ς ∷ []) "Jude.1.23" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.23" ∷ word (ἐ ∷ ∙λ ∷ ε ∷ ᾶ ∷ τ ∷ ε ∷ []) "Jude.1.23" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.23" ∷ word (φ ∷ ό ∷ β ∷ ῳ ∷ []) "Jude.1.23" ∷ word (μ ∷ ι ∷ σ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Jude.1.23" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.23" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Jude.1.23" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "Jude.1.23" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Jude.1.23" ∷ word (σ ∷ α ∷ ρ ∷ κ ∷ ὸ ∷ ς ∷ []) "Jude.1.23" ∷ word (ἐ ∷ σ ∷ π ∷ ι ∷ ∙λ ∷ ω ∷ μ ∷ έ ∷ ν ∷ ο ∷ ν ∷ []) "Jude.1.23" ∷ word (χ ∷ ι ∷ τ ∷ ῶ ∷ ν ∷ α ∷ []) "Jude.1.23" ∷ word (Τ ∷ ῷ ∷ []) "Jude.1.24" ∷ word (δ ∷ ὲ ∷ []) "Jude.1.24" ∷ word (δ ∷ υ ∷ ν ∷ α ∷ μ ∷ έ ∷ ν ∷ ῳ ∷ []) "Jude.1.24" ∷ word (φ ∷ υ ∷ ∙λ ∷ ά ∷ ξ ∷ α ∷ ι ∷ []) "Jude.1.24" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Jude.1.24" ∷ word (ἀ ∷ π ∷ τ ∷ α ∷ ί ∷ σ ∷ τ ∷ ο ∷ υ ∷ ς ∷ []) "Jude.1.24" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.24" ∷ word (σ ∷ τ ∷ ῆ ∷ σ ∷ α ∷ ι ∷ []) "Jude.1.24" ∷ word (κ ∷ α ∷ τ ∷ ε ∷ ν ∷ ώ ∷ π ∷ ι ∷ ο ∷ ν ∷ []) "Jude.1.24" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Jude.1.24" ∷ word (δ ∷ ό ∷ ξ ∷ η ∷ ς ∷ []) "Jude.1.24" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.24" ∷ word (ἀ ∷ μ ∷ ώ ∷ μ ∷ ο ∷ υ ∷ ς ∷ []) "Jude.1.24" ∷ word (ἐ ∷ ν ∷ []) "Jude.1.24" ∷ word (ἀ ∷ γ ∷ α ∷ ∙λ ∷ ∙λ ∷ ι ∷ ά ∷ σ ∷ ε ∷ ι ∷ []) "Jude.1.24" ∷ word (μ ∷ ό ∷ ν ∷ ῳ ∷ []) "Jude.1.25" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "Jude.1.25" ∷ word (σ ∷ ω ∷ τ ∷ ῆ ∷ ρ ∷ ι ∷ []) "Jude.1.25" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.25" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Jude.1.25" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Jude.1.25" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Jude.1.25" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.25" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "Jude.1.25" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Jude.1.25" ∷ word (δ ∷ ό ∷ ξ ∷ α ∷ []) "Jude.1.25" ∷ word (μ ∷ ε ∷ γ ∷ α ∷ ∙λ ∷ ω ∷ σ ∷ ύ ∷ ν ∷ η ∷ []) "Jude.1.25" ∷ word (κ ∷ ρ ∷ ά ∷ τ ∷ ο ∷ ς ∷ []) "Jude.1.25" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.25" ∷ word (ἐ ∷ ξ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ []) "Jude.1.25" ∷ word (π ∷ ρ ∷ ὸ ∷ []) "Jude.1.25" ∷ word (π ∷ α ∷ ν ∷ τ ∷ ὸ ∷ ς ∷ []) "Jude.1.25" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Jude.1.25" ∷ word (α ∷ ἰ ∷ ῶ ∷ ν ∷ ο ∷ ς ∷ []) "Jude.1.25" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.25" ∷ word (ν ∷ ῦ ∷ ν ∷ []) "Jude.1.25" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Jude.1.25" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Jude.1.25" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Jude.1.25" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Jude.1.25" ∷ word (α ∷ ἰ ∷ ῶ ∷ ν ∷ α ∷ ς ∷ []) "Jude.1.25" ∷ word (ἀ ∷ μ ∷ ή ∷ ν ∷ []) "Jude.1.25" ∷ []
{ "alphanum_fraction": 0.3402528694, "avg_line_length": 47.4553191489, "ext": "agda", "hexsha": "41176879bb4b10b5327567b1c07effdff9df1c80", "lang": "Agda", "max_forks_count": 5, "max_forks_repo_forks_event_max_datetime": "2017-06-11T11:25:09.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-27T22:34:13.000Z", "max_forks_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "scott-fleischman/GreekGrammar", "max_forks_repo_path": "agda/Text/Greek/SBLGNT/Jude.agda", "max_issues_count": 13, "max_issues_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_issues_repo_issues_event_max_datetime": "2020-09-07T11:58:38.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-28T20:04:08.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "scott-fleischman/GreekGrammar", "max_issues_repo_path": "agda/Text/Greek/SBLGNT/Jude.agda", "max_line_length": 85, "max_stars_count": 44, "max_stars_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "scott-fleischman/GreekGrammar", "max_stars_repo_path": "agda/Text/Greek/SBLGNT/Jude.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-06T15:41:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-29T14:48:51.000Z", "num_tokens": 16076, "size": 22304 }
open import Level import Categories.Category open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; subst; cong) open import Syntax open import Renaming open import Substitution open import Instantiation module SyntaxMap where open Signature open Expression open Equality infix 5 _→ᵐ_ -- syntax map _→ᵐ_ : Signature → Signature → Set 𝕊 →ᵐ 𝕋 = ∀ {cl} (S : symb 𝕊 cl) → Expr 𝕋 (obj cl) (symb-arg 𝕊 S) 𝟘 -- equality of syntax maps infix 4 _≈ᵐ_ _≈ᵐ_ : ∀ {𝕊 𝕋} (f g : 𝕊 →ᵐ 𝕋) → Set _≈ᵐ_ {𝕊 = 𝕊} {𝕋 = 𝕋} f g = ∀ {cl} (S : symb 𝕊 cl) → f S ≈ g S -- equality is an equivalence relation ≈ᵐ-refl : ∀ {𝕊 𝕋} {f : 𝕊 →ᵐ 𝕋} → f ≈ᵐ f ≈ᵐ-refl {𝕋 = 𝕋} S = ≈-refl ≈ᵐ-sym : ∀ {𝕊 𝕋} {f g : 𝕊 →ᵐ 𝕋} → f ≈ᵐ g → g ≈ᵐ f ≈ᵐ-sym {𝕋 = 𝕋} ξ S = ≈-sym (ξ S) ≈ᵐ-trans : ∀ {𝕊 𝕋} {f g h : 𝕊 →ᵐ 𝕋} → f ≈ᵐ g → g ≈ᵐ h → f ≈ᵐ h ≈ᵐ-trans {𝕋 = 𝕋} ζ ξ S = ≈-trans (ζ S) (ξ S) -- The identity raw syntax map 𝟙ᵐ : ∀ {𝕊} → (𝕊 →ᵐ 𝕊) 𝟙ᵐ {𝕊} S = expr-symb S (expr-meta-generic 𝕊) -- Action of a raw syntax map infixr 10 [_]ᵐ_ [_]ᵐ_ : ∀ {𝕊 𝕋} → (𝕊 →ᵐ 𝕋) → ∀ {cl 𝕄 γ} → Expr 𝕊 𝕄 cl γ → Expr 𝕋 𝕄 cl γ [ f ]ᵐ (expr-var x) = expr-var x [_]ᵐ_ {𝕋 = 𝕋} f {𝕄 = 𝕄} (expr-symb S es) = [ (λ M → [ f ]ᵐ es M) ]ⁱ ([ 𝟘-initial ]ʳ f S) [ f ]ᵐ (expr-meta M ts) = expr-meta M (λ i → [ f ]ᵐ (ts i)) [ f ]ᵐ expr-eqty = expr-eqty [ f ]ᵐ expr-eqtm = expr-eqtm -- Action preserves equality []ᵐ-resp-≈ : ∀ {𝕊 𝕋} {cl 𝕄 γ} (f : 𝕊 →ᵐ 𝕋) {t u : Expr 𝕊 𝕄 cl γ} → t ≈ u → [ f ]ᵐ t ≈ [ f ]ᵐ u []ᵐ-resp-≈ f (≈-≡ ξ) = ≈-≡ (cong ([ f ]ᵐ_) ξ) []ᵐ-resp-≈ {𝕋 = 𝕋} f (≈-symb {S = S} ξ) = []ⁱ-resp-≈ⁱ ([ 𝟘-initial ]ʳ f S) λ M → []ᵐ-resp-≈ f (ξ M) []ᵐ-resp-≈ f (≈-meta ξ) = ≈-meta (λ i → []ᵐ-resp-≈ f (ξ i)) []ᵐ-resp-≈ᵐ : ∀ {𝕊 𝕋} {cl 𝕄 γ} {f g : 𝕊 →ᵐ 𝕋} (t : Expr 𝕊 𝕄 cl γ) → f ≈ᵐ g → [ f ]ᵐ t ≈ [ g ]ᵐ t []ᵐ-resp-≈ᵐ (expr-var x) ξ = ≈-refl []ᵐ-resp-≈ᵐ {f = f} {g = g} (expr-symb S es) ξ = []ⁱ-resp-≈ⁱ-≈ {I = λ M → [ f ]ᵐ es M} {J = λ M → [ g ]ᵐ es M} (λ M → []ᵐ-resp-≈ᵐ (es M) ξ) ([]ʳ-resp-≈ 𝟘-initial (ξ S)) []ᵐ-resp-≈ᵐ (expr-meta M ts) ξ = ≈-meta (λ i → []ᵐ-resp-≈ᵐ (ts i) ξ) []ᵐ-resp-≈ᵐ expr-eqty ξ = ≈-eqty []ᵐ-resp-≈ᵐ expr-eqtm ξ = ≈-eqtm []ᵐ-resp-≈ᵐ-≈ : ∀ {𝕊 𝕋} {cl 𝕄 γ} {f g : 𝕊 →ᵐ 𝕋} {t u : Expr 𝕊 𝕄 cl γ} → f ≈ᵐ g → t ≈ u → [ f ]ᵐ t ≈ [ g ]ᵐ u []ᵐ-resp-≈ᵐ-≈ {g = g} {t = t} ζ ξ = ≈-trans ([]ᵐ-resp-≈ᵐ t ζ) ([]ᵐ-resp-≈ g ξ) -- Composition of raw syntax maps infixl 7 _∘ᵐ_ _∘ᵐ_ : ∀ {𝕊 𝕋 𝕌} → (𝕋 →ᵐ 𝕌) → (𝕊 →ᵐ 𝕋) → (𝕊 →ᵐ 𝕌) (g ∘ᵐ f) S = [ g ]ᵐ (f S) -- Action preserves identity module _ {𝕊} where open Equality open Renaming open Substitution [𝟙ᵐ] : ∀ {cl 𝕄 γ} (t : Expr 𝕊 cl 𝕄 γ) → [ 𝟙ᵐ ]ᵐ t ≈ t [𝟙ᵐ] (expr-var x) = ≈-refl [𝟙ᵐ] (expr-symb S es) = ≈-symb (λ {cⁱ γⁱ} i → [𝟙ᵐ]-arg cⁱ γⁱ i) where [𝟙ᵐ]-arg : ∀ cⁱ γⁱ (i : [ cⁱ , γⁱ ]∈ symb-arg 𝕊 S) → _ [𝟙ᵐ]-arg (obj x) γⁱ i = ≈-trans ([]ˢ-resp-≈ _ ([]ʳ-resp-≈ _ ([𝟙ᵐ] (es i)))) (≈-trans (≈-sym ([ˢ∘ʳ] (es i))) ([]ˢ-id (λ { (var-left _) → ≈-refl ; (var-right _) → ≈-refl }))) [𝟙ᵐ]-arg EqTy γⁱ i = ≈-eqty [𝟙ᵐ]-arg EqTm γⁱ i = ≈-eqtm [𝟙ᵐ] (expr-meta M ts) = ≈-meta λ i → [𝟙ᵐ] (ts i) [𝟙ᵐ] expr-eqty = ≈-eqty [𝟙ᵐ] expr-eqtm = ≈-eqtm -- interaction of maps with instantiation and substitution module _ {𝕊 𝕋} where open Substitution infixl 7 _ᵐ∘ˢ_ _ᵐ∘ˢ_ : ∀ {𝕊 𝕋} {𝕄 γ δ} (f : 𝕊 →ᵐ 𝕋) (σ : 𝕊 % 𝕄 ∥ γ →ˢ δ) → (𝕋 % 𝕄 ∥ γ →ˢ δ) (f ᵐ∘ˢ σ) x = [ f ]ᵐ σ x []ᵐ-[]ʳ : ∀ {f : 𝕊 →ᵐ 𝕋} {cl 𝕄 γ δ} {ρ : γ →ʳ δ} (t : Expr 𝕊 cl 𝕄 γ) → ([ f ]ᵐ ([ ρ ]ʳ t)) ≈ ([ ρ ]ʳ [ f ]ᵐ t) []ᵐ-[]ʳ (expr-var x) = ≈-refl []ᵐ-[]ʳ {f = f} {ρ = ρ} (expr-symb S es) = ≈-trans ([]ⁱ-resp-≈ⁱ ([ 𝟘-initial ]ʳ f S) λ M → []ᵐ-[]ʳ (es M)) (≈-trans ([]ⁱ-resp-≈ⁱ-≈ {t = [ 𝟘-initial ]ʳ f S} {u = [ ρ ]ʳ ([ 𝟘-initial ]ʳ f S)} (λ M → ≈-refl) (≈-trans ([]ʳ-resp-≡ʳ (f S) (λ {()})) ([∘ʳ] (f S)))) (≈-sym ([ʳ∘ⁱ] ([ 𝟘-initial ]ʳ f S)))) []ᵐ-[]ʳ (expr-meta M ts) = ≈-meta (λ i → []ᵐ-[]ʳ (ts i)) []ᵐ-[]ʳ expr-eqty = ≈-eqty []ᵐ-[]ʳ expr-eqtm = ≈-eqtm []ᵐ-[]ˢ : ∀ {cl 𝕄 γ δ} {f : 𝕊 →ᵐ 𝕋} {σ : 𝕊 % 𝕄 ∥ γ →ˢ δ} (t : Expr 𝕊 cl 𝕄 γ) → [ f ]ᵐ ([ σ ]ˢ t) ≈ [ f ᵐ∘ˢ σ ]ˢ [ f ]ᵐ t []ᵐ-[]ˢ (expr-var x) = ≈-refl []ᵐ-[]ˢ {f = f} {σ = σ} (expr-symb S es) = ≈-trans ([]ⁱ-resp-≈ⁱ ([ 𝟘-initial ]ʳ f S) (λ M → []ᵐ-[]ˢ (es M))) (≈-trans ([]ⁱ-resp-≈ⁱ ([ 𝟘-initial ]ʳ f S) (λ M → []ˢ-resp-≈ˢ (λ { (var-left x) → []ᵐ-[]ʳ (σ x) ; (var-right _) → ≈-refl}) ([ f ]ᵐ es M))) (≈-sym ([]ˢ-[]ⁱ {ρ = 𝟘-initial} (f S) λ {()}))) []ᵐ-[]ˢ (expr-meta M ts) = ≈-meta (λ i → []ᵐ-[]ˢ (ts i)) []ᵐ-[]ˢ expr-eqty = ≈-eqty []ᵐ-[]ˢ expr-eqtm = ≈-eqtm infixl 7 _ᵐ∘ⁱ_ _ᵐ∘ⁱ_ : ∀ {𝕂 𝕄 γ} (f : 𝕊 →ᵐ 𝕋) (I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ) → 𝕋 % 𝕂 →ⁱ 𝕄 ∥ γ (f ᵐ∘ⁱ I) M = [ f ]ᵐ I M ⇑ⁱ-resp-ᵐ∘ⁱ : ∀ {𝕂 𝕄 γ δ} {f : 𝕊 →ᵐ 𝕋} {I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ} → ⇑ⁱ {δ = δ} (f ᵐ∘ⁱ I) ≈ⁱ f ᵐ∘ⁱ ⇑ⁱ I ⇑ⁱ-resp-ᵐ∘ⁱ {I = I} M = ≈-sym ([]ᵐ-[]ʳ (I M)) []ᵐ-[]ⁱ : ∀ {cl 𝕂 𝕄 γ} {f : 𝕊 →ᵐ 𝕋} {I : 𝕊 % 𝕂 →ⁱ 𝕄 ∥ γ} (t : Expr 𝕊 cl 𝕂 γ) → [ f ]ᵐ ([ I ]ⁱ t) ≈ [ f ᵐ∘ⁱ I ]ⁱ [ f ]ᵐ t []ᵐ-[]ⁱ (expr-var x) = ≈-refl []ᵐ-[]ⁱ {f = f} {I = I} (expr-symb S es) = ≈-trans ([]ⁱ-resp-≈ⁱ ([ 𝟘-initial ]ʳ f S) λ M → ≈-trans ([]ᵐ-[]ⁱ (es M)) ([]ⁱ-resp-≈ⁱ ([ f ]ᵐ es M) (≈ⁱ-sym (⇑ⁱ-resp-ᵐ∘ⁱ {I = I})))) ([∘ⁱ] ([ 𝟘-initial ]ʳ f S)) []ᵐ-[]ⁱ {f = f} {I = I} (expr-meta M ts) = ≈-trans ([]ᵐ-[]ˢ (I M)) ([]ˢ-resp-≈ˢ (λ { (var-left _) → ≈-refl ; (var-right x) → []ᵐ-[]ⁱ (ts x)}) ([ f ]ᵐ I M)) []ᵐ-[]ⁱ expr-eqty = ≈-eqty []ᵐ-[]ⁱ expr-eqtm = ≈-eqtm -- idenity is right-neutral []ᵐ-meta-generic : ∀ {𝕊 𝕋} {𝕄 γ} {f : 𝕊 →ᵐ 𝕋} {clᴹ γᴹ} {M : [ clᴹ , γᴹ ]∈ 𝕄} → [ f ]ᵐ (expr-meta-generic 𝕊 {γ = γ} M) ≈ expr-meta-generic 𝕋 M []ᵐ-meta-generic {clᴹ = obj _} = ≈-refl []ᵐ-meta-generic {clᴹ = EqTy} = ≈-eqty []ᵐ-meta-generic {clᴹ = EqTm} = ≈-eqtm 𝟙ᵐ-right : ∀ {𝕊 𝕋} {f : 𝕊 →ᵐ 𝕋} → f ∘ᵐ 𝟙ᵐ ≈ᵐ f 𝟙ᵐ-right {f = f} S = ≈-trans ([]ⁱ-resp-≈ⁱ ([ 𝟘-initial ]ʳ (f S)) λ M → []ᵐ-meta-generic {M = M}) (≈-trans ([𝟙ⁱ] ([ 𝟘-initial ]ʳ f S)) ([]ʳ-id (λ { ()}))) -- Action preserves composition module _ {𝕊 𝕋 𝕌} where [∘ᵐ] : ∀ {f : 𝕊 →ᵐ 𝕋} {g : 𝕋 →ᵐ 𝕌} {cl 𝕄 γ} (t : Expr 𝕊 cl 𝕄 γ) → [ g ∘ᵐ f ]ᵐ t ≈ [ g ]ᵐ [ f ]ᵐ t [∘ᵐ] (expr-var x) = ≈-refl [∘ᵐ] {f = f} {g = g} (expr-symb S es) = ≈-trans ([]ⁱ-resp-≈ⁱ-≈ (λ M → [∘ᵐ] (es M)) (≈-sym ([]ᵐ-[]ʳ (f S)))) (≈-sym ([]ᵐ-[]ⁱ ([ 𝟘-initial ]ʳ f S))) [∘ᵐ] (expr-meta M ts) = ≈-meta (λ i → [∘ᵐ] (ts i)) [∘ᵐ] expr-eqty = ≈-eqty [∘ᵐ] expr-eqtm = ≈-eqtm -- Associativity of composition assocᵐ : ∀ {𝕊 𝕋 𝕌 𝕍} {f : 𝕊 →ᵐ 𝕋} {g : 𝕋 →ᵐ 𝕌} {h : 𝕌 →ᵐ 𝕍} → (h ∘ᵐ g) ∘ᵐ f ≈ᵐ h ∘ᵐ (g ∘ᵐ f) assocᵐ {f = f} S = [∘ᵐ] (f S) -- The category of signatures and syntax maps module _ where open Categories.Category SyntaxMaps : Category (suc zero) zero zero SyntaxMaps = record { Obj = Signature ; _⇒_ = _→ᵐ_ ; _≈_ = _≈ᵐ_ ; id = 𝟙ᵐ ; _∘_ = _∘ᵐ_ ; assoc = λ {_} {_} {_} {_} {f} {_} {_} {_} S → [∘ᵐ] (f S) ; sym-assoc = λ {_} {_} {_} {𝕍} {f} {_} {_} {_} S → ≈-sym ([∘ᵐ] (f S)) ; identityˡ = λ S → [𝟙ᵐ] _ ; identityʳ = λ {_} {_} {f} {_} → 𝟙ᵐ-right {f = f} ; identity² = λ _ → [𝟙ᵐ] _ ; equiv = record { refl = λ _ → ≈-refl ; sym = ≈ᵐ-sym ; trans = ≈ᵐ-trans } ; ∘-resp-≈ = λ ζ ξ S → []ᵐ-resp-≈ᵐ-≈ ζ (ξ S) }
{ "alphanum_fraction": 0.4133400707, "avg_line_length": 33.685106383, "ext": "agda", "hexsha": "1c0974f1d7a7fa7fd5eeb236a9de6a99743f92d5", "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": "9b634d284a0ec5108c68489575194cd573f38908", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/dependent-type-theory-syntax", "max_forks_repo_path": "src/SyntaxMap.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9b634d284a0ec5108c68489575194cd573f38908", "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": "andrejbauer/dependent-type-theory-syntax", "max_issues_repo_path": "src/SyntaxMap.agda", "max_line_length": 114, "max_stars_count": 7, "max_stars_repo_head_hexsha": "9b634d284a0ec5108c68489575194cd573f38908", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejbauer/dependent-type-theory-syntax", "max_stars_repo_path": "src/SyntaxMap.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-14T01:48:00.000Z", "max_stars_repo_stars_event_min_datetime": "2021-05-25T11:14:42.000Z", "num_tokens": 4711, "size": 7916 }
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category module Categories.Object.BinaryCoproducts {o ℓ e} (C : Category o ℓ e) where open Category C open Equiv open import Level import Categories.Object.Coproduct as Coproduct open import Categories.Morphisms C open module CP = Coproduct C hiding (module BinCoproducts) open CP public using (BinCoproducts) record BinaryCoproducts : Set (o ⊔ ℓ ⊔ e) where infix 10 _⧻_ field coproduct : ∀ {A B} → Coproduct A B _∐_ : Obj → Obj → Obj A ∐ B = Coproduct.A+B (coproduct {A} {B}) ∐-comm : ∀ {A B} → _≅_ (A ∐ B) (B ∐ A) ∐-comm = Commutative coproduct coproduct ∐-assoc : ∀ {X Y Z} → _≅_ (X ∐ (Y ∐ Z)) ((X ∐ Y) ∐ Z) ∐-assoc = Associative coproduct coproduct coproduct coproduct -- Convenience! i₁ : {A B : Obj} → (A ⇒ (A ∐ B)) i₁ = Coproduct.i₁ coproduct i₂ : {A B : Obj} → (B ⇒ (A ∐ B)) i₂ = Coproduct.i₂ coproduct [_,_] : ∀ {A B Q} → (A ⇒ Q) → (B ⇒ Q) → ((A ∐ B) ⇒ Q) [_,_] = Coproduct.[_,_] coproduct .commute₁ : ∀ {A B C} {f : A ⇒ C} {g : B ⇒ C} → [ f , g ] ∘ i₁ ≡ f commute₁ = Coproduct.commute₁ coproduct .commute₂ : ∀ {A B C} {f : A ⇒ C} {g : B ⇒ C} → [ f , g ] ∘ i₂ ≡ g commute₂ = Coproduct.commute₂ coproduct .universal : ∀ {A B C} {f : A ⇒ C} {g : B ⇒ C} {i : (A ∐ B) ⇒ C} → i ∘ i₁ ≡ f → i ∘ i₂ ≡ g → [ f , g ] ≡ i universal = Coproduct.universal coproduct assocˡ : ∀ {A B C} → (((A ∐ B) ∐ C) ⇒ (A ∐ (B ∐ C))) assocˡ = _≅_.g ∐-assoc assocʳ : ∀ {A B C} → ((A ∐ (B ∐ C)) ⇒ ((A ∐ B) ∐ C)) assocʳ = _≅_.f ∐-assoc .g-η : ∀ {A B C} {f : (A ∐ B) ⇒ C} → [ f ∘ i₁ , f ∘ i₂ ] ≡ f g-η = Coproduct.g-η coproduct .η : ∀ {A B} → [ i₁ , i₂ ] ≡ id {A ∐ B} η = Coproduct.η coproduct .[]-cong₂ : ∀ {A B C} → {f f′ : A ⇒ C} {g g′ : B ⇒ C} → f ≡ f′ → g ≡ g′ → [ f , g ] ≡ [ f′ , g′ ] []-cong₂ = Coproduct.[]-cong₂ coproduct -- If I _really_ wanted to, I could do this for a specific pair of coproducts like the rest above, but I'll write that one -- when I need it. _⧻_ : ∀ {A B C D} → (A ⇒ B) → (C ⇒ D) → ((A ∐ C) ⇒ (B ∐ D)) f ⧻ g = [ i₁ ∘ f , i₂ ∘ g ] -- TODO: this is probably harder to use than necessary because of this definition. Maybe make a version -- that doesn't have an explicit id in it, too? left : ∀ {A B C} → (A ⇒ B) → ((A ∐ C) ⇒ (B ∐ C)) left f = f ⧻ id right : ∀ {A C D} → (C ⇒ D) → ((A ∐ C) ⇒ (A ∐ D)) right g = id ⧻ g -- Just to make this more obvious .⧻∘i₁ : ∀ {A B C D} → {f : A ⇒ B} → {g : C ⇒ D} → (f ⧻ g) ∘ i₁ ≡ i₁ ∘ f ⧻∘i₁ {f = f} {g} = commute₁ .⧻∘i₂ : ∀ {A B C D} → {f : A ⇒ B} → {g : C ⇒ D} → (f ⧻ g) ∘ i₂ ≡ i₂ ∘ g ⧻∘i₂ {f = f} {g} = commute₂ .[]∘⧻ : ∀ {A B C D E} → {f : B ⇒ E} {f′ : A ⇒ B} {g : D ⇒ E} {g′ : C ⇒ D} → [ f , g ] ∘ ( f′ ⧻ g′ ) ≡ [ f ∘ f′ , g ∘ g′ ] []∘⧻ {f = f} {f′} {g} {g′} = sym (universal helper₁ helper₂) where helper₁ : ([ f , g ] ∘ (f′ ⧻ g′)) ∘ i₁ ≡ f ∘ f′ helper₁ = begin ([ f , g ] ∘ (f′ ⧻ g′)) ∘ i₁ ↓⟨ assoc ⟩ [ f , g ] ∘ ((f′ ⧻ g′) ∘ i₁) ↓⟨ ∘-resp-≡ʳ ⧻∘i₁ ⟩ [ f , g ] ∘ (i₁ ∘ f′) ↑⟨ assoc ⟩ ([ f , g ] ∘ i₁) ∘ f′ ↓⟨ ∘-resp-≡ˡ commute₁ ⟩ f ∘ f′ ∎ where open HomReasoning helper₂ : ([ f , g ] ∘ (f′ ⧻ g′)) ∘ i₂ ≡ g ∘ g′ helper₂ = begin ([ f , g ] ∘ (f′ ⧻ g′)) ∘ i₂ ↓⟨ assoc ⟩ [ f , g ] ∘ ((f′ ⧻ g′) ∘ i₂) ↓⟨ ∘-resp-≡ʳ ⧻∘i₂ ⟩ [ f , g ] ∘ (i₂ ∘ g′) ↑⟨ assoc ⟩ ([ f , g ] ∘ i₂) ∘ g′ ↓⟨ ∘-resp-≡ˡ commute₂ ⟩ g ∘ g′ ∎ where open HomReasoning .[]∘left : ∀ {A B C D} → {f : C ⇒ B} {f′ : B ⇒ A} {g′ : D ⇒ A} → [ f′ , g′ ] ∘ left f ≡ [ f′ ∘ f , g′ ] []∘left {f = f} {f′} {g′} = begin [ f′ , g′ ] ∘ left f ↓⟨ []∘⧻ ⟩ [ f′ ∘ f , g′ ∘ id ] ↓⟨ []-cong₂ refl identityʳ ⟩ [ f′ ∘ f , g′ ] ∎ where open HomReasoning .[]∘right : ∀ {A B D E} → {f′ : B ⇒ A} {g : E ⇒ D} {g′ : D ⇒ A} → [ f′ , g′ ] ∘ right g ≡ [ f′ , g′ ∘ g ] []∘right {f′ = f′} {g} {g′} = begin [ f′ , g′ ] ∘ right g ↓⟨ []∘⧻ ⟩ [ f′ ∘ id , g′ ∘ g ] ↓⟨ []-cong₂ identityʳ refl ⟩ [ f′ , g′ ∘ g ] ∎ where open HomReasoning .⧻∘⧻ : ∀ {A B C D E F} → {f : B ⇒ C} → {f′ : A ⇒ B} {g : E ⇒ F} {g′ : D ⇒ E} → (f ⧻ g) ∘ (f′ ⧻ g′) ≡ (f ∘ f′) ⧻ (g ∘ g′) ⧻∘⧻ {B = B} {E = E} {f = f} {f′} {g} {g′} = begin (f ⧻ g) ∘ (f′ ⧻ g′) ↓⟨ []∘⧻ ⟩ [ (i₁ ∘ f) ∘ f′ , (i₂ ∘ g) ∘ g′ ] ↓⟨ []-cong₂ assoc assoc ⟩ (f ∘ f′) ⧻ (g ∘ g′) ∎ where open HomReasoning .∘[] : ∀ {A B C D} {f : B ⇒ A} {g : C ⇒ A} {q : A ⇒ D} → q ∘ [ f , g ] ≡ [ q ∘ f , q ∘ g ] ∘[] = sym (universal (trans assoc (∘-resp-≡ʳ commute₁)) (trans assoc (∘-resp-≡ʳ commute₂))) Bin→Binary : BinCoproducts -> BinaryCoproducts Bin→Binary bc = record { coproduct = λ {A} {B} → record { A+B = A + B; i₁ = i₁; i₂ = i₂; [_,_] = [_,_]; commute₁ = commute₁; commute₂ = commute₂; universal = universal } } where open CP.BinCoproducts bc
{ "alphanum_fraction": 0.4029599101, "avg_line_length": 30.6781609195, "ext": "agda", "hexsha": "dc07affd2ce5a2a5562a1597212d1b1e9968c81d", "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/Object/BinaryCoproducts.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/Object/BinaryCoproducts.agda", "max_line_length": 124, "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/Object/BinaryCoproducts.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": 2493, "size": 5338 }
-- Andreas, 2014-12-02, issue reported by Jesper Cockx data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x subst : ∀ (A : Set)(P : A → Set)(x y : A) → x ≡ y → P x → P y subst A P x .x refl t = t mutual Type : Set postulate type : Type Term : Type → Set Type = Term type mutual weakenType : Type → Type → Type weaken : (ty ty' : Type) → Term ty → Term (weakenType ty' ty) weakenType ty ty' = let X : Type X = {!!} in subst Type Term (weakenType X type) type {!!} (weaken type X ty) weaken ty ty' t = {!!} data Test : Type → Set where test : Test (weakenType type type) -- Checking the constructor declaration was looping -- should work now.
{ "alphanum_fraction": 0.5870503597, "avg_line_length": 21.71875, "ext": "agda", "hexsha": "fc5a6df6a022258c12ef64595f48c280cdf8de2a", "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": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Fail/Issue1375-2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "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": "alhassy/agda", "max_issues_repo_path": "test/Fail/Issue1375-2.agda", "max_line_length": 72, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Fail/Issue1375-2.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": 238, "size": 695 }
------------------------------------------------------------------------ -- Half adjoint equivalences ------------------------------------------------------------------------ -- This development is partly based on the presentation of half -- adjoint equivalences in the HoTT book, and partly based on -- Voevodsky's work on univalent foundations. {-# OPTIONS --without-K --safe #-} open import Equality module Equivalence.Half-adjoint {e⁺} (eq : ∀ {a p} → Equality-with-J a p e⁺) where open Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude open import Bijection eq as B using (_↔_) import Equivalence.Contractible-preimages eq as CP open import H-level eq as H-level open import H-level.Closure eq open import Preimage eq as Preimage using (_⁻¹_) open import Surjection eq as S hiding (id; _∘_) private variable a b p q : Level A B C : Type a P : A → Type p Q : (x : A) → P x → Type q f g : A → B A↔B : A ↔ B ------------------------------------------------------------------------ -- The definition of Is-equivalence mutual -- Is-equivalence f means that f is a half adjoint equivalence. Is-equivalence : {A : Type a} {B : Type b} → (A → B) → Type (a ⊔ b) Is-equivalence {A = A} {B = B} f = ∃ λ (f⁻¹ : B → A) → Proofs f f⁻¹ -- The "proofs" contained in Is-equivalence f. Proofs : {A : Type a} {B : Type b} → (A → B) → (B → A) → Type (a ⊔ b) Proofs f f⁻¹ = ∃ λ (f-f⁻¹ : ∀ x → f (f⁻¹ x) ≡ x) → ∃ λ (f⁻¹-f : ∀ x → f⁻¹ (f x) ≡ x) → ∀ x → cong f (f⁻¹-f x) ≡ f-f⁻¹ (f x) -- Some projections. inverse : {@0 A : Type a} {@0 B : Type b} {@0 f : A → B} → Is-equivalence f → B → A inverse = proj₁ right-inverse-of : {@0 A : Type a} {@0 B : Type b} {@0 f : A → B} → (eq : Is-equivalence f) → ∀ x → f (inverse eq x) ≡ x right-inverse-of = proj₁ ∘ proj₂ left-inverse-of : {@0 A : Type a} {@0 B : Type b} {@0 f : A → B} → (eq : Is-equivalence f) → ∀ x → inverse eq (f x) ≡ x left-inverse-of = proj₁ ∘ proj₂ ∘ proj₂ ------------------------------------------------------------------------ -- Identity, inverse, composition -- The identity function is an equivalence. id-equivalence : Is-equivalence (id {A = A}) id-equivalence = id , refl , refl , (λ x → cong id (refl x) ≡⟨ sym $ cong-id _ ⟩∎ refl x ∎) -- If f is an equivalence, then its inverse is also an equivalence. inverse-equivalence : (eq : Is-equivalence f) → Is-equivalence (inverse eq) inverse-equivalence {f = f} (f⁻¹ , f-f⁻¹ , f⁻¹-f , f-f⁻¹-f) = f , f⁻¹-f , f-f⁻¹ , f⁻¹-f-f⁻¹ where abstract f⁻¹-f-f⁻¹ : ∀ x → cong f⁻¹ (f-f⁻¹ x) ≡ f⁻¹-f (f⁻¹ x) f⁻¹-f-f⁻¹ x = subst (λ x → cong f⁻¹ (f-f⁻¹ x) ≡ f⁻¹-f (f⁻¹ x)) (f-f⁻¹ x) (cong f⁻¹ (f-f⁻¹ (f (f⁻¹ x))) ≡⟨ cong (cong f⁻¹) $ sym $ f-f⁻¹-f _ ⟩ cong f⁻¹ (cong f (f⁻¹-f (f⁻¹ x))) ≡⟨ cong-∘ f⁻¹ f _ ⟩ cong (f⁻¹ ∘ f) (f⁻¹-f (f⁻¹ x)) ≡⟨ cong-≡id-≡-≡id f⁻¹-f ⟩∎ f⁻¹-f (f⁻¹ (f (f⁻¹ x))) ∎) -- If f and g are inverses, then f ∘ g is an equivalence. composition-equivalence : Is-equivalence f → Is-equivalence g → Is-equivalence (f ∘ g) composition-equivalence {f = f} {g = g} (f⁻¹ , f-f⁻¹ , f⁻¹-f , f-f⁻¹-f) (g⁻¹ , g-g⁻¹ , g⁻¹-g , g-g⁻¹-g) = [f-g]⁻¹ , [f-g]-[f-g]⁻¹ , [f-g]⁻¹-[f-g] , [f-g]-[f-g]⁻¹-[f-g] where [f-g] = f ∘ g [f-g]⁻¹ = g⁻¹ ∘ f⁻¹ [f-g]-[f-g]⁻¹ = λ x → f (g (g⁻¹ (f⁻¹ x))) ≡⟨ cong f $ g-g⁻¹ _ ⟩ f (f⁻¹ x) ≡⟨ f-f⁻¹ _ ⟩∎ x ∎ [f-g]⁻¹-[f-g] = λ x → g⁻¹ (f⁻¹ (f (g x))) ≡⟨ cong g⁻¹ $ f⁻¹-f _ ⟩ g⁻¹ (g x) ≡⟨ g⁻¹-g _ ⟩∎ x ∎ abstract [f-g]-[f-g]⁻¹-[f-g] : ∀ x → cong [f-g] ([f-g]⁻¹-[f-g] x) ≡ [f-g]-[f-g]⁻¹ ([f-g] x) [f-g]-[f-g]⁻¹-[f-g] x = cong (f ∘ g) (trans (cong g⁻¹ (f⁻¹-f (g x))) (g⁻¹-g x)) ≡⟨ trans (sym $ cong-∘ _ _ _) $ cong (cong _) $ trans (cong-trans _ _ _) $ cong (flip trans _) $ cong-∘ _ _ _ ⟩ cong f (trans (cong (g ∘ g⁻¹) (f⁻¹-f (g x))) (cong g (g⁻¹-g x))) ≡⟨ cong (cong _) $ cong (trans _) $ g-g⁻¹-g _ ⟩ cong f (trans (cong (g ∘ g⁻¹) (f⁻¹-f (g x))) (g-g⁻¹ (g x))) ≡⟨ cong (cong f) $ naturality g-g⁻¹ ⟩ cong f (trans (g-g⁻¹ (f⁻¹ (f (g x)))) (cong id (f⁻¹-f (g x)))) ≡⟨ cong (cong _) $ cong (trans _) $ sym $ cong-id _ ⟩ cong f (trans (g-g⁻¹ (f⁻¹ (f (g x)))) (f⁻¹-f (g x))) ≡⟨ cong-trans _ _ _ ⟩ trans (cong f (g-g⁻¹ (f⁻¹ (f (g x))))) (cong f (f⁻¹-f (g x))) ≡⟨ cong (trans _) $ f-f⁻¹-f _ ⟩∎ trans (cong f (g-g⁻¹ (f⁻¹ (f (g x))))) (f-f⁻¹ (f (g x))) ∎ ------------------------------------------------------------------------ -- Conversions to and from bijections -- Equivalences are bijections (functions with quasi-inverses). Is-equivalence→↔ : {@0 A : Type a} {@0 B : Type b} {f : A → B} → Is-equivalence f → A ↔ B Is-equivalence→↔ {f = f} (f⁻¹ , f-f⁻¹ , f⁻¹-f , _) = record { surjection = record { logical-equivalence = record { to = f ; from = f⁻¹ } ; right-inverse-of = f-f⁻¹ } ; left-inverse-of = f⁻¹-f } -- Functions with quasi-inverses are equivalences. -- -- Note that the left inverse proof is preserved unchanged. ↔→Is-equivalenceˡ : (A↔B : A ↔ B) → Is-equivalence (_↔_.to A↔B) ↔→Is-equivalenceˡ A↔B = from , right-inverse-of′ , A↔B.left-inverse-of , left-right where open module A↔B = _↔_ A↔B using (to; from) abstract right-inverse-of′ : ∀ x → to (from x) ≡ x right-inverse-of′ x = to (from x) ≡⟨ sym (A↔B.right-inverse-of _) ⟩ to (from (to (from x))) ≡⟨ cong to (A↔B.left-inverse-of _) ⟩ to (from x) ≡⟨ A↔B.right-inverse-of _ ⟩∎ x ∎ left-right : ∀ x → cong to (A↔B.left-inverse-of x) ≡ right-inverse-of′ (to x) left-right x = let lemma = trans (A↔B.right-inverse-of _) (cong to (A↔B.left-inverse-of _)) ≡⟨ cong (trans _) $ cong-id _ ⟩ trans (A↔B.right-inverse-of _) (cong id (cong to (A↔B.left-inverse-of _))) ≡⟨ sym $ naturality A↔B.right-inverse-of ⟩ trans (cong (to ∘ from) (cong to (A↔B.left-inverse-of _))) (A↔B.right-inverse-of _) ≡⟨ cong (flip trans _) $ cong-∘ _ _ _ ⟩ trans (cong (to ∘ from ∘ to) (A↔B.left-inverse-of _)) (A↔B.right-inverse-of _) ≡⟨ cong (flip trans _) $ sym $ cong-∘ _ _ _ ⟩ trans (cong to (cong (from ∘ to) (A↔B.left-inverse-of _))) (A↔B.right-inverse-of _) ≡⟨ cong (flip trans _ ∘ cong to) $ cong-≡id-≡-≡id A↔B.left-inverse-of ⟩∎ trans (cong to (A↔B.left-inverse-of _)) (A↔B.right-inverse-of _) ∎ in cong to (A↔B.left-inverse-of x) ≡⟨ sym $ trans-sym-[trans] _ _ ⟩ trans (sym (A↔B.right-inverse-of _)) (trans (A↔B.right-inverse-of _) (cong to (A↔B.left-inverse-of _))) ≡⟨ cong (trans _) lemma ⟩∎ trans (sym (A↔B.right-inverse-of _)) (trans (cong to (A↔B.left-inverse-of _)) (A↔B.right-inverse-of _)) ∎ _ : proj₁ (↔→Is-equivalenceˡ A↔B) ≡ _↔_.from A↔B _ = refl _ _ : proj₁ (proj₂ (proj₂ (↔→Is-equivalenceˡ A↔B))) ≡ _↔_.left-inverse-of A↔B _ = refl _ -- Functions with quasi-inverses are equivalences. -- -- Note that the right inverse proof is preserved unchanged. ↔→Is-equivalenceʳ : (A↔B : A ↔ B) → Is-equivalence (_↔_.to A↔B) ↔→Is-equivalenceʳ = inverse-equivalence ∘ ↔→Is-equivalenceˡ ∘ B.inverse _ : proj₁ (↔→Is-equivalenceʳ A↔B) ≡ _↔_.from A↔B _ = refl _ _ : proj₁ (proj₂ (↔→Is-equivalenceʳ A↔B)) ≡ _↔_.right-inverse-of A↔B _ = refl _ ------------------------------------------------------------------------ -- Is-equivalence is related to CP.Is-equivalence (part one) -- Is-equivalence f and CP.Is-equivalence f are logically equivalent. Is-equivalence⇔Is-equivalence-CP : Is-equivalence f ⇔ CP.Is-equivalence f Is-equivalence⇔Is-equivalence-CP = record { to = to ; from = from } where to : Is-equivalence f → CP.Is-equivalence f to {f = f} (f⁻¹ , f-f⁻¹ , f⁻¹-f , f-f⁻¹-f) y = (f⁻¹ y , f-f⁻¹ y) , λ (x , f-f⁻¹′) → Σ-≡,≡→≡ (f⁻¹ y ≡⟨ sym $ cong f⁻¹ f-f⁻¹′ ⟩ f⁻¹ (f x) ≡⟨ f⁻¹-f x ⟩∎ x ∎) (elim¹ (λ {y} f-f⁻¹′ → subst (λ x → f x ≡ y) (trans (sym (cong f⁻¹ f-f⁻¹′)) (f⁻¹-f x)) (f-f⁻¹ y) ≡ f-f⁻¹′) (subst (λ x′ → f x′ ≡ f x) (trans (sym (cong f⁻¹ (refl _))) (f⁻¹-f x)) (f-f⁻¹ (f x)) ≡⟨ cong (flip (subst _) _) $ trans (cong (flip trans _) $ trans (cong sym $ cong-refl _) $ sym-refl) $ trans-reflˡ _ ⟩ subst (λ x′ → f x′ ≡ f x) (f⁻¹-f x) (f-f⁻¹ (f x)) ≡⟨ subst-∘ _ _ _ ⟩ subst (_≡ f x) (cong f (f⁻¹-f x)) (f-f⁻¹ (f x)) ≡⟨ subst-trans-sym ⟩ trans (sym (cong f (f⁻¹-f x))) (f-f⁻¹ (f x)) ≡⟨ cong (flip trans _ ∘ sym) $ f-f⁻¹-f _ ⟩ trans (sym (f-f⁻¹ (f x))) (f-f⁻¹ (f x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) f-f⁻¹′) from : CP.Is-equivalence f → Is-equivalence f from eq = CP.inverse eq , CP.right-inverse-of eq , CP.left-inverse-of eq , CP.left-right-lemma eq -- All fibres of an equivalence over a given point are equal to a -- given fibre. irrelevance : (eq : Is-equivalence f) → ∀ y (p : f ⁻¹ y) → (inverse eq y , right-inverse-of eq y) ≡ p irrelevance = CP.irrelevance ∘ _⇔_.to Is-equivalence⇔Is-equivalence-CP -- When proving that a function is an equivalence one can assume that -- the codomain is inhabited. [inhabited→Is-equivalence]→Is-equivalence : {f : A → B} → (B → Is-equivalence f) → Is-equivalence f [inhabited→Is-equivalence]→Is-equivalence hyp = _⇔_.from Is-equivalence⇔Is-equivalence-CP $ λ x → _⇔_.to Is-equivalence⇔Is-equivalence-CP (hyp x) x ------------------------------------------------------------------------ -- The "inverse of extensionality" is an equivalence (assuming -- extensionality) -- Is-equivalence respects extensional equality. respects-extensional-equality : (∀ x → f x ≡ g x) → Is-equivalence f → Is-equivalence g respects-extensional-equality {f = f} {g = g} f≡g (f⁻¹ , f-f⁻¹ , f⁻¹-f , f-f⁻¹-f) = ↔→Is-equivalenceʳ (record { surjection = record { logical-equivalence = record { to = g ; from = f⁻¹ } ; right-inverse-of = λ x → g (f⁻¹ x) ≡⟨ sym $ f≡g _ ⟩ f (f⁻¹ x) ≡⟨ f-f⁻¹ _ ⟩∎ x ∎ } ; left-inverse-of = λ x → f⁻¹ (g x) ≡⟨ cong f⁻¹ $ sym $ f≡g _ ⟩ f⁻¹ (f x) ≡⟨ f⁻¹-f _ ⟩∎ x ∎ }) -- Functions between contractible types are equivalences. function-between-contractible-types-is-equivalence : ∀ {a b} {A : Type a} {B : Type b} (f : A → B) → Contractible A → Contractible B → Is-equivalence f function-between-contractible-types-is-equivalence f A-contr B-contr = ↔→Is-equivalenceˡ (record { surjection = record { logical-equivalence = record { from = λ _ → proj₁ A-contr } ; right-inverse-of = λ x → f (proj₁ A-contr) ≡⟨ sym $ proj₂ B-contr _ ⟩ proj₁ B-contr ≡⟨ proj₂ B-contr _ ⟩∎ x ∎ } ; left-inverse-of = proj₂ A-contr }) abstract -- If Σ-map id f is an equivalence, then f is also an equivalence. drop-Σ-map-id : {A : Type a} {P : A → Type p} {Q : A → Type q} (f : ∀ {x} → P x → Q x) → Is-equivalence {A = Σ A P} {B = Σ A Q} (Σ-map id f) → ∀ x → Is-equivalence (f {x = x}) drop-Σ-map-id f eq x = _⇔_.from Is-equivalence⇔Is-equivalence-CP $ CP.drop-Σ-map-id f (_⇔_.to Is-equivalence⇔Is-equivalence-CP eq) x -- A "computation" rule for drop-Σ-map-id. inverse-drop-Σ-map-id : {A : Type a} {P : A → Type p} {Q : A → Type q} {f : ∀ {x} → P x → Q x} {x : A} {y : Q x} {eq : Is-equivalence {A = Σ A P} {B = Σ A Q} (Σ-map id f)} → inverse (drop-Σ-map-id f eq x) y ≡ subst P (cong proj₁ (right-inverse-of eq (x , y))) (proj₂ (inverse eq (x , y))) inverse-drop-Σ-map-id = CP.inverse-drop-Σ-map-id -- The function ext⁻¹ is an equivalence (assuming extensionality). ext⁻¹-is-equivalence : ({P : A → Type b} → Extensionality′ A P) → {P : A → Type b} {f g : (x : A) → P x} → Is-equivalence (ext⁻¹ {f = f} {g = g}) ext⁻¹-is-equivalence {A = A} ext {P = P} {f = f} {g = g} = drop-Σ-map-id ext⁻¹ lemma₂ f where surj : (∀ x → Singleton (g x)) ↠ (∃ λ (f : (x : A) → P x) → ∀ x → f x ≡ g x) surj = record { logical-equivalence = record { to = λ f → proj₁ ∘ f , proj₂ ∘ f ; from = λ p x → proj₁ p x , proj₂ p x } ; right-inverse-of = refl } lemma₁ : Contractible (∃ λ (f : (x : A) → P x) → ∀ x → f x ≡ g x) lemma₁ = H-level.respects-surjection surj 0 $ _⇔_.from Π-closure-contractible⇔extensionality ext (singleton-contractible ∘ g) lemma₂ : Is-equivalence {A = ∃ λ f → f ≡ g} {B = ∃ λ f → ∀ x → f x ≡ g x} (Σ-map id ext⁻¹) lemma₂ = function-between-contractible-types-is-equivalence _ (singleton-contractible g) lemma₁ ------------------------------------------------------------------------ -- Results related to h-levels abstract -- Is-equivalence f is a proposition (assuming extensionality). propositional : {A : Type a} {B : Type b} → Extensionality (a ⊔ b) (a ⊔ b) → (f : A → B) → Is-proposition (Is-equivalence f) propositional {a = a} {b = b} {A = A} {B = B} ext f = [inhabited⇒+]⇒+ 0 λ eq → mono₁ 0 $ H-level.respects-surjection ((∃ λ ((f⁻¹ , f-f⁻¹) : ∃ λ f⁻¹ → ∀ x → f (f⁻¹ x) ≡ x) → ∃ λ (f⁻¹-f : ∀ x → f⁻¹ (f x) ≡ x) → ∀ x → cong f (f⁻¹-f x) ≡ f-f⁻¹ (f x)) ↠⟨ _↔_.surjection $ B.inverse B.Σ-assoc ⟩□ Is-equivalence f □) 0 $ Σ-closure 0 (lemma₁ eq) (uncurry $ lemma₂ eq) where ext₁ : Extensionality b b ext₁ = lower-extensionality a a ext ext₁′ : Extensionality b a ext₁′ = lower-extensionality a b ext ext-↠ : {A B : Type b} {f g : A → B} → f ≡ g ↠ (∀ x → f x ≡ g x) ext-↠ = _↔_.surjection $ Is-equivalence→↔ $ ext⁻¹-is-equivalence (apply-ext ext₁) lemma₁ : Is-equivalence f → Contractible (∃ λ (f⁻¹ : B → A) → ∀ x → f (f⁻¹ x) ≡ x) lemma₁ (f⁻¹ , f-f⁻¹ , f⁻¹-f , f-f⁻¹-f) = H-level.respects-surjection ((∃ λ f⁻¹ → f ∘ f⁻¹ ≡ id) ↠⟨ (∃-cong λ _ → ext-↠) ⟩□ (∃ λ f⁻¹ → ∀ x → f (f⁻¹ x) ≡ x) □) 0 $ Preimage.bijection⁻¹-contractible (record { surjection = record { logical-equivalence = record { to = f ∘_ ; from = f⁻¹ ∘_ } ; right-inverse-of = λ g → apply-ext ext₁ λ x → f (f⁻¹ (g x)) ≡⟨ f-f⁻¹ (g x) ⟩∎ g x ∎ } ; left-inverse-of = λ g → apply-ext ext₁′ λ x → f⁻¹ (f (g x)) ≡⟨ f⁻¹-f (g x) ⟩∎ g x ∎ }) id ext₂ : Extensionality a (a ⊔ b) ext₂ = lower-extensionality b lzero ext lemma₂ : Is-equivalence f → (f⁻¹ : B → A) (f-f⁻¹ : ∀ x → f (f⁻¹ x) ≡ x) → Contractible (∃ λ (f⁻¹-f : ∀ x → f⁻¹ (f x) ≡ x) → ∀ x → cong f (f⁻¹-f x) ≡ f-f⁻¹ (f x)) lemma₂ eq f⁻¹ f-f⁻¹ = H-level.respects-surjection ((∀ x → (f⁻¹ (f x) , f-f⁻¹ (f x)) ≡ (x , refl (f x))) ↠⟨ (∀-cong ext₂ λ _ → _↔_.surjection $ B.inverse B.Σ-≡,≡↔≡) ⟩ (∀ x → ∃ λ f⁻¹-f → subst (λ y → f y ≡ f x) f⁻¹-f (f-f⁻¹ (f x)) ≡ refl (f x)) ↠⟨ (∀-cong ext₂ λ x → ∃-cong λ f⁻¹-f → elim (λ {A B} _ → A ↠ B) (λ _ → S.id) ( subst (λ y → f y ≡ f x) f⁻¹-f (f-f⁻¹ (f x)) ≡ refl (f x) ≡⟨ cong (_≡ _) $ subst-∘ _ _ _ ⟩ subst (_≡ f x) (cong f f⁻¹-f) (f-f⁻¹ (f x)) ≡ refl (f x) ≡⟨ cong (_≡ _) subst-trans-sym ⟩ trans (sym (cong f f⁻¹-f)) (f-f⁻¹ (f x)) ≡ refl (f x) ≡⟨ [trans≡]≡[≡trans-symˡ] _ _ _ ⟩ f-f⁻¹ (f x) ≡ trans (sym (sym (cong f f⁻¹-f))) (refl (f x)) ≡⟨ cong (_ ≡_) $ trans-reflʳ _ ⟩ f-f⁻¹ (f x) ≡ sym (sym (cong f f⁻¹-f)) ≡⟨ cong (_ ≡_) $ sym-sym _ ⟩∎ f-f⁻¹ (f x) ≡ cong f f⁻¹-f ∎)) ⟩ (∀ x → ∃ λ f⁻¹-f → f-f⁻¹ (f x) ≡ cong f f⁻¹-f) ↠⟨ (∀-cong ext₂ λ _ → ∃-cong λ _ → _↔_.surjection B.≡-comm) ⟩ (∀ x → ∃ λ f⁻¹-f → cong f f⁻¹-f ≡ f-f⁻¹ (f x)) ↠⟨ _↔_.surjection B.ΠΣ-comm ⟩□ (∃ λ f⁻¹-f → ∀ x → cong f (f⁻¹-f x) ≡ f-f⁻¹ (f x)) □) 0 $ Π-closure ext₂ 0 λ x → H-level.⇒≡ 0 $ _⇔_.to Is-equivalence⇔Is-equivalence-CP eq (f x) -- If the domain of f is contractible and the codomain is -- propositional, then Is-equivalence f is contractible (assuming -- extensionality). sometimes-contractible : Extensionality (a ⊔ b) (a ⊔ b) → {A : Type a} {B : Type b} {f : A → B} → Contractible A → Is-proposition B → Contractible (Is-equivalence f) sometimes-contractible {a = a} {b = b} ext A-contr B-prop = Σ-closure 0 (Π-closure ext-b-a 0 λ _ → A-contr) λ _ → Σ-closure 0 (Π-closure ext-b-b 0 λ _ → H-level.+⇒≡ B-prop) λ _ → Σ-closure 0 (Π-closure ext-a-a 0 λ _ → H-level.⇒≡ 0 A-contr) λ _ → Π-closure ext-a-b 0 λ _ → H-level.⇒≡ 0 $ H-level.+⇒≡ B-prop where ext-a-a : Extensionality a a ext-a-a = lower-extensionality b b ext ext-a-b : Extensionality a b ext-a-b = lower-extensionality b a ext ext-b-a : Extensionality b a ext-b-a = lower-extensionality a b ext ext-b-b : Extensionality b b ext-b-b = lower-extensionality a a ext ------------------------------------------------------------------------ -- Is-equivalence is related to CP.Is-equivalence (part two) -- Is-equivalence f and CP.Is-equivalence f are isomorphic (assuming -- extensionality). Is-equivalence↔Is-equivalence-CP : {A : Type a} {B : Type b} {f : A → B} → Extensionality (a ⊔ b) (a ⊔ b) → Is-equivalence f ↔ CP.Is-equivalence f Is-equivalence↔Is-equivalence-CP ext = record { surjection = record { logical-equivalence = Is-equivalence⇔Is-equivalence-CP ; right-inverse-of = λ _ → CP.propositional ext _ _ _ } ; left-inverse-of = λ _ → propositional ext _ _ _ }
{ "alphanum_fraction": 0.4537631199, "avg_line_length": 34.6603448276, "ext": "agda", "hexsha": "af51a4cdbba4205d7bbd4483eb56528a5d2b0613", "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/Half-adjoint.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/Half-adjoint.agda", "max_line_length": 135, "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/Half-adjoint.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": 7344, "size": 20103 }
module Prelude where open import Agda.Primitive public open import Prelude.Unit public open import Prelude.Empty public open import Prelude.Function public open import Prelude.Char public open import Prelude.String public open import Prelude.Bool public open import Prelude.Nat public open import Prelude.Word public open import Prelude.Int public open import Prelude.Bytes public open import Prelude.Product public open import Prelude.Sum public open import Prelude.List public open import Prelude.Maybe public open import Prelude.Fin public open import Prelude.Vec public open import Prelude.Semiring public open import Prelude.Number public open import Prelude.Fractional public open import Prelude.Erased public open import Prelude.Strict public open import Prelude.Monoid public open import Prelude.Equality public open import Prelude.Decidable public open import Prelude.Functor public open import Prelude.Applicative public open import Prelude.Alternative public open import Prelude.Monad public open import Prelude.Show public open import Prelude.Ord public open import Prelude.Ord.Reasoning public open import Prelude.Smashed public open import Prelude.IO public open import Prelude.Equality.Unsafe public using (eraseEquality) open import Prelude.Equality.Inspect public
{ "alphanum_fraction": 0.7447098976, "avg_line_length": 33.2954545455, "ext": "agda", "hexsha": "6e4ee992a2bc87fe27d7a45cd12f0ed79a33f740", "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": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "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": "lclem/agda-prelude", "max_issues_repo_path": "src/Prelude.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Prelude.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 288, "size": 1465 }
module MUniverse where -- This is universe polymorphism and extensional equality module open import Sec2 -- import Data.List data _≃₀_ {A : Set} (a : A) (b : A) : Set where a≃b : (a ≡ b) → a ≃₀ b data _≃₁_ {A : Set} (f : A → A) (g : A → A) : Set where f≃g : ((x y : A) → (x ≃₀ y) → (f x ≃₀ g y)) → f ≃₁ g B==B : 1 ≃₀ 1 B==B = a≃b refl B==B1 : T ≃₀ T B==B1 = a≃b refl -- This is the same as + for natural numbers _⋆_ : (x y : ℕ) → ℕ Z ⋆ y = y (S x) ⋆ y = S (x ⋆ y) -- Proof that + and ⋆ are equivalent functions! +==⋆ : (x : ℕ) → ((_+_) x) ≃₁ ((_⋆_) x) +==⋆ x = f≃g (λ x₁ y x₂ → a≃b (prove x x₁ y x₂)) where fcong : (x y : ℕ) → (p : (x + y) ≡ (x ⋆ y)) → S (x + y) ≡ S (x ⋆ y) fcong x y p with (x + y) | (x ⋆ y) fcong x y refl | m | .m = refl prove' : (x y : ℕ) → (x + y) ≡ (x ⋆ y) prove' Z y = refl prove' (S x) y with (prove' x y) prove' (S x) y | p = fcong x y p prove : (x y z : ℕ) → (p : y ≃₀ z) → (x + y) ≡ (x ⋆ z) prove x y .y (a≃b refl) = prove' x y elim≃₁ : {A : Set} → (f g : A → A) (a : f ≃₁ g) → (x y : A) → (p : x ≃₀ y) → (f x ≃₀ g y) elim≃₁ f g (f≃g a) x .x (a≃b refl) = a x x (a≃b refl) -- Theorem that ≃₁ is a partial equivalence relation ≃₁-symmetric : {A : Set} → {f g : A → A} → (f ≃₁ g) → (g ≃₁ f) ≃₁-symmetric {A} {f} {g} (f≃g x) = f≃g (λ x₁ y x₂ → a≃b (prove x₁ y x₂ (f≃g x))) where prove : (z y : A) → (p : z ≃₀ y) → (f ≃₁ g) → (g z ≡ f y) prove z .z (a≃b refl) (f≃g x) with (x z z (a≃b refl) ) prove z .z (a≃b refl) (f≃g x₁) | a≃b p with (f z) | (g z) prove z .z (a≃b refl) (f≃g x₁) | a≃b refl | m | .m = refl ≃₁-transitive : {A : Set} → {f g h : A → A} → (f ≃₁ g) → (g ≃₁ h) → (f ≃₁ h) ≃₁-transitive {A} {f} {g} {h} (f≃g x) (f≃g y) = f≃g (λ x₁ y₁ x₂ → a≃b (prove x₁ y₁ x₂ (f≃g x) (f≃g y))) where prove : (x y : A) (p : x ≃₀ y) → (f ≃₁ g) → (g ≃₁ h) → (f x ≡ h y) prove x₁ .x₁ (a≃b refl) (f≃g x₂) (f≃g x₃) with (x₂ x₁ x₁ (a≃b refl)) | (x₃ x₁ x₁ (a≃b refl)) prove x₁ .x₁ (a≃b refl) (f≃g x₂) (f≃g x₃) | a≃b x₄ | a≃b x₅ with (f x₁) | (g x₁) | (h x₁) prove x₁ .x₁ (a≃b refl) (f≃g x₂) (f≃g x₃) | a≃b refl | a≃b refl | p1 | .p1 | .p1 = refl
{ "alphanum_fraction": 0.4385886556, "avg_line_length": 33.4179104478, "ext": "agda", "hexsha": "38439f46cc834f4870346b0a99e38543303c0a5b", "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": "MUniverse.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": "MUniverse.agda", "max_line_length": 103, "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": "MUniverse.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": 1194, "size": 2239 }
-- Andreas, 2014-05-21, reported and test case by Fabien Renaud module Issue1138 where open import Common.Equality postulate Var : Set Varset : Set _∖_ : Varset -> Var -> Varset _⊆_ : Varset -> Varset -> Set data Expression : Set where abs : Var -> Expression -> Expression FV : Expression -> Varset FV (abs x M) = FV M ∖ x data Env (A : Set) : Set where <> : Env A _,_:=_ : Env A -> Var -> A -> Env A postulate dom : ∀ {A} -> Env A -> Varset extend-dom : ∀ {A : Set} {a : A} {x xs ρ} -> (xs ∖ x) ⊆ dom ρ -> xs ⊆ dom (ρ , x := a) record Model (D : Set) : Set where field eval : (e : Expression) (ρ : Env D) -> FV e ⊆ dom ρ -> D d : D law : ∀ {M N ρ ν x y} -> eval M (ρ , x := d) (extend-dom {!!}) ≡ eval N (ν , y := d) (extend-dom {!!}) -> eval (abs x M) ρ {!!} ≡ eval (abs y N) ν {!!} -- Expected: For holes numbered 0,1,2,3 above and four goals below: -- ?0 : (FV M ∖ x) ⊆ dom ρ -- ?1 : (FV N ∖ y) ⊆ dom ν -- ?2 : FV (abs x M) ⊆ dom ρ -- ?3 : FV (abs y N) ⊆ dom ν -- There was a problem that two interaction points were created -- per ? in record fields, thus, they were off in emacs. -- (Introduced by fix for issue 1083).
{ "alphanum_fraction": 0.5117739403, "avg_line_length": 26, "ext": "agda", "hexsha": "29afc43a8ff6e4af733d97802c820d7782ad76e4", "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/Issue1138.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/Issue1138.agda", "max_line_length": 68, "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/Issue1138.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": 463, "size": 1274 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of the polymorphic unit type -- Defines Decidable Equality and Decidable Ordering as well ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Unit.Polymorphic.Properties where open import Level open import Data.Sum.Base using (inj₁) open import Data.Unit.Polymorphic.Base using (⊤; tt) open import Relation.Nullary open import Relation.Binary open import Relation.Binary.PropositionalEquality private variable ℓ : Level ------------------------------------------------------------------------ -- Equality ------------------------------------------------------------------------ infix 4 _≟_ _≟_ : Decidable {A = ⊤ {ℓ}} _≡_ _ ≟ _ = yes refl ≡-setoid : ∀ ℓ → Setoid ℓ ℓ ≡-setoid _ = setoid ⊤ ≡-decSetoid : ∀ ℓ → DecSetoid ℓ ℓ ≡-decSetoid _ = decSetoid _≟_ ------------------------------------------------------------------------ -- Ordering ------------------------------------------------------------------------ ≡-total : Total {A = ⊤ {ℓ}} _≡_ ≡-total _ _ = inj₁ refl ≡-antisym : Antisymmetric {A = ⊤ {ℓ}} _≡_ _≡_ ≡-antisym p _ = p ------------------------------------------------------------------------ -- Structures ≡-isPreorder : ∀ ℓ → IsPreorder {ℓ} {_} {⊤} _≡_ _≡_ ≡-isPreorder ℓ = record { isEquivalence = isEquivalence ; reflexive = λ x → x ; trans = trans } ≡-isPartialOrder : ∀ ℓ → IsPartialOrder {ℓ} _≡_ _≡_ ≡-isPartialOrder ℓ = record { isPreorder = ≡-isPreorder ℓ ; antisym = ≡-antisym } ≡-isTotalOrder : ∀ ℓ → IsTotalOrder {ℓ} _≡_ _≡_ ≡-isTotalOrder ℓ = record { isPartialOrder = ≡-isPartialOrder ℓ ; total = ≡-total } ≡-isDecTotalOrder : ∀ ℓ → IsDecTotalOrder {ℓ} _≡_ _≡_ ≡-isDecTotalOrder ℓ = record { isTotalOrder = ≡-isTotalOrder ℓ ; _≟_ = _≟_ ; _≤?_ = _≟_ } ------------------------------------------------------------------------ -- Bundles ≡-preorder : ∀ ℓ → Preorder ℓ ℓ ℓ ≡-preorder ℓ = record { isPreorder = ≡-isPreorder ℓ } ≡-poset : ∀ ℓ → Poset ℓ ℓ ℓ ≡-poset ℓ = record { isPartialOrder = ≡-isPartialOrder ℓ } ≡-totalOrder : ∀ ℓ → TotalOrder ℓ ℓ ℓ ≡-totalOrder ℓ = record { isTotalOrder = ≡-isTotalOrder ℓ } ≡-decTotalOrder : ∀ ℓ → DecTotalOrder ℓ ℓ ℓ ≡-decTotalOrder ℓ = record { isDecTotalOrder = ≡-isDecTotalOrder ℓ }
{ "alphanum_fraction": 0.484055601, "avg_line_length": 24.7070707071, "ext": "agda", "hexsha": "c0ddf92e095adca471404c2e68fa04543e85ac32", "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": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/Unit/Polymorphic/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "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": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/Unit/Polymorphic/Properties.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/Unit/Polymorphic/Properties.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": 779, "size": 2446 }